qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Various NICs: Fix suspend/resume of multiple instances
@ 2008-07-16 17:20 Jan Kiszka
  2008-07-16 23:44 ` Paul Brook
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2008-07-16 17:20 UTC (permalink / raw)
  To: qemu-devel

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 <jan.kiszka@siemens.com>
---
 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);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-17  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-16 17:20 [Qemu-devel] [PATCH] Various NICs: Fix suspend/resume of multiple instances Jan Kiszka
2008-07-16 23:44 ` Paul Brook
2008-07-17  8:15   ` Jan Kiszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).