nbd: add -t tracelog flag support

Adjust the usage() output so it matches the spdk_tracelog_usage() style.

Change-Id: I2555b7587ebb9a891a08412f045d94f980cd1255
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/368802
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-07-10 09:48:33 -07:00
parent 58b9ea3ac0
commit b509410cb1
2 changed files with 23 additions and 8 deletions

View File

@ -43,7 +43,7 @@ C_SRCS := nbd.c
CFLAGS += -I. $(ENV_CFLAGS)
SPDK_LIB_LIST = event_bdev event_copy event_rpc
SPDK_LIB_LIST += bdev bdev_rpc copy event trace log conf util rpc jsonrpc json
SPDK_LIB_LIST += bdev bdev_rpc copy event trace log log_rpc conf util rpc jsonrpc json
LIBS += $(BLOCKDEV_MODULES_LINKER_ARGS) \
$(COPY_MODULES_LINKER_ARGS)

View File

@ -432,12 +432,13 @@ nbd_start(void *arg1, void *arg2)
static void usage(char *program_name)
{
printf("%s options\n", program_name);
printf("\t[-b bdev name]\n");
printf("\t[-c configuration file]\n");
printf("\t[-m core mask for distributing I/O submission/completion work\n");
printf("\t\t(default: 0x1 - use core 0 only)]\n");
printf("\t[-n nbd device name]\n");
printf("\t\t(default: /dev/nbd0)\n");
printf(" -b bdev export bdev via NBD (required)\n");
printf(" -c conf configuration file (required)\n");
printf(" -m mask core mask for distributing I/O submission/completion work\n");
printf(" (default: 0x1 - use core 0 only)\n");
printf(" -n dev nbd device name\n");
printf(" (default: /dev/nbd0)\n");
spdk_tracelog_usage(stdout, "-t");
}
int
@ -452,7 +453,7 @@ main(int argc, char **argv)
config_file = NULL;
core_mask = NULL;
while ((op = getopt(argc, argv, "b:c:m:n:")) != -1) {
while ((op = getopt(argc, argv, "b:c:m:n:t:")) != -1) {
switch (op) {
case 'b':
g_bdev_name = optarg;
@ -466,6 +467,20 @@ main(int argc, char **argv)
case 'n':
g_nbd_name = optarg;
break;
case 't':
if (spdk_log_set_trace_flag(optarg) < 0) {
fprintf(stderr, "unknown flag\n");
usage(argv[0]);
exit(EXIT_FAILURE);
}
spdk_log_set_print_level(SPDK_LOG_DEBUG);
#ifndef DEBUG
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
argv[0]);
usage(argv[0]);
exit(EXIT_FAILURE);
#endif
break;
default:
usage(argv[0]);
exit(1);