All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Woodhouse <dwmw@amazon.co.uk>,
	qemu-stable@nongnu.org, Michael Tokarev <mjt@tls.msk.ru>,
	Jason Wang <jasowang@redhat.com>
Subject: [PULL 8/8] net: Reinstate '-net nic, model=help' output as documented in man page
Date: Fri,  2 Aug 2024 11:19:29 +0800	[thread overview]
Message-ID: <20240802031929.44060-9-jasowang@redhat.com> (raw)
In-Reply-To: <20240802031929.44060-1-jasowang@redhat.com>

From: David Woodhouse <dwmw@amazon.co.uk>

While refactoring the NIC initialization code, I broke '-net nic,model=help'
which no longer outputs a list of available NIC models.

Fixes: 2cdeca04adab ("net: report list of available models according to platform")
Cc: qemu-stable@nongnu.org
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 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, bool match_default,
     return NULL;
 }
 
+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 = g_hash_table_new_full(g_str_hash, g_str_equal,
+                                                   g_free, NULL);
+        }
+        return true;
+    }
+    return false;
+}
 
 /* "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)
 
 static int net_init_client(void *dummy, QemuOpts *opts, Error **errp)
 {
+    const char *model = qemu_opt_get_del(opts, "model");
+
+    if (is_nic_model_help_option(model)) {
+        return 0;
+    }
+
     return net_client_init(opts, false, errp);
 }
 
@@ -1778,9 +1799,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts, Error **errp)
     memset(ni, 0, sizeof(*ni));
     ni->model = qemu_opt_get_del(opts, "model");
 
-    if (!nic_model_help && !g_strcmp0(ni->model, "help")) {
-        nic_model_help = g_hash_table_new_full(g_str_hash, g_str_equal,
-                                               g_free, NULL);
+    if (is_nic_model_help_option(ni->model)) {
         return 0;
     }
 
-- 
2.42.0



  parent reply	other threads:[~2024-08-02  3:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-02  3:19 [PULL 0/8] Net patches Jason Wang
2024-08-02  3:19 ` [PULL 1/8] rtl8139: Fix behaviour for old kernels Jason Wang
2024-08-02  3:19 ` [PULL 2/8] virtio-net: Ensure queue index fits with RSS Jason Wang
2024-08-06 13:30   ` Daniel P. Berrangé
2024-08-02  3:19 ` [PULL 3/8] virtio-net: Fix network stall at the host side waiting for kick Jason Wang
2024-08-02  3:19 ` [PULL 4/8] net: update netdev stream/dgram man page Jason Wang
2024-08-02  3:19 ` [PULL 5/8] net: update netdev stream man page with unix socket Jason Wang
2024-08-02  3:19 ` [PULL 6/8] net: update netdev dgram " Jason Wang
2024-08-02  3:19 ` [PULL 7/8] net: update netdev stream man page with the reconnect parameter Jason Wang
2024-08-02  3:19 ` Jason Wang [this message]
2024-08-02  9:48 ` [PULL 0/8] Net patches Richard Henderson
2024-08-05  2:38   ` Jason Wang
2024-08-05 22:00     ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240802031929.44060-9-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=dwmw@amazon.co.uk \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.