qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] vhost-user-blk: start vhost when guest kicks


From: Yongji Xie
Subject: [Qemu-devel] [PATCH] vhost-user-blk: start vhost when guest kicks
Date: Tue, 5 Jun 2018 21:56:10 +0800

Some old guests (before commit 7a11370e5: "virtio_blk: enable VQs early")
kick virtqueue before setting VIRTIO_CONFIG_S_DRIVER_OK. This would cause
that those old guests fail to boot with vhost-user-blk device.

To fix it, start vhost when guest kicks instead of waiting for .set_status().

Signed-off-by: Yongji Xie <address@hidden>
Signed-off-by: Chai Wen <address@hidden>
Signed-off-by: Ni Xun <address@hidden>
---
 hw/block/vhost-user-blk.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index d755223..8fd0e6f 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -217,7 +217,27 @@ static uint64_t vhost_user_blk_get_features(VirtIODevice 
*vdev,
 
 static void vhost_user_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
+    VHostUserBlk *s = VHOST_USER_BLK(vdev);
+    int i;
 
+    if (s->dev.started) {
+        return;
+    }
+
+    /* Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
+     * vhost here instead of waiting for .set_status().
+     */
+    vhost_user_blk_start(vdev);
+
+    /* Kick right away to begin processing requests already in vring */
+    for (i = 0; i < s->dev.nvqs; i++) {
+        VirtQueue *kick_vq = virtio_get_queue(vdev, i);
+
+        if (!virtio_queue_get_desc_addr(vdev, i)) {
+            continue;
+        }
+        event_notifier_set(virtio_queue_get_host_notifier(kick_vq));
+    }
 }
 
 static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
-- 
1.7.9.5




reply via email to

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