[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 25/26] pcnet: Add pci_pcnet_{save/load} functions, t
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 25/26] pcnet: Add pci_pcnet_{save/load} functions, then remove PCNetState pci_dev field |
Date: |
Mon, 24 Aug 2009 18:42:59 +0200 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/pcnet.c | 39 ++++++++++++++++++++++++++-------------
1 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/hw/pcnet.c b/hw/pcnet.c
index d5be673..6cba99b 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -60,7 +60,6 @@
typedef struct PCNetState_st PCNetState;
struct PCNetState_st {
- PCIDevice *pci_dev;
VLANClientState *vc;
uint8_t macaddr[6];
QEMUTimer *poll_timer;
@@ -1885,9 +1884,6 @@ static void pcnet_save(QEMUFile *f, void *opaque)
PCNetState *s = opaque;
unsigned int i;
- if (s->pci_dev)
- pci_device_save(s->pci_dev, f);
-
qemu_put_sbe32(f, s->rap);
qemu_put_sbe32(f, s->isr);
qemu_put_sbe32(f, s->lnkst);
@@ -1909,17 +1905,11 @@ static void pcnet_save(QEMUFile *f, void *opaque)
static int pcnet_load(QEMUFile *f, void *opaque, int version_id)
{
PCNetState *s = opaque;
- int i, ret;
+ int i;
if (version_id != 2)
return -EINVAL;
- if (s->pci_dev) {
- ret = pci_device_load(s->pci_dev, f);
- if (ret < 0)
- return ret;
- }
-
qemu_get_sbe32s(f, &s->rap);
qemu_get_sbe32s(f, &s->isr);
qemu_get_sbe32s(f, &s->lnkst);
@@ -1940,6 +1930,29 @@ static int pcnet_load(QEMUFile *f, void *opaque, int
version_id)
return 0;
}
+static void pci_pcnet_save(QEMUFile *f, void *opaque)
+{
+ PCIPCNetState *s = opaque;
+
+ pci_device_save(&s->pci_dev, f);
+ pcnet_save(f, &s->state);
+}
+
+static int pci_pcnet_load(QEMUFile *f, void *opaque, int version_id)
+{
+ PCIPCNetState *s = opaque;
+ int ret;
+
+ if (version_id != 2)
+ return -EINVAL;
+
+ ret = pci_device_load(&s->pci_dev, f);
+ if (ret < 0)
+ return ret;
+
+ return pcnet_load(f, &s->state, version_id);
+}
+
static void pcnet_common_cleanup(PCNetState *d)
{
unregister_savevm("pcnet", d);
@@ -1958,7 +1971,6 @@ static void pcnet_common_init(DeviceState *dev,
PCNetState *s,
pcnet_can_receive, pcnet_receive, NULL,
cleanup, s);
pcnet_h_reset(s);
- register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, s);
}
/* PCI interface */
@@ -2059,9 +2071,9 @@ static void pci_pcnet_init(PCIDevice *pci_dev)
s->irq = pci_dev->irq[0];
s->phys_mem_read = pci_physical_memory_read;
s->phys_mem_write = pci_physical_memory_write;
- s->pci_dev = pci_dev;
pcnet_common_init(&pci_dev->qdev, s, pci_pcnet_cleanup);
+ register_savevm("pcnet", -1, 2, pci_pcnet_save, pci_pcnet_load, d);
}
/* SPARC32 interface */
@@ -2138,6 +2150,7 @@ static void lance_init(SysBusDevice *dev)
s->phys_mem_write = ledma_memory_write;
pcnet_common_init(&dev->qdev, s, lance_cleanup);
+ register_savevm("pcnet", -1, 2, pcnet_save, pcnet_load, s);
}
static SysBusDeviceInfo lance_info = {
--
1.6.2.5
- [Qemu-devel] [PATCH 16/26] ne2000: pci_dev has this very value with the right type, (continued)
- [Qemu-devel] [PATCH 16/26] ne2000: pci_dev has this very value with the right type, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 17/26] ne2000: Change casts to DO_UPCAST() for PCINE2000State, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 18/26] We need PCINE2000State for save/load functions, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 19/26] Add pci_ne2000_{save/load} functions, then remove pci_dev NE2000State field, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 20/26] cirrus_vga: remove pointless cast from void *, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 22/26] Add pci_cirrus_vga_{save/load} functions, then remove vga.pci_dev use, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 24/26] pcnet: remove useless casts This are casts to the very type of the function, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 23/26] pcnet: Change casts to DO_UPCAST() for PCIPCNetState, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 21/26] cirrus_vga: Change casts to DO_UPCAST() for PCICirrusVGAState, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 26/26] e1000 cleanup, Juan Quintela, 2009/08/24
- [Qemu-devel] [PATCH 25/26] pcnet: Add pci_pcnet_{save/load} functions, then remove PCNetState pci_dev field,
Juan Quintela <=
- Re: [Qemu-devel] [PATCH 00/26] Indirection Cleanup, Gerd Hoffmann, 2009/08/25