From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54452) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFR7r-00083V-3d for qemu-devel@nongnu.org; Tue, 21 Jun 2016 15:14:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFR7p-0003CX-VW for qemu-devel@nongnu.org; Tue, 21 Jun 2016 15:14:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44578) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFR7p-0003CN-NO for qemu-devel@nongnu.org; Tue, 21 Jun 2016 15:14:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6898F78226 for ; Tue, 21 Jun 2016 19:14:17 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" Date: Tue, 21 Jun 2016 20:13:59 +0100 Message-Id: <1466536447-30146-6-git-send-email-dgilbert@redhat.com> In-Reply-To: <1466536447-30146-1-git-send-email-dgilbert@redhat.com> References: <1466536447-30146-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH 05/13] virtio-blk: Wrap in vmstate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mst@redhat.com, amit.shah@redhat.com, quintela@redhat.com, kraxel@redhat.com From: "Dr. David Alan Gilbert" Forcibly convert it to a vmstate wrapper; proper conversion comes later. Signed-off-by: Dr. David Alan Gilbert --- 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 284e646..8b93f9f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -792,7 +792,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); VirtIOBlock *s = VIRTIO_BLK(vdev); @@ -817,15 +817,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, @@ -861,7 +858,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; if (!conf->conf.blk) { error_setg(errp, "drive property not set"); @@ -897,8 +893,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); @@ -913,7 +907,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); } @@ -931,6 +924,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), @@ -950,6 +945,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