Commit 04c48172 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

conf: add accessors for section name and num



Remove usage of the conf structs so they can be moved out of the public
API header.

Change-Id: I1c7375ec7708b323f50af09aeb7b2b2c9c770df4
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 9df6675e
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -437,10 +437,11 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
	int i, ret;
	uint64_t mask;
	int lcore = 0;
	int num = spdk_conf_section_get_num(sp);

	nqn = spdk_conf_section_get_val(sp, "NQN");
	if (nqn == NULL) {
		SPDK_ERRLOG("No NQN specified for Subsystem %d\n", sp->num);
		SPDK_ERRLOG("No NQN specified for Subsystem %d\n", num);
		return -1;
	}

@@ -449,7 +450,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
	lcore = spdk_conf_section_get_intval(sp, "Core");
	if (lcore < 0) {
		lcore = 0;
		for (i = 0; i < sp->num; i++) {
		for (i = 0; i < num; i++) {
			lcore = spdk_nvmf_allocate_lcore(mask, lcore);
			lcore++;
		}
@@ -458,7 +459,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)

	mode_str = spdk_conf_section_get_val(sp, "Mode");
	if (mode_str == NULL) {
		SPDK_ERRLOG("No Mode specified for Subsystem %d\n", sp->num);
		SPDK_ERRLOG("No Mode specified for Subsystem %d\n", num);
		return -1;
	}

@@ -531,7 +532,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
		/* Parse NVMe section */
		bdf = spdk_conf_section_get_val(sp, "NVMe");
		if (bdf == NULL) {
			SPDK_ERRLOG("Subsystem %d: missing NVMe directive\n", sp->num);
			SPDK_ERRLOG("Subsystem %d: missing NVMe directive\n", num);
			return -1;
		}

@@ -552,7 +553,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)
		}

		if (!ctx.found) {
			SPDK_ERRLOG("Could not find NVMe controller for Subsystem%d\n", sp->num);
			SPDK_ERRLOG("Could not find NVMe controller for Subsystem%d\n", num);
			return -1;
		}
	} else {
@@ -561,7 +562,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)

		sn = spdk_conf_section_get_val(sp, "SN");
		if (sn == NULL) {
			SPDK_ERRLOG("Subsystem %d: missing serial number\n", sp->num);
			SPDK_ERRLOG("Subsystem %d: missing serial number\n", num);
			return -1;
		}
		if (spdk_nvmf_validate_sn(sn) != 0) {
@@ -570,7 +571,7 @@ spdk_nvmf_parse_subsystem(struct spdk_conf_section *sp)

		namespace = spdk_conf_section_get_val(sp, "Namespace");
		if (namespace == NULL) {
			SPDK_ERRLOG("Subsystem %d: missing Namespace directive\n", sp->num);
			SPDK_ERRLOG("Subsystem %d: missing Namespace directive\n", num);
			return -1;
		}

+2 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ struct spdk_conf_section *spdk_conf_first_section(struct spdk_conf *cp);
struct spdk_conf_section *spdk_conf_next_section(struct spdk_conf_section *sp);

bool spdk_conf_section_match_prefix(const struct spdk_conf_section *sp, const char *name_prefix);
const char *spdk_conf_section_get_name(const struct spdk_conf_section *sp);
int spdk_conf_section_get_num(const struct spdk_conf_section *sp);
char *spdk_conf_section_get_nmval(struct spdk_conf_section *sp, const char *key,
				  int idx1, int idx2);
char *spdk_conf_section_get_nval(struct spdk_conf_section *sp, const char *key, int idx);
+12 −0
Original line number Diff line number Diff line
@@ -325,6 +325,18 @@ spdk_conf_section_match_prefix(const struct spdk_conf_section *sp, const char *n
	return strncasecmp(sp->name, name_prefix, strlen(name_prefix)) == 0;
}

const char *
spdk_conf_section_get_name(const struct spdk_conf_section *sp)
{
	return sp->name;
}

int
spdk_conf_section_get_num(const struct spdk_conf_section *sp)
{
	return sp->num;
}

char *
spdk_conf_section_get_nmval(struct spdk_conf_section *sp, const char *key, int idx1, int idx2)
{
+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ spdk_app_init(struct spdk_app_opts *opts)
			fprintf(stderr, "Could not read config file %s\n", opts->config_file);
			exit(EXIT_FAILURE);
		}
		if (config->section == NULL) {
		if (spdk_conf_first_section(config) == NULL) {
			fprintf(stderr, "Invalid config file %s\n", opts->config_file);
			exit(EXIT_FAILURE);
		}
+4 −3
Original line number Diff line number Diff line
@@ -65,8 +65,9 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
	int num_initiator_names;
	int num_initiator_masks;
	char **initiators = NULL, **netmasks = NULL;
	int tag = spdk_conf_section_get_num(sp);

	SPDK_TRACELOG(SPDK_TRACE_DEBUG, "add initiator group %d\n", sp->num);
	SPDK_TRACELOG(SPDK_TRACE_DEBUG, "add initiator group %d\n", tag);

	val = spdk_conf_section_get_val(sp, "Comment");
	if (val != NULL) {
@@ -145,7 +146,7 @@ spdk_iscsi_init_grp_create_from_configfile(struct spdk_conf_section *sp)
		}
	}

	rc = spdk_iscsi_init_grp_create_from_initiator_list(sp->num,
	rc = spdk_iscsi_init_grp_create_from_initiator_list(tag,
			num_initiator_names, initiators, num_initiator_masks, netmasks);
	if (rc < 0) {
		goto cleanup;
@@ -307,7 +308,7 @@ spdk_iscsi_init_grp_array_create(void)
	sp = spdk_conf_first_section(NULL);
	while (sp != NULL) {
		if (spdk_conf_section_match_prefix(sp, "InitiatorGroup")) {
			if (sp->num == 0) {
			if (spdk_conf_section_get_num(sp) == 0) {
				SPDK_ERRLOG("Group 0 is invalid\n");
				return -1;
			}
Loading