peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame qemu-do-not-exit-on-pci-hotplug-invalid-nic1.patch

Mark McLoughlin 48e123
From 0ce1af6e7d4b1e2ffa4dedf6d415c4d86a1af490 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:50 +0200
Mark McLoughlin 48e123
Subject: [PATCH] Make it obvious that pci_nic_init() can't fail
Mark McLoughlin 48e123
Mark McLoughlin 48e123
Before this patch, pci_nic_init() returns NULL when it can't find the
Mark McLoughlin 48e123
model in pci_nic_models[].  Except this can't happen, because
Mark McLoughlin 48e123
qemu_check_nic_model_list() just searched for model in
Mark McLoughlin 48e123
pci_nic_models[], and terminated the program on failure.
Mark McLoughlin 48e123
Mark McLoughlin 48e123
Repeating the search here is pointless.  Instead, change
Mark McLoughlin 48e123
qemu_check_nic_model_list() to return the model's array index.
Mark McLoughlin 48e123
Mark McLoughlin 48e123
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Mark McLoughlin 48e123
Signed-off-by: Mark McLoughlin 
Mark McLoughlin 48e123
Fedora-patch: qemu-do-not-exit-on-pci-hotplug-invalid-nic1.patch
Mark McLoughlin 48e123
---
Mark McLoughlin 48e123
 hw/pci.c |   25 +++++++++----------------
Mark McLoughlin 48e123
 net.c    |    6 +++---
Mark McLoughlin 48e123
 net.h    |    4 ++--
Mark McLoughlin 48e123
 3 files changed, 14 insertions(+), 21 deletions(-)
Mark McLoughlin 48e123
Mark McLoughlin 48e123
diff --git a/hw/pci.c b/hw/pci.c
Mark McLoughlin 48e123
index a575d4a..eb990f9 100644
Mark McLoughlin 48e123
--- a/hw/pci.c
Mark McLoughlin 48e123
+++ b/hw/pci.c
Mark McLoughlin 48e123
@@ -937,22 +937,15 @@ 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
-    qemu_check_nic_model_list(nd, pci_nic_models, default_model);
Mark McLoughlin 48e123
-
Mark McLoughlin 48e123
-    for (i = 0; pci_nic_models[i]; i++) {
Mark McLoughlin 48e123
-        if (strcmp(nd->model, pci_nic_models[i]) == 0) {
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
-                dev->id = qemu_strdup(nd->id);
Mark McLoughlin 48e123
-            dev->nd = nd;
Mark McLoughlin 48e123
-            qdev_init(dev);
Mark McLoughlin 48e123
-            nd->private = dev;
Mark McLoughlin 48e123
-            return pci_dev;
Mark McLoughlin 48e123
-        }
Mark McLoughlin 48e123
-    }
Mark McLoughlin 48e123
-
Mark McLoughlin 48e123
-    return NULL;
Mark McLoughlin 48e123
+    i = qemu_check_nic_model_list(nd, pci_nic_models, default_model);
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
+        dev->id = qemu_strdup(nd->id);
Mark McLoughlin 48e123
+    dev->nd = nd;
Mark McLoughlin 48e123
+    qdev_init(dev);
Mark McLoughlin 48e123
+    nd->private = dev;
Mark McLoughlin 48e123
+    return pci_dev;
Mark McLoughlin 48e123
 }
Mark McLoughlin 48e123
 
Mark McLoughlin 48e123
 typedef struct {
Mark McLoughlin 48e123
diff --git a/net.c b/net.c
Mark McLoughlin 48e123
index da2f428..047e72e 100644
Mark McLoughlin 48e123
--- a/net.c
Mark McLoughlin 48e123
+++ b/net.c
Mark McLoughlin 48e123
@@ -2553,8 +2553,8 @@ void qemu_check_nic_model(NICInfo *nd, const char *model)
Mark McLoughlin 48e123
     qemu_check_nic_model_list(nd, models, model);
Mark McLoughlin 48e123
 }
Mark McLoughlin 48e123
 
Mark McLoughlin 48e123
-void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
Mark McLoughlin 48e123
-                               const char *default_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
 {
Mark McLoughlin 48e123
     int i, exit_status = 0;
Mark McLoughlin 48e123
 
Mark McLoughlin 48e123
@@ -2564,7 +2564,7 @@ void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
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;
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
diff --git a/net.h b/net.h
Mark McLoughlin 48e123
index 94db0d7..9662988 100644
Mark McLoughlin 48e123
--- a/net.h
Mark McLoughlin 48e123
+++ b/net.h
Mark McLoughlin 48e123
@@ -80,8 +80,8 @@ 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
 void qemu_check_nic_model(NICInfo *nd, const char *model);
Mark McLoughlin 48e123
-void qemu_check_nic_model_list(NICInfo *nd, const char * const *models,
Mark McLoughlin 48e123
-                               const char *default_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
 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