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

[qemu-xen staging-4.16] vhost-vsock: fix migration issue when seqpacket is supported



commit 246ccfbf44a0ff5967393adb7b7a79dc7c353eb6
Author:     Stefano Garzarella <sgarzare@xxxxxxxxxx>
AuthorDate: Tue Sep 21 18:16:41 2021 +0200
Commit:     Michael Roth <michael.roth@xxxxxxx>
CommitDate: Tue Dec 14 13:04:13 2021 -0600

    vhost-vsock: fix migration issue when seqpacket is supported
    
    Commit 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support")
    enabled the SEQPACKET feature bit.
    This commit is released with QEMU 6.1, so if we try to migrate a VM where
    the host kernel supports SEQPACKET but machine type version is less than
    6.1, we get the following errors:
    
        Features 0x130000002 unsupported. Allowed features: 0x179000000
        Failed to load virtio-vhost_vsock:virtio
        error while loading state for instance 0x0 of device 
'0000:00:05.0/virtio-vhost_vsock'
        load of migration failed: Operation not permitted
    
    Let's disable the feature bit for machine types < 6.1.
    We add a new OnOffAuto property for this, called `seqpacket`.
    When it is `auto` (default), QEMU behaves as before, trying to enable the
    feature, when it is `on` QEMU will fail if the backend (vhost-vsock
    kernel module) doesn't support it.
    
    Fixes: 1e08fd0a46 ("vhost-vsock: SOCK_SEQPACKET feature bit support")
    Cc: qemu-stable@xxxxxxxxxx
    Reported-by: Jiang Wang <jiang.wang@xxxxxxxxxxxxx>
    Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
    Message-Id: <20210921161642.206461-2-sgarzare@xxxxxxxxxx>
    Reviewed-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    (cherry picked from commit d6a9378f47515c6d70dbff4912c5740c98709880)
    Signed-off-by: Michael Roth <michael.roth@xxxxxxx>
---
 hw/core/machine.c               |  1 +
 hw/virtio/vhost-vsock.c         | 19 ++++++++++++++++---
 include/hw/virtio/vhost-vsock.h |  3 +++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 54e040587d..2cf2f321f9 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -43,6 +43,7 @@ GlobalProperty hw_compat_6_0[] = {
     { "nvme-ns", "eui64-default", "off"},
     { "e1000", "init-vet", "off" },
     { "e1000e", "init-vet", "off" },
+    { "vhost-vsock-device", "seqpacket", "off" },
 };
 const size_t hw_compat_6_0_len = G_N_ELEMENTS(hw_compat_6_0);
 
diff --git a/hw/virtio/vhost-vsock.c b/hw/virtio/vhost-vsock.c
index 1b1a5c70ed..dade0da031 100644
--- a/hw/virtio/vhost-vsock.c
+++ b/hw/virtio/vhost-vsock.c
@@ -114,10 +114,21 @@ static uint64_t vhost_vsock_get_features(VirtIODevice 
*vdev,
                                          Error **errp)
 {
     VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev);
+    VHostVSock *vsock = VHOST_VSOCK(vdev);
+
+    if (vsock->seqpacket != ON_OFF_AUTO_OFF) {
+        virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
+    }
+
+    requested_features = vhost_get_features(&vvc->vhost_dev, feature_bits,
+                                            requested_features);
+
+    if (vsock->seqpacket == ON_OFF_AUTO_ON &&
+        !virtio_has_feature(requested_features, VIRTIO_VSOCK_F_SEQPACKET)) {
+        error_setg(errp, "vhost-vsock backend doesn't support seqpacket");
+    }
 
-    virtio_add_feature(&requested_features, VIRTIO_VSOCK_F_SEQPACKET);
-    return vhost_get_features(&vvc->vhost_dev, feature_bits,
-                                requested_features);
+    return requested_features;
 }
 
 static const VMStateDescription vmstate_virtio_vhost_vsock = {
@@ -218,6 +229,8 @@ static void vhost_vsock_device_unrealize(DeviceState *dev)
 static Property vhost_vsock_properties[] = {
     DEFINE_PROP_UINT64("guest-cid", VHostVSock, conf.guest_cid, 0),
     DEFINE_PROP_STRING("vhostfd", VHostVSock, conf.vhostfd),
+    DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSock, seqpacket,
+                            ON_OFF_AUTO_AUTO),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/virtio/vhost-vsock.h b/include/hw/virtio/vhost-vsock.h
index 84f4e727c7..3f121a624f 100644
--- a/include/hw/virtio/vhost-vsock.h
+++ b/include/hw/virtio/vhost-vsock.h
@@ -30,6 +30,9 @@ struct VHostVSock {
     VHostVSockCommon parent;
     VHostVSockConf conf;
 
+    /* features */
+    OnOffAuto seqpacket;
+
     /*< public >*/
 };
 
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.