From nobody Sun Nov 24 19:27:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720528546287461.6999404557091; Tue, 9 Jul 2024 05:35:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sRA3d-00083l-H4; Tue, 09 Jul 2024 08:34:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRA3b-00082p-Mr for qemu-devel@nongnu.org; Tue, 09 Jul 2024 08:34:56 -0400 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sRA3Z-0006Gs-M1 for qemu-devel@nongnu.org; Tue, 09 Jul 2024 08:34:55 -0400 Received: from [2001:8b0:10b:1::ebe] (helo=i7.infradead.org) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA3R-00000007ssi-0JDb; Tue, 09 Jul 2024 12:34:45 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1sRA3Q-000000001o2-350H; Tue, 09 Jul 2024 13:34:44 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=XFj/aYk/11KYGp/Qglu/nGIvZPUYwcUEZlKtyEtB/oM=; b=k4J9SccxzOxYJcn3/4weZAdzSU W5nVwBVtxR+RQ5Fvp1JQwA8rlb6W013rBzdDcOBt7R9vRCqJ2GWzdHSvxxw4JIwe2g9FGI3wO/Eq4 K7Z7xdwzFzUKq5Z6Tbzbnsqnf12mljT5tCmV27Cx4EPYdksagufc8U51Cks++N8WwUsdH+v1aJea6 hc4HJRkzAi+m5pChZx5JKAATHf9aE068WQOOK0JD6LsQsIFH2HjWA/ZyAAk3qFC2JwDsK6T0jI9XY dPfeJq9yCVVY7gXrDpGufLGrKz7Sd61+nWYtxqwjJHpVX02SU7SzckKjVDXJXXnQyGBm0lk4Hs9Bt 8/6HE2lA==; From: David Woodhouse To: Jason Wang Cc: qemu-devel@nongnu.org, Michael Tokarev Subject: [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page Date: Tue, 9 Jul 2024 13:34:44 +0100 Message-ID: <20240709123444.6933-1-dwmw2@infradead.org> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2001:8b0:10b:1236::1; envelope-from=BATV+f7b76dcc04d1efc10869+7625+infradead.org+dwmw2@casper.srs.infradead.org; helo=casper.infradead.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1720528548709116600 Content-Type: text/plain; charset="utf-8" From: David Woodhouse While refactoring the NIC initialization code, I broke '-net nic,model=3Dhe= lp' which no longer outputs a list of available NIC models. Fixes: 2cdeca04adab ("net: report list of available models according to pla= tform") Signed-off-by: David Woodhouse Reviewed-by: Michael Tokarev --- net/net.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/net/net.c b/net/net.c index 6938da05e0..2eb8bc9c0b 100644 --- a/net/net.c +++ b/net/net.c @@ -1139,6 +1139,21 @@ NICInfo *qemu_find_nic_info(const char *typename, bo= ol match_default, return NULL; } =20 +static bool is_nic_model_help_option(const char *model) +{ + if (model && is_help_option(model)) { + /* + * Trigger the help output by instantiating the hash table which + * will gather tha available models as they get registered. + */ + if (!nic_model_help) { + nic_model_help =3D g_hash_table_new_full(g_str_hash, g_str_equ= al, + g_free, NULL); + } + return true; + } + return false; +} =20 /* "I have created a device. Please configure it if you can" */ bool qemu_configure_nic_device(DeviceState *dev, bool match_default, @@ -1722,6 +1737,12 @@ void net_check_clients(void) =20 static int net_init_client(void *dummy, QemuOpts *opts, Error **errp) { + const char *model =3D qemu_opt_get_del(opts, "model"); + + if (is_nic_model_help_option(model)) { + return 0; + } + return net_client_init(opts, false, errp); } =20 @@ -1778,9 +1799,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts,= Error **errp) memset(ni, 0, sizeof(*ni)); ni->model =3D qemu_opt_get_del(opts, "model"); =20 - if (!nic_model_help && !g_strcmp0(ni->model, "help")) { - nic_model_help =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, NULL); + if (is_nic_model_help_option(ni->model)) { return 0; } =20 --=20 2.44.0