diff mbox

[kvm-unit-tests,v2,1/8] virtio-mmio: fix queue allocation

Message ID 20180207193408.21332-1-drjones@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andrew Jones Feb. 7, 2018, 7:34 p.m. UTC
Ensure we clear the queue memory we get from alloc_pages().
Otherwise QEMU gets angry when we attempt to migrate a unit
test as the used vring index is corrupted by the page
allocator's next page link.

Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 lib/virtio-mmio.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/lib/virtio-mmio.c b/lib/virtio-mmio.c
index e5e8f660b5cd..57fe78ecbb6c 100644
--- a/lib/virtio-mmio.c
+++ b/lib/virtio-mmio.c
@@ -56,6 +56,7 @@  static struct virtqueue *vm_setup_vq(struct virtio_device *vdev,
 	vq = calloc(1, sizeof(*vq));
 	assert(VIRTIO_MMIO_QUEUE_SIZE_MIN <= 2*PAGE_SIZE);
 	queue = alloc_pages(1);
+	memset(queue, 0, 2*PAGE_SIZE);
 	assert(vq && queue);
 
 	writel(index, vm_dev->base + VIRTIO_MMIO_QUEUE_SEL);