qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 16/24] vhost: vhost-user: update vhost_dev_virtqueue_stop()


From: Kangjie Xu
Subject: [PATCH v2 16/24] vhost: vhost-user: update vhost_dev_virtqueue_stop()
Date: Tue, 16 Aug 2022 09:06:28 +0800

Update vhost_dev_virtqueue_stop() for vhost-user scenario.

Signed-off-by: Kangjie Xu <kangjie.xu@linux.alibaba.com>
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
 hw/virtio/vhost.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index fc3f550c76..a0d6824353 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1908,10 +1908,29 @@ int vhost_net_set_backend(struct vhost_dev *hdev,
 void vhost_dev_virtqueue_stop(struct vhost_dev *hdev, VirtIODevice *vdev,
                               int idx)
 {
+    const VhostOps *vhost_ops = hdev->vhost_ops;
+    struct vhost_vring_state state;
+    int r;
+
+    assert(vhost_ops);
+
+    if (vhost_ops->vhost_reset_vring) {
+        state.index = hdev->vq_index + idx;
+        r = vhost_ops->vhost_reset_vring(hdev, &state);
+        if (r < 0) {
+            goto err_queue_reset;
+        }
+    }
+
     vhost_virtqueue_unmap(hdev,
                           vdev,
                           hdev->vqs + idx,
                           idx);
+
+    return;
+
+err_queue_reset:
+    error_report("Error when stopping the qeuue.");
 }
 
 int vhost_dev_virtqueue_restart(struct vhost_dev *hdev, VirtIODevice *vdev,
-- 
2.32.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]