net: Reinstate '-net nic, model=help' output as documented in man page
While refactoring the NIC initialization code, I broke '-net nic,model=help'
which no longer outputs a list of available NIC models.
Fixes: 2cdeca04ad
("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>
This commit is contained in:
parent
f6a3158c82
commit
64f75f57f9
25
net/net.c
25
net/net.c
@ -1139,6 +1139,21 @@ NICInfo *qemu_find_nic_info(const char *typename, bool match_default,
|
|||||||
return NULL;
|
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" */
|
/* "I have created a device. Please configure it if you can" */
|
||||||
bool qemu_configure_nic_device(DeviceState *dev, bool match_default,
|
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)
|
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);
|
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));
|
memset(ni, 0, sizeof(*ni));
|
||||||
ni->model = qemu_opt_get_del(opts, "model");
|
ni->model = qemu_opt_get_del(opts, "model");
|
||||||
|
|
||||||
if (!nic_model_help && !g_strcmp0(ni->model, "help")) {
|
if (is_nic_model_help_option(ni->model)) {
|
||||||
nic_model_help = g_hash_table_new_full(g_str_hash, g_str_equal,
|
|
||||||
g_free, NULL);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user