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 2B3B24584A; Thu, 22 Aug 2024 19:19:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0A60B42F08; Thu, 22 Aug 2024 19:19:04 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mails.dpdk.org (Postfix) with ESMTP id C870642F07 for ; Thu, 22 Aug 2024 19:19:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724347142; x=1755883142; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Wi5RuTrd4nrDQY3Uj4W2dkzJ5Ig+/j+qZdQqtLEQAq4=; b=ZfeOhIOq4uhU6Tstb66QCc3Rq+tumFq2HEivtNKw0regBv928IfFEZCs 2gGFbAGielR9OAdgID5P5dwCjB9dGb6NKnAhcOwKhP0V2T83ejoX56GYV 8+AUd4C7tAztsZvNwMEWTpajX9jkb3ipbmIcuUdsRBQ/iY92hYLvDTgQE DzTDshNq+XxUQOTAbWo/Dv8dCTBanGBbnTQH9AGzEXtY56Lab1ctudKrR t4qI1hvkjIek8q0v/04wXwkYwWjHf1IWB9GOvTV2A/0crDoHuJN8gwhTw /lvkIzsvzVZWWzrvuSWVxpFxYUAca2R69XDrZudVkhn2NsdEHwbGg1L9m g==; X-CSE-ConnectionGUID: SffmWOcUS7mIj/TynRg2kg== X-CSE-MsgGUID: C/uoMw3MQT+t+HDXuWWySQ== X-IronPort-AV: E=McAfee;i="6700,10204,11172"; a="26578824" X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="26578824" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2024 10:18:59 -0700 X-CSE-ConnectionGUID: llLXOqoGQcGoCEKPmq2lvg== X-CSE-MsgGUID: mm3jNuo9Rim0yeGtCUCp4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,167,1719903600"; d="scan'208";a="92257636" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa002.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Aug 2024 10:18:59 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 22 Aug 2024 10:18:58 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 22 Aug 2024 10:18:58 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Thu, 22 Aug 2024 10:18:58 -0700 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (104.47.73.177) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 10:18:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DyHSaO5dpmXDaznUoIXG+abin0oYvyXlKz8aYhiNwvLd8Yp/qq4FEYLfidjXmPuekP5E14Un/AHT0Bf7HpcEtuHyinS+aV1qdiWXMtZwiHr52B/FUaOSvRqo7pS77QSTvGXF11opkASXP0Z3zm9T8J37SGAcy00eDFrWrWaooVAhvN7/QveE090504NgbyWyuS9ASR3eZjCqJ6cvnaEcKC6dvQN1plmG2pOsrdrRgFedEmqMxmjjC9MpuYLrSXIPty++z/U6psqvQq3X1Sg7/AFqUzRZkwLaAqhm+SFqiV6sDIpWRNNdcjL9ML+d0FyDfy6Jjtqg1kAd8QlS+MZPyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q03NwjdC9/fpFHARuKzWjvu/Y9DrK3TnhLoKgfKTsbI=; b=xsGFg17rY7POYcu4zSZk4bvqCrXN9ziFd6OhgIleSSF5Z1iAKDxk2cSo4dPqHaKLfDIcAW/jogfqai5/6L3UC8CYVqs3qx5AN8GUgwz76IcPrbBK/SS4MF+G4zHZW4E3Nr+Yq7UuH3nNeToEZ6Wk7HwVTyfK9UsiDCQrJSY0Cur3CvMHX0LmyihuRc77+QfC15mh9MkSIKyyH1hm5AQci4t6IPSurEKtmiZFhePBUa7DnzkkrvLtmVT2hHgciiisdrgHu2x/RdsEP6l/jfqyS4Pnc2LMCP967aWn16gD3K0/X1lMd31JApDXuaizXrRZBYEqbNUNCVkWTxxwQKs6zg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by CY5PR11MB6464.namprd11.prod.outlook.com (2603:10b6:930:30::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.20; Thu, 22 Aug 2024 17:18:55 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%2]) with mapi id 15.20.7897.014; Thu, 22 Aug 2024 17:18:55 +0000 Date: Thu, 22 Aug 2024 18:18:50 +0100 From: Bruce Richardson To: Ferruh Yigit CC: Subject: Re: [PATCH v2] app/testpmd: show output of commands read from file Message-ID: References: <20240822103604.113246-1-bruce.richardson@intel.com> <20240822104109.116208-2-bruce.richardson@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: DU2PR04CA0312.eurprd04.prod.outlook.com (2603:10a6:10:2b5::17) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|CY5PR11MB6464:EE_ X-MS-Office365-Filtering-Correlation-Id: 848a81e4-c126-4bcb-6756-08dcc2ce802b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?P09jPBh3GkFMtb8FhM6JSH2UQvD6EORp4FJdqdk/g6Pt7CnhYqc1W3FT3NMu?= =?us-ascii?Q?BqVw96SaPgbnw03p8QVVu/4YtoZhmLSx2Nwfn+eJmEYTIr3Fx9acEYWCuUdY?= =?us-ascii?Q?xXeoTASkbjOBSJXSWaSgOwKBKJnphHTNOrNgLdxyiLfzwacU6alZiOmvXNOB?= =?us-ascii?Q?B4+jlfkZyiJ0wvtrG6xxS1GoKGIe6OmW7i4Ull9+ZJyFzE/PctIL5jmmNbvM?= =?us-ascii?Q?1lMXHSAdduG4S5xagarFTg47Y820IosyHwd+EYYaHZmX/obdYcmQYd/A6cKx?= =?us-ascii?Q?Nm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B?= =?us-ascii?Q?g4BPE/fl31QBO42s8TWKkMtkDhCXT1nnKBDIB+EVDVfl5K/131aydI1Xrmdm?= =?us-ascii?Q?kyRYUCLFpJMJzYmdaqpofYK42+fwol04cIjeQw0v4hMzPuqQMgysN7YztgXg?= =?us-ascii?Q?PQdneOnwoE8RWYeMYcFsJ4b7LdGVZEXBSs7s9OgGllttAQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(366016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?RA0m2kV9DcI8k3HdtBFuMxTOzOxiJSAnHcVmv52gN4qLKZcntdgB1W0n8ZNP?= =?us-ascii?Q?xf8z3l4xeeYEpg69TXlf8fo1oEWwI/lvEdwhwOECvLMwa3lqeyVAadlMGgwi?= =?us-ascii?Q?EuiwuMWswi9xPZETCoVgzC2hZOn8X8FQ5iqc0QnIymOo3QX27mexrQk6osUT?= =?us-ascii?Q?6wtRO6JY7IldSUKYISR6514VVIaik660bRnuNkJLG+0j43utqxTR4wbAw05T?= =?us-ascii?Q?/d8jbXa/tTrBDDTG9gTLaiWmtFU/qXO62veltFwUqoS6iUmiDkDL7K6376lI?= =?us-ascii?Q?OrYy3AZzs9AO/J0VJ283yHGb0+poNZpgIqDjpDk8j0TDOc4K5637bMlnTGuf?= =?us-ascii?Q?rq8m5gMb1tbeg8ZRFeOrYCEb2bQJrcivP8I8m4y159UbBZFzxCFyaxUa4wu2?= =?us-ascii?Q?fcdFrN+oNtMWPnTvNcJaK0Ep/rSEIRDJHRn6zaS8E0bmBT+RI7jhKsfa27c/?= =?us-ascii?Q?mEBGj7B9xt69fB2O9G4vyO67PI5/+CDiCCaKBv+nzlC38liTi/bG3y/LlEJ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5dMCtsvdACCn47RWr8wlCZkKDrKhftkHcxZI/?= =?us-ascii?Q?j8gg4Skod4gi0YkUZyxXne+q9LMOwUj2SUvicrPj872KeFcYAReGYlLTtujW?= =?us-ascii?Q?uLFUb+mWrpaviv8MD+ikys/A8sYputPXwHA8XTZDGrX8mRheT0dGO8Ysi/mN?= =?us-ascii?Q?wAGGAmiIiKBEocUtjLMzFmp7jJtmG/DVS0WXWy9sS2xcbfmx9x0OJmLJEPze?= =?us-ascii?Q?wA=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 848a81e4-c126-4bcb-6756-08dcc2ce802b X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 17:18:55.1239 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rh0iwUhuL6Grs33DIND92MBu4OkJhjTh537/aN6o/beRIDnuOSR5XZdmMUQj+J+dFdkiHWCxpioRLYtO7jOfuQKtunh2WC3ovqtUzCgxJc8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR11MB6464 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Aug 22, 2024 at 06:14:55PM +0100, Bruce Richardson wrote: > On Thu, Aug 22, 2024 at 05:53:27PM +0100, Ferruh Yigit wrote: > > On 8/22/2024 11:41 AM, Bruce Richardson wrote: > > > Testpmd supports the "--cmdline-file" parameter to read a set of initial > > > commands from a file. However, the only indication that this has been > > > done successfully on startup is a single-line message, no output from > > > the commands is seen. > > > > > > > For user I think it makes sense to see the command [1], only concern is > > if someone parsing testpmd output may be impacted on this, although I > > expect it should be trivial to update the relevant parsing. > > > > [1] > > Btw, I can still see the command output, I assume because command does > > the printf itself, for example for 'show port summary 0' command: > > - before patch: > > ... > > Number of available ports: 2 > > Port MAC Address Name Driver Status Link > > 0 xx:xx:xx:xx:xx:xx xxxx:xx:xx.x aaaaaaaa up xxx Gbps > > ... > > > > - after patch > > ... > > testpmd> show port summary 0 > > Number of available ports: 2 > > Port MAC Address Name Driver Status Link > > 0 xx:xx:xx:xx:xx:xx xxxx:xx:xx.x aaaaaaaa up xxx Gbps > > ... > > > > Only difference above is, after patch the command itself also printed. > > > > > > That's because the function uses printf itself, which is actually wrong. > Any output from a cmdline function should use the "cmdline_printf" call > which outputs to the proper cmdline filehandle. > > > > To improve usability here, we can use cmdline_new rather than > > > cmdline_file_new and have the output from the various commands sent to > > > stdout, allowing the user to see better what is happening. > > > > > > Signed-off-by: Bruce Richardson > > > > > > --- > > > v2: use STDOUT_FILENO in place of hard-coded "1" > > > --- > > > app/test-pmd/cmdline.c | 14 +++++++++++++- > > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > > > index b7759e38a8..52e64430d9 100644 > > > --- a/app/test-pmd/cmdline.c > > > +++ b/app/test-pmd/cmdline.c > > > @@ -6,6 +6,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -13431,7 +13432,18 @@ cmdline_read_from_file(const char *filename) > > > { > > > struct cmdline *cl; > > > > > > - cl = cmdline_file_new(main_ctx, "testpmd> ", filename); > > > + /* cmdline_file_new does not produce any output which is not ideal here. > > > + * Much better to show output of the commands, so we open filename directly > > > + * and then pass that to cmdline_new with stdout as the output path. > > > + */ > > > + int fd = open(filename, O_RDONLY); > > > + if (fd < 0) { > > > + fprintf(stderr, "Failed to open file %s: %s\n", > > > + filename, strerror(errno)); > > > + return; > > > + } > > > + > > > + cl = cmdline_new(main_ctx, "testpmd> ", fd, STDOUT_FILENO); > > > > > > > Above is almost save as 'cmdline_file_new()' function with only > > difference that it uses '-1' for 's_out'. > > > > If this usecase may be required by others, do you think does it have a > > value to pass 's_out' to 'cmdline_file_new()' or have a new version of > > API that accepts 's_out' as parameter? > > > > Yes, I thought about this, and actually started implementing a new API for > cmdline library to that. However, I decided that, given the complexity > here, that it's not really necessary - especially as there is no clear way > to do things. The options are: > > * extend cmdline_file_new to have a flag to echo to stdout (which would be > the very common case here). > * extend cmdline_file_new to take a file handle - this is more flexible, > but slightly less usable. > * add a new cmdline_file__new function to echo to stdout. > * add a new cmdline_file__new function to write to a filehandle. > > I don't like breaking the cmdline API (and ABI), so I didn't want to do > either #1 or #2, which would be the cleanest solutions. For #3 and #4, > naming is hard, and deciding between them is even harder. Given the choice, > I prefer #3, as I can't see #4 being very common and we always have > cmdline_new as a fallback anyway. > > Overall, though, I threw away that work, because it didn't seem worth it, > for the sake of having the user to do an extra "open" call. > And also to add: If there is clear consensus on what the correct option for this case is, I'm happy enough to go back and extend the cmdline library as agreed. :-)