qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, mst@redhat.com, amit.shah@redhat.com,
	quintela@redhat.com
Cc: cornelia.huck@del.ibm.com, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH v2 05/13] virtio-blk: Wrap in vmstate
Date: Tue, 12 Jul 2016 13:19:17 +0100	[thread overview]
Message-ID: <1468325965-22818-6-git-send-email-dgilbert@redhat.com> (raw)
In-Reply-To: <1468325965-22818-1-git-send-email-dgilbert@redhat.com>

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Forcibly convert it to a vmstate wrapper;  proper conversion
comes later.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/block/virtio-blk.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ae86e94..a616b43 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -798,7 +798,7 @@ static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
     }
 }
 
-static void virtio_blk_save(QEMUFile *f, void *opaque)
+static void virtio_blk_save(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(opaque);
 
@@ -823,15 +823,12 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f)
     qemu_put_sbyte(f, 0);
 }
 
-static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
+static int virtio_blk_load(QEMUFile *f, void *opaque, size_t size)
 {
     VirtIOBlock *s = opaque;
     VirtIODevice *vdev = VIRTIO_DEVICE(s);
 
-    if (version_id != 2)
-        return -EINVAL;
-
-    return virtio_load(vdev, f, version_id);
+    return virtio_load(vdev, f, 2);
 }
 
 static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -880,7 +877,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     VirtIOBlock *s = VIRTIO_BLK(dev);
     VirtIOBlkConf *conf = &s->conf;
     Error *err = NULL;
-    static int virtio_blk_id;
     unsigned i;
 
     if (!conf->conf.blk) {
@@ -923,8 +919,6 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
     }
 
     s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s);
-    register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
-                    virtio_blk_save, virtio_blk_load, s);
     blk_set_dev_ops(s->blk, &virtio_block_ops, s);
     blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size);
 
@@ -939,7 +933,6 @@ static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
     virtio_blk_data_plane_destroy(s->dataplane);
     s->dataplane = NULL;
     qemu_del_vm_change_state_handler(s->change);
-    unregister_savevm(dev, "virtio-blk", s);
     blockdev_mark_auto_del(s->blk);
     virtio_cleanup(vdev);
 }
@@ -957,6 +950,8 @@ static void virtio_blk_instance_init(Object *obj)
                                   DEVICE(obj), NULL);
 }
 
+VMSTATE_VIRTIO_DEVICE(blk, 2, virtio_blk_load, virtio_blk_save);
+
 static Property virtio_blk_properties[] = {
     DEFINE_BLOCK_PROPERTIES(VirtIOBlock, conf.conf),
     DEFINE_BLOCK_CHS_PROPERTIES(VirtIOBlock, conf.conf),
@@ -977,6 +972,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     dc->props = virtio_blk_properties;
+    dc->vmsd = &vmstate_virtio_blk;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     vdc->realize = virtio_blk_device_realize;
     vdc->unrealize = virtio_blk_device_unrealize;
-- 
2.7.4

  parent reply	other threads:[~2016-07-12 12:19 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-12 12:19 [Qemu-devel] [PATCH v2 00/13] virtio migration: Flip outer layer to vmstate Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 01/13] virtio-net: Remove old migration version support Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 02/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 03/13] virtio: Migration helper function and macro Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 04/13] virtio-scsi: Wrap in vmstate Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` Dr. David Alan Gilbert (git) [this message]
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 06/13] virtio-rng: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 07/13] virtio-balloon: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 08/13] virtio-net: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 09/13] virtio-serial: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 10/13] 9pfs: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 11/13] virtio-input: " Dr. David Alan Gilbert (git)
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 12/13] virtio-gpu: " Dr. David Alan Gilbert (git)
2016-07-12 13:54   ` Gerd Hoffmann
2016-07-12 14:02     ` Cornelia Huck
2016-07-12 15:09       ` Gerd Hoffmann
2016-07-12 15:12         ` Dr. David Alan Gilbert
2016-07-14 16:04         ` Dr. David Alan Gilbert
2016-07-15  9:53           ` Gerd Hoffmann
2016-07-12 12:19 ` [Qemu-devel] [PATCH v2 13/13] virtio: Update migration docs Dr. David Alan Gilbert (git)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468325965-22818-6-git-send-email-dgilbert@redhat.com \
    --to=dgilbert@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=cornelia.huck@del.ibm.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).