diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-31 11:28:59 +0100 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2016-02-06 20:44:08 +0200 |
commit | ab281c1781add112a257c15924d670616a99c41a (patch) | |
tree | 4b24857c83b3c5494cecf1836c874ea385c79d04 /hw/block | |
parent | 51b19ebe4320f3dcd93cea71235c1219318ddfd2 (diff) |
virtio: introduce qemu_get/put_virtqueue_element
Move allocation to virtio functions also when loading/saving a
VirtQueueElement. This will also let the load/save functions
keep backwards compatibility when the VirtQueueElement layout
is changed.
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/block')
-rw-r--r-- | hw/block/virtio-blk.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index bf70b52dfd..c427698fcb 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -808,8 +808,7 @@ static void virtio_blk_save_device(VirtIODevice *vdev, QEMUFile *f) while (req) { qemu_put_sbyte(f, 1); - qemu_put_buffer(f, (unsigned char *)&req->elem, - sizeof(VirtQueueElement)); + qemu_put_virtqueue_element(f, &req->elem); req = req->next; } qemu_put_sbyte(f, 0); @@ -832,14 +831,11 @@ static int virtio_blk_load_device(VirtIODevice *vdev, QEMUFile *f, VirtIOBlock *s = VIRTIO_BLK(vdev); while (qemu_get_sbyte(f)) { - VirtIOBlockReq *req = g_new(VirtIOBlockReq, 1); + VirtIOBlockReq *req; + req = qemu_get_virtqueue_element(f, sizeof(VirtIOBlockReq)); virtio_blk_init_request(s, req); - qemu_get_buffer(f, (unsigned char *)&req->elem, - sizeof(VirtQueueElement)); req->next = s->rq; s->rq = req; - - virtqueue_map(&req->elem); } return 0; |