event/app: Refactor read global params of config file in spdk_app_start()
Refactor spdk_app_start() in lib/event/app.c to support JSON config file. Change-Id: Ia2b36e517b59b6ac1ffb12cb818efc8064fae495 Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/405362 Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
a4c86be7f0
commit
cf4cf8d52a
@ -300,12 +300,43 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_app_read_config_file_global_params(struct spdk_app_opts *opts)
|
||||||
|
{
|
||||||
|
struct spdk_conf_section *sp;
|
||||||
|
|
||||||
|
sp = spdk_conf_find_section(NULL, "Global");
|
||||||
|
|
||||||
|
if (opts->shm_id == -1) {
|
||||||
|
if (sp != NULL) {
|
||||||
|
opts->shm_id = spdk_conf_section_get_intval(sp, "SharedMemoryID");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->reactor_mask == NULL) {
|
||||||
|
if (sp && spdk_conf_section_get_val(sp, "ReactorMask")) {
|
||||||
|
opts->reactor_mask = spdk_conf_section_get_val(sp, "ReactorMask");
|
||||||
|
} else {
|
||||||
|
opts->reactor_mask = SPDK_APP_DPDK_DEFAULT_CORE_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!opts->no_pci && sp) {
|
||||||
|
opts->no_pci = spdk_conf_section_get_boolval(sp, "NoPci", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opts->tpoint_group_mask == NULL) {
|
||||||
|
if (sp != NULL) {
|
||||||
|
opts->tpoint_group_mask = spdk_conf_section_get_val(sp, "TpointGroupMask");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
||||||
void *arg1, void *arg2)
|
void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
struct spdk_conf *config = NULL;
|
struct spdk_conf *config = NULL;
|
||||||
struct spdk_conf_section *sp;
|
|
||||||
char shm_name[64];
|
char shm_name[64];
|
||||||
int rc;
|
int rc;
|
||||||
uint64_t tpoint_group_mask;
|
uint64_t tpoint_group_mask;
|
||||||
@ -344,29 +375,11 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
|||||||
goto app_start_setup_conf_err;
|
goto app_start_setup_conf_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->shm_id == -1) {
|
spdk_app_read_config_file_global_params(opts);
|
||||||
sp = spdk_conf_find_section(config, "Global");
|
|
||||||
if (sp != NULL) {
|
|
||||||
opts->shm_id = spdk_conf_section_get_intval(sp, "SharedMemoryID");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_log_set_level(SPDK_APP_DEFAULT_LOG_PRIORITY);
|
spdk_log_set_level(SPDK_APP_DEFAULT_LOG_PRIORITY);
|
||||||
spdk_log_open();
|
spdk_log_open();
|
||||||
|
|
||||||
sp = spdk_conf_find_section(config, "Global");
|
|
||||||
if (opts->reactor_mask == NULL) {
|
|
||||||
if (sp && spdk_conf_section_get_val(sp, "ReactorMask")) {
|
|
||||||
opts->reactor_mask = spdk_conf_section_get_val(sp, "ReactorMask");
|
|
||||||
} else {
|
|
||||||
opts->reactor_mask = SPDK_APP_DPDK_DEFAULT_CORE_MASK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!opts->no_pci && sp) {
|
|
||||||
opts->no_pci = spdk_conf_section_get_boolval(sp, "NoPci", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_env_opts_init(&env_opts);
|
spdk_env_opts_init(&env_opts);
|
||||||
|
|
||||||
env_opts.name = opts->name;
|
env_opts.name = opts->name;
|
||||||
@ -412,13 +425,6 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
|||||||
goto app_start_log_close_err;
|
goto app_start_log_close_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->tpoint_group_mask == NULL) {
|
|
||||||
sp = spdk_conf_find_section(config, "Global");
|
|
||||||
if (sp != NULL) {
|
|
||||||
opts->tpoint_group_mask = spdk_conf_section_get_val(sp, "TpointGroupMask");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opts->tpoint_group_mask != NULL) {
|
if (opts->tpoint_group_mask != NULL) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
tpoint_group_mask = strtoull(opts->tpoint_group_mask, &end, 16);
|
tpoint_group_mask = strtoull(opts->tpoint_group_mask, &end, 16);
|
||||||
|
Loading…
Reference in New Issue
Block a user