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

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