virtio: slim down allocation of VirtQueueElements
commit3b3b0628217e2726069990ff9942a5d6d9816bd7
authorPaolo Bonzini <pbonzini@redhat.com>
Sun, 31 Jan 2016 10:29:01 +0000 (31 11:29 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sat, 6 Feb 2016 18:44:08 +0000 (6 20:44 +0200)
tree0e6f5e0f5d38ceb536ccd51bb6092c6d8c1e94a7
parent3724650db07057333879484c8bc7d900b5c1bf8e
virtio: slim down allocation of VirtQueueElements

Build the addresses and s/g lists on the stack, and then copy them
to a VirtQueueElement that is just as big as required to contain this
particular s/g list.  The cost of the copy is minimal compared to that
of a large malloc.

When virtqueue_map is used on the destination side of migration or on
loadvm, the iovecs have already been split at memory region boundary,
so we can just reuse the out_num/in_num we find in the file.

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>
hw/virtio/virtio.c