From bccd19d357045c20db332d185e93f8cf54caa340 Mon Sep 17 00:00:00 2001
From: Michal Novotny <minovotn@redhat.com>
Date: Mon, 20 Sep 2010 11:37:54 +0200
Subject: [PATCH] Make NIC model fallback to default when specified model is not supported
Hi,
this is the patch to introduce a NIC model fallback to default when model
specified is not supported. It's been tested on i386-softmmu target on
i386 host using the Windows XP x86 virtual machine and by trying to setup
the invalid (unsupported) model of NIC device. Also, the new constant in
the net.h called the DEFAULT_NIC_MODEL has been introduced to be able to
change the default NIC model easily. This variable is being used to set
the default NIC model when necessary.
Also, some bits per mips_jazz were added but usage of some constant for
MIPS is not necessary since there is only one NIC model supported there.
Michal
Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
hw/mips_jazz.c | 4 ++--
hw/pc_piix.c | 2 +-
hw/pci.c | 8 ++++++--
hw/ppc440_bamboo.c | 2 +-
net.c | 12 +++++++++---
net.h | 3 +++
6 files changed, 22 insertions(+), 9 deletions(-)
@@ -237,8 +237,8 @@ void mips_jazz_init (ram_addr_t ram_size,
fprintf(stderr, "qemu: Supported NICs: dp83932\n");
exit(1);
} else {
- fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
- exit(1);
+ fprintf(stderr, "qemu: Unsupported NIC: %s, using default: dp83932\n", nd->model);
+ nd->model = qemu_strdup("dp83932");
}
}
@@ -122,7 +122,7 @@ static void pc_init1(ram_addr_t ram_size,
if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
pc_init_ne2k_isa(nd);
else
- pci_nic_init_nofail(nd, "e1000", NULL);
+ pci_nic_init_nofail(nd, NIC_DEFAULT_MODEL, NULL);
}
if (drive_get_max_bus(IF_IDE) >= MAX_IDE_BUS) {
@@ -1502,8 +1502,12 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
int i;
i = qemu_find_nic_model(nd, pci_nic_models, default_model);
- if (i < 0)
- return NULL;
+ if (i < 0) {
+ nd->model = qemu_strdup(NIC_DEFAULT_MODEL);
+ i = qemu_find_nic_model(nd, pci_nic_models, NIC_DEFAULT_MODEL);
+ if (i < 0)
+ return NULL;
+ }
bus = pci_get_bus_devfn(&devfn, devaddr);
if (!bus) {
@@ -115,7 +115,7 @@ static void bamboo_init(ram_addr_t ram_size,
for (i = 0; i < nb_nics; i++) {
/* There are no PCI NICs on the Bamboo board, but there are
* PCI slots, so we can pick whatever default model we want. */
- pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
+ pci_nic_init_nofail(&nd_table[i], NIC_DEFAULT_MODEL, NULL);
}
}
@@ -716,8 +716,14 @@ void qemu_check_nic_model(NICInfo *nd, const char *model)
if (qemu_show_nic_models(nd->model, models))
exit(0);
- if (qemu_find_nic_model(nd, models, model) < 0)
- exit(1);
+ if (qemu_find_nic_model(nd, models, model) < 0) {
+ /* Fallback to default model if unsupported */
+ models[0] = NIC_DEFAULT_MODEL;
+ nd->model = qemu_strdup(NIC_DEFAULT_MODEL);
+
+ if (qemu_find_nic_model(nd, models, model) < 0)
+ exit(1);
+ }
}
int qemu_find_nic_model(NICInfo *nd, const char * const *models,
@@ -733,7 +739,7 @@ int qemu_find_nic_model(NICInfo *nd, const char * const *models,
return i;
}
- error_report("qemu: Unsupported NIC model: %s", nd->model);
+ error_report("qemu: Unsupported NIC model: %s, using default: %s", nd->model, NIC_DEFAULT_MODEL);
return -1;
}
@@ -24,6 +24,9 @@ typedef struct NICConf {
DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \
DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
+/* Default NIC model to be used - also used as a fallback model when model specified doesn't exist */
+#define NIC_DEFAULT_MODEL "e1000"
+
/* VLANs support */
typedef enum {
--
1.7.2.3
Hi, this is the patch to introduce a NIC model fallback to default when model specified is not supported. It's been tested on i386-softmmu target on i386 host using the Windows XP x86 virtual machine and by trying to setup the invalid (unsupported) model of NIC device. Also, the new constant in the net.h called the DEFAULT_NIC_MODEL has been introduced to be able to change the default NIC model easily. This variable is being used to set the default NIC model when necessary. Also, some bits per mips_jazz were added but usage of some constant for MIPS is not necessary since there is only one NIC model supported there. Michal Signed-off-by: Michal Novotny <minovotn@redhat.com>