From ab281c1781add112a257c15924d670616a99c41a Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 31 Jan 2016 11:28:59 +0100 Subject: 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 Signed-off-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/char/virtio-serial-bus.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'hw/char') diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index cf3d12b9d5..99cb6836ad 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -646,9 +646,7 @@ static void virtio_serial_save_device(VirtIODevice *vdev, QEMUFile *f) if (elem_popped) { qemu_put_be32s(f, &port->iov_idx); qemu_put_be64s(f, &port->iov_offset); - - qemu_put_buffer(f, (unsigned char *)port->elem, - sizeof(VirtQueueElement)); + qemu_put_virtqueue_element(f, port->elem); } } } @@ -723,10 +721,8 @@ static int fetch_active_ports_list(QEMUFile *f, int version_id, qemu_get_be32s(f, &port->iov_idx); qemu_get_be64s(f, &port->iov_offset); - port->elem = g_new(VirtQueueElement, 1); - qemu_get_buffer(f, (unsigned char *)port->elem, - sizeof(VirtQueueElement)); - virtqueue_map(port->elem); + port->elem = + qemu_get_virtqueue_element(f, sizeof(VirtQueueElement)); /* * Port was throttled on source machine. Let's -- cgit v1.2.3