Patchwork [06/10] gus: port to vmstate

login
register
mail settings
Submitter Juan Quintela
Date Dec. 2, 2009, 10:49 a.m.
Message ID <7fe5649471ae8b73039795c0e11a3afa0d9be602.1259750689.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/39990/
State New
Headers show

Comments

Juan Quintela - Dec. 2, 2009, 10:49 a.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/gus.c |   47 +++++++++++++++++------------------------------
 1 files changed, 17 insertions(+), 30 deletions(-)

Patch

diff --git a/hw/gus.c b/hw/gus.c
index c6b98b3..d35da0a 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -215,35 +215,22 @@  static int GUS_read_DMA (void *opaque, int nchan, int dma_pos, int dma_len)
     return dma_len;
 }

-static void GUS_save (QEMUFile *f, void *opaque)
-{
-    GUSState *s = opaque;
-
-    qemu_put_be32 (f, s->pos);
-    qemu_put_be32 (f, s->left);
-    qemu_put_be32 (f, s->shift);
-    qemu_put_be32 (f, s->irqs);
-    qemu_put_be32 (f, s->samples);
-    qemu_put_be64 (f, s->last_ticks);
-    qemu_put_buffer (f, s->himem, sizeof (s->himem));
-}
-
-static int GUS_load (QEMUFile *f, void *opaque, int version_id)
-{
-    GUSState *s = opaque;
-
-    if (version_id != 2)
-        return -EINVAL;
-
-    s->pos = qemu_get_be32 (f);
-    s->left = qemu_get_be32 (f);
-    s->shift = qemu_get_be32 (f);
-    s->irqs = qemu_get_be32 (f);
-    s->samples = qemu_get_be32 (f);
-    s->last_ticks = qemu_get_be64 (f);
-    qemu_get_buffer (f, s->himem, sizeof (s->himem));
-    return 0;
-}
+static const VMStateDescription vmstate_gus = {
+    .name = "gus",
+    .version_id = 2,
+    .minimum_version_id = 2,
+    .minimum_version_id_old = 2,
+    .fields      = (VMStateField []) {
+        VMSTATE_INT32(pos, GUSState),
+        VMSTATE_INT32(left, GUSState),
+        VMSTATE_INT32(shift, GUSState),
+        VMSTATE_INT32(irqs, GUSState),
+        VMSTATE_INT32(samples, GUSState),
+        VMSTATE_INT64(last_ticks, GUSState),
+        VMSTATE_BUFFER(himem, GUSState),
+        VMSTATE_END_OF_LIST()
+    }
+};

 static int gus_initfn (ISADevice *dev)
 {
@@ -300,7 +287,7 @@  static int gus_initfn (ISADevice *dev)

     AUD_set_active_out (s->voice, 1);

-    register_savevm ("gus", 0, 2, GUS_save, GUS_load, s);
+    vmstate_register (0, &vmstate_gus, s);
     return 0;
 }