From 690783a3ae82ebe58c00d643520a66103d66d540 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 6 Aug 2021 22:00:25 +0000 Subject: [PATCH] env_dpdk: tokenize env_context DPDK requires each command line parameter to be passed as a separate string in the args array. So we need to tokenize opts.env_context to handle the case where a user passes multiple arguments in the env_context string. Signed-off-by: Jim Harris Change-Id: Ifc72a7c25b31f1296d3aba3a3f7664ad8edf128f Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9132 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk --- lib/env_dpdk/init.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/env_dpdk/init.c b/lib/env_dpdk/init.c index 9c8962eaa..5854bd9cb 100644 --- a/lib/env_dpdk/init.c +++ b/lib/env_dpdk/init.c @@ -401,10 +401,19 @@ build_eal_cmdline(const struct spdk_env_opts *opts) } if (opts->env_context) { - args = push_arg(args, &argcount, strdup(opts->env_context)); - if (args == NULL) { - return -1; + char *ptr = strdup(opts->env_context); + char *tok = strtok(ptr, " \t"); + + /* DPDK expects each argument as a separate string in the argv + * array, so we need to tokenize here in case the caller + * passed multiple arguments in the env_context string. + */ + while (tok != NULL) { + args = push_arg(args, &argcount, strdup(tok)); + tok = strtok(NULL, " \t"); } + + free(ptr); } #ifdef __linux__