* [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page
@ 2024-07-09 12:34 David Woodhouse
2024-07-09 12:46 ` Michael Tokarev
0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2024-07-09 12:34 UTC (permalink / raw)
To: Jason Wang; +Cc: qemu-devel, Michael Tokarev
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")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
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.44.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page
2024-07-09 12:34 [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page David Woodhouse
@ 2024-07-09 12:46 ` Michael Tokarev
2024-07-24 12:01 ` David Woodhouse
0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2024-07-09 12:46 UTC (permalink / raw)
To: David Woodhouse, Jason Wang; +Cc: qemu-devel, qemu-stable
09.07.2024 15:34, David Woodhouse wrote:
> 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")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Cc: qemu-stable@nongnu.org
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Thanks,
/mjt
> ---
> 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;
> }
>
--
GPG Key transition (from rsa2048 to rsa4096) since 2024-04-24.
New key: rsa4096/61AD3D98ECDF2C8E 9D8B E14E 3F2A 9DD7 9199 28F1 61AD 3D98 ECDF 2C8E
Old key: rsa2048/457CE0A0804465C5 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5
Transition statement: http://www.corpit.ru/mjt/gpg-transition-2024.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page
2024-07-09 12:46 ` Michael Tokarev
@ 2024-07-24 12:01 ` David Woodhouse
2024-07-26 2:25 ` Jason Wang
0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2024-07-24 12:01 UTC (permalink / raw)
To: Michael Tokarev, Jason Wang; +Cc: qemu-devel, qemu-stable
[-- Attachment #1: Type: text/plain, Size: 541 bytes --]
On Tue, 2024-07-09 at 15:46 +0300, Michael Tokarev wrote:
> 09.07.2024 15:34, David Woodhouse wrote:
> > 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")
> > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
>
> Cc: qemu-stable@nongnu.org
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Ping?
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page
2024-07-24 12:01 ` David Woodhouse
@ 2024-07-26 2:25 ` Jason Wang
0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2024-07-26 2:25 UTC (permalink / raw)
To: David Woodhouse; +Cc: Michael Tokarev, qemu-devel, qemu-stable
On Wed, Jul 24, 2024 at 8:02 PM David Woodhouse <dwmw2@infradead.org> wrote:
>
> On Tue, 2024-07-09 at 15:46 +0300, Michael Tokarev wrote:
> > 09.07.2024 15:34, David Woodhouse wrote:
> > > 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")
> > > Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> >
> > Cc: qemu-stable@nongnu.org
> > Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
>
> Ping?
Queued.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-26 2:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-09 12:34 [PATCH] net: Reinstate '-net nic, model=help' output as documented in man page David Woodhouse
2024-07-09 12:46 ` Michael Tokarev
2024-07-24 12:01 ` David Woodhouse
2024-07-26 2:25 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).