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/virtio | |
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/virtio')
-rw-r--r-- | hw/virtio/virtio.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 229a092c83..28fa7fe760 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -576,6 +576,19 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz) return elem; } +void *qemu_get_virtqueue_element(QEMUFile *f, size_t sz) +{ + VirtQueueElement *elem = g_malloc(sz); + qemu_get_buffer(f, (uint8_t *)elem, sizeof(VirtQueueElement)); + virtqueue_map(elem); + return elem; +} + +void qemu_put_virtqueue_element(QEMUFile *f, VirtQueueElement *elem) +{ + qemu_put_buffer(f, (uint8_t *)elem, sizeof(VirtQueueElement)); +} + /* virtio device */ static void virtio_notify_vector(VirtIODevice *vdev, uint16_t vector) { |