qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH v2 5/5] vhost: send VHOST_USER_SET_VRING_ENABLE at s


From: Yuanhan Liu
Subject: [Qemu-devel] [PATCH v2 5/5] vhost: send VHOST_USER_SET_VRING_ENABLE at start/stop
Date: Wed, 21 Oct 2015 17:07:18 +0800

Send VHOST_USER_SET_VRING_ENABLE at start/stop when multiple queue
is negotiated, to inform the backend that we are ready or not.

And exclude VHOST_USER_GET_QUEUE_NUM as one time request, as we need
to get max_queues for each vhost_dev.

Suggested-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Yuanhan Liu <address@hidden>
---
 hw/virtio/vhost-user.c |  1 -
 hw/virtio/vhost.c      | 18 ++++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 12a9104..6532a73 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -194,7 +194,6 @@ static bool vhost_user_one_time_request(VhostUserRequest 
request)
     case VHOST_USER_SET_OWNER:
     case VHOST_USER_RESET_OWNER:
     case VHOST_USER_SET_MEM_TABLE:
-    case VHOST_USER_GET_QUEUE_NUM:
         return true;
     default:
         return false;
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index c0ed5b2..54a4633 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1146,6 +1146,19 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice 
*vdev)
         }
     }
 
+    /*
+     * Send VHOST_USER_SET_VRING_ENABLE message when multiple queue
+     * is negotiated to inform the back end that we are ready.
+     *
+     * Only set enable to 1 for first queue pair, as we enable one
+     * queue pair by default.
+     */
+    if (hdev->max_queues > 1 &&
+        hdev->vhost_ops->vhost_backend_set_vring_enable) {
+        hdev->vhost_ops->vhost_backend_set_vring_enable(hdev,
+                                                        hdev->vq_index == 0);
+    }
+
     return 0;
 fail_log:
     vhost_log_put(hdev, false);
@@ -1180,5 +1193,10 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice 
*vdev)
     hdev->started = false;
     hdev->log = NULL;
     hdev->log_size = 0;
+
+    if (hdev->max_queues > 1 &&
+        hdev->vhost_ops->vhost_backend_set_vring_enable) {
+        hdev->vhost_ops->vhost_backend_set_vring_enable(hdev, 0);
+    }
 }
 
-- 
1.9.0




reply via email to

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