app: add print_level to opts structure
This allows us to remove some duplicated code from our main target applications. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I15b517fd2b58ce682660b4f6ba0b8412beda053b Reviewed-on: https://review.gerrithub.io/385714 Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
4bcfef0021
commit
973a27d08c
@ -93,7 +93,6 @@ main(int argc, char **argv)
|
|||||||
int rc;
|
int rc;
|
||||||
int daemon_mode = 0;
|
int daemon_mode = 0;
|
||||||
struct spdk_app_opts opts = {};
|
struct spdk_app_opts opts = {};
|
||||||
enum spdk_log_level print_level = SPDK_LOG_NOTICE;
|
|
||||||
|
|
||||||
/* default value in opts structure */
|
/* default value in opts structure */
|
||||||
spdk_app_opts_init(&opts);
|
spdk_app_opts_init(&opts);
|
||||||
@ -121,7 +120,7 @@ main(int argc, char **argv)
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
print_level = SPDK_LOG_DEBUG;
|
opts.print_level = SPDK_LOG_DEBUG;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
fprintf(stderr, "%s must be built with CONFIG_DEBUG=y for -t flag\n",
|
fprintf(stderr, "%s must be built with CONFIG_DEBUG=y for -t flag\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
@ -133,7 +132,7 @@ main(int argc, char **argv)
|
|||||||
opts.tpoint_group_mask = optarg;
|
opts.tpoint_group_mask = optarg;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
print_level = SPDK_LOG_WARN;
|
opts.print_level = SPDK_LOG_WARN;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
opts.reactor_mask = optarg;
|
opts.reactor_mask = optarg;
|
||||||
@ -164,18 +163,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_level > SPDK_LOG_WARN &&
|
|
||||||
isatty(STDERR_FILENO) &&
|
|
||||||
!strncmp(ttyname(STDERR_FILENO), "/dev/tty", strlen("/dev/tty"))) {
|
|
||||||
printf("Warning: printing stderr to console terminal without -q option specified.\n");
|
|
||||||
printf("Suggest using -q to disable logging to stderr and monitor syslog, or\n");
|
|
||||||
printf("redirect stderr to a file.\n");
|
|
||||||
printf("(Delaying for 10 seconds...)\n");
|
|
||||||
sleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_log_set_print_level(print_level);
|
|
||||||
|
|
||||||
opts.shutdown_cb = spdk_iscsi_shutdown;
|
opts.shutdown_cb = spdk_iscsi_shutdown;
|
||||||
opts.usr1_handler = spdk_sigusr1;
|
opts.usr1_handler = spdk_sigusr1;
|
||||||
|
|
||||||
|
@ -72,7 +72,6 @@ main(int argc, char **argv)
|
|||||||
int ch;
|
int ch;
|
||||||
int rc;
|
int rc;
|
||||||
struct spdk_app_opts opts = {};
|
struct spdk_app_opts opts = {};
|
||||||
enum spdk_log_level print_level = SPDK_LOG_NOTICE;
|
|
||||||
|
|
||||||
/* default value in opts */
|
/* default value in opts */
|
||||||
spdk_app_opts_init(&opts);
|
spdk_app_opts_init(&opts);
|
||||||
@ -100,7 +99,7 @@ main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
print_level = SPDK_LOG_DEBUG;
|
opts.print_level = SPDK_LOG_DEBUG;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
|
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
@ -124,7 +123,7 @@ main(int argc, char **argv)
|
|||||||
opts.tpoint_group_mask = optarg;
|
opts.tpoint_group_mask = optarg;
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
print_level = SPDK_LOG_WARN;
|
opts.print_level = SPDK_LOG_WARN;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
case 'H':
|
case 'H':
|
||||||
@ -134,18 +133,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_level > SPDK_LOG_WARN &&
|
|
||||||
isatty(STDERR_FILENO) &&
|
|
||||||
!strncmp(ttyname(STDERR_FILENO), "/dev/tty", strlen("/dev/tty"))) {
|
|
||||||
printf("Warning: printing stderr to console terminal without -q option specified.\n");
|
|
||||||
printf("Suggest using -q to disable logging to stderr and monitor syslog, or\n");
|
|
||||||
printf("redirect stderr to a file.\n");
|
|
||||||
printf("(Delaying for 10 seconds...)\n");
|
|
||||||
sleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_log_set_print_level(print_level);
|
|
||||||
|
|
||||||
rc = spdk_nvmf_tgt_start(&opts);
|
rc = spdk_nvmf_tgt_start(&opts);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -101,7 +101,6 @@ main(int argc, char *argv[])
|
|||||||
int ch;
|
int ch;
|
||||||
int rc;
|
int rc;
|
||||||
const char *socket_path = NULL;
|
const char *socket_path = NULL;
|
||||||
enum spdk_log_level print_level = SPDK_LOG_NOTICE;
|
|
||||||
const char *pid_path = NULL;
|
const char *pid_path = NULL;
|
||||||
|
|
||||||
vhost_app_opts_init(&opts);
|
vhost_app_opts_init(&opts);
|
||||||
@ -136,7 +135,7 @@ main(int argc, char *argv[])
|
|||||||
opts.master_core = strtoul(optarg, NULL, 10);
|
opts.master_core = strtoul(optarg, NULL, 10);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
print_level = SPDK_LOG_WARN;
|
opts.print_level = SPDK_LOG_WARN;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
opts.mem_size = strtoul(optarg, NULL, 10);
|
opts.mem_size = strtoul(optarg, NULL, 10);
|
||||||
@ -151,7 +150,7 @@ main(int argc, char *argv[])
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
print_level = SPDK_LOG_DEBUG;
|
opts.print_level = SPDK_LOG_DEBUG;
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
|
fprintf(stderr, "%s must be rebuilt with CONFIG_DEBUG=y for -t flag.\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
@ -170,18 +169,6 @@ main(int argc, char *argv[])
|
|||||||
save_pid(pid_path);
|
save_pid(pid_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (print_level > SPDK_LOG_WARN &&
|
|
||||||
isatty(STDERR_FILENO) &&
|
|
||||||
!strncmp(ttyname(STDERR_FILENO), "/dev/tty", strlen("/dev/tty"))) {
|
|
||||||
printf("Warning: printing stderr to console terminal without -q option specified.\n");
|
|
||||||
printf("Suggest using -q to disable logging to stderr and monitor syslog, or\n");
|
|
||||||
printf("redirect stderr to a file.\n");
|
|
||||||
printf("(Delaying for 10 seconds...)\n");
|
|
||||||
sleep(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
spdk_log_set_print_level(print_level);
|
|
||||||
|
|
||||||
opts.shutdown_cb = spdk_vhost_shutdown_cb;
|
opts.shutdown_cb = spdk_vhost_shutdown_cb;
|
||||||
|
|
||||||
/* Blocks until the application is exiting */
|
/* Blocks until the application is exiting */
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include "spdk/queue.h"
|
#include "spdk/queue.h"
|
||||||
|
#include "spdk/log.h"
|
||||||
|
|
||||||
typedef void (*spdk_event_fn)(void *arg1, void *arg2);
|
typedef void (*spdk_event_fn)(void *arg1, void *arg2);
|
||||||
|
|
||||||
@ -81,6 +82,7 @@ struct spdk_app_opts {
|
|||||||
int master_core;
|
int master_core;
|
||||||
int mem_size;
|
int mem_size;
|
||||||
bool no_pci;
|
bool no_pci;
|
||||||
|
enum spdk_log_level print_level;
|
||||||
|
|
||||||
/* The maximum latency allowed when passing an event
|
/* The maximum latency allowed when passing an event
|
||||||
* from one core to another. A value of 0
|
* from one core to another. A value of 0
|
||||||
|
@ -192,6 +192,7 @@ spdk_app_opts_init(struct spdk_app_opts *opts)
|
|||||||
opts->mem_channel = SPDK_APP_DPDK_DEFAULT_MEM_CHANNEL;
|
opts->mem_channel = SPDK_APP_DPDK_DEFAULT_MEM_CHANNEL;
|
||||||
opts->reactor_mask = NULL;
|
opts->reactor_mask = NULL;
|
||||||
opts->max_delay_us = 0;
|
opts->max_delay_us = 0;
|
||||||
|
opts->print_level = SPDK_LOG_NOTICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -276,6 +277,18 @@ spdk_app_start(struct spdk_app_opts *opts, spdk_event_fn start_fn,
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opts->print_level > SPDK_LOG_WARN &&
|
||||||
|
isatty(STDERR_FILENO) &&
|
||||||
|
!strncmp(ttyname(STDERR_FILENO), "/dev/tty", strlen("/dev/tty"))) {
|
||||||
|
printf("Warning: printing stderr to console terminal without -q option specified.\n");
|
||||||
|
printf("Suggest using -q to disable logging to stderr and monitor syslog, or\n");
|
||||||
|
printf("redirect stderr to a file.\n");
|
||||||
|
printf("(Delaying for 10 seconds...)\n");
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_log_set_print_level(opts->print_level);
|
||||||
|
|
||||||
if (opts->enable_coredump) {
|
if (opts->enable_coredump) {
|
||||||
struct rlimit core_limits;
|
struct rlimit core_limits;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user