Blame SOURCES/kvm-virtio-net-setup-vhost_dev-and-notifiers-for-cvq-onl.patch

29b115
From 9e737aba614e94da4458f02d4ff97e95ffffd19f Mon Sep 17 00:00:00 2001
29b115
From: Si-Wei Liu <si-wei.liu@oracle.com>
29b115
Date: Fri, 6 May 2022 19:28:12 -0700
29b115
Subject: [PATCH 08/16] virtio-net: setup vhost_dev and notifiers for cvq only
29b115
 when feature is negotiated
29b115
MIME-Version: 1.0
29b115
Content-Type: text/plain; charset=UTF-8
29b115
Content-Transfer-Encoding: 8bit
29b115
29b115
RH-Author: Jason Wang <jasowang@redhat.com>
29b115
RH-MergeRequest: 98: Multiqueue fixes for vhost-vDPA
29b115
RH-Commit: [1/7] a5c5a2862b2e4d15ef7c09da3e4234fdef37cc66 (jasowang/qemu-kvm-cs)
29b115
RH-Bugzilla: 2070804
29b115
RH-Acked-by: Eugenio PĂ©rez <eperezma@redhat.com>
29b115
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
29b115
RH-Acked-by: Cindy Lu <lulu@redhat.com>
29b115
29b115
When the control virtqueue feature is absent or not negotiated,
29b115
vhost_net_start() still tries to set up vhost_dev and install
29b115
vhost notifiers for the control virtqueue, which results in
29b115
erroneous ioctl calls with incorrect queue index sending down
29b115
to driver. Do that only when needed.
29b115
29b115
Fixes: 22288fe ("virtio-net: vhost control virtqueue support")
29b115
Signed-off-by: Si-Wei Liu <si-wei.liu@oracle.com>
29b115
Acked-by: Jason Wang <jasowang@redhat.com>
29b115
Message-Id: <1651890498-24478-2-git-send-email-si-wei.liu@oracle.com>
29b115
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
29b115
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
29b115
(cherry picked from commit aa8581945a13712ff3eed0ad3ba7a9664fc1604b)
29b115
Signed-off-by: Jason Wang <jasowang@redhat.com>
29b115
---
29b115
 hw/net/virtio-net.c | 3 ++-
29b115
 1 file changed, 2 insertions(+), 1 deletion(-)
29b115
29b115
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
29b115
index 1067e72b39..ffb3475201 100644
29b115
--- a/hw/net/virtio-net.c
29b115
+++ b/hw/net/virtio-net.c
29b115
@@ -245,7 +245,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
29b115
     VirtIODevice *vdev = VIRTIO_DEVICE(n);
29b115
     NetClientState *nc = qemu_get_queue(n->nic);
29b115
     int queue_pairs = n->multiqueue ? n->max_queue_pairs : 1;
29b115
-    int cvq = n->max_ncs - n->max_queue_pairs;
29b115
+    int cvq = virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ) ?
29b115
+              n->max_ncs - n->max_queue_pairs : 0;
29b115
 
29b115
     if (!get_vhost_net(nc->peer)) {
29b115
         return;
29b115
-- 
29b115
2.31.1
29b115