Patchwork [11/13] ide: port pmac ide to vmstate

login
register
mail settings
Submitter Juan Quintela
Date Oct. 14, 2009, 11:37 a.m.
Message ID <b5688e973b59c1da95d8e8a1fc680a631990f407.1255520033.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/35955/
State New
Headers show

Comments

Juan Quintela - Oct. 14, 2009, 11:37 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/ide/macio.c |   42 +++++++++++-------------------------------
 1 files changed, 11 insertions(+), 31 deletions(-)

Patch

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index a11223e..e02e499 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -291,37 +291,17 @@  static CPUReadMemoryFunc * const pmac_ide_read[] = {
     pmac_ide_readl,
 };

-static void pmac_ide_save(QEMUFile *f, void *opaque)
-{
-    MACIOIDEState *d = opaque;
-    unsigned int i;
-
-    /* per IDE interface data */
-    idebus_save(f, &d->bus);
-
-    /* per IDE drive data */
-    for(i = 0; i < 2; i++) {
-        ide_save(f, &d->bus.ifs[i]);
-    }
-}
-
-static int pmac_ide_load(QEMUFile *f, void *opaque, int version_id)
-{
-    MACIOIDEState *d = opaque;
-    unsigned int i;
-
-    if (version_id != 1 && version_id != 3)
-        return -EINVAL;
-
-    /* per IDE interface data */
-    idebus_load(f, &d->bus, version_id);
-
-    /* per IDE drive data */
-    for(i = 0; i < 2; i++) {
-        ide_load(f, &d->bus.ifs[i], version_id);
+static const VMStateDescription vmstate_pmac = {
+    .name = "ide",
+    .version_id = 3,
+    .minimum_version_id = 0,
+    .minimum_version_id_old = 0,
+    .fields      = (VMStateField []) {
+        VMSTATE_IDE_BUS(bus, MACIOIDEState),
+        VMSTATE_IDE_DRIVES(bus.ifs, MACIOIDEState),
+        VMSTATE_END_OF_LIST()
     }
-    return 0;
-}
+};

 static void pmac_ide_reset(void *opaque)
 {
@@ -348,7 +328,7 @@  int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq,

     pmac_ide_memory = cpu_register_io_memory(pmac_ide_read,
                                              pmac_ide_write, d);
-    register_savevm("ide", 0, 3, pmac_ide_save, pmac_ide_load, d);
+    vmstate_register(0, &vmstate_pmac, d);
     qemu_register_reset(pmac_ide_reset, d);
     pmac_ide_reset(d);