[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/16] vhost: introduce restart and release for vhost_dev's vqs
|
From: |
Kangjie Xu |
|
Subject: |
[PATCH 11/16] vhost: introduce restart and release for vhost_dev's vqs |
|
Date: |
Mon, 18 Jul 2022 19:17:08 +0800 |
Introduce vhost_dev_virtqueue_restart(), which can restart the
virtqueue when the vhost has already started running.
Meanwhile, vhost_dev_virtqueue_release(), which can ummap the
vrings and the desc of a specific vq of a device.
Combining the two functions, we can reset a virtqueue with a
started vhost.
Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
hw/virtio/vhost.c | 29 +++++++++++++++++++++++++++++
include/hw/virtio/vhost.h | 6 ++++++
2 files changed, 35 insertions(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e467dfc7bc..d158d71866 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1904,3 +1904,32 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
return -ENOSYS;
}
+
+void vhost_dev_virtqueue_release(struct vhost_dev *hdev, VirtIODevice *vdev,
+ int vq_index)
+{
+ int idx = vq_index - hdev->vq_index;
+
+ idx = hdev->vhost_ops->vhost_get_vq_index(hdev, idx);
+
+ vhost_virtqueue_unmap(hdev,
+ vdev,
+ hdev->vqs + idx,
+ hdev->vq_index + idx);
+}
+
+int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev,
+ int vq_index)
+{
+ int idx = vq_index - hdev->vq_index;
+ int r = 0;
+
+ idx = hdev->vhost_ops->vhost_get_vq_index(hdev, idx);
+
+ r = vhost_virtqueue_start(hdev,
+ vdev,
+ hdev->vqs + idx,
+ hdev->vq_index + idx);
+
+ return r;
+}
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index a346f23d13..7df7dbe24d 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -277,6 +277,12 @@ bool vhost_has_free_slot(void);
int vhost_net_set_backend(struct vhost_dev *hdev,
struct vhost_vring_file *file);
+
+void vhost_dev_virtqueue_release(struct vhost_dev *hdev, VirtIODevice *vdev,
+ int vq_index);
+int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev,
+ int vq_index);
+
int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write);
void vhost_dev_reset_inflight(struct vhost_inflight *inflight);
--
2.32.0
- [PATCH 16/16] vhost-net: vq reset feature bit support, (continued)
[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
[PATCH 11/16] vhost: introduce restart and release for vhost_dev's vqs,
Kangjie Xu <=
[PATCH 13/16] virtio: introduce queue_enable in virtio, Kangjie Xu, 2022/07/18
[PATCH 08/16] vhost: add op to enable or disable a single vring, Kangjie Xu, 2022/07/18