Commit 18fdb1c5c614ebdf9c3ea9ef0a548bd81cc1f981
1 parent
2cfc5f17
Various NICs: Fix suspend/resume of multiple instances, by Jan Kiszka.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4892 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
6 changed files
with
11 additions
and
16 deletions
hw/e1000.c
| @@ -76,7 +76,6 @@ typedef struct E1000State_st { | @@ -76,7 +76,6 @@ typedef struct E1000State_st { | ||
| 76 | PCIDevice dev; | 76 | PCIDevice dev; |
| 77 | VLANClientState *vc; | 77 | VLANClientState *vc; |
| 78 | NICInfo *nd; | 78 | NICInfo *nd; |
| 79 | - uint32_t instance; | ||
| 80 | uint32_t mmio_base; | 79 | uint32_t mmio_base; |
| 81 | int mmio_index; | 80 | int mmio_index; |
| 82 | 81 | ||
| @@ -814,7 +813,6 @@ nic_save(QEMUFile *f, void *opaque) | @@ -814,7 +813,6 @@ nic_save(QEMUFile *f, void *opaque) | ||
| 814 | int i, j; | 813 | int i, j; |
| 815 | 814 | ||
| 816 | pci_device_save(&s->dev, f); | 815 | pci_device_save(&s->dev, f); |
| 817 | - qemu_put_be32s(f, &s->instance); | ||
| 818 | qemu_put_be32s(f, &s->mmio_base); | 816 | qemu_put_be32s(f, &s->mmio_base); |
| 819 | qemu_put_be32s(f, &s->rxbuf_size); | 817 | qemu_put_be32s(f, &s->rxbuf_size); |
| 820 | qemu_put_be32s(f, &s->rxbuf_min_shift); | 818 | qemu_put_be32s(f, &s->rxbuf_min_shift); |
| @@ -859,7 +857,8 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | @@ -859,7 +857,8 @@ nic_load(QEMUFile *f, void *opaque, int version_id) | ||
| 859 | 857 | ||
| 860 | if ((ret = pci_device_load(&s->dev, f)) < 0) | 858 | if ((ret = pci_device_load(&s->dev, f)) < 0) |
| 861 | return ret; | 859 | return ret; |
| 862 | - qemu_get_be32s(f, &s->instance); | 860 | + if (version_id == 1) |
| 861 | + qemu_get_be32s(f, &i); /* once some unused instance id */ | ||
| 863 | qemu_get_be32s(f, &s->mmio_base); | 862 | qemu_get_be32s(f, &s->mmio_base); |
| 864 | qemu_get_be32s(f, &s->rxbuf_size); | 863 | qemu_get_be32s(f, &s->rxbuf_size); |
| 865 | qemu_get_be32s(f, &s->rxbuf_min_shift); | 864 | qemu_get_be32s(f, &s->rxbuf_min_shift); |
| @@ -958,7 +957,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -958,7 +957,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
| 958 | { | 957 | { |
| 959 | E1000State *d; | 958 | E1000State *d; |
| 960 | uint8_t *pci_conf; | 959 | uint8_t *pci_conf; |
| 961 | - static int instance; | ||
| 962 | uint16_t checksum = 0; | 960 | uint16_t checksum = 0; |
| 963 | char *info_str = "e1000"; | 961 | char *info_str = "e1000"; |
| 964 | int i; | 962 | int i; |
| @@ -989,8 +987,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -989,8 +987,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
| 989 | pci_register_io_region((PCIDevice *)d, 1, IOPORT_SIZE, | 987 | pci_register_io_region((PCIDevice *)d, 1, IOPORT_SIZE, |
| 990 | PCI_ADDRESS_SPACE_IO, ioport_map); | 988 | PCI_ADDRESS_SPACE_IO, ioport_map); |
| 991 | 989 | ||
| 992 | - d->instance = instance++; | ||
| 993 | - | ||
| 994 | d->nd = nd; | 990 | d->nd = nd; |
| 995 | memmove(d->eeprom_data, e1000_eeprom_template, | 991 | memmove(d->eeprom_data, e1000_eeprom_template, |
| 996 | sizeof e1000_eeprom_template); | 992 | sizeof e1000_eeprom_template); |
| @@ -1016,5 +1012,5 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -1016,5 +1012,5 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
| 1016 | d->nd->macaddr[0], d->nd->macaddr[1], d->nd->macaddr[2], | 1012 | d->nd->macaddr[0], d->nd->macaddr[1], d->nd->macaddr[2], |
| 1017 | d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]); | 1013 | d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]); |
| 1018 | 1014 | ||
| 1019 | - register_savevm(info_str, d->instance, 1, nic_save, nic_load, d); | 1015 | + register_savevm(info_str, -1, 2, nic_save, nic_load, d); |
| 1020 | } | 1016 | } |
hw/eepro100.c
| @@ -1792,8 +1792,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, | @@ -1792,8 +1792,7 @@ static void nic_init(PCIBus * bus, NICInfo * nd, | ||
| 1792 | 1792 | ||
| 1793 | qemu_register_reset(nic_reset, s); | 1793 | qemu_register_reset(nic_reset, s); |
| 1794 | 1794 | ||
| 1795 | - /* XXX: instance number ? */ | ||
| 1796 | - register_savevm(name, 0, 3, nic_save, nic_load, s); | 1795 | + register_savevm(name, -1, 3, nic_save, nic_load, s); |
| 1797 | } | 1796 | } |
| 1798 | 1797 | ||
| 1799 | void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn) | 1798 | void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn) |
hw/ne2000.c
| @@ -753,7 +753,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) | @@ -753,7 +753,7 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd) | ||
| 753 | s->macaddr[4], | 753 | s->macaddr[4], |
| 754 | s->macaddr[5]); | 754 | s->macaddr[5]); |
| 755 | 755 | ||
| 756 | - register_savevm("ne2000", 0, 2, ne2000_save, ne2000_load, s); | 756 | + register_savevm("ne2000", -1, 2, ne2000_save, ne2000_load, s); |
| 757 | } | 757 | } |
| 758 | 758 | ||
| 759 | /***********************************************************/ | 759 | /***********************************************************/ |
| @@ -823,6 +823,5 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -823,6 +823,5 @@ void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
| 823 | s->macaddr[4], | 823 | s->macaddr[4], |
| 824 | s->macaddr[5]); | 824 | s->macaddr[5]); |
| 825 | 825 | ||
| 826 | - /* XXX: instance number ? */ | ||
| 827 | - register_savevm("ne2000", 0, 3, ne2000_save, ne2000_load, s); | 826 | + register_savevm("ne2000", -1, 3, ne2000_save, ne2000_load, s); |
| 828 | } | 827 | } |
hw/pcnet.c
| @@ -1916,7 +1916,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) | @@ -1916,7 +1916,7 @@ static void pcnet_common_init(PCNetState *d, NICInfo *nd, const char *info_str) | ||
| 1916 | d->vc = NULL; | 1916 | d->vc = NULL; |
| 1917 | } | 1917 | } |
| 1918 | pcnet_h_reset(d); | 1918 | pcnet_h_reset(d); |
| 1919 | - register_savevm("pcnet", 0, 2, pcnet_save, pcnet_load, d); | 1919 | + register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, d); |
| 1920 | } | 1920 | } |
| 1921 | 1921 | ||
| 1922 | /* PCI interface */ | 1922 | /* PCI interface */ |
hw/rtl8139.c
| @@ -3454,8 +3454,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) | @@ -3454,8 +3454,7 @@ void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn) | ||
| 3454 | s->cplus_txbuffer_len = 0; | 3454 | s->cplus_txbuffer_len = 0; |
| 3455 | s->cplus_txbuffer_offset = 0; | 3455 | s->cplus_txbuffer_offset = 0; |
| 3456 | 3456 | ||
| 3457 | - /* XXX: instance number ? */ | ||
| 3458 | - register_savevm("rtl8139", 0, 3, rtl8139_save, rtl8139_load, s); | 3457 | + register_savevm("rtl8139", -1, 3, rtl8139_save, rtl8139_load, s); |
| 3459 | 3458 | ||
| 3460 | #if RTL8139_ONBOARD_TIMER | 3459 | #if RTL8139_ONBOARD_TIMER |
| 3461 | s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s); | 3460 | s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s); |
vl.c
| @@ -6081,7 +6081,9 @@ typedef struct SaveStateEntry { | @@ -6081,7 +6081,9 @@ typedef struct SaveStateEntry { | ||
| 6081 | static SaveStateEntry *first_se; | 6081 | static SaveStateEntry *first_se; |
| 6082 | 6082 | ||
| 6083 | /* TODO: Individual devices generally have very little idea about the rest | 6083 | /* TODO: Individual devices generally have very little idea about the rest |
| 6084 | - of the system, so instance_id should be removed/replaced. */ | 6084 | + of the system, so instance_id should be removed/replaced. |
| 6085 | + Meanwhile pass -1 as instance_id if you do not already have a clearly | ||
| 6086 | + distinguishing id for all instances of your device class. */ | ||
| 6085 | int register_savevm(const char *idstr, | 6087 | int register_savevm(const char *idstr, |
| 6086 | int instance_id, | 6088 | int instance_id, |
| 6087 | int version_id, | 6089 | int version_id, |