]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
vhost: mask VIRTIO_F_RING_RESET for vhost and vhost-user devices
authorStefano Garzarella <sgarzare@redhat.com>
Mon, 21 Nov 2022 10:11:01 +0000 (11:11 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 22 Nov 2022 10:19:00 +0000 (05:19 -0500)
Commit 69e1c14aa2 ("virtio: core: vq reset feature negotation support")
enabled VIRTIO_F_RING_RESET by default for all virtio devices.

This feature is not currently emulated by QEMU, so for vhost and
vhost-user devices we need to make sure it is supported by the offloaded
device emulation (in-kernel or in another process).
To do this we need to add VIRTIO_F_RING_RESET to the features bitmap
passed to vhost_get_features(). This way it will be masked if the device
does not support it.

This issue was initially discovered with vhost-vsock and vhost-user-vsock,
and then also tested with vhost-user-rng which confirmed the same issue.
They fail when sending features through VHOST_SET_FEATURES ioctl or
VHOST_USER_SET_FEATURES message, since VIRTIO_F_RING_RESET is negotiated
by the guest (Linux >= v6.0), but not supported by the device.

Fixes: 69e1c14aa2 ("virtio: core: vq reset feature negotation support")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1318
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20221121101101.29400-1-sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Acked-by: Jason Wang <jasowang@redhat.com>
hw/block/vhost-user-blk.c
hw/net/vhost_net.c
hw/scsi/vhost-scsi.c
hw/scsi/vhost-user-scsi.c
hw/virtio/vhost-user-fs.c
hw/virtio/vhost-user-gpio.c
hw/virtio/vhost-user-i2c.c
hw/virtio/vhost-user-rng.c
hw/virtio/vhost-vsock-common.c
net/vhost-vdpa.c

index 16ad4008893a9fee642d00ec10c40a3c63320119..0d5190accf39b8fa40b7611ca93f24740465dcac 100644 (file)
@@ -52,6 +52,7 @@ static const int user_feature_bits[] = {
     VIRTIO_F_NOTIFY_ON_EMPTY,
     VIRTIO_F_RING_PACKED,
     VIRTIO_F_IOMMU_PLATFORM,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index feda448878695a082d561c044493273ef0f32523..26e493067696fa640060e3d0626ac2a3af6ee30f 100644 (file)
@@ -75,6 +75,7 @@ static const int user_feature_bits[] = {
     VIRTIO_NET_F_MTU,
     VIRTIO_F_IOMMU_PLATFORM,
     VIRTIO_F_RING_PACKED,
+    VIRTIO_F_RING_RESET,
     VIRTIO_NET_F_RSS,
     VIRTIO_NET_F_HASH_REPORT,
 
index bdf337a7a28ee192840088be4865ff063d5f5113..6a0fd0dfb13d60eaa0a27b1168e3b86636831829 100644 (file)
@@ -38,6 +38,7 @@ static const int kernel_feature_bits[] = {
     VIRTIO_RING_F_INDIRECT_DESC,
     VIRTIO_RING_F_EVENT_IDX,
     VIRTIO_SCSI_F_HOTPLUG,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index bc37317d5599e5acb2375abeecd0b10d34330fdb..b7a71a802cdbf7430704f83fc8c6c04c135644b7 100644 (file)
@@ -36,6 +36,7 @@ static const int user_feature_bits[] = {
     VIRTIO_RING_F_INDIRECT_DESC,
     VIRTIO_RING_F_EVENT_IDX,
     VIRTIO_SCSI_F_HOTPLUG,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index 1c40f420457525b8ffe0aa61193f2b71ccfb2c5f..dc4014cdef5dfc8c295c0f52747bb3f3a300752d 100644 (file)
@@ -32,6 +32,7 @@ static const int user_feature_bits[] = {
     VIRTIO_F_NOTIFY_ON_EMPTY,
     VIRTIO_F_RING_PACKED,
     VIRTIO_F_IOMMU_PLATFORM,
+    VIRTIO_F_RING_RESET,
 
     VHOST_INVALID_FEATURE_BIT
 };
index 677d1c77302e8d9d86d23c1e721fa07292801b47..5851cb3bc9916ed13f184a2da1a1855d14d687c7 100644 (file)
@@ -24,6 +24,7 @@ static const int feature_bits[] = {
     VIRTIO_RING_F_INDIRECT_DESC,
     VIRTIO_RING_F_EVENT_IDX,
     VIRTIO_GPIO_F_IRQ,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index 864eba695eb6125c86a168c5f8ab8b365ad2784d..1c9f3d20dce109c7fe4e641d9b6c41c926a6a3ec 100644 (file)
@@ -16,6 +16,7 @@
 
 static const int feature_bits[] = {
     VIRTIO_I2C_F_ZERO_LENGTH_REQUEST,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index 8b47287875606b5ed9e46739e88a5ef6be5267dd..f9084cde58a0395c996a521d8647d2403cfcd523 100644 (file)
 #include "qemu/error-report.h"
 #include "standard-headers/linux/virtio_ids.h"
 
+static const int feature_bits[] = {
+    VIRTIO_F_RING_RESET,
+    VHOST_INVALID_FEATURE_BIT
+};
+
 static void vu_rng_start(VirtIODevice *vdev)
 {
     VHostUserRNG *rng = VHOST_USER_RNG(vdev);
@@ -106,8 +111,10 @@ static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status)
 static uint64_t vu_rng_get_features(VirtIODevice *vdev,
                                     uint64_t requested_features, Error **errp)
 {
-    /* No feature bits used yet */
-    return requested_features;
+    VHostUserRNG *rng = VHOST_USER_RNG(vdev);
+
+    return vhost_get_features(&rng->vhost_dev, feature_bits,
+                              requested_features);
 }
 
 static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq)
index 29b9ab4f7292f2849b84558720f306e3d7bc2c11..a67a275de2d4eed7f940e476af846f394ffa1ac7 100644 (file)
@@ -21,6 +21,7 @@
 
 const int feature_bits[] = {
     VIRTIO_VSOCK_F_SEQPACKET,
+    VIRTIO_F_RING_RESET,
     VHOST_INVALID_FEATURE_BIT
 };
 
index 68110892313a54722e8fc23e7df5e95c2267514c..2b4b85d8f84fe0374423f0ff9535f28b81997e32 100644 (file)
@@ -69,6 +69,7 @@ const int vdpa_feature_bits[] = {
     VIRTIO_NET_F_CTRL_VQ,
     VIRTIO_F_IOMMU_PLATFORM,
     VIRTIO_F_RING_PACKED,
+    VIRTIO_F_RING_RESET,
     VIRTIO_NET_F_RSS,
     VIRTIO_NET_F_HASH_REPORT,
     VIRTIO_NET_F_GUEST_ANNOUNCE,