Example #1
0
/*
 * Initialize context for plugin
 */
extern int launch_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "launch";
	char *type = NULL;

	if (init_run && plugin_context)
		return retval;

	slurm_mutex_lock(&plugin_context_lock);

	if (plugin_context)
		goto done;

	type = slurm_get_launch_type();
	plugin_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!plugin_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&plugin_context_lock);
	xfree(type);

	return retval;
}
Example #2
0
extern int
g_slurm_jobcomp_init( char *jobcomp_loc )
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "jobcomp";
	char *type = NULL;

	slurm_mutex_lock( &context_lock );

	if (init_run && g_context)
		goto done;

	if (g_context)
		plugin_context_destroy(g_context);

	type = slurm_get_jobcomp_type();
	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	xfree(type);
	if (g_context)
		retval = (*(ops.set_loc))(jobcomp_loc);
	slurm_mutex_unlock( &context_lock );
	return retval;
}
Example #3
0
extern int acct_gather_profile_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "acct_gather_profile";
	char *type = NULL;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&g_context_lock);

	if (g_context)
		goto done;

	type = slurm_get_acct_gather_profile_type();

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	xfree(type);
	if (retval == SLURM_SUCCESS)
		retval = acct_gather_conf_init();

	return retval;
}
Example #4
0
extern int bg_configure_init(void)
{
	int rc = SLURM_SUCCESS;
	char *plugin_type = "select", *type="select/bluegene";
	if (init_run && g_context)
		return rc;

	slurm_mutex_lock(&g_context_lock);

	if (g_context)
		goto done;

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		rc = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	return rc;

}
Example #5
0
/*
 * Initialize context for acct_storage plugin
 */
extern int slurm_acct_storage_init(char *loc)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "accounting_storage";
	char *type = NULL;

	if (init_run && plugin_context)
		return retval;

	slurm_mutex_lock(&plugin_context_lock);

	if (plugin_context)
		goto done;

	if (loc)
		slurm_set_accounting_storage_loc(loc);

	type = slurm_get_accounting_storage_type();

	plugin_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!plugin_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;
	enforce = slurm_get_accounting_storage_enforce();
done:
	slurm_mutex_unlock(&plugin_context_lock);
	xfree(type);
	return retval;
}
Example #6
0
/* initialize checkpoint plugin */
extern int
checkpoint_init(char *type)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "checkpoint";

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&context_lock);

	if (g_context)
		plugin_context_destroy(g_context);

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

	debug("Checkpoint plugin loaded: %s", type);
done:
	slurm_mutex_unlock(&context_lock);
	return retval;
}
Example #7
0
/*
 * Initialize context for node selection plugin
 */
extern int other_select_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "select";
	char *type = NULL;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&g_context_lock);

	if (g_context)
		goto done;

	if (slurmctld_conf.select_type_param & CR_OTHER_CONS_RES)
		type = "select/cons_res";
	else
		type = "select/linear";

	if (!(g_context = plugin_context_create(
		     plugin_type, type, (void **)&ops,
		     node_select_syms, sizeof(node_select_syms)))) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	return retval;
}
Example #8
0
extern int jobacct_gather_init(void)
{
	char    *plugin_type = "jobacct_gather";
	char	*type = NULL;
	int	retval=SLURM_SUCCESS;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&g_context_lock);
	if (g_context)
		goto done;

	type = slurm_get_jobacct_gather_type();

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}

	if (!strcasecmp(type, "jobacct_gather/none")) {
		plugin_polling = false;
		goto done;
	}

	plugin_type = type;
	type = slurm_get_proctrack_type();
	if (!strcasecmp(type, "proctrack/pgid")) {
		info("WARNING: We will use a much slower algorithm with "
		     "proctrack/pgid, use Proctracktype=proctrack/linuxproc "
		     "or some other proctrack when using %s",
		     plugin_type);
		pgid_plugin = true;
	}
	xfree(type);
	xfree(plugin_type);

	type = slurm_get_accounting_storage_type();
	if (!strcasecmp(type, ACCOUNTING_STORAGE_TYPE_NONE)) {
		error("WARNING: Even though we are collecting accounting "
		      "information you have asked for it not to be stored "
		      "(%s) if this is not what you have in mind you will "
		      "need to change it.", ACCOUNTING_STORAGE_TYPE_NONE);
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	xfree(type);

	return(retval);
}
extern int acct_gather_interconnect_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "acct_gather_interconnect";
	char *full_plugin_type = NULL;
	char *last = NULL, *plugin_entry, *type = NULL;

	if (init_run && (g_context_num >= 0))
		return retval;

	slurm_mutex_lock(&g_context_lock);

	if (g_context_num >= 0)
		goto done;

	full_plugin_type = slurm_get_acct_gather_interconnect_type();
	g_context_num = 0; /* mark it before anything else */
	plugin_entry = full_plugin_type;
	while ((type = strtok_r(plugin_entry, ",", &last))) {
		xrealloc(ops, sizeof(slurm_acct_gather_interconnect_ops_t) *
			 (g_context_num + 1));
		xrealloc(g_context, (sizeof(plugin_context_t *) *
				     (g_context_num + 1)));
		if (xstrncmp(type, "acct_gather_interconnect/", 25) == 0)
			type += 25; /* backward compatibility */
		type = xstrdup_printf("%s/%s", plugin_type, type);
		g_context[g_context_num] = plugin_context_create(
			plugin_type, type, (void **)&ops[g_context_num],
			syms, sizeof(syms));
		if (!g_context[g_context_num]) {
			error("cannot create %s context for %s",
			      plugin_type, type);
			xfree(type);
			retval = SLURM_ERROR;
			break;
		}

		xfree(type);
		g_context_num++;
		plugin_entry = NULL; /* for next iteration */
	}
	xfree(full_plugin_type);
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	if (retval == SLURM_SUCCESS)
		retval = acct_gather_conf_init();
	if (retval != SLURM_SUCCESS)
		fatal("can not open the %s plugin", plugin_type);
	xfree(type);


	return retval;
}
Example #10
0
/*
 * Initialize the slurmctld plugstack plugin.
 *
 * Returns a SLURM errno.
 */
extern int slurmctld_plugstack_init(void)
{
	int rc = SLURM_SUCCESS;
	char *last = NULL, *names;
	char *plugin_type = "slurmctld_plugstack";
	char *type;

	if (init_run && (g_context_cnt >= 0))
		return rc;

	slurm_mutex_lock(&g_context_lock);
	if (g_context_cnt >= 0)
		goto fini;

	slurmctld_plugstack_list = slurm_get_slurmctld_plugstack();
	g_context_cnt = 0;
	if ((slurmctld_plugstack_list == NULL) ||
	    (slurmctld_plugstack_list[0] == '\0'))
		goto fini;

	names = slurmctld_plugstack_list;
	while ((type = strtok_r(names, ",", &last))) {
		xrealloc(ops, (sizeof(slurmctld_plugstack_ops_t) *
			      (g_context_cnt + 1)));
		xrealloc(g_context,
			 (sizeof(plugin_context_t *) * (g_context_cnt + 1)));
		if (xstrncmp(type, "slurmctld/", 10) == 0)
			type += 10; /* backward compatibility */
		type = xstrdup_printf("slurmctld/%s", type);
		g_context[g_context_cnt] = plugin_context_create(
			plugin_type, type, (void **)&ops[g_context_cnt],
			syms, sizeof(syms));
		if (!g_context[g_context_cnt]) {
			error("cannot create %s context for %s",
			      plugin_type, type);
			rc = SLURM_ERROR;
			xfree(type);
			break;
		}

		xfree(type);
		g_context_cnt++;
		names = NULL; /* for next iteration */
	}
	init_run = true;

fini:
	slurm_mutex_unlock(&g_context_lock);

	if (rc != SLURM_SUCCESS)
		slurmctld_plugstack_fini();

	return rc;
}
Example #11
0
/*
 * Initialize context for mcs plugin
 */
extern int slurm_mcs_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "mcs";
	char *type = NULL;
	char *sep;

	if (init_run && g_mcs_context)
		return retval;
	slurm_mutex_lock(&g_mcs_context_lock);

	if (g_mcs_context)
		goto done;

	xfree(mcs_params);
	xfree(mcs_params_common);
	xfree(mcs_params_specific);

	type = slurm_get_mcs_plugin();
	mcs_params = slurm_get_mcs_plugin_params();
	if (mcs_params == NULL) {
		info("No parameter for mcs plugin, default values set");
	} else {
		mcs_params_common = xstrdup(mcs_params);
		sep = index(mcs_params_common, ':');
		if (sep != NULL) {
			if (sep[1] != '\0')
				mcs_params_specific = xstrdup(sep + 1);
			*sep = '\0';
		}
	}
	_slurm_mcs_check_and_load_privatedata(mcs_params_common);
	_slurm_mcs_check_and_load_enforced(mcs_params_common);
	_slurm_mcs_check_and_load_select(mcs_params_common);

	g_mcs_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_mcs_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_mcs_context_lock);
	xfree(type);
	return retval;
}
Example #12
0
static int _load_plugins(void *x, void *arg)
{
	char *plugin_name     = (char *)x;
	_plugin_args_t *pargs = (_plugin_args_t *)arg;

	switch_context[switch_context_cnt] =
		plugin_context_create(pargs->plugin_type, plugin_name,
				      (void **)&ops[switch_context_cnt], syms,
				      sizeof(syms));

	if (switch_context[switch_context_cnt]) {
		/* set the default */
		if (!xstrcmp(plugin_name, pargs->default_plugin))
			switch_context_default = switch_context_cnt;
		switch_context_cnt++;
	}

	return 0;
}
Example #13
0
/*
 * Initialize context for node selection plugin
 */
extern int other_select_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "select";
	char *type = NULL;
	int n_syms;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&g_context_lock);

	if (g_context)
		goto done;

	if (slurmctld_conf.select_type_param & CR_OTHER_CONS_RES)
		type = "select/cons_res";
	else
		type = "select/linear";

	n_syms = sizeof(node_select_syms);
	if (n_syms != sizeof(ops))
		fatal("For some reason node_select_syms in "
		      "src/plugins/select/other/other_select.c differs from "
		      "slurm_select_ops_t found in src/common/node_select.h.  "
		      "node_select_syms should match what is in "
		      "src/common/node_select.c");

	if (!(g_context = plugin_context_create(
		     plugin_type, type, (void **)&ops,
		     node_select_syms, n_syms))) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	slurm_mutex_unlock(&g_context_lock);
	return retval;
}
Example #14
0
/* ************************************************************************** */
extern int route_init(char *node_name)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "route";
	char *type = NULL;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock(&g_context_lock);

	if (g_context)
		goto done;

	type = slurm_get_route_plugin();

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}

	tree_width = slurm_get_tree_width();
	debug_flags = slurm_get_debug_flags();

	init_run = true;
	_set_collectors(node_name);

done:
	slurm_mutex_unlock(&g_context_lock);
	xfree(type);
	return retval;
}
Example #15
0
/*
 * Initialize the job container plugin.
 *
 * RET - slurm error code
 */
extern int job_container_init(void)
{
    int retval = SLURM_SUCCESS;
    char *plugin_type = "job_container";
    char *container_plugin_type = NULL;
    char *last = NULL, *job_container_plugin_list, *job_container = NULL;

    if (init_run && (g_container_context_num >= 0))
        return retval;

    slurm_mutex_lock(&g_container_context_lock);

    if (g_container_context_num >= 0)
        goto done;

    container_plugin_type = slurm_get_job_container_plugin();
    g_container_context_num = 0; /* mark it before anything else */
    if ((container_plugin_type == NULL) ||
            (container_plugin_type[0] == '\0'))
        goto done;

    job_container_plugin_list = container_plugin_type;
    while ((job_container =
                strtok_r(job_container_plugin_list, ",", &last))) {
        xrealloc(ops,
                 sizeof(job_container_ops_t) *
                 (g_container_context_num + 1));
        xrealloc(g_container_context, (sizeof(plugin_context_t *)
                                       * (g_container_context_num + 1)));
        if (strncmp(job_container, "job_container/", 14) == 0)
            job_container += 14; /* backward compatibility */
        job_container = xstrdup_printf("job_container/%s",
                                       job_container);
        g_container_context[g_container_context_num] =
            plugin_context_create(
                plugin_type, job_container,
                (void **)&ops[g_container_context_num],
                syms, sizeof(syms));
        if (!g_container_context[g_container_context_num]) {
            error("cannot create %s context for %s",
                  plugin_type, job_container);
            xfree(job_container);
            retval = SLURM_ERROR;
            break;
        }

        xfree(job_container);
        g_container_context_num++;
        job_container_plugin_list = NULL; /* for next iteration */
    }
    init_run = true;

done:
    slurm_mutex_unlock(&g_container_context_lock);
    xfree(container_plugin_type);

    if (retval != SLURM_SUCCESS)
        job_container_fini();

    return retval;
}
Example #16
0
/* Get this plugin's sequence number in Slurm's internal tables */
extern int select_get_plugin_id_pos(uint32_t plugin_id)
{
	int i;
	static bool cray_other_cons_res = false;

	if (slurm_select_init(0) < 0)
		return SLURM_ERROR;
again:
	for (i = 0; i < select_context_cnt; i++) {
		if (*(ops[i].plugin_id) == plugin_id)
			break;
	}
	if (i >= select_context_cnt) {
		/*
		 * Put on the extra Cray select plugins that do not get
		 * generated automatically.
		 */
		if (!cray_other_cons_res &&
		    ((plugin_id == SELECT_PLUGIN_CRAY_CONS_RES)  ||
		     (plugin_id == SELECT_PLUGIN_CRAY_CONS_TRES) ||
		     (plugin_id == SELECT_PLUGIN_CRAY_LINEAR))) {
			char *type = "select", *name = "select/cray";
			uint16_t save_params = slurm_get_select_type_param();
			uint16_t params[2];
			int cray_plugin_id[2], cray_offset;

			cray_other_cons_res = true;

			if (plugin_id == SELECT_PLUGIN_CRAY_LINEAR) {
				params[0] = save_params & ~CR_OTHER_CONS_RES;
				cray_plugin_id[0] = SELECT_PLUGIN_CRAY_CONS_RES;
				params[1] = save_params & ~CR_OTHER_CONS_TRES;
				cray_plugin_id[1] = SELECT_PLUGIN_CRAY_CONS_TRES;
			} else if (plugin_id == SELECT_PLUGIN_CRAY_CONS_RES) {
				params[0] = save_params | CR_OTHER_CONS_RES;
				cray_plugin_id[0] = SELECT_PLUGIN_CRAY_LINEAR;
				params[1] = save_params & ~CR_OTHER_CONS_RES;
				cray_plugin_id[1] = SELECT_PLUGIN_CRAY_CONS_TRES;
			} else {	/* SELECT_PLUGIN_CRAY_CONS_TRES */
				params[0] = save_params | CR_OTHER_CONS_TRES;
				cray_plugin_id[0] = SELECT_PLUGIN_CRAY_LINEAR;
				params[1] = save_params & ~CR_OTHER_CONS_RES;
				cray_plugin_id[1] = SELECT_PLUGIN_CRAY_CONS_RES;
			}

			for (cray_offset = 0; cray_offset < 2; cray_offset++) {
				for (i = 0; i < select_context_cnt; i++) {
					if (*(ops[i].plugin_id) ==
					    cray_plugin_id[cray_offset])
						break;
				}
				if (i < select_context_cnt)
					break;	/* Found match */
			}
			if (i >= select_context_cnt)
				goto end_it;	/* No match */

			slurm_mutex_lock(&select_context_lock);
			slurm_set_select_type_param(params[cray_offset]);
			plugin_context_destroy(select_context[i]);
			select_context[i] =
				plugin_context_create(type, name,
						      (void **)&ops[i],
						      node_select_syms,
						      sizeof(node_select_syms));
			slurm_set_select_type_param(save_params);
			slurm_mutex_unlock(&select_context_lock);
			goto again;
		}

	end_it:
		return SLURM_ERROR;
	}
	return i;
}
Example #17
0
/*
 * Initialize context for node selection plugin
 */
extern int slurm_select_init(bool only_default)
{
	int retval = SLURM_SUCCESS;
	char *type = NULL;
	int i, j, len;
	DIR *dirp;
	struct dirent *e;
	char *dir_array = NULL, *head = NULL;
	char *plugin_type = "select";

	if ( init_run && select_context )
		return retval;

	slurm_mutex_lock( &select_context_lock );

	if ( select_context )
		goto done;

	type = slurm_get_select_type();
	if (working_cluster_rec) {
		/* just ignore warnings here */
	} else {
#ifdef HAVE_XCPU
		if (strcasecmp(type, "select/linear")) {
			error("%s is incompatible with XCPU use", type);
			fatal("Use SelectType=select/linear");
		}
#endif
		if (!strcasecmp(type, "select/linear")) {
			uint16_t cr_type = slurm_get_select_type_param();
			if ((cr_type & CR_SOCKET) || (cr_type & CR_CORE) ||
			    (cr_type & CR_CPU))
				fatal("Invalid SelectTypeParameter "
				      "for select/linear");
		}

#ifdef HAVE_BG
		if (strcasecmp(type, "select/bluegene")) {
			error("%s is incompatible with BlueGene", type);
			fatal("Use SelectType=select/bluegene");
		}
#else
		if (!strcasecmp(type, "select/bluegene")) {
			fatal("Requested SelectType=select/bluegene "
			      "in slurm.conf, but not running on a BG[L|P|Q] "
			      "system.  If looking to emulate a BG[L|P|Q] "
			      "system use --enable-bgl-emulation or "
			      "--enable-bgp-emulation respectively.");
		}
#endif

#ifdef HAVE_ALPS_CRAY
		if (strcasecmp(type, "select/alps")) {
			error("%s is incompatible with Cray system "
			      "running alps", type);
			fatal("Use SelectType=select/alps");
		}
#else
		if (!strcasecmp(type, "select/alps")) {
			fatal("Requested SelectType=select/alps "
			      "in slurm.conf, but not running on a ALPS Cray "
			      "system.  If looking to emulate a Alps Cray "
			      "system use --enable-alps-cray-emulation.");
		}
#endif
	}

	select_context_cnt = 0;
	if (only_default) {
		ops = xmalloc(sizeof(slurm_select_ops_t));
		select_context = xmalloc(sizeof(plugin_context_t));
		if ((select_context[0] = plugin_context_create(
			     plugin_type, type, (void **)&ops[0],
			     node_select_syms, sizeof(node_select_syms)))) {
			select_context_default = 0;
			select_context_cnt++;
		}
		goto skip_load_all;
	}

	if (!(dir_array = slurm_get_plugin_dir())) {
		error("plugin_load_and_link: No plugin dir given");
		goto done;
	}

	head = dir_array;
	for (i=0; ; i++) {
		bool got_colon = 0;
		if (dir_array[i] == ':') {
			dir_array[i] = '\0';
			got_colon = 1;
		} else if (dir_array[i] != '\0')
			continue;

		/* Open the directory. */
		if (!(dirp = opendir(head))) {
			error("cannot open plugin directory %s", head);
			goto done;
		}

		while (1) {
			char full_name[128];

			if (!(e = readdir( dirp )))
				break;
			/* Check only files with select_ in them. */
			if (strncmp(e->d_name, "select_", 7))
				continue;

			len = strlen(e->d_name);
#if defined(__CYGWIN__)
			len -= 4;
#else
			len -= 3;
#endif
			/* Check only shared object files */
			if (strcmp(e->d_name+len,
#if defined(__CYGWIN__)
				   ".dll"
#else
				   ".so"
#endif
				    ))
				continue;
			/* add one for the / */
			len++;
			xassert(len<sizeof(full_name));
			snprintf(full_name, len, "select/%s", e->d_name+7);
			for (j=0; j<select_context_cnt; j++) {
				if (!strcmp(full_name,
					    select_context[j]->type))
					break;
			}
			if (j >= select_context_cnt) {
				xrealloc(ops,
					 (sizeof(slurm_select_ops_t) *
					  (select_context_cnt + 1)));
				xrealloc(select_context,
					 (sizeof(plugin_context_t) *
					  (select_context_cnt + 1)));

				select_context[select_context_cnt] =
					plugin_context_create(
						plugin_type, full_name,
						(void **)&ops[
							select_context_cnt],
						node_select_syms,
						sizeof(node_select_syms));
				if (select_context[select_context_cnt]) {
					/* set the default */
					if (!strcmp(full_name, type))
						select_context_default =
							select_context_cnt;
					select_context_cnt++;
				}
			}
		}

		closedir(dirp);

		if (got_colon) {
			head = dir_array + i + 1;
		} else
			break;
	}

skip_load_all:
	if (select_context_default == -1)
		fatal("Can't find plugin for %s", type);

	/* Insure that plugin_id is valid and unique */
	for (i=0; i<select_context_cnt; i++) {
		for (j=i+1; j<select_context_cnt; j++) {
			if (*(ops[i].plugin_id) !=
			    *(ops[j].plugin_id))
				continue;
			fatal("SelectPlugins: Duplicate plugin_id %u for "
			      "%s and %s",
			      *(ops[i].plugin_id),
			      select_context[i]->type,
			      select_context[j]->type);
		}
		if (*(ops[i].plugin_id) < 100) {
			fatal("SelectPlugins: Invalid plugin_id %u (<100) %s",
			      *(ops[i].plugin_id),
			      select_context[i]->type);
		}

	}
	init_run = true;

done:
	slurm_mutex_unlock( &select_context_lock );
	xfree(type);
	xfree(dir_array);
	return retval;
}
Example #18
0
/*
 * Initialize the core specialization plugin.
 *
 * RET - slurm error code
 */
extern int core_spec_g_init(void)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "core_spec";
	char *core_spec_plugin_type = NULL;
	char *last = NULL, *core_spec_plugin_list, *core_spec = NULL;

	if (init_run && (g_core_spec_context_num >= 0))
		return retval;

	slurm_mutex_lock(&g_core_spec_context_lock);

	if (g_core_spec_context_num >= 0)
		goto done;

	core_spec_plugin_type = slurm_get_core_spec_plugin();
	g_core_spec_context_num = 0; /* mark it before anything else */
	if ((core_spec_plugin_type == NULL) ||
	    (core_spec_plugin_type[0] == '\0'))
		goto done;

	core_spec_plugin_list = core_spec_plugin_type;
	while ((core_spec =
		strtok_r(core_spec_plugin_list, ",", &last))) {
		xrealloc(ops,
			 sizeof(core_spec_ops_t) *
			 (g_core_spec_context_num + 1));
		xrealloc(g_core_spec_context, (sizeof(plugin_context_t *)
					  * (g_core_spec_context_num + 1)));
		if (xstrncmp(core_spec, "core_spec/", 10) == 0)
			core_spec += 10; /* backward compatibility */
		core_spec = xstrdup_printf("core_spec/%s",
					       core_spec);
		g_core_spec_context[g_core_spec_context_num] =
			plugin_context_create(
				plugin_type, core_spec,
				(void **)&ops[g_core_spec_context_num],
				syms, sizeof(syms));
		if (!g_core_spec_context[g_core_spec_context_num]) {
			error("cannot create %s context for %s",
			      plugin_type, core_spec);
			xfree(core_spec);
			retval = SLURM_ERROR;
			break;
		}

		xfree(core_spec);
		g_core_spec_context_num++;
		core_spec_plugin_list = NULL; /* for next iteration */
	}
	init_run = true;

 done:
	slurm_mutex_unlock(&g_core_spec_context_lock);
	xfree(core_spec_plugin_type);

	if (retval != SLURM_SUCCESS)
		core_spec_g_fini();

	return retval;
}
Example #19
0
File: mpi.c Project: IFCA/slurm
int _mpi_init (char *mpi_type)
{
	int retval = SLURM_SUCCESS;
	char *plugin_type = "mpi";
	char *type = NULL;
	int got_default = 0;

	if (init_run && g_context)
		return retval;

	slurm_mutex_lock( &context_lock );

	if ( g_context )
		goto done;

	if (mpi_type == NULL) {
		mpi_type = slurm_get_mpi_default();
		got_default = 1;
	}
	if (mpi_type == NULL) {
		error("No MPI default set.");
		retval = SLURM_ERROR;
		goto done;
	}

	if (!strcmp(mpi_type, "list")) {
		char *plugin_dir;
		plugrack_t mpi_rack;

		mpi_rack = plugrack_create();
		if (!mpi_rack) {
			error("Unable to create a plugin manager");
			exit(0);
		}
		plugrack_set_major_type(mpi_rack, "mpi");
		plugin_dir = slurm_get_plugin_dir();
		plugrack_read_dir(mpi_rack, plugin_dir);
		plugrack_print_all_plugin(mpi_rack);
		exit(0);
	}

	setenvf(NULL, "SLURM_MPI_TYPE", "%s", mpi_type);

	type = xstrdup_printf("mpi/%s", mpi_type);

	g_context = plugin_context_create(
		plugin_type, type, (void **)&ops, syms, sizeof(syms));

	if (!g_context) {
		error("cannot create %s context for %s", plugin_type, type);
		retval = SLURM_ERROR;
		goto done;
	}
	init_run = true;

done:
	xfree(type);
	if (got_default)
		xfree(mpi_type);
	slurm_mutex_unlock( &context_lock );
	return retval;
}