From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 74A2243327 for ; Tue, 14 Nov 2023 11:43:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6CBA6402E0; Tue, 14 Nov 2023 11:43:01 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id 8A91B4027B; Tue, 14 Nov 2023 11:42:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699958579; x=1731494579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gdVVY75+gGUXvqFr38ZF6+wRSAh3ztn2jJ69u+JDXYU=; b=miE/1BhZJHsjqfMUc9KMJziiSGIowiFQ2/LTdiNJFT8twIAPUyBynUvS zoPGicFYncqadVJUM8sh44WUL0r2CRcMx7zW2l9yynmVlYurQYJBospeC AGDp2kz/j24xXFPFizqbt7hDCKcd9vjYzXzqZm7OlAo6MUJTaIJwTCrdh KEfyis9lek3rnwGS7H6R0457Acf7rx5MULiD35s4YW7v0fAVSc4co0+Cz N5IXrEXWJSkkHJXa21M43/ZSQZeXQNIYNHxB2Pgb+KwVSMnQ+2RfmZdoR dtkVmlw8DM+coBtHEwhbjce621vJI/adDNn1hIq4FGHikW4ta3FxuXjA8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="370827133" X-IronPort-AV: E=Sophos;i="6.03,301,1694761200"; d="scan'208";a="370827133" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 02:42:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="768218758" X-IronPort-AV: E=Sophos;i="6.03,301,1694761200"; d="scan'208";a="768218758" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 02:42:55 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: qiming.yang@intel.com, Mingjin Ye , stable@dpdk.org Subject: [PATCH v7] app/test: secondary process passes allow parameters Date: Tue, 14 Nov 2023 10:28:15 +0000 Message-Id: <20231114102815.409998-1-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231113104222.85891-1-mingjinx.ye@intel.com> References: <20231113104222.85891-1-mingjinx.ye@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org In EAL related test cases, the allow parameters are not passed to the secondary process, resulting in unexpected NICs being loaded. This patch fixes this issue by appending the allow parameters to the secondary process. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Mingjin Ye --- v5: Optimized. --- v6: Optimized. --- v7: Fix CI errors. --- app/test/process.h | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/app/test/process.h b/app/test/process.h index af7bc3e0de..06b2f8b192 100644 --- a/app/test/process.h +++ b/app/test/process.h @@ -17,6 +17,7 @@ #include #include /* strlcpy */ +#include #ifdef RTE_EXEC_ENV_FREEBSD #define self "curproc" @@ -34,6 +35,34 @@ extern uint16_t flag_for_send_pkts; #endif #endif +#define PREFIX_ALLOW "--allow=" + +static int +add_parameter_allow(char **argv, int max_capacity) +{ + struct rte_devargs *devargs; + int count = 0; + + RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { + if (strlen(devargs->name) == 0) + continue; + + if (devargs->data == NULL || strlen(devargs->data) == 0) { + if (asprintf(&argv[count], PREFIX_ALLOW"%s", devargs->name) < 0) + break; + } else { + if (asprintf(&argv[count], PREFIX_ALLOW"%s,%s", + devargs->name, devargs->data) < 0) + break; + } + + if (++count == max_capacity) + break; + } + + return count; +} + /* * launches a second copy of the test process using the given argv parameters, * which should include argv[0] as the process name. To identify in the @@ -43,8 +72,10 @@ extern uint16_t flag_for_send_pkts; static inline int process_dup(const char *const argv[], int numargs, const char *env_value) { - int num; - char *argv_cpy[numargs + 1]; + int num = 0; + char **argv_cpy; + int allow_num; + int argv_num; int i, status; char path[32]; #ifdef RTE_LIB_PDUMP @@ -58,11 +89,18 @@ process_dup(const char *const argv[], int numargs, const char *env_value) if (pid < 0) return -1; else if (pid == 0) { + allow_num = rte_devargs_type_count(RTE_DEVTYPE_ALLOWED); + argv_num = numargs + allow_num + 1; + argv_cpy = calloc(argv_num, sizeof(char *)); + if (!argv_cpy) + rte_panic("Memory allocation failed\n"); + /* make a copy of the arguments to be passed to exec */ for (i = 0; i < numargs; i++) argv_cpy[i] = strdup(argv[i]); - argv_cpy[i] = NULL; - num = numargs; + if (allow_num > 0) + num = add_parameter_allow(&argv_cpy[i], allow_num); + num += numargs; #ifdef RTE_EXEC_ENV_LINUX { -- 2.25.1