Commit cc9c7723 authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Daniel Verkamp
Browse files

spdk_tgt: fix parsing vhost arguments



'S' and 'f' was not ported from vhost target app.

Change-Id: I1a450b83e969fc3ede1d9b5c2478acd350bbd601
Signed-off-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-on: https://review.gerrithub.io/410091


Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent eac02a4a
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -42,18 +42,47 @@
#undef SPDK_CONFIG_VHOST
#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
spdk_tgt_usage(void)
{
	printf(" -f pidfile save pid to file under given path\n");
#ifdef SPDK_CONFIG_VHOST
	printf(" -S dir     directory where to create vhost sockets (default: pwd)\n");
#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
spdk_tgt_parse_arg(int ch, char *arg)
{
	switch (ch) {
	case 'f':
		g_pid_path = arg;
		break;
#ifdef SPDK_CONFIG_VHOST
	case 'S':
		spdk_vhost_set_socket_path(arg);
@@ -65,6 +94,10 @@ spdk_tgt_parse_arg(int ch, char *arg)
static void
spdk_tgt_started(void *arg1, void *arg2)
{
	if (g_pid_path) {
		spdk_tgt_save_pid(g_pid_path);
	}

	if (getenv("MEMZONE_DUMP") != NULL) {
		spdk_memzone_dump(stdout);
		fflush(stdout);
@@ -79,7 +112,7 @@ main(int argc, char **argv)

	spdk_app_opts_init(&opts);
	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_APP_PARSE_ARGS_SUCCESS) {
		return rc;