Patchwork [6/6] ib700: port to vmstate

login
register
mail settings
Submitter Juan Quintela
Date Oct. 14, 2009, 11:40 p.m.
Message ID <a86791dad8f5e00dc6ceac4545ddde489945c29a.1255563370.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36037/
State New
Headers show

Comments

Juan Quintela - Oct. 14, 2009, 11:40 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/wdt_ib700.c |   30 +++++++++++-------------------
 1 files changed, 11 insertions(+), 19 deletions(-)
Richard W.M. Jones - Oct. 15, 2009, 8:43 a.m.
On Thu, Oct 15, 2009 at 01:40:02AM +0200, Juan Quintela wrote:
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

As for patch 1/6, as far as I understand the VMState API, this
looks like a simple, straightforward translation.

ACK.

Rich.

Patch

diff --git a/hw/wdt_ib700.c b/hw/wdt_ib700.c
index d2b9b41..d67bf9e 100644
--- a/hw/wdt_ib700.c
+++ b/hw/wdt_ib700.c
@@ -82,31 +82,23 @@  static void ib700_timer_expired(void *vp)
     qemu_del_timer(s->timer);
 }

-static void ib700_save(QEMUFile *f, void *vp)
-{
-    IB700State *s = vp;
-
-    qemu_put_timer(f, s->timer);
-}
-
-static int ib700_load(QEMUFile *f, void *vp, int version)
-{
-    IB700State *s = vp;
-
-    if (version != 0)
-        return -EINVAL;
-
-    qemu_get_timer(f, s->timer);
-
-    return 0;
-}
+static const VMStateDescription vmstate_ib700 = {
+    .name = "ib700_wdt",
+    .version_id = 0,
+    .minimum_version_id = 0,
+    .minimum_version_id_old = 0,
+    .fields      = (VMStateField []) {
+        VMSTATE_TIMER(timer, IB700State),
+        VMSTATE_END_OF_LIST()
+    }
+};

 static int wdt_ib700_init(ISADevice *dev)
 {
     IB700State *s = DO_UPCAST(IB700State, dev, dev);

     s->timer = qemu_new_timer(vm_clock, ib700_timer_expired, s);
-    register_savevm("ib700_wdt", -1, 0, ib700_save, ib700_load, s);
+    vmstate_register(-1, &vmstate_ib700, s);
     register_ioport_write(0x441, 2, 1, ib700_write_disable_reg, s);
     register_ioport_write(0x443, 2, 1, ib700_write_enable_reg, s);