From: Michal Novotny <minovotn@redhat.com>
To: "qe >> \"qemu-devel@nongnu.org\"" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Make NIC model fallback to default when specified model is not supported
Date: Mon, 20 Sep 2010 11:47:59 +0200 [thread overview]
Message-ID: <4C972DCF.1050003@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 781 bytes --]
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>
--
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat
[-- Attachment #2: qemu-make-nic-model-fallback-to-default-when-unsupported.patch --]
[-- Type: text/x-patch, Size: 4729 bytes --]
>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(-)
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 66397c0..0b66e65 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -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");
}
}
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 12359a7..0f95910 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -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) {
diff --git a/hw/pci.c b/hw/pci.c
index 6d0934d..a2afa3a 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -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) {
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 34ddf45..0d41428 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -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);
}
}
diff --git a/net.c b/net.c
index 3d0fde7..ffd471e 100644
--- a/net.c
+++ b/net.c
@@ -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;
}
diff --git a/net.h b/net.h
index 518cf9c..fc8e04c 100644
--- a/net.h
+++ b/net.h
@@ -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
next reply other threads:[~2010-09-20 9:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-20 9:47 Michal Novotny [this message]
2010-09-20 10:34 ` [Qemu-devel] Re: [PATCH] Make NIC model fallback to default when specified model is not supported Paolo Bonzini
2010-09-20 10:48 ` Michal Novotny
2010-09-20 10:53 ` Daniel P. Berrange
2010-09-20 11:05 ` Michal Novotny
2010-09-20 11:07 ` Daniel P. Berrange
2010-09-20 11:15 ` Michal Novotny
2010-09-20 14:35 ` Anthony Liguori
2010-09-20 17:58 ` Michael S. Tsirkin
2010-09-21 7:10 ` Michal Novotny
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=4C972DCF.1050003@redhat.com \
--to=minovotn@redhat.com \
--cc=qemu-devel@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.