From 15d92f6a12277511186967b13ba1e8185a6350e5 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 30 Jan 2020 14:45:46 +0100 Subject: [PATCH] examples/hello_bdev: allow running without ini config file Remove the config file check explicitly preventing hello_bdev from starting and also update the docs not to reference config files at all. Change-Id: Ieefb629ef16d75a43c2c1fad2ac442f6e37cc16d Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/483386 Tested-by: SPDK CI Jenkins Community-CI: SPDK CI Jenkins Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- examples/bdev/hello_world/hello_bdev.c | 31 +++++++++++--------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/examples/bdev/hello_world/hello_bdev.c b/examples/bdev/hello_world/hello_bdev.c index bb7599702..565005212 100644 --- a/examples/bdev/hello_world/hello_bdev.c +++ b/examples/bdev/hello_world/hello_bdev.c @@ -199,9 +199,9 @@ hello_start(void *arg1) SPDK_NOTICELOG("Successfully started the application\n"); /* - * Get the bdev. There can be many bdevs configured in - * in the configuration file but this application will only - * use the one input by the user at runtime so we get it via its name. + * Get the bdev. There can be many bdevs configured, but this + * application will only use the one input by the user at runtime so + * we get it via its name. */ hello_context->bdev = spdk_bdev_get_by_name(hello_context->bdev_name); if (hello_context->bdev == NULL) { @@ -262,35 +262,30 @@ main(int argc, char **argv) opts.name = "hello_bdev"; /* - * The user can provide the config file and bdev name at run time. - * For example, to use Malloc0 in file bdev.conf run with params - * ./hello_bdev -c bdev.conf -b Malloc0 - * To use passthru bdev PT0 run with params - * ./hello_bdev -c bdev.conf -b PT0 - * If the bdev name is not specified, - * then Malloc0 is used by default + * Parse built-in SPDK command line parameters as well + * as our custom one(s). */ if ((rc = spdk_app_parse_args(argc, argv, &opts, "b:", NULL, hello_bdev_parse_arg, hello_bdev_usage)) != SPDK_APP_PARSE_ARGS_SUCCESS) { exit(rc); } - if (opts.config_file == NULL) { - SPDK_ERRLOG("configfile must be specified using -c e.g. -c bdev.conf\n"); - exit(1); - } hello_context.bdev_name = g_bdev_name; /* - * spdk_app_start() will block running hello_start() until - * spdk_app_stop() is called by someone (not simply when - * hello_start() returns), or if an error occurs during - * spdk_app_start() before hello_start() runs. + * spdk_app_start() will initialize the SPDK framework, call hello_start(), + * and then block until spdk_app_stop() is called (or if an initialization + * error occurs, spdk_app_start() will return with rc even without calling + * hello_start(). */ rc = spdk_app_start(&opts, hello_start, &hello_context); if (rc) { SPDK_ERRLOG("ERROR starting application\n"); } + /* At this point either spdk_app_stop() was called, or spdk_app_start() + * failed because of internal error. + */ + /* When the app stops, free up memory that we allocated. */ spdk_dma_free(hello_context.buff);