aboutsummaryrefslogtreecommitdiff
path: root/hw/piix_pci.c
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2009-08-28 15:28:24 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-09-04 09:37:25 -0500
commitda64182c4e41966a061b8b883f0a23ded9dc8e5e (patch)
tree761bf752054c7172c3973911d8549ee8abdb81fb /hw/piix_pci.c
parent8372615d3ff5e29925b75562c838e69d3fd96c73 (diff)
Update SaveVM versions
Now that we have all fields belonging to a PCIDevice, save each field on the device that it belongs. This means moving pci_irq_levels from PCII440FXState to PIIX3State. Old formats are loaded, but we only save on the new saner format. Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/piix_pci.c')
-rw-r--r--hw/piix_pci.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 80296acd7c..a044883c3a 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -157,13 +157,9 @@ static void i440fx_write_config(PCIDevice *dev,
static void i440fx_save(QEMUFile* f, void *opaque)
{
PCII440FXState *d = opaque;
- int i;
pci_device_save(&d->dev, f);
qemu_put_8s(f, &d->smm_enabled);
-
- for (i = 0; i < 4; i++)
- qemu_put_be32(f, d->irq_state->piix3->pci_irq_levels[i]);
}
static int i440fx_load(QEMUFile* f, void *opaque, int version_id)
@@ -171,7 +167,7 @@ static int i440fx_load(QEMUFile* f, void *opaque, int version_id)
PCII440FXState *d = opaque;
int ret, i;
- if (version_id > 2)
+ if (version_id > 3)
return -EINVAL;
ret = pci_device_load(&d->dev, f);
if (ret < 0)
@@ -179,7 +175,7 @@ static int i440fx_load(QEMUFile* f, void *opaque, int version_id)
i440fx_update_memory_mappings(d);
qemu_get_8s(f, &d->smm_enabled);
- if (version_id >= 2)
+ if (version_id == 2)
for (i = 0; i < 4; i++)
d->irq_state->piix3->pci_irq_levels[i] = qemu_get_be32(f);
@@ -214,7 +210,7 @@ static int i440fx_initfn(PCIDevice *dev)
d->dev.config[0x72] = 0x02; /* SMRAM */
- register_savevm("I440FX", 0, 2, i440fx_save, i440fx_load, d);
+ register_savevm("I440FX", 0, 3, i440fx_save, i440fx_load, d);
return 0;
}
@@ -309,18 +305,32 @@ static void piix3_reset(void *opaque)
memset(d->pci_irq_levels, 0, sizeof(d->pci_irq_levels));
}
-static void piix_save(QEMUFile* f, void *opaque)
+static void piix3_save(QEMUFile* f, void *opaque)
{
- PCIDevice *d = opaque;
- pci_device_save(d, f);
+ PIIX3State *d = opaque;
+ int i;
+
+ pci_device_save(&d->dev, f);
+
+ for (i = 0; i < 4; i++)
+ qemu_put_be32(f, d->pci_irq_levels[i]);
}
-static int piix_load(QEMUFile* f, void *opaque, int version_id)
+static int piix3_load(QEMUFile* f, void *opaque, int version_id)
{
- PCIDevice *d = opaque;
- if (version_id != 2)
+ PIIX3State *d = opaque;
+ int i, ret;
+
+ if (version_id > 3 || version_id < 2)
return -EINVAL;
- return pci_device_load(d, f);
+ ret = pci_device_load(&d->dev, f);
+ if (ret < 0)
+ return ret;
+ if (version_id >= 3) {
+ for (i = 0; i < 4; i++)
+ d->pci_irq_levels[i] = qemu_get_be32(f);
+ }
+ return 0;
}
static int piix3_initfn(PCIDevice *dev)
@@ -329,7 +339,7 @@ static int piix3_initfn(PCIDevice *dev)
uint8_t *pci_conf;
isa_bus_new(&d->dev.qdev);
- register_savevm("PIIX3", 0, 2, piix_save, piix_load, d);
+ register_savevm("PIIX3", 0, 3, piix3_save, piix3_load, d);
pci_conf = d->dev.config;
pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);