spdk_tgt: fix parsing vhost arguments
'S' and 'f' was not ported from vhost target app. Change-Id: I1a450b83e969fc3ede1d9b5c2478acd350bbd601 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/410091 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
eac02a4ace
commit
cc9c772379
@ -42,18 +42,47 @@
|
|||||||
#undef SPDK_CONFIG_VHOST
|
#undef SPDK_CONFIG_VHOST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SPDK_CONFIG_VHOST
|
||||||
|
#define SPDK_VHOST_OPTS "S:"
|
||||||
|
#else
|
||||||
|
#define SPDK_VHOST_OPTS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *g_pid_path = NULL;
|
||||||
|
static const char g_spdk_tgt_get_opts_string[] = "f:" SPDK_VHOST_OPTS;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_tgt_usage(void)
|
spdk_tgt_usage(void)
|
||||||
{
|
{
|
||||||
|
printf(" -f pidfile save pid to file under given path\n");
|
||||||
#ifdef SPDK_CONFIG_VHOST
|
#ifdef SPDK_CONFIG_VHOST
|
||||||
printf(" -S dir directory where to create vhost sockets (default: pwd)\n");
|
printf(" -S dir directory where to create vhost sockets (default: pwd)\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_tgt_save_pid(const char *pid_path)
|
||||||
|
{
|
||||||
|
FILE *pid_file;
|
||||||
|
|
||||||
|
pid_file = fopen(pid_path, "w");
|
||||||
|
if (pid_file == NULL) {
|
||||||
|
fprintf(stderr, "Couldn't create pid file '%s': %s\n", pid_path, strerror(errno));
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(pid_file, "%d\n", getpid());
|
||||||
|
fclose(pid_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_tgt_parse_arg(int ch, char *arg)
|
spdk_tgt_parse_arg(int ch, char *arg)
|
||||||
{
|
{
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
case 'f':
|
||||||
|
g_pid_path = arg;
|
||||||
|
break;
|
||||||
#ifdef SPDK_CONFIG_VHOST
|
#ifdef SPDK_CONFIG_VHOST
|
||||||
case 'S':
|
case 'S':
|
||||||
spdk_vhost_set_socket_path(arg);
|
spdk_vhost_set_socket_path(arg);
|
||||||
@ -65,6 +94,10 @@ spdk_tgt_parse_arg(int ch, char *arg)
|
|||||||
static void
|
static void
|
||||||
spdk_tgt_started(void *arg1, void *arg2)
|
spdk_tgt_started(void *arg1, void *arg2)
|
||||||
{
|
{
|
||||||
|
if (g_pid_path) {
|
||||||
|
spdk_tgt_save_pid(g_pid_path);
|
||||||
|
}
|
||||||
|
|
||||||
if (getenv("MEMZONE_DUMP") != NULL) {
|
if (getenv("MEMZONE_DUMP") != NULL) {
|
||||||
spdk_memzone_dump(stdout);
|
spdk_memzone_dump(stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -79,7 +112,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
spdk_app_opts_init(&opts);
|
spdk_app_opts_init(&opts);
|
||||||
opts.name = "spdk_tgt";
|
opts.name = "spdk_tgt";
|
||||||
if ((rc = spdk_app_parse_args(argc, argv, &opts, "",
|
if ((rc = spdk_app_parse_args(argc, argv, &opts, g_spdk_tgt_get_opts_string,
|
||||||
spdk_tgt_parse_arg, spdk_tgt_usage)) !=
|
spdk_tgt_parse_arg, spdk_tgt_usage)) !=
|
||||||
SPDK_APP_PARSE_ARGS_SUCCESS) {
|
SPDK_APP_PARSE_ARGS_SUCCESS) {
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user