|
Mark McLoughlin |
48e123 |
From 0ba615f4e6ecf13839b7688c762961aa1d092504 Mon Sep 17 00:00:00 2001
|
|
Mark McLoughlin |
48e123 |
From: Markus Armbruster <armbru@redhat.com>
|
|
Mark McLoughlin |
48e123 |
Date: Fri, 25 Sep 2009 03:53:51 +0200
|
|
Mark McLoughlin |
48e123 |
Subject: [PATCH] Fix pci_add nic not to exit on bad model
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
Monitor command "pci_add ADDR nic model=MODEL" uses pci_nic_init() to
|
|
Mark McLoughlin |
48e123 |
create the NIC. When MODEL is unknown or "?", this prints to stderr
|
|
Mark McLoughlin |
48e123 |
and terminates the program.
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
Change pci_nic_init() not to treat "?" specially, and to return NULL
|
|
Mark McLoughlin |
48e123 |
on failure. Switch uses during startup to new convenience wrapper
|
|
Mark McLoughlin |
48e123 |
pci_nic_init_nofail(), which behaves just like pci_nic_init() used to
|
|
Mark McLoughlin |
48e123 |
do.
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
[markmc:
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- rebase to stable-0.11
|
|
Mark McLoughlin |
48e123 |
- drop qemu_error() usage
|
|
Mark McLoughlin |
48e123 |
- go back to pci_create() in pci_nic_init
|
|
Mark McLoughlin |
48e123 |
- qdev_init() doesn't have an error return
|
|
Mark McLoughlin |
48e123 |
]
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
Mark McLoughlin |
48e123 |
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
|
|
Mark McLoughlin |
48e123 |
Fedora-patch: qemu-do-not-exit-on-pci-hotplug-invalid-nic2.patch
|
|
Mark McLoughlin |
48e123 |
---
|
|
Mark McLoughlin |
48e123 |
hw/mips_malta.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/pc.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/pci.c | 19 ++++++++++++++++++-
|
|
Mark McLoughlin |
48e123 |
hw/pci.h | 2 ++
|
|
Mark McLoughlin |
48e123 |
hw/ppc440_bamboo.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/ppc_newworld.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/ppc_oldworld.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/ppc_prep.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/ppce500_mpc8544ds.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/r2d.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/realview.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/sun4u.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
hw/versatilepb.c | 2 +-
|
|
Mark McLoughlin |
48e123 |
net.c | 41 +++++++++++++++++++++++++----------------
|
|
Mark McLoughlin |
48e123 |
net.h | 5 +++--
|
|
Mark McLoughlin |
48e123 |
15 files changed, 59 insertions(+), 30 deletions(-)
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
|
|
Mark McLoughlin |
48e123 |
index 7728e58..ed86d4b 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/mips_malta.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/mips_malta.c
|
|
Mark McLoughlin |
48e123 |
@@ -486,7 +486,7 @@ static void network_init(void)
|
|
Mark McLoughlin |
48e123 |
/* The malta board has a PCNet card using PCI SLOT 11 */
|
|
Mark McLoughlin |
48e123 |
default_devaddr = "0b";
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(nd, "pcnet", default_devaddr);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(nd, "pcnet", default_devaddr);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/pc.c b/hw/pc.c
|
|
Mark McLoughlin |
48e123 |
index bcd2989..3b226f4 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/pc.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/pc.c
|
|
Mark McLoughlin |
48e123 |
@@ -1360,7 +1360,7 @@ static void pc_init1(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
|
|
Mark McLoughlin |
48e123 |
pc_init_ne2k_isa(nd, i8259);
|
|
Mark McLoughlin |
48e123 |
else
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
piix4_acpi_system_hot_add_init(cpu_model);
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/pci.c b/hw/pci.c
|
|
Mark McLoughlin |
48e123 |
index eb990f9..9bcf49d 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/pci.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/pci.c
|
|
Mark McLoughlin |
48e123 |
@@ -937,7 +937,10 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
|
|
Mark McLoughlin |
48e123 |
DeviceState *dev;
|
|
Mark McLoughlin |
48e123 |
int i;
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- i = qemu_check_nic_model_list(nd, pci_nic_models, default_model);
|
|
Mark McLoughlin |
48e123 |
+ i = qemu_find_nic_model(nd, pci_nic_models, default_model);
|
|
Mark McLoughlin |
48e123 |
+ if (i < 0)
|
|
Mark McLoughlin |
48e123 |
+ return NULL;
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
pci_dev = pci_create(pci_nic_names[i], devaddr);
|
|
Mark McLoughlin |
48e123 |
dev = &pci_dev->qdev;
|
|
Mark McLoughlin |
48e123 |
if (nd->id)
|
|
Mark McLoughlin |
48e123 |
@@ -948,6 +951,20 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
|
|
Mark McLoughlin |
48e123 |
return pci_dev;
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
+PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
|
|
Mark McLoughlin |
48e123 |
+ const char *default_devaddr)
|
|
Mark McLoughlin |
48e123 |
+{
|
|
Mark McLoughlin |
48e123 |
+ PCIDevice *res;
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
+ if (qemu_show_nic_models(nd->model, pci_nic_models))
|
|
Mark McLoughlin |
48e123 |
+ exit(0);
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
+ res = pci_nic_init(nd, default_model, default_devaddr);
|
|
Mark McLoughlin |
48e123 |
+ if (!res)
|
|
Mark McLoughlin |
48e123 |
+ exit(1);
|
|
Mark McLoughlin |
48e123 |
+ return res;
|
|
Mark McLoughlin |
48e123 |
+}
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
typedef struct {
|
|
Mark McLoughlin |
48e123 |
PCIDevice dev;
|
|
Mark McLoughlin |
48e123 |
PCIBus *bus;
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/pci.h b/hw/pci.h
|
|
Mark McLoughlin |
48e123 |
index 7ca3ba9..18a05f5 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/pci.h
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/pci.h
|
|
Mark McLoughlin |
48e123 |
@@ -291,6 +291,8 @@ PCIBus *pci_register_bus(DeviceState *parent, const char *name,
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
|
|
Mark McLoughlin |
48e123 |
const char *default_devaddr);
|
|
Mark McLoughlin |
48e123 |
+PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
|
|
Mark McLoughlin |
48e123 |
+ const char *default_devaddr);
|
|
Mark McLoughlin |
48e123 |
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
|
|
Mark McLoughlin |
48e123 |
uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
|
|
Mark McLoughlin |
48e123 |
int pci_bus_num(PCIBus *s);
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
|
|
Mark McLoughlin |
48e123 |
index c74aa2f..9f22623 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/ppc440_bamboo.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/ppc440_bamboo.c
|
|
Mark McLoughlin |
48e123 |
@@ -128,7 +128,7 @@ static void bamboo_init(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
for (i = 0; i < nb_nics; i++) {
|
|
Mark McLoughlin |
48e123 |
/* There are no PCI NICs on the Bamboo board, but there are
|
|
Mark McLoughlin |
48e123 |
* PCI slots, so we can pick whatever default model we want. */
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "e1000", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
|
|
Mark McLoughlin |
48e123 |
index 45480ea..5fa9e82 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/ppc_newworld.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/ppc_newworld.c
|
|
Mark McLoughlin |
48e123 |
@@ -304,7 +304,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
for(i = 0; i < nb_nics; i++)
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
|
Mark McLoughlin |
48e123 |
fprintf(stderr, "qemu: too many IDE bus\n");
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
|
|
Mark McLoughlin |
48e123 |
index 5c745a0..49c8a00 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/ppc_oldworld.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/ppc_oldworld.c
|
|
Mark McLoughlin |
48e123 |
@@ -315,7 +315,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
serial_hds[1], ESCC_CLOCK, 4);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
for(i = 0; i < nb_nics; i++)
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
|
|
Mark McLoughlin |
48e123 |
index 7a21977..a8f0002 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/ppc_prep.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/ppc_prep.c
|
|
Mark McLoughlin |
48e123 |
@@ -681,7 +681,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
if (strcmp(nd_table[i].model, "ne2k_isa") == 0) {
|
|
Mark McLoughlin |
48e123 |
isa_ne2000_init(ne2000_io[i], i8259[ne2000_irq[i]], &nd_table[i]);
|
|
Mark McLoughlin |
48e123 |
} else {
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/ppce500_mpc8544ds.c b/hw/ppce500_mpc8544ds.c
|
|
Mark McLoughlin |
48e123 |
index db52cdd..5f2b526 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/ppce500_mpc8544ds.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/ppce500_mpc8544ds.c
|
|
Mark McLoughlin |
48e123 |
@@ -228,7 +228,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
/* Register network interfaces. */
|
|
Mark McLoughlin |
48e123 |
for (i = 0; i < nb_nics; i++) {
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "virtio", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/r2d.c b/hw/r2d.c
|
|
Mark McLoughlin |
48e123 |
index 8ce6832..af229d4 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/r2d.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/r2d.c
|
|
Mark McLoughlin |
48e123 |
@@ -231,7 +231,7 @@ static void r2d_init(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
/* NIC: rtl8139 on-board, and 2 slots. */
|
|
Mark McLoughlin |
48e123 |
for (i = 0; i < nb_nics; i++)
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "rtl8139", i==0 ? "2" : NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "rtl8139", i==0 ? "2" : NULL);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
/* Todo: register on board registers */
|
|
Mark McLoughlin |
48e123 |
if (kernel_filename) {
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/realview.c b/hw/realview.c
|
|
Mark McLoughlin |
48e123 |
index 8e176b9..70c129b 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/realview.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/realview.c
|
|
Mark McLoughlin |
48e123 |
@@ -125,7 +125,7 @@ static void realview_init(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
smc91c111_init(nd, 0x4e000000, pic[28]);
|
|
Mark McLoughlin |
48e123 |
done_smc = 1;
|
|
Mark McLoughlin |
48e123 |
} else {
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/sun4u.c b/hw/sun4u.c
|
|
Mark McLoughlin |
48e123 |
index 9d2a7f5..9fb5dcd 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/sun4u.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/sun4u.c
|
|
Mark McLoughlin |
48e123 |
@@ -497,7 +497,7 @@ static void sun4uv_init(ram_addr_t RAM_size,
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
for(i = 0; i < nb_nics; i++)
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
|
|
Mark McLoughlin |
48e123 |
fprintf(stderr, "qemu: too many IDE bus\n");
|
|
Mark McLoughlin |
48e123 |
diff --git a/hw/versatilepb.c b/hw/versatilepb.c
|
|
Mark McLoughlin |
48e123 |
index 3371121..8e06c31 100644
|
|
Mark McLoughlin |
48e123 |
--- a/hw/versatilepb.c
|
|
Mark McLoughlin |
48e123 |
+++ b/hw/versatilepb.c
|
|
Mark McLoughlin |
48e123 |
@@ -212,7 +212,7 @@ static void versatile_init(ram_addr_t ram_size,
|
|
Mark McLoughlin |
48e123 |
smc91c111_init(nd, 0x10010000, sic[25]);
|
|
Mark McLoughlin |
48e123 |
done_smc = 1;
|
|
Mark McLoughlin |
48e123 |
} else {
|
|
Mark McLoughlin |
48e123 |
- pci_nic_init(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
+ pci_nic_init_nofail(nd, "rtl8139", NULL);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
if (usb_enabled) {
|
|
Mark McLoughlin |
48e123 |
diff --git a/net.c b/net.c
|
|
Mark McLoughlin |
48e123 |
index 047e72e..3572c48 100644
|
|
Mark McLoughlin |
48e123 |
--- a/net.c
|
|
Mark McLoughlin |
48e123 |
+++ b/net.c
|
|
Mark McLoughlin |
48e123 |
@@ -2543,6 +2543,19 @@ static int nic_get_free_idx(void)
|
|
Mark McLoughlin |
48e123 |
return -1;
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
+int qemu_show_nic_models(const char *arg, const char *const *models)
|
|
Mark McLoughlin |
48e123 |
+{
|
|
Mark McLoughlin |
48e123 |
+ int i;
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
+ if (!arg || strcmp(arg, "?"))
|
|
Mark McLoughlin |
48e123 |
+ return 0;
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
+ fprintf(stderr, "qemu: Supported NIC models: ");
|
|
Mark McLoughlin |
48e123 |
+ for (i = 0 ; models[i]; i++)
|
|
Mark McLoughlin |
48e123 |
+ fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
|
|
Mark McLoughlin |
48e123 |
+ return 1;
|
|
Mark McLoughlin |
48e123 |
+}
|
|
Mark McLoughlin |
48e123 |
+
|
|
Mark McLoughlin |
48e123 |
void qemu_check_nic_model(NICInfo *nd, const char *model)
|
|
Mark McLoughlin |
48e123 |
{
|
|
Mark McLoughlin |
48e123 |
const char *models[2];
|
|
Mark McLoughlin |
48e123 |
@@ -2550,31 +2563,27 @@ void qemu_check_nic_model(NICInfo *nd, const char *model)
|
|
Mark McLoughlin |
48e123 |
models[0] = model;
|
|
Mark McLoughlin |
48e123 |
models[1] = NULL;
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- qemu_check_nic_model_list(nd, models, model);
|
|
Mark McLoughlin |
48e123 |
+ if (qemu_show_nic_models(nd->model, models))
|
|
Mark McLoughlin |
48e123 |
+ exit(0);
|
|
Mark McLoughlin |
48e123 |
+ if (qemu_find_nic_model(nd, models, model) < 0)
|
|
Mark McLoughlin |
48e123 |
+ exit(1);
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
-int qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
|
|
Mark McLoughlin |
48e123 |
- const char *default_model)
|
|
Mark McLoughlin |
48e123 |
+int qemu_find_nic_model(NICInfo *nd, const char * const *models,
|
|
Mark McLoughlin |
48e123 |
+ const char *default_model)
|
|
Mark McLoughlin |
48e123 |
{
|
|
Mark McLoughlin |
48e123 |
- int i, exit_status = 0;
|
|
Mark McLoughlin |
48e123 |
+ int i;
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
if (!nd->model)
|
|
Mark McLoughlin |
48e123 |
nd->model = qemu_strdup(default_model);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- if (strcmp(nd->model, "?") != 0) {
|
|
Mark McLoughlin |
48e123 |
- for (i = 0 ; models[i]; i++)
|
|
Mark McLoughlin |
48e123 |
- if (strcmp(nd->model, models[i]) == 0)
|
|
Mark McLoughlin |
48e123 |
- return i;
|
|
Mark McLoughlin |
48e123 |
-
|
|
Mark McLoughlin |
48e123 |
- fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model);
|
|
Mark McLoughlin |
48e123 |
- exit_status = 1;
|
|
Mark McLoughlin |
48e123 |
+ for (i = 0 ; models[i]; i++) {
|
|
Mark McLoughlin |
48e123 |
+ if (strcmp(nd->model, models[i]) == 0)
|
|
Mark McLoughlin |
48e123 |
+ return i;
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
- fprintf(stderr, "qemu: Supported NIC models: ");
|
|
Mark McLoughlin |
48e123 |
- for (i = 0 ; models[i]; i++)
|
|
Mark McLoughlin |
48e123 |
- fprintf(stderr, "%s%c", models[i], models[i+1] ? ',' : '\n');
|
|
Mark McLoughlin |
48e123 |
-
|
|
Mark McLoughlin |
48e123 |
- exit(exit_status);
|
|
Mark McLoughlin |
48e123 |
+ fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model);
|
|
Mark McLoughlin |
48e123 |
+ return -1;
|
|
Mark McLoughlin |
48e123 |
}
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
static int net_handle_fd_param(Monitor *mon, const char *param)
|
|
Mark McLoughlin |
48e123 |
diff --git a/net.h b/net.h
|
|
Mark McLoughlin |
48e123 |
index 9662988..07b4c9a 100644
|
|
Mark McLoughlin |
48e123 |
--- a/net.h
|
|
Mark McLoughlin |
48e123 |
+++ b/net.h
|
|
Mark McLoughlin |
48e123 |
@@ -79,9 +79,10 @@ ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
|
|
Mark McLoughlin |
48e123 |
void qemu_purge_queued_packets(VLANClientState *vc);
|
|
Mark McLoughlin |
48e123 |
void qemu_flush_queued_packets(VLANClientState *vc);
|
|
Mark McLoughlin |
48e123 |
void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
|
|
Mark McLoughlin |
48e123 |
+int qemu_show_nic_models(const char *arg, const char *const *models);
|
|
Mark McLoughlin |
48e123 |
void qemu_check_nic_model(NICInfo *nd, const char *model);
|
|
Mark McLoughlin |
48e123 |
-int qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
|
|
Mark McLoughlin |
48e123 |
- const char *default_model);
|
|
Mark McLoughlin |
48e123 |
+int qemu_find_nic_model(NICInfo *nd, const char * const *models,
|
|
Mark McLoughlin |
48e123 |
+ const char *default_model);
|
|
Mark McLoughlin |
48e123 |
void qemu_handler_true(void *opaque);
|
|
Mark McLoughlin |
48e123 |
|
|
Mark McLoughlin |
48e123 |
void do_info_network(Monitor *mon);
|
|
Mark McLoughlin |
48e123 |
--
|
|
Mark McLoughlin |
48e123 |
1.6.2.5
|
|
Mark McLoughlin |
48e123 |
|