From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KJAfz-0001z9-15 for qemu-devel@nongnu.org; Wed, 16 Jul 2008 13:20:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KJAfx-0001yV-MO for qemu-devel@nongnu.org; Wed, 16 Jul 2008 13:20:25 -0400 Received: from [199.232.76.173] (port=41206 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KJAfw-0001yO-Ks for qemu-devel@nongnu.org; Wed, 16 Jul 2008 13:20:24 -0400 Received: from lizzard.sbs.de ([194.138.37.39]:21108) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KJAfw-0004kj-GG for qemu-devel@nongnu.org; Wed, 16 Jul 2008 13:20:24 -0400 Received: from mail2.sbs.de (localhost [127.0.0.1]) by lizzard.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m6GHKBu8025814 for ; Wed, 16 Jul 2008 19:20:11 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail2.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m6GHKAg7017267 for ; Wed, 16 Jul 2008 19:20:11 +0200 Message-ID: <487E2DCB.2090902@siemens.com> Date: Wed, 16 Jul 2008 19:20:11 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] Various NICs: Fix suspend/resume of multiple instances Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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);