env_dpdk: save and restore optind in spdk_env_init
DPDK's use of getopt() needs special handling of the optind global variable since we are passing it a separate array of arguments (not the typical argv and argc). Set optind to 1 internally to env_dpdk so that the apps don't need to know about it, and restore optind in case the calling app is also using getopt(). Change-Id: Icbf07002c99fa9f94c866e8eff707124b0ef679b Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/365062 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
1f5bbe02cf
commit
9f237eac85
@ -175,8 +175,6 @@ main(int argc, char **argv)
|
|||||||
sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1; /* reset the optind */
|
|
||||||
|
|
||||||
opts.shutdown_cb = spdk_iscsi_shutdown;
|
opts.shutdown_cb = spdk_iscsi_shutdown;
|
||||||
opts.usr1_handler = spdk_sigusr1;
|
opts.usr1_handler = spdk_sigusr1;
|
||||||
spdk_app_init(&opts);
|
spdk_app_init(&opts);
|
||||||
|
@ -298,7 +298,7 @@ parse_args(int argc, char **argv)
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ parse_args(int argc, char **argv)
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +409,6 @@ parse_args(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,8 +960,6 @@ parse_args(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,7 +1179,7 @@ parse_args(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_aio_optind = optind;
|
g_aio_optind = optind;
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,6 +236,7 @@ void spdk_env_init(const struct spdk_env_opts *opts)
|
|||||||
char **args = NULL;
|
char **args = NULL;
|
||||||
char **dpdk_args = NULL;
|
char **dpdk_args = NULL;
|
||||||
int argcount, i, rc;
|
int argcount, i, rc;
|
||||||
|
int orig_optind;
|
||||||
|
|
||||||
argcount = spdk_build_eal_cmdline(opts, &args);
|
argcount = spdk_build_eal_cmdline(opts, &args);
|
||||||
if (argcount <= 0) {
|
if (argcount <= 0) {
|
||||||
@ -262,7 +263,10 @@ void spdk_env_init(const struct spdk_env_opts *opts)
|
|||||||
memcpy(dpdk_args, args, sizeof(char *) * argcount);
|
memcpy(dpdk_args, args, sizeof(char *) * argcount);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
orig_optind = optind;
|
||||||
|
optind = 1;
|
||||||
rc = rte_eal_init(argcount, dpdk_args);
|
rc = rte_eal_init(argcount, dpdk_args);
|
||||||
|
optind = orig_optind;
|
||||||
|
|
||||||
spdk_free_args(args, argcount);
|
spdk_free_args(args, argcount);
|
||||||
free(dpdk_args);
|
free(dpdk_args);
|
||||||
|
@ -105,8 +105,6 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1; /* reset the optind */
|
|
||||||
|
|
||||||
spdk_env_init(&opts);
|
spdk_env_init(&opts);
|
||||||
if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
|
if (spdk_nvme_probe(NULL, NULL, probe_cb, attach_cb, NULL) != 0) {
|
||||||
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
fprintf(stderr, "spdk_nvme_probe() failed\n");
|
||||||
|
@ -714,8 +714,6 @@ main(int argc, char **argv)
|
|||||||
g_zcopy = false;
|
g_zcopy = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1; /* reset the optind */
|
|
||||||
|
|
||||||
blockdev_heads_init();
|
blockdev_heads_init();
|
||||||
|
|
||||||
bdevtest_init(config_file, core_mask);
|
bdevtest_init(config_file, core_mask);
|
||||||
|
@ -143,8 +143,6 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1; /* reset the optind */
|
|
||||||
|
|
||||||
spdk_app_init(&opts);
|
spdk_app_init(&opts);
|
||||||
|
|
||||||
g_tsc_rate = spdk_get_ticks_hz();
|
g_tsc_rate = spdk_get_ticks_hz();
|
||||||
|
@ -134,8 +134,6 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
|
|
||||||
opts.shutdown_cb = test_cleanup;
|
opts.shutdown_cb = test_cleanup;
|
||||||
|
|
||||||
spdk_app_init(&opts);
|
spdk_app_init(&opts);
|
||||||
|
@ -130,8 +130,6 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
|
|
||||||
opts.shutdown_cb = test_cleanup;
|
opts.shutdown_cb = test_cleanup;
|
||||||
|
|
||||||
spdk_app_init(&opts);
|
spdk_app_init(&opts);
|
||||||
|
@ -240,8 +240,6 @@ parse_args(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ parse_args(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_aio_optind = optind;
|
g_aio_optind = optind;
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +485,6 @@ parse_args(int argc, char **argv)
|
|||||||
g_is_random = 1;
|
g_is_random = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
optind = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user