From 5a6f3a6f91436fa17e63547e45a52435b0387a58 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 18 Aug 2022 08:37:35 +0800 Subject: [PATCH] event: accept negative --shm-id as a valid option Before this change, a negative `--shm-id` value is rejected by `spdk_app_parse_args()` and this function simply errors out after detecting it. However, `build_eal_cmdline()` has a dedicated branch checking for a negative `opts->shm_id` and passes `--no-shconf` down to DPDK as a parameter, so we cannot disable the shared config support in DPDK. After this change, a negative value `--shm-id` is accepted, but if it cannot be parsed as an integer, `spdk_app_parse_args()` errors out as before. In result we can disable shared config support in DPDK by passing `--shm-id=-1` to SPDK application. Signed-off-by: Kefu Chai Change-Id: Ibe089f13638eefa9ac28c5c99e303bcc3102f307 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14097 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Krzysztof Karas Reviewed-by: Tomasz Zawadzki --- lib/event/app.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/event/app.c b/lib/event/app.c index ff431ea69..d92774397 100644 --- a/lib/event/app.c +++ b/lib/event/app.c @@ -750,6 +750,7 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, int ch, rc, opt_idx, global_long_opts_len, app_long_opts_len; struct option *cmdline_options; char *cmdline_short_opts = NULL; + char *shm_id_str = NULL; enum spdk_app_parse_args_rvals retval = SPDK_APP_PARSE_ARGS_FAIL; long int tmp; @@ -822,11 +823,22 @@ spdk_app_parse_args(int argc, char **argv, struct spdk_app_opts *opts, retval = SPDK_APP_PARSE_ARGS_HELP; goto out; case SHM_ID_OPT_IDX: - opts->shm_id = spdk_strtol(optarg, 0); + shm_id_str = optarg; + /* a negative shm-id disables shared configuration file */ + if (optarg[0] == '-') { + shm_id_str++; + } + /* check if the positive value of provided shm_id can be parsed as + * an integer + */ + opts->shm_id = spdk_strtol(shm_id_str, 0); if (opts->shm_id < 0) { SPDK_ERRLOG("Invalid shared memory ID %s\n", optarg); goto out; } + if (optarg[0] == '-') { + opts->shm_id = -opts->shm_id; + } break; case CPUMASK_OPT_IDX: opts->reactor_mask = optarg;