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

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