[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 35/41] virtio-balloon: port to vmstate
From: |
Juan Quintela |
Subject: |
[Qemu-devel] [PATCH 35/41] virtio-balloon: port to vmstate |
Date: |
Wed, 2 Dec 2009 13:04:33 +0100 |
Signed-off-by: Juan Quintela <address@hidden>
---
hw/virtio-balloon.c | 38 +++++++++++++-------------------------
1 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 6f60fb1..f461c32 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -139,30 +139,18 @@ static ram_addr_t virtio_balloon_to_target(void *opaque,
ram_addr_t target)
return ram_size - (dev->actual << VIRTIO_BALLOON_PFN_SHIFT);
}
-static void virtio_balloon_save(QEMUFile *f, void *opaque)
-{
- VirtIOBalloon *s = opaque;
-
- virtio_save(&s->vdev, f);
-
- qemu_put_be32(f, s->num_pages);
- qemu_put_be32(f, s->actual);
-}
-
-static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
-{
- VirtIOBalloon *s = opaque;
-
- if (version_id != 1)
- return -EINVAL;
-
- virtio_load(&s->vdev, f);
-
- s->num_pages = qemu_get_be32(f);
- s->actual = qemu_get_be32(f);
-
- return 0;
-}
+static const VMStateDescription vmstate_virtio_balloon = {
+ .name = "virtio-balloon",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .minimum_version_id_old = 1,
+ .fields = (VMStateField []) {
+ VMSTATE_VIRTIO(vdev, VirtIOBalloon),
+ VMSTATE_UINT32(num_pages, VirtIOBalloon),
+ VMSTATE_UINT32(actual, VirtIOBalloon),
+ VMSTATE_END_OF_LIST()
+ }
+};
VirtIODevice *virtio_balloon_init(DeviceState *dev)
{
@@ -181,7 +169,7 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev)
qemu_add_balloon_handler(virtio_balloon_to_target, s);
- register_savevm("virtio-balloon", -1, 1, virtio_balloon_save,
virtio_balloon_load, s);
+ vmstate_register(-1, &vmstate_virtio_balloon, s);
return &s->vdev;
}
--
1.6.5.2
[Qemu-devel] [PATCH 34/41] virtio-console: port to vmstate, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 35/41] virtio-balloon: port to vmstate,
Juan Quintela <=
[Qemu-devel] [PATCH 36/41] virtio-blk: change rq type to VirtIOBlockReq, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 37/41] QLIST: Introduce QLIST_COPY_HEAD, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 38/41] virtio-blk: use QLIST for the list of requests, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 39/41] virtio-blk: add VirtIOBlokReqHead type, Juan Quintela, 2009/12/02
[Qemu-devel] [PATCH 40/41] virtio-blk: port to vmstate, Juan Quintela, 2009/12/02