在 2022/8/24 10:37, Jason Wang 写道:
在 2022/8/16 09:06, Kangjie Xu 写道:
Introduce vhost_dev_virtqueue_restart(), which can restart the
virtqueue when the vhost has already started running.
Signed-off-by: Kangjie Xu <kangjie...@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanz...@linux.alibaba.com>
---
hw/virtio/vhost.c | 13 +++++++++++++
include/hw/virtio/vhost.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1bca9ff48d..fc3f550c76 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1913,3 +1913,16 @@ void vhost_dev_virtqueue_stop(struct vhost_dev
*hdev, VirtIODevice *vdev,
hdev->vqs + idx,
idx);
}
+
+int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice
*vdev,
+ int idx)
+{
+ const VhostOps *vhost_ops = hdev->vhost_ops;
+
+ assert(vhost_ops);
So we had the comment like:
/* should only be called after backend is connected */
in vhost_virtqueue_mask().
If this assert has the same reason, let's add a comment here.
Get it.
+
+ return vhost_virtqueue_start(hdev,
+ vdev,
+ hdev->vqs + idx,
+ hdev->vq_index + idx);
So it just a wrapper of vhost_virtqueue_start(), any value to have a
re-start wrapper?
Thanks
Because in subsequent patches, to support vhost-user, we will add
vhost_ops->vhost_set_single_vring_enable() in this function.
Thanks.
+}
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 574888440c..b3394b6348 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -291,4 +291,6 @@ int vhost_dev_get_inflight(struct vhost_dev *dev,
uint16_t queue_size,
void vhost_dev_virtqueue_stop(struct vhost_dev *hdev,
VirtIODevice *vdev,
int idx);
+int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice
*vdev,
+ int idx);
#endif