All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Novotny <minovotn@redhat.com>
To: "'xen-devel@lists.xensource.com'" <xen-devel@lists.xensource.com>
Subject: [PATCH] Make NIC model fallback to default when specified model is not supported
Date: Mon, 20 Sep 2010 12:21:52 +0200	[thread overview]
Message-ID: <4C9735C0.5000806@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 996 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 x86_64 host with current
version of qemu-dm using the RHEL-5 i386 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.

It's been tested by running a guest with NIC model set to be "eee" which
is not supported and when the guest was started I tried to issue "lspci"
to list all the PCI devices and there was Realtek RTL-8239 (AS) card
which is basically the ne2k_pci card (default for Xen-4.1 qemu-dm) so
the old default has been preserved and it's being used as a fallback.

Michal

Signed-off-by: Michal Novotny<minovotn@redhat.com>

-- 
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat


[-- Attachment #2: xen-qemu-make-nic-model-fallback-to-default-when-unsupported.patch --]
[-- Type: text/x-patch, Size: 3538 bytes --]

>From fabe98d01d43a7b8157726407f344a943a233ad7 Mon Sep 17 00:00:00 2001
From: Michal Novotny <minovotn@redhat.com>
Date: Mon, 20 Sep 2010 14:22:28 +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 x86_64 host with current
version of qemu-dm using the RHEL-5 i386 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.

It's been tested by running a guest with NIC model set to be "eee" which
is not supported and when the guest was started I tried to issue "lspci"
to list all the PCI devices and there was Realtek RTL-8239 (AS) card
which is basically the ne2k_pci card (default for Xen-4.1 qemu-dm) so
the old default has been preserved and it's being used as a fallback.

Michal

Signed-off-by: Michal Novotny<minovotn@redhat.com>
---
 hw/pc.c |    2 +-
 net.c   |   11 ++++++++++-
 net.h   |    3 +++
 vl.c    |    2 +-
 4 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 4c9a164..3b6d15d 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1077,7 +1077,7 @@ vga_bios_error:
         if (!pci_enabled || (nd->model && strcmp(nd->model, "ne2k_isa") == 0))
             pc_init_ne2k_isa(nd, i8259);
         else
-            pci_nic_init(pci_bus, nd, -1, "ne2k_pci");
+            pci_nic_init(pci_bus, nd, -1, NIC_DEFAULT_MODEL);
     }
 
     qemu_system_hot_add_init();
diff --git a/net.c b/net.c
index 720027c..f10ba8b 100644
--- a/net.c
+++ b/net.c
@@ -1610,12 +1610,21 @@ void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
     if (!nd->model)
         nd->model = strdup(default_model);
 
+again:
     if (strcmp(nd->model, "?") != 0) {
         for (i = 0 ; models[i]; i++)
             if (strcmp(nd->model, models[i]) == 0)
                 return;
 
-        fprintf(stderr, "qemu: Unsupported NIC model: %s\n", nd->model);
+        if (strcmp(nd->model, NIC_DEFAULT_MODEL) != 0) {
+            fprintf(stderr, "qemu: Unsupported NIC model: %s, using default: %s\n",
+                             nd->model, NIC_DEFAULT_MODEL);
+            nd->model = strdup(NIC_DEFAULT_MODEL);
+            goto again;
+        }
+        else
+            fprintf(stderr, "qemu: Unsupported default NIC model: %s (probably a bug)\n", nd->model);
+
         exit_status = 1;
     }
 
diff --git a/net.h b/net.h
index bc749d9..e7626f4 100644
--- a/net.h
+++ b/net.h
@@ -3,6 +3,9 @@
 
 #include "qemu-common.h"
 
+/* Default NIC model to be used - also used as a fallback model when model specified doesn't exist */
+#define NIC_DEFAULT_MODEL "ne2k_pci"
+
 /* VLANs support */
 
 typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
diff --git a/vl.c b/vl.c
index 1673cd4..25db3a0 100644
--- a/vl.c
+++ b/vl.c
@@ -5727,7 +5727,7 @@ int main(int argc, char **argv, char **envp)
 	    char buf[1024];
             if (net_boot & (1 << i)) {
                 if (model == NULL)
-                    model = "ne2k_pci";
+                    model = NIC_DEFAULT_MODEL;
                 snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
                 if (get_image_size(buf) > 0) {
                     if (nb_option_roms >= MAX_OPTION_ROMS) {
-- 
1.5.5.6


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

             reply	other threads:[~2010-09-20 10:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-20 10:21 Michal Novotny [this message]
2010-09-20 12:07 ` [PATCH] Make NIC model fallback to default when specified model is not supported Paolo Bonzini
2010-09-20 14:53 ` Ian Jackson

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=4C9735C0.5000806@redhat.com \
    --to=minovotn@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /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.