[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/16] vhost: extract the logic of unmapping the vrings and desc
From: |
Kangjie Xu |
Subject: |
[PATCH 10/16] vhost: extract the logic of unmapping the vrings and desc |
Date: |
Mon, 18 Jul 2022 19:17:07 +0800 |
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.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@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
- [PATCH 00/16] Support VIRTIO_F_RING_RESET for virtio-net and vhost-user in virtio pci, Kangjie Xu, 2022/07/18
- [PATCH 07/16] virtio-net: support queue reset, Kangjie Xu, 2022/07/18
- Re: [PATCH 07/16] virtio-net: support queue reset, Jason Wang, 2022/07/25
- Re: [PATCH 07/16] virtio-net: support queue reset, Kangjie Xu, 2022/07/26
- Re: [PATCH 07/16] virtio-net: support queue reset, Jason Wang, 2022/07/27
- Re: [PATCH 07/16] virtio-net: support queue reset, Kangjie Xu, 2022/07/27
- Re: [PATCH 07/16] virtio-net: support queue reset, Jason Wang, 2022/07/27
- Re: [PATCH 07/16] virtio-net: support queue reset, Kangjie Xu, 2022/07/27
[PATCH 10/16] vhost: extract the logic of unmapping the vrings and desc,
Kangjie Xu <=
[PATCH 16/16] vhost-net: vq reset feature bit support, Kangjie Xu, 2022/07/18
[PATCH 01/16] virtio-pci: virtio_pci_common_cfg add queue_notify_data, Kangjie Xu, 2022/07/18
[PATCH 05/16] virtio: introduce virtio_queue_reset(), Kangjie Xu, 2022/07/18