@@ -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;
}
Signed-off-by: Juan Quintela <quintela@redhat.com> --- hw/virtio-balloon.c | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-)