diff mbox

[34/41] virtio-console: port to vmstate

Message ID 6ff4dc9e7d1cefc8dd63f0ca7ab101380c9cfe00.1259754427.git.quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela Dec. 2, 2009, 12:04 p.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-console.c |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)
diff mbox

Patch

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 57f5e9d..1ebb3dd 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -100,23 +100,16 @@  static void vcon_event(void *opaque, int event)
     /* we will ignore any event for the time being */
 }

-static void virtio_console_save(QEMUFile *f, void *opaque)
-{
-    VirtIOConsole *s = opaque;
-
-    virtio_save(&s->vdev, f);
-}
-
-static int virtio_console_load(QEMUFile *f, void *opaque, int version_id)
-{
-    VirtIOConsole *s = opaque;
-
-    if (version_id != 1)
-        return -EINVAL;
-
-    virtio_load(&s->vdev, f);
-    return 0;
-}
+static const VMStateDescription vmstate_virtio_console = {
+    .name = "virtio-console",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField []) {
+        VMSTATE_VIRTIO(vdev, VirtIOConsole),
+        VMSTATE_END_OF_LIST()
+    }
+};

 VirtIODevice *virtio_console_init(DeviceState *dev)
 {
@@ -133,7 +126,7 @@  VirtIODevice *virtio_console_init(DeviceState *dev)
     s->chr = qdev_init_chardev(dev);
     qemu_chr_add_handlers(s->chr, vcon_can_read, vcon_read, vcon_event, s);

-    register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s);
+    vmstate_register(-1, &vmstate_virtio_console, s);

     return &s->vdev;
 }