Beispiel #1
0
static int _unpack_acct_coord_msg(dbd_acct_coord_msg_t **msg,
				  uint16_t rpc_version, Buf buffer)
{
	uint32_t uint32_tmp;
	int i;
	char *acct = NULL;
	uint32_t count = 0;
	dbd_acct_coord_msg_t *msg_ptr = xmalloc(sizeof(dbd_acct_coord_msg_t));
	*msg = msg_ptr;

	safe_unpack32(&count, buffer);
	if (count) {
		msg_ptr->acct_list = list_create(slurm_destroy_char);
		for(i=0; i<count; i++) {
			safe_unpackstr_xmalloc(&acct, &uint32_tmp, buffer);
			list_append(msg_ptr->acct_list, acct);
		}
	}

	if (slurmdb_unpack_user_cond((void *)&msg_ptr->cond,
				     rpc_version, buffer)
	    == SLURM_ERROR)
		goto unpack_error;
	return SLURM_SUCCESS;

unpack_error:
	slurmdbd_free_acct_coord_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #2
0
/*
 *  Unpack options from buffer "buf" into options container opts.
 */
int job_options_unpack (job_options_t opts, Buf buf)
{
	uint32_t count;
	uint32_t len;
	char *   tag = NULL;
	int      i;

	safe_unpackstr_xmalloc (&tag, &len, buf);

	if (strncmp (tag, JOB_OPTIONS_PACK_TAG, len) != 0) {
		xfree(tag);
		return (-1);
	}
	xfree(tag);
	safe_unpack32 (&count, buf);

	for (i = 0; i < count; i++) {
		struct job_option_info *ji;
		if ((ji = job_option_info_unpack (buf)) == NULL)
			return (SLURM_ERROR);
		list_append (opts->options, ji);
	}

	return (0);

  unpack_error:
	xfree(tag);
	return SLURM_ERROR;
}
Beispiel #3
0
extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer,
				 uint16_t protocol_version)
{
	uint32_t uint32_tmp;
	struct check_job_info *check_ptr =
		(struct check_job_info *)jobinfo;

	if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {
		safe_unpack16(&check_ptr->disabled, buffer);
		safe_unpack16(&check_ptr->node_cnt, buffer);
		safe_unpack16(&check_ptr->reply_cnt, buffer);
		safe_unpack16(&check_ptr->wait_time, buffer);

		safe_unpack32(&check_ptr->error_code, buffer);
		safe_unpackstr_xmalloc(&check_ptr->error_msg,
				       &uint32_tmp, buffer);
		safe_unpack_time(&check_ptr->time_stamp, buffer);
	}

	return SLURM_SUCCESS;

    unpack_error:
	xfree(check_ptr->error_msg);
	return SLURM_ERROR;
}
Beispiel #4
0
extern int
name_unpublish_up(char *name)
{
	Buf buf = NULL, resp_buf = NULL;
	uint32_t size, tmp_32;
	int rc;

	buf = init_buf(1024);
	pack16((uint16_t)TREE_CMD_NAME_UNPUBLISH, buf);
	packstr(name, buf);
	size = get_buf_offset(buf);

	rc = tree_msg_to_srun_with_resp(size, get_buf_data(buf), &resp_buf);
	free_buf(buf);

	if (rc == SLURM_SUCCESS) {
		safe_unpack32(&tmp_32, resp_buf);
		rc = (int) tmp_32;
	}

unpack_error:
	if (resp_buf)
		free_buf(resp_buf);
	
	return rc;
}
Beispiel #5
0
extern int select_p_select_jobinfo_unpack(select_jobinfo_t **jobinfo_pptr,
					  Buf buffer, uint16_t protocol_version)
{
	int rc = SLURM_ERROR;
	select_jobinfo_t *jobinfo = xmalloc(sizeof(struct select_jobinfo));

	*jobinfo_pptr = jobinfo;

	jobinfo->magic = JOBINFO_MAGIC;
	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack8(&jobinfo->confirmed, buffer);
		safe_unpack32(&jobinfo->reservation_id, buffer);
		safe_unpack64(&jobinfo->confirm_cookie, buffer);
		rc = other_select_jobinfo_unpack(&jobinfo->other_jobinfo,
						 buffer, protocol_version);
	} else {
 		error("select_p_select_jobinfo_unpack: protocol_version "
 		      "%hu not supported", protocol_version);
	}

	if (rc != SLURM_SUCCESS)
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	select_p_select_jobinfo_free(jobinfo);
	*jobinfo_pptr = NULL;

	return SLURM_ERROR;
}
Beispiel #6
0
extern int slurm_persist_unpack_rc_msg(
	persist_rc_msg_t **msg, Buf buffer, uint16_t protocol_version)
{
	uint32_t uint32_tmp;

	persist_rc_msg_t *msg_ptr = xmalloc(sizeof(persist_rc_msg_t));

	*msg = msg_ptr;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpackstr_xmalloc(&msg_ptr->comment, &uint32_tmp, buffer);
		safe_unpack16(&msg_ptr->flags, buffer);
		safe_unpack32(&msg_ptr->rc, buffer);
		safe_unpack16(&msg_ptr->ret_info, buffer);
	} else {
		error("%s: invalid protocol_version %u",
		      __func__, protocol_version);
		goto unpack_error;
	}

	return SLURM_SUCCESS;

unpack_error:
	slurm_persist_free_rc_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #7
0
extern int unpack_slurm_step_layout(slurm_step_layout_t **layout, Buf buffer,
				    uint16_t protocol_version)
{
	uint16_t uint16_tmp;
	uint32_t num_tids, uint32_tmp;
	slurm_step_layout_t *step_layout = NULL;
	int i;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack16(&uint16_tmp, buffer);
		if (!uint16_tmp)
			return SLURM_SUCCESS;

		step_layout = xmalloc(sizeof(slurm_step_layout_t));
		*layout = step_layout;

		safe_unpackstr_xmalloc(&step_layout->front_end,
				       &uint32_tmp, buffer);
		safe_unpackstr_xmalloc(&step_layout->node_list,
				       &uint32_tmp, buffer);
		safe_unpack32(&step_layout->node_cnt, buffer);
		safe_unpack16(&step_layout->start_protocol_ver, buffer);
		safe_unpack32(&step_layout->task_cnt, buffer);
		safe_unpack32(&step_layout->task_dist, buffer);

		step_layout->tasks =
			xmalloc(sizeof(uint32_t) * step_layout->node_cnt);
		step_layout->tids = xmalloc(sizeof(uint32_t *)
					    * step_layout->node_cnt);
		for (i = 0; i < step_layout->node_cnt; i++) {
			safe_unpack32_array(&(step_layout->tids[i]),
					    &num_tids,
					    buffer);
			step_layout->tasks[i] = num_tids;
		}
	} else {
		error("unpack_slurm_step_layout: protocol_version "
		      "%hu not supported", protocol_version);
		goto unpack_error;
	}
	return SLURM_SUCCESS;

unpack_error:
	slurm_step_layout_destroy(step_layout);
	*layout = NULL;
	return SLURM_ERROR;
}
Beispiel #8
0
int switch_p_unpack_jobinfo(switch_jobinfo_t *switch_job, Buf buffer,
			    uint16_t protocol_version)
{
	sw_gen_step_info_t *gen_step_info = (sw_gen_step_info_t *) switch_job;
	sw_gen_node_t *node_ptr;
	sw_gen_ifa_t *ifa_ptr;
	uint32_t uint32_tmp;
	int i, j;

	if (debug_flags & DEBUG_FLAG_SWITCH)
		info("switch_p_unpack_jobinfo() starting");
	safe_unpack32(&gen_step_info->node_cnt, buffer);
	gen_step_info->node_array = xmalloc(sizeof(sw_gen_node_t *) *
					    gen_step_info->node_cnt);
	for (i = 0; i < gen_step_info->node_cnt; i++) {
		node_ptr = xmalloc(sizeof(sw_gen_node_t));
		gen_step_info->node_array[i] = node_ptr;
		safe_unpackstr_xmalloc(&node_ptr->node_name, &uint32_tmp,
				       buffer);
		safe_unpack16(&node_ptr->ifa_cnt, buffer);
		node_ptr->ifa_array = xmalloc(sizeof(sw_gen_ifa_t *) *
					      node_ptr->ifa_cnt);
		for (j = 0; j < node_ptr->ifa_cnt; j++) {
			ifa_ptr = xmalloc(sizeof(sw_gen_ifa_t));
			node_ptr->ifa_array[j] = ifa_ptr;
			safe_unpackstr_xmalloc(&ifa_ptr->ifa_addr, &uint32_tmp,
					       buffer);
			safe_unpackstr_xmalloc(&ifa_ptr->ifa_family,
					       &uint32_tmp, buffer);
			safe_unpackstr_xmalloc(&ifa_ptr->ifa_name, &uint32_tmp,
					       buffer);
			if (debug_flags & DEBUG_FLAG_SWITCH) {
				info("node=%s name=%s family=%s addr=%s",
				     node_ptr->node_name, ifa_ptr->ifa_name,
				     ifa_ptr->ifa_family, ifa_ptr->ifa_addr);
			}
		}
	}

	return SLURM_SUCCESS;

unpack_error:
	for (i = 0; i < gen_step_info->node_cnt; i++) {
		node_ptr = gen_step_info->node_array[i];
		for (j = 0; j < node_ptr->ifa_cnt; j++) {
			ifa_ptr = node_ptr->ifa_array[j];
			xfree(ifa_ptr->ifa_addr);
			xfree(ifa_ptr->ifa_family);
			xfree(ifa_ptr->ifa_name);
			xfree(ifa_ptr);
		}
		xfree(node_ptr->ifa_array);
		xfree(node_ptr->node_name);
		xfree(node_ptr);
	}
	gen_step_info->node_cnt = 0;
	xfree(gen_step_info->node_array);
	return SLURM_ERROR;
}
Beispiel #9
0
static int
io_init_msg_unpack(struct slurm_io_init_msg *hdr, Buf buffer)
{
	uint32_t val;
	safe_unpack16(&hdr->version, buffer);
	safe_unpack32(&hdr->nodeid, buffer);
	safe_unpack32(&hdr->stdout_objs, buffer);
	safe_unpack32(&hdr->stderr_objs, buffer);
	safe_unpackmem((char *) hdr->cred_signature, &val, buffer);
	if (val != SLURM_IO_KEY_SIZE)
		goto unpack_error;

	return SLURM_SUCCESS;

    unpack_error:
	error("unpack error in io_init_msg_unpack");
	return SLURM_ERROR;
}
Beispiel #10
0
static int _unpack_jobacct_id(jobacct_id_t *jobacct_id,
			      uint16_t rpc_version, Buf buffer)
{
	safe_unpack32(&jobacct_id->nodeid, buffer);
	safe_unpack16(&jobacct_id->taskid, buffer);

	return SLURM_SUCCESS;
unpack_error:
	return SLURM_ERROR;
}
Beispiel #11
0
static int _unpack_register_ctld_msg(dbd_register_ctld_msg_t **msg,
				     uint16_t rpc_version, Buf buffer)
{
	dbd_register_ctld_msg_t *msg_ptr = xmalloc(
		sizeof(dbd_register_ctld_msg_t));
	*msg = msg_ptr;
	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack16(&msg_ptr->dimensions, buffer);
		safe_unpack32(&msg_ptr->flags, buffer);
		safe_unpack32(&msg_ptr->plugin_id_select, buffer);
		safe_unpack16(&msg_ptr->port, buffer);
	}
	return SLURM_SUCCESS;

unpack_error:
	slurmdbd_free_register_ctld_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #12
0
extern int slurmdbd_unpack_id_rc_msg(void **msg,
				     uint16_t rpc_version, Buf buffer)
{
	dbd_id_rc_msg_t *msg_ptr = xmalloc(sizeof(dbd_id_rc_msg_t));

	*msg = msg_ptr;

	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack32(&msg_ptr->job_id, buffer);
		safe_unpack64(&msg_ptr->db_index, buffer);
		safe_unpack32(&msg_ptr->return_code, buffer);
	}

	return SLURM_SUCCESS;

unpack_error:
	slurmdbd_free_id_rc_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #13
0
extern int ext_sensors_data_unpack(ext_sensors_data_t **ext_sensors, Buf buffer,
				     uint16_t protocol_version)
{
	ext_sensors_data_t *ext_sensors_ptr = ext_sensors_alloc();
	*ext_sensors = ext_sensors_ptr;
	if (ext_sensors_ptr == NULL)
		return SLURM_ERROR;

	safe_unpack32(&ext_sensors_ptr->consumed_energy, buffer);
	safe_unpack32(&ext_sensors_ptr->temperature, buffer);
	safe_unpack_time(&ext_sensors_ptr->energy_update_time, buffer);
	safe_unpack32(&ext_sensors_ptr->current_watts, buffer);

	return SLURM_SUCCESS;

unpack_error:
	ext_sensors_destroy(ext_sensors_ptr);
	*ext_sensors = NULL;
	return SLURM_ERROR;
}
Beispiel #14
0
/* Load jobcomp data from save state file */
static int _load_pending_jobs(void)
{
	int i, rc = SLURM_SUCCESS;
	char *saved_data = NULL, *state_file = NULL, *job_data = NULL;
	uint32_t data_size, job_cnt = 0, tmp32 = 0;
	Buf buffer;
	struct job_node *jnode;

	state_file = slurm_get_state_save_location();
	if (state_file == NULL) {
		error("%s: Could not retrieve StateSaveLocation from conf",
		      plugin_type);
		return SLURM_ERROR;
	}

	if (state_file[strlen(state_file) - 1] != '/')
		xstrcat(state_file, "/");
	xstrcat(state_file, save_state_file);

	slurm_mutex_lock(&save_lock);
	data_size = _read_file(state_file, &saved_data);
	if ((data_size <= 0) || (saved_data == NULL)) {
		slurm_mutex_unlock(&save_lock);
		xfree(saved_data);
		xfree(state_file);
		return rc;
	}
	slurm_mutex_unlock(&save_lock);

	buffer = create_buf(saved_data, data_size);
	safe_unpack32(&job_cnt, buffer);
	for (i = 0; i < job_cnt; i++) {
		safe_unpackstr_xmalloc(&job_data, &tmp32, buffer);
		jnode = xmalloc(sizeof(struct job_node));
		jnode->serialized_job = job_data;
		list_enqueue(jobslist, jnode);
	}
	if (job_cnt > 0) {
		if (slurm_get_debug_flags() & DEBUG_FLAG_ESEARCH)
			info("%s: Loaded %u jobs from state file", plugin_type,
			     job_cnt);
	}
	free_buf(buffer);
	xfree(state_file);

	return rc;

unpack_error:
	error("%s: Error unpacking file %s", plugin_type, state_file);
	free_buf(buffer);
	xfree(state_file);
	return SLURM_ERROR;
}
Beispiel #15
0
int
io_hdr_unpack(io_hdr_t *hdr, Buf buffer)
{
	safe_unpack16(&hdr->type, buffer);
	safe_unpack16(&hdr->gtaskid, buffer);
	safe_unpack16(&hdr->ltaskid, buffer);
	safe_unpack32(&hdr->length, buffer);
	return SLURM_SUCCESS;

    unpack_error:
	error("io_hdr_unpack error: %m");
	return SLURM_ERROR;
}
Beispiel #16
0
extern int acct_gather_energy_unpack(acct_gather_energy_t **energy, Buf buffer,
				     uint16_t protocol_version)
{
	acct_gather_energy_t *energy_ptr = acct_gather_energy_alloc();
	*energy = energy_ptr;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack32(&energy_ptr->base_consumed_energy, buffer);
		safe_unpack32(&energy_ptr->base_watts, buffer);
		safe_unpack32(&energy_ptr->consumed_energy, buffer);
		safe_unpack32(&energy_ptr->current_watts, buffer);
		safe_unpack32(&energy_ptr->previous_consumed_energy, buffer);
		safe_unpack_time(&energy_ptr->poll_time, buffer);
	}

	return SLURM_SUCCESS;

unpack_error:
	acct_gather_energy_destroy(energy_ptr);
	*energy = NULL;
	return SLURM_ERROR;
}
Beispiel #17
0
static int _unpack_job_suspend_msg(dbd_job_suspend_msg_t **msg,
				   uint16_t rpc_version, Buf buffer)
{
	dbd_job_suspend_msg_t *msg_ptr = xmalloc(sizeof(dbd_job_suspend_msg_t));
	*msg = msg_ptr;

	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack32(&msg_ptr->assoc_id, buffer);
		safe_unpack64(&msg_ptr->db_index, buffer);
		safe_unpack32(&msg_ptr->job_id, buffer);
		safe_unpack32(&msg_ptr->job_state, buffer);
		safe_unpack_time(&msg_ptr->submit_time, buffer);
		safe_unpack_time(&msg_ptr->suspend_time, buffer);
	}

	return SLURM_SUCCESS;

unpack_error:
	slurmdbd_free_job_suspend_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #18
0
extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer,
				 uint16_t protocol_version)
{
	uint32_t uint32_tmp;
	struct check_job_info *check_ptr =
		(struct check_job_info *)jobinfo;

	if (protocol_version >= SLURM_14_03_PROTOCOL_VERSION) {
		uint16_t id;
		uint32_t size;

		safe_unpack16(&id, buffer);
		safe_unpack32(&size, buffer);
		if (id != CHECK_BLCR) {
			uint32_t x;
			x = get_buf_offset(buffer);
			set_buf_offset(buffer, x + size);
		} else {
			safe_unpack16(&check_ptr->disabled, buffer);
			safe_unpack_time(&check_ptr->time_stamp, buffer);
			safe_unpack32(&check_ptr->error_code, buffer);
			safe_unpackstr_xmalloc(&check_ptr->error_msg,
					       &uint32_tmp, buffer);
		}

	} else if (protocol_version >= SLURM_2_6_PROTOCOL_VERSION) {
		safe_unpack16(&check_ptr->disabled, buffer);
		safe_unpack_time(&check_ptr->time_stamp, buffer);
		safe_unpack32(&check_ptr->error_code, buffer);
		safe_unpackstr_xmalloc(&check_ptr->error_msg,
				       &uint32_tmp, buffer);
	}
	return SLURM_SUCCESS;

    unpack_error:
	xfree(check_ptr->error_msg);
	return SLURM_ERROR;
}
Beispiel #19
0
/* Unpack a power management data structure
 * Use power_mgmt_data_free() to free the returned structure */
extern int power_mgmt_data_unpack(power_mgmt_data_t **power, Buf buffer,
				  uint16_t protocol_version)
{
	power_mgmt_data_t *power_ptr = xmalloc(sizeof(power_mgmt_data_t));

	safe_unpack32(&power_ptr->cap_watts, buffer);
	*power = power_ptr;
	return SLURM_SUCCESS;

unpack_error:
	xfree(power_ptr);
	*power = NULL;
	return SLURM_ERROR;
}
Beispiel #20
0
extern int unpack_slurmd_conf_lite_no_alloc(slurmd_conf_t *conf, Buf buffer)
{
    uint32_t uint32_tmp;

    safe_unpackstr_xmalloc(&conf->hostname, &uint32_tmp, buffer);
    safe_unpack16(&conf->cpus, buffer);
    safe_unpack16(&conf->boards, buffer);
    safe_unpack16(&conf->sockets, buffer);
    safe_unpack16(&conf->cores, buffer);
    safe_unpack16(&conf->threads, buffer);
    safe_unpack32(&conf->real_memory_size, buffer);
    safe_unpack16(&conf->block_map_size, buffer);
    safe_unpack16_array(&conf->block_map, &uint32_tmp, buffer);
    safe_unpack16_array(&conf->block_map_inv,  &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->spooldir,    &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->node_name,   &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->logfile,     &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->task_prolog, &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->task_epilog, &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->job_acct_gather_freq, &uint32_tmp,
                           buffer);
    safe_unpackstr_xmalloc(&conf->job_acct_gather_type, &uint32_tmp,
                           buffer);
    safe_unpack16(&conf->propagate_prio, buffer);
    safe_unpack32(&conf->debug_flags, buffer);
    safe_unpack32(&uint32_tmp, buffer);
    conf->debug_level = uint32_tmp;
    safe_unpack32(&uint32_tmp, buffer);
    conf->daemonize = uint32_tmp;
    safe_unpack32(&uint32_tmp, buffer);
    conf->slurm_user_id = (uid_t)uint32_tmp;
    safe_unpack16(&conf->use_pam, buffer);
    safe_unpack16(&conf->task_plugin_param, buffer);
    safe_unpackstr_xmalloc(&conf->node_topo_addr, &uint32_tmp, buffer);
    safe_unpackstr_xmalloc(&conf->node_topo_pattern, &uint32_tmp, buffer);
    safe_unpack32(&uint32_tmp, buffer);
    safe_unpack16(&conf->log_fmt, buffer);
    safe_unpack16(&conf->mem_limit_enforce, buffer);
    conf->port = uint32_tmp;
    return SLURM_SUCCESS;

unpack_error:
    error("unpack_error in unpack_slurmd_conf_lite_no_alloc: %m");
    xfree(conf->job_acct_gather_freq);
    xfree(conf->job_acct_gather_type);
    xfree(conf->hostname);
    xfree(conf->spooldir);
    xfree(conf->node_name);
    xfree(conf->logfile);
    xfree(conf->task_prolog);
    xfree(conf->task_epilog);
    xfree(conf->node_topo_addr);
    xfree(conf->node_topo_pattern);
    return SLURM_ERROR;
}
Beispiel #21
0
/*
 * Unmarshall a credential after transmission over the network according
 * to SLURM's marshalling protocol.
 */
slurm_auth_credential_t *
slurm_auth_unpack( Buf buf )
{
	slurm_auth_credential_t *cred = NULL;
	char    *type;
	uint32_t size;
	uint32_t version;

	if ( buf == NULL ) {
		plugin_errno = SLURM_AUTH_BADARG;
		return NULL;
	}

	/*
	 * Get the authentication type.
	 */
	safe_unpackmem_ptr( &type, &size, buf );

	if (( type == NULL ) ||
	    ( strcmp( type, plugin_type ) != 0 )) {
		plugin_errno = SLURM_AUTH_MISMATCH;
		return NULL;
	}
	safe_unpack32( &version, buf );
	if ( version < min_plug_version ) {
		plugin_errno = SLURM_AUTH_VERSION;
		return NULL;
	}

	/* Allocate and initialize credential. */
	cred = xmalloc(sizeof(*cred));
	cred->verified = false;
	cred->m_str    = NULL;
	cred->buf      = NULL;
	cred->len      = 0;
	cred->cr_errno = SLURM_SUCCESS;

	xassert(cred->magic = MUNGE_MAGIC);

	safe_unpackstr_malloc(&cred->m_str, &size, buf);
	return cred;

 unpack_error:
	plugin_errno = SLURM_AUTH_UNPACK;
	xfree( cred );
	return NULL;
}
Beispiel #22
0
static struct job_option_info * job_option_info_unpack (Buf buf)
{
	struct job_option_info *ji = xmalloc (sizeof (*ji));
	uint32_t type;
	uint32_t len;

	safe_unpack32 (&type, buf);
	safe_unpackstr_xmalloc (&ji->option, &len, buf);
	safe_unpackstr_xmalloc (&ji->optarg, &len, buf);

	ji->type = (int) type;
	return (ji);

  unpack_error:
	job_option_info_destroy (ji);
	return (NULL);
}
Beispiel #23
0
static int _unpack_step_start_msg(dbd_step_start_msg_t **msg,
				  uint16_t rpc_version, Buf buffer)
{
	uint32_t uint32_tmp = 0;
	dbd_step_start_msg_t *msg_ptr = xmalloc(sizeof(dbd_step_start_msg_t));
	*msg = msg_ptr;

	if (rpc_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack32(&msg_ptr->assoc_id, buffer);
		safe_unpack64(&msg_ptr->db_index, buffer);
		safe_unpack32(&msg_ptr->job_id, buffer);
		safe_unpackstr_xmalloc(&msg_ptr->name, &uint32_tmp, buffer);
		safe_unpackstr_xmalloc(&msg_ptr->nodes, &uint32_tmp, buffer);
		safe_unpackstr_xmalloc(&msg_ptr->node_inx, &uint32_tmp, buffer);
		safe_unpack32(&msg_ptr->node_cnt, buffer);
		safe_unpack_time(&msg_ptr->start_time, buffer);
		safe_unpack_time(&msg_ptr->job_submit_time, buffer);
		safe_unpack32(&msg_ptr->req_cpufreq_min, buffer);
		safe_unpack32(&msg_ptr->req_cpufreq_max, buffer);
		safe_unpack32(&msg_ptr->req_cpufreq_gov, buffer);
		safe_unpack32(&msg_ptr->step_id, buffer);
		safe_unpack32(&msg_ptr->task_dist, buffer);
		safe_unpack32(&msg_ptr->total_tasks, buffer);
		safe_unpackstr_xmalloc(&msg_ptr->tres_alloc_str,
				       &uint32_tmp, buffer);
	} else
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	debug2("slurmdbd_unpack_step_start_msg:"
	       "unpack_error: size_buf(buffer) %u",
	       size_buf(buffer));
	slurmdbd_free_step_start_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #24
0
extern int select_g_select_nodeinfo_unpack(dynamic_plugin_data_t **nodeinfo,
					   Buf buffer,
					   uint16_t protocol_version)
{
	dynamic_plugin_data_t *nodeinfo_ptr = NULL;

	if (slurm_select_init(0) < 0)
		return SLURM_ERROR;

	nodeinfo_ptr = xmalloc(sizeof(dynamic_plugin_data_t));
	*nodeinfo = nodeinfo_ptr;

	if (protocol_version >= SLURM_2_5_PROTOCOL_VERSION) {
		int i;
		uint32_t plugin_id;
		safe_unpack32(&plugin_id, buffer);
		for (i=0; i<select_context_cnt; i++)
			if (*(ops[i].plugin_id) == plugin_id) {
				nodeinfo_ptr->plugin_id = i;
				break;
			}
		if (i >= select_context_cnt) {
			error("we don't have select plugin type %u",plugin_id);
			goto unpack_error;
		}
	} else {
		nodeinfo_ptr->plugin_id = select_context_default;
		error("select_g_select_nodeinfo_unpack: protocol_version"
		      " %hu not supported", protocol_version);
		goto unpack_error;
	}

	if ((*(ops[nodeinfo_ptr->plugin_id].nodeinfo_unpack))
	   ((select_nodeinfo_t **)&nodeinfo_ptr->data, buffer,
	    protocol_version) != SLURM_SUCCESS)
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	select_g_select_nodeinfo_free(nodeinfo_ptr);
	*nodeinfo = NULL;
	error("select_g_select_nodeinfo_unpack: unpack error");
	return SLURM_ERROR;
}
Beispiel #25
0
extern int switch_g_unpack_jobinfo(dynamic_plugin_data_t **jobinfo, Buf buffer,
				   uint16_t protocol_version)
{
	dynamic_plugin_data_t *jobinfo_ptr = NULL;

	if ( switch_init(0) < 0 )
		return SLURM_ERROR;

	jobinfo_ptr = xmalloc(sizeof(dynamic_plugin_data_t));
	*jobinfo = jobinfo_ptr;

	if (protocol_version >= SLURM_17_11_PROTOCOL_VERSION) {
		int i;
		uint32_t plugin_id;
		safe_unpack32(&plugin_id, buffer);
		for (i = 0; i < switch_context_cnt; i++) {
			if (*(ops[i].plugin_id) == plugin_id) {
				jobinfo_ptr->plugin_id = i;
				break;
			}
		}
		if (i >= switch_context_cnt) {
			error("we don't have switch plugin type %u", plugin_id);
			goto unpack_error;
		}
	} else {
		jobinfo_ptr->plugin_id = switch_context_default;
	}

	if  ((*(ops[jobinfo_ptr->plugin_id].unpack_jobinfo))
	     ((switch_jobinfo_t **)&jobinfo_ptr->data, buffer,
	      protocol_version))
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	switch_g_free_jobinfo(jobinfo_ptr);
	*jobinfo = NULL;
	error("%s: unpack error", __func__);
	return SLURM_ERROR;
}
Beispiel #26
0
extern int slurm_persist_unpack_rc_msg(
	persist_rc_msg_t **msg, Buf buffer, uint16_t protocol_version)
{
	uint32_t uint32_tmp;

	persist_rc_msg_t *msg_ptr = xmalloc(sizeof(persist_rc_msg_t));

	*msg = msg_ptr;

	safe_unpackstr_xmalloc(&msg_ptr->comment, &uint32_tmp, buffer);
	safe_unpack32(&msg_ptr->rc, buffer);
	safe_unpack16(&msg_ptr->ret_info, buffer);

	return SLURM_SUCCESS;

unpack_error:
	slurm_persist_free_rc_msg(msg_ptr);
	*msg = NULL;
	return SLURM_ERROR;
}
Beispiel #27
0
extern int slurm_ckpt_unpack_job(check_jobinfo_t jobinfo, Buf buffer,
				 uint16_t protocol_version)
{
	uint16_t id;
	uint32_t x;
	uint32_t size;

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack16(&id, buffer);
		safe_unpack32(&size, buffer);
		if (id != CHECK_NONE) {
			x = get_buf_offset(buffer);
			set_buf_offset(buffer, x + size);
		}
	}
	return SLURM_SUCCESS;

unpack_error:
	return SLURM_ERROR;
}
Beispiel #28
0
/* unpack a select job credential from a buffer
 * OUT jobinfo - the select job credential read
 * IN  buffer  - buffer with select credential read from current pointer loc
 * RET         - slurm error code
 * NOTE: returned value must be freed using select_g_free_jobinfo
 */
extern int select_g_select_jobinfo_unpack(dynamic_plugin_data_t **jobinfo,
					  Buf buffer,
					  uint16_t protocol_version)
{
	dynamic_plugin_data_t *jobinfo_ptr = NULL;

	if (slurm_select_init(0) < 0)
		return SLURM_ERROR;

	jobinfo_ptr = xmalloc(sizeof(dynamic_plugin_data_t));
	*jobinfo = jobinfo_ptr;

	if(protocol_version >= SLURM_2_2_PROTOCOL_VERSION) {
		int i;
		uint32_t plugin_id;
		safe_unpack32(&plugin_id, buffer);
		for (i=0; i<select_context_cnt; i++)
			if(*(select_context[i].ops.plugin_id) == plugin_id) {
				jobinfo_ptr->plugin_id = i;
				break;
			}
		if (i >= select_context_cnt) {
			error("we don't have this plugin type %u", plugin_id);
			goto unpack_error;
		}
	} else
		jobinfo_ptr->plugin_id = select_context_default;

	if ((*(select_context[jobinfo_ptr->plugin_id].ops.jobinfo_unpack))
		((select_jobinfo_t **)&jobinfo_ptr->data, buffer,
		 protocol_version) != SLURM_SUCCESS)
		goto unpack_error;

	return SLURM_SUCCESS;

unpack_error:
	select_g_select_jobinfo_free(jobinfo_ptr);
	*jobinfo = NULL;
	error("select_g_select_jobinfo_unpack: unpack error");
	return SLURM_ERROR;
}
extern int acct_gather_energy_unpack(acct_gather_energy_t **energy, Buf buffer,
				     uint16_t protocol_version, bool need_alloc)
{
	uint32_t uint32_tmp;
	acct_gather_energy_t *energy_ptr;

	if (need_alloc) {
		energy_ptr = acct_gather_energy_alloc(1);
		*energy = energy_ptr;
	} else {
		energy_ptr = *energy;
	}

	if (protocol_version >= SLURM_15_08_PROTOCOL_VERSION) {
		safe_unpack64(&energy_ptr->base_consumed_energy, buffer);
		safe_unpack32(&energy_ptr->base_watts, buffer);
		safe_unpack64(&energy_ptr->consumed_energy, buffer);
		safe_unpack32(&energy_ptr->current_watts, buffer);
		safe_unpack64(&energy_ptr->previous_consumed_energy, buffer);
		safe_unpack_time(&energy_ptr->poll_time, buffer);
	} else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		safe_unpack32(&uint32_tmp, buffer);
		energy_ptr->base_consumed_energy = (uint64_t) uint32_tmp;
		safe_unpack32(&energy_ptr->base_watts, buffer);
		safe_unpack32(&uint32_tmp, buffer);
		energy_ptr->consumed_energy = (uint64_t) uint32_tmp;
		safe_unpack32(&energy_ptr->current_watts, buffer);
		safe_unpack32(&uint32_tmp, buffer);
		energy_ptr->previous_consumed_energy = (uint64_t) uint32_tmp;
		safe_unpack_time(&energy_ptr->poll_time, buffer);
	}

	return SLURM_SUCCESS;

unpack_error:
	if (need_alloc) {
		acct_gather_energy_destroy(energy_ptr);
		*energy = NULL;
	} else
		memset(energy_ptr, 0, sizeof(acct_gather_energy_t));

	return SLURM_ERROR;
}
Beispiel #30
0
static void _state_read_buf(Buf buffer)
{
    uint16_t protocol_version = (uint16_t) NO_VAL;
    uint32_t min_port, max_port;
    int i;

    /* Validate state version */
    safe_unpack16(&protocol_version, buffer);
    debug3("Version in switch_cray header is %u", protocol_version);
    if (protocol_version < SLURM_MIN_PROTOCOL_VERSION) {
        error("******************************************************");
        error("Can't recover switch/cray state, incompatible version");
        error("******************************************************");
        return;
    }
    if (protocol_version >= SLURM_14_11_PROTOCOL_VERSION) {
        safe_unpack32(&min_port, buffer);
        safe_unpack32(&max_port, buffer);
        safe_unpack32(&last_alloc_port, buffer);
        unpack_bit_str(&port_resv, buffer);
    } else if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
        uint8_t port_set = 0;
        safe_unpack32(&min_port, buffer);
        safe_unpack32(&max_port, buffer);
        safe_unpack32(&last_alloc_port, buffer);
        port_resv = bit_alloc(PORT_CNT);
        for (i = 0; i < PORT_CNT; i++) {
            safe_unpack8(&port_set, buffer);
            if (port_set)
                bit_set(port_resv, i);
        }
    }
    if ((min_port != MIN_PORT) || (max_port != MAX_PORT)) {
        error("******************************************************");
        error("Can not recover switch/cray state");
        error("Changed MIN_PORT (%u != %u) and/or MAX_PORT (%u != %u)",
              min_port, MIN_PORT, max_port, MAX_PORT);
        error("******************************************************");
        return;
    }

    return;

unpack_error:
    CRAY_ERR("unpack error");
    return;
}