From 3724650db07057333879484c8bc7d900b5c1bf8e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 31 Jan 2016 11:29:00 +0100 Subject: virtio: introduce virtqueue_alloc_element Allocate the arrays for in_addr/out_addr/in_sg/out_sg outside the VirtQueueElement. For now, virtqueue_pop and vring_pop keep allocating a very large VirtQueueElement. Reviewed-by: Cornelia Huck Signed-off-by: Paolo Bonzini Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/dataplane/vring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'hw/virtio/dataplane/vring.c') diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 4fb84bb00a..57ada3bcbe 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -403,8 +403,7 @@ void *vring_pop(VirtIODevice *vdev, Vring *vring, size_t sz) goto out; } - assert(sz >= sizeof(VirtQueueElement)); - elem = g_malloc(sz); + elem = virtqueue_alloc_element(sz, VIRTQUEUE_MAX_SIZE, VIRTQUEUE_MAX_SIZE); /* Initialize elem so it can be safely unmapped */ elem->in_num = elem->out_num = 0; -- cgit v1.2.3