在 2022/8/23 16:03, Kangjie Xu 写道:

在 2022/8/23 15:52, Jason Wang 写道:

在 2022/8/16 09:06, Kangjie Xu 写道:
Introduce vhost_dev_virtqueue_stop(), which can ummap the
vrings and the desc of it.

Signed-off-by: Kangjie Xu <kangjie...@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanz...@linux.alibaba.com>
---
  hw/virtio/vhost.c         | 9 +++++++++
  include/hw/virtio/vhost.h | 3 +++
  2 files changed, 12 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index e467dfc7bc..1bca9ff48d 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1904,3 +1904,12 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
        return -ENOSYS;
  }
+
+void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
+                              int idx)
+{
+    vhost_virtqueue_unmap(hdev,
+                          vdev,
+                          hdev->vqs + idx,
+                          idx);


So I think the unmap is not sufficient, we need backend specific support. E.g for vhost kernel, need a SET_BACKEND here?

Thanks

But SET_BACKEND of vhost-net needs a parameter fd in vhost_vring_file: that is net->backend of VHostNetState.

If we add the fd parameter or struct vhost_vring_file to vhost_dev_virtqueue_stop/restart, it exposes some implementation details in the parameter list.

And that seems not good? So I put SET_BACKEND in the vhost-net module. The workflow is similar to vhost_net_start_one().


That looks fine.

Thanks



Thanks


+}
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index a346f23d13..574888440c 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -288,4 +288,7 @@ int vhost_dev_set_inflight(struct vhost_dev *dev,
                             struct vhost_inflight *inflight);
  int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,
                             struct vhost_inflight *inflight);
+
+void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
+                              int idx);
  #endif



Reply via email to