qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFT 4/4] vhost_net: don't start vhost for the virtqueue th


From: Jason Wang
Subject: [Qemu-devel] [RFT 4/4] vhost_net: don't start vhost for the virtqueue that is not enabled
Date: Fri, 22 Mar 2019 17:28:06 +0800

According to the spec, device should not use the virtqueues that is
not enabled. So this patch just try to obey the spec by checking
whether queue is enabled before starting it.

Signed-off-by: Jason Wang <address@hidden>
---
 hw/virtio/vhost.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 7f61018f2a..b61d659a35 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1580,6 +1580,9 @@ int vhost_dev_get_inflight(struct vhost_dev *dev, 
uint16_t queue_size,
 /* Host notifiers must be enabled at this point. */
 int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev)
 {
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusState *vbus = VIRTIO_BUS(qbus);
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
     int i, r;
 
     /* should only be called after backend is connected */
@@ -1604,6 +1607,10 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice 
*vdev)
         goto fail_mem;
     }
     for (i = 0; i < hdev->nvqs; ++i) {
+        if (k->queue_enabled &&
+            !k->queue_enabled(qbus->parent, hdev->vq_index + i)) {
+            continue;
+        }
         r = vhost_virtqueue_start(hdev,
                                   vdev,
                                   hdev->vqs + i,
@@ -1645,6 +1652,10 @@ fail_log:
     vhost_log_put(hdev, false);
 fail_vq:
     while (--i >= 0) {
+        if (k->queue_enabled &&
+            !k->queue_enabled(qbus->parent, hdev->vq_index + i)) {
+            continue;
+        }
         vhost_virtqueue_stop(hdev,
                              vdev,
                              hdev->vqs + i,
-- 
2.19.1




reply via email to

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