Introduce vhost_virtqueue_unmap() to ummap the vrings and desc of a virtqueue.
The function will be used later. Signed-off-by: Kangjie Xu <kangjie...@linux.alibaba.com> Signed-off-by: Xuan Zhuo <xuanz...@linux.alibaba.com> --- hw/virtio/vhost.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..e467dfc7bc 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1197,6 +1197,19 @@ fail_alloc_desc: return r; } +static void vhost_virtqueue_unmap(struct vhost_dev *dev, + struct VirtIODevice *vdev, + struct vhost_virtqueue *vq, + unsigned idx) +{ + vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx), + 1, virtio_queue_get_used_size(vdev, idx)); + vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx), + 0, virtio_queue_get_avail_size(vdev, idx)); + vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx), + 0, virtio_queue_get_desc_size(vdev, idx)); +} + static void vhost_virtqueue_stop(struct vhost_dev *dev, struct VirtIODevice *vdev, struct vhost_virtqueue *vq, @@ -1235,12 +1248,7 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev, vhost_vq_index); } - vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx), - 1, virtio_queue_get_used_size(vdev, idx)); - vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx), - 0, virtio_queue_get_avail_size(vdev, idx)); - vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx), - 0, virtio_queue_get_desc_size(vdev, idx)); + vhost_virtqueue_unmap(dev, vdev, vq, idx); } static void vhost_eventfd_add(MemoryListener *listener, -- 2.32.0