示例#1
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;
}
示例#2
0
extern int unpack_job_resources(job_resources_t **job_resrcs_pptr,
				Buf buffer, uint16_t protocol_version)
{
	char *bit_fmt = NULL;
	uint32_t empty, tmp32;
	job_resources_t *job_resrcs;
	uint32_t cluster_flags = slurmdb_setup_cluster_flags();

	xassert(job_resrcs_pptr);
	if (protocol_version >= SLURM_2_5_PROTOCOL_VERSION) {
		safe_unpack32(&empty, buffer);
		if (empty == NO_VAL) {
			*job_resrcs_pptr = NULL;
			return SLURM_SUCCESS;
		}

		job_resrcs = xmalloc(sizeof(struct job_resources));
		job_resrcs->nhosts = empty;
		safe_unpack32(&job_resrcs->ncpus, buffer);
		safe_unpack32(&job_resrcs->node_req, buffer);
		safe_unpackstr_xmalloc(&job_resrcs->nodes, &tmp32, buffer);

		safe_unpack32_array(&job_resrcs->cpu_array_reps,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpu_array_reps);
		job_resrcs->cpu_array_cnt = tmp32;

		safe_unpack16_array(&job_resrcs->cpu_array_value,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpu_array_value);

		if (tmp32 != job_resrcs->cpu_array_cnt)
			goto unpack_error;

		safe_unpack16_array(&job_resrcs->cpus, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpus);
		if (tmp32 != job_resrcs->nhosts)
			goto unpack_error;
		safe_unpack16_array(&job_resrcs->cpus_used, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpus_used);

		safe_unpack32_array(&job_resrcs->memory_allocated,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->memory_allocated);
		safe_unpack32_array(&job_resrcs->memory_used, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->memory_used);

		if (!(cluster_flags & CLUSTER_FLAG_BG)) {
			safe_unpack16_array(&job_resrcs->sockets_per_node,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->sockets_per_node);
			safe_unpack16_array(&job_resrcs->cores_per_socket,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->cores_per_socket);
			safe_unpack32_array(&job_resrcs->sock_core_rep_count,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->sock_core_rep_count);

			unpack_bit_str(&job_resrcs->core_bitmap, buffer);
			unpack_bit_str(&job_resrcs->core_bitmap_used, buffer);
		}
	} else if (protocol_version >= SLURM_2_3_PROTOCOL_VERSION) {
		uint8_t tmp_8;
		safe_unpack32(&empty, buffer);
		if (empty == NO_VAL) {
			*job_resrcs_pptr = NULL;
			return SLURM_SUCCESS;
		}

		job_resrcs = xmalloc(sizeof(struct job_resources));
		job_resrcs->nhosts = empty;
		safe_unpack32(&job_resrcs->ncpus, buffer);
		safe_unpack8(&tmp_8, buffer);
		if (tmp_8 < 100)		/* Not NODE_CR_RESERVED */
			job_resrcs->node_req = tmp_8;	/* 32-bit in v2.5 */
		else
			job_resrcs->node_req = NODE_CR_RESERVED;
		safe_unpackstr_xmalloc(&job_resrcs->nodes, &tmp32, buffer);

		safe_unpack32_array(&job_resrcs->cpu_array_reps,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpu_array_reps);
		job_resrcs->cpu_array_cnt = tmp32;

		safe_unpack16_array(&job_resrcs->cpu_array_value,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpu_array_value);

		if (tmp32 != job_resrcs->cpu_array_cnt)
			goto unpack_error;

		safe_unpack16_array(&job_resrcs->cpus, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpus);
		if (tmp32 != job_resrcs->nhosts)
			goto unpack_error;
		safe_unpack16_array(&job_resrcs->cpus_used, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->cpus_used);

		safe_unpack32_array(&job_resrcs->memory_allocated,
				    &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->memory_allocated);
		safe_unpack32_array(&job_resrcs->memory_used, &tmp32, buffer);
		if (tmp32 == 0)
			xfree(job_resrcs->memory_used);

		if (!(cluster_flags & CLUSTER_FLAG_BG)) {
			safe_unpack16_array(&job_resrcs->sockets_per_node,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->sockets_per_node);
			safe_unpack16_array(&job_resrcs->cores_per_socket,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->cores_per_socket);
			safe_unpack32_array(&job_resrcs->sock_core_rep_count,
					    &tmp32, buffer);
			if (tmp32 == 0)
				xfree(job_resrcs->sock_core_rep_count);

			unpack_bit_str(&job_resrcs->core_bitmap, buffer);
			unpack_bit_str(&job_resrcs->core_bitmap_used, buffer);
		}
	} else {
		error("unpack_job_resources: protocol_version %hu not "
		      "supported", protocol_version);
		goto unpack_error;
	}

	*job_resrcs_pptr = job_resrcs;
	return SLURM_SUCCESS;

unpack_error:
	error("unpack_job_resources: unpack error");
	free_job_resources(&job_resrcs);
	xfree(bit_fmt);
	*job_resrcs_pptr = NULL;
	return SLURM_ERROR;
}
示例#3
0
extern int unpack_slurmd_conf_lite_no_alloc(slurmd_conf_t *conf, Buf buffer)
{
	uint32_t uint32_tmp;
	uint16_t protocol_version;
	char *ver_str = NULL;

	safe_unpackstr_xmalloc(&ver_str, &uint32_tmp, buffer);
	safe_unpack16(&protocol_version, buffer);
	xfree(ver_str);

	if (protocol_version >= SLURM_MIN_PROTOCOL_VERSION) {
		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_unpack64(&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_unpack64(&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_unpack32(&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);
		conf->port = uint32_tmp;
		safe_unpack16(&conf->log_fmt, buffer);
		safe_unpack16(&conf->mem_limit_enforce, buffer);
		safe_unpack64(&conf->msg_aggr_window_msgs, buffer);
		safe_unpackstr_xmalloc(&conf->tmpfs, &uint32_tmp, buffer);
		safe_unpackstr_xmalloc(&conf->x11_params, &uint32_tmp, buffer);
	}

	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);
	xfree(conf->tmpfs);
	xfree(conf->x11_params);
	return SLURM_ERROR;
}
extern int unpack_slurmd_conf_lite_no_alloc(slurmd_conf_t *conf, Buf buffer)
{
	uint32_t uint32_tmp;
	uint16_t protocol_version;
	char *ver_str = NULL;

	safe_unpackstr_xmalloc(&ver_str, &uint32_tmp, buffer);
	if (ver_str && !xstrcmp(ver_str, PROTOCOL_VERSION)) {
		safe_unpack16(&protocol_version, buffer);
		xfree(ver_str);
	} else {
		/* Kludge to add protocol version in existing data structure:
		 * use "hostname" as a version marker. Eliminate this in
		 * the future. */
		conf->hostname = ver_str;
		protocol_version = SLURM_16_05_PROTOCOL_VERSION;
	}

	if (protocol_version >= SLURM_17_02_PROTOCOL_VERSION) {
		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_unpack64(&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_unpack64(&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_unpack32(&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);
		conf->port = uint32_tmp;
		safe_unpack16(&conf->log_fmt, buffer);
		safe_unpack16(&conf->mem_limit_enforce, buffer);
		safe_unpack64(&conf->msg_aggr_window_msgs, buffer);
	} else {
		uint32_t real_memory_size = 0;
		// 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(&real_memory_size, buffer);
		conf->real_memory_size = real_memory_size;
		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_unpack64(&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_unpack32(&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);
		conf->port = uint32_tmp;
		safe_unpack16(&conf->log_fmt, buffer);
		safe_unpack16(&conf->mem_limit_enforce, buffer);
		safe_unpack64(&conf->msg_aggr_window_msgs, buffer);
	}

	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;
}