qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Various NICs: Fix suspend/resume of multiple instan


From: Jan Kiszka
Subject: [Qemu-devel] [PATCH] Various NICs: Fix suspend/resume of multiple instances
Date: Wed, 16 Jul 2008 19:20:11 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

We ran into the issue that restoring two (or more) instances of the same
NIC does not work. The reason is that the same instance number is passed
to register_savevm by many NIC emulations. Patch below addresses this
for eepro100, ne2000, pcnet and rtl8139 (I just quickly checked the set
available for x86).

Signed-off-by: Jan Kiszka <address@hidden>
---
 hw/eepro100.c |    4 ++--
 hw/ne2000.c   |    3 ++-
 hw/pcnet.c    |    4 +++-
 hw/rtl8139.c  |    4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)

Index: b/hw/pcnet.c
===================================================================
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -1896,6 +1896,8 @@ static int pcnet_load(QEMUFile *f, void
 
 static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str)
 {
+    static int instance;
+
     d->poll_timer = qemu_new_timer(vm_clock, pcnet_poll_timer, d);
 
     d->nd = nd;
@@ -1916,7 +1918,7 @@ static void pcnet_common_init(PCNetState
         d->vc = NULL;
     }
     pcnet_h_reset(d);
-    register_savevm("pcnet", 0, 2, pcnet_save, pcnet_load, d);
+    register_savevm("pcnet", instance++, 2, pcnet_save, pcnet_load, d);
 }
 
 /* PCI interface */
Index: b/hw/eepro100.c
===================================================================
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -1745,6 +1745,7 @@ static void nic_save(QEMUFile * f, void
 static void nic_init(PCIBus * bus, NICInfo * nd,
                      const char *name, uint32_t device)
 {
+    static int instance;
     PCIEEPRO100State *d;
     EEPRO100State *s;
 
@@ -1792,8 +1793,7 @@ static void nic_init(PCIBus * bus, NICIn
 
     qemu_register_reset(nic_reset, s);
 
-    /* XXX: instance number ? */
-    register_savevm(name, 0, 3, nic_save, nic_load, s);
+    register_savevm(name, instance++, 3, nic_save, nic_load, s);
 }
 
 void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
Index: b/hw/ne2000.c
===================================================================
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -720,6 +720,7 @@ static int ne2000_load(QEMUFile* f,void*
 
 void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
 {
+    static int instance;
     NE2000State *s;
 
     s = qemu_mallocz(sizeof(NE2000State));
@@ -753,7 +754,7 @@ void isa_ne2000_init(int base, qemu_irq
              s->macaddr[4],
              s->macaddr[5]);
 
-    register_savevm("ne2000", 0, 2, ne2000_save, ne2000_load, s);
+    register_savevm("ne2000", instance++, 2, ne2000_save, ne2000_load, s);
 }
 
 /***********************************************************/
Index: b/hw/rtl8139.c
===================================================================
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -3402,6 +3402,7 @@ static void rtl8139_timer(void *opaque)
 
 void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
+    static int instance;
     PCIRTL8139State *d;
     RTL8139State *s;
     uint8_t *pci_conf;
@@ -3454,8 +3455,7 @@ void pci_rtl8139_init(PCIBus *bus, NICIn
     s->cplus_txbuffer_len = 0;
     s->cplus_txbuffer_offset = 0;
 
-    /* XXX: instance number ? */
-    register_savevm("rtl8139", 0, 3, rtl8139_save, rtl8139_load, s);
+    register_savevm("rtl8139", instance++, 3, rtl8139_save, rtl8139_load, s);
 
 #if RTL8139_ONBOARD_TIMER
     s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]