Skip to contentSkip to conversation

virtio-net: introduce strict peer feature check

RFC PATCH In review Jason Wang 6 participants 26 messages Nov 7, 2025 – Nov 20, 2025

lore
Share & tools
lore

Jason Wang

author
#0 lore raw

RFC PATCH 1/1 virtio-net: introduce strict peer feature check

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

---
 hw/core/machine.c              |   1 +
 hw/net/virtio-net.c            | 153 +++++++++++++++++++++++++--------
 include/hw/virtio/virtio-net.h |   1 +
 3 files changed, 119 insertions(+), 36 deletions(-)
hw/core/machine.c +1 -0
index 681adbb7ac..a9e43c4990 100644
@@ -40,6 +40,7 @@
 
 GlobalProperty hw_compat_10_1[] = {
     { TYPE_ACPI_GED, "x-has-hest-addr", "false" },
+    { TYPE_VIRTIO_NET, "strict-peer-feature-check", "false"},
 };
 const size_t hw_compat_10_1_len = G_N_ELEMENTS(hw_compat_10_1);
 
hw/net/virtio-net.c +117 -36

190 lines not on this page · raw message

include/hw/virtio/virtio-net.h +1 -0
index 5b8ab7bda7..abd4ca4bb0 100644
@@ -222,6 +222,7 @@ struct VirtIONet {
     /* primary failover device is hidden*/
     bool failover_primary_hidden;
     bool failover;
+    bool strict_peer_feature_check;
     DeviceListener primary_listener;
     QDict *primary_opts;
     bool primary_opts_from_json;
Signature · 1 line
2.34.1
#1 lore raw
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

Jason, thanks for help looking into the problem!

Am I right that after this patch applied, whenever a new QEMU boots with the new machine types (e.g. having USO* by default ON), will fail to boot on an old kernel that doesn't support USO*, but ask the users to turn off USO* features explicitly in the virtio-net devices?

Thanks,

Quoted 230 lines
---
 hw/core/machine.c              |   1 +
 hw/net/virtio-net.c            | 153 +++++++++++++++++++++++++--------
 include/hw/virtio/virtio-net.h |   1 +
 3 files changed, 119 insertions(+), 36 deletions(-)
hw/core/machine.c +1 -0
index 681adbb7ac..a9e43c4990 100644
@@ -40,6 +40,7 @@
 
 GlobalProperty hw_compat_10_1[] = {
     { TYPE_ACPI_GED, "x-has-hest-addr", "false" },
+    { TYPE_VIRTIO_NET, "strict-peer-feature-check", "false"},
 };
 const size_t hw_compat_10_1_len = G_N_ELEMENTS(hw_compat_10_1);
 
hw/net/virtio-net.c +117 -36
index 33116712eb..3acc5ed4a6 100644
@@ -3090,53 +3090,120 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     virtio_add_feature_ex(features, VIRTIO_NET_F_MAC);
 
     if (!peer_has_vnet_hdr(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HASH_REPORT)) {
+                error_setg(errp, "virtio_net: peer doesn't support vnet hdr");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
 
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
     }
 
     if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_UFO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_UFO)) {
+                error_setg(errp, "virtio_net: peer doesn't support UFO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        }
     }
     if (!peer_has_uso(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6)) {
+                error_setg(errp, "virtio_net: peer doesn't support USO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        }
     }
 
     if (!peer_has_tunnel(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM)) {
+                error_setg(errp, "virtio_net: peer doesn't support tunnel GSO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        }
     }
 
     if (!get_vhost_net(nc->peer)) {
         if (!use_own_hash) {
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check) {
+                if (virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT) |
+                    virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                    error_setg(errp,
+                               "virtio_net: peer doesn't support RSS/HASH_REPORT");
+                    return;
+                }
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         } else if (virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
             virtio_net_load_ebpf(n, errp);
         }
@@ -3145,14 +3212,26 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     }
 
     if (!use_peer_hash) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        if (n->strict_peer_feature_check &&
+            virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT)) {
+            error_setg(errp, "virtio_net: peer doesn't HASH_REPORT");
+            return;
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
 
         if (!use_own_hash || !virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
             if (!virtio_net_load_ebpf(n, errp)) {
                 return;
             }
 
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check &&
+                virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                error_setg(errp, "virtio_net: fail to attach eBPF for RSS");
+                return;
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         }
     }
 
@@ -4313,6 +4392,8 @@ static const Property virtio_net_properties[] = {
                                host_features_ex,
                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM,
                                false),
+    DEFINE_PROP_BOOL("strict-peer-feature-check", VirtIONet,
+                     strict_peer_feature_check, true),
 };
 
 static void virtio_net_class_init(ObjectClass *klass, const void *data)
include/hw/virtio/virtio-net.h +1 -0
index 5b8ab7bda7..abd4ca4bb0 100644
@@ -222,6 +222,7 @@ struct VirtIONet {
     /* primary failover device is hidden*/
     bool failover_primary_hidden;
     bool failover;
+    bool strict_peer_feature_check;
     DeviceListener primary_listener;
     QDict *primary_opts;
     bool primary_opts_from_json;
Signature · 1 line
2.34.1
Signature · 1 line
Peter Xu
author
#2 lore raw
Quoted 15 lines · Peter Xu
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

Quoted 8 lines

Jason, thanks for help looking into the problem!

Am I right that after this patch applied, whenever a new QEMU boots with the new machine types (e.g. having USO* by default ON), will fail to boot on an old kernel that doesn't support USO*, but ask the users to turn off USO* features explicitly in the virtio-net devices?

Thanks,

Yes, I wonder if this can help in dealing with migration compatibility issues.

Thanks

Acked-by
#3 lore raw
Quoted 18 lines · Jason Wang
Quoted 17 lines · Peter Xu
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

Jason, thanks for help looking into the problem!

Quoted 8 lines
Quoted 6 lines

Am I right that after this patch applied, whenever a new QEMU boots with the new machine types (e.g. having USO* by default ON), will fail to boot on an old kernel that doesn't support USO*, but ask the users to turn off USO* features explicitly in the virtio-net devices?

Thanks,

Yes, I wonder if this can help in dealing with migration compatibility issues.

Yes I think so.

The only thing I do not know well is how much risk new qemu will start to fail boot on old kernels. One thing we can do here is be less aggressive on set default-ON to new network features.

E.g. for features like USO* we can avoid turning it ON by default when introduced, but wait for a few more releases. Distros / Downstreams can still be aggresive though to tweak the default if they know exactly the kernels to be run on top will be new enough.

Thanks again for the proposal, Jason. Anyway, from migration side, feel free to take:

Signature · 1 line
Peter Xu
#4 lore raw
In reply to Peter Xu
Quoted 12 lines · Peter Xu
Quoted 11 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

Quoted 8 lines
Quoted 1 line

Jason, thanks for help looking into the problem!

Am I right that after this patch applied, whenever a new QEMU boots with the new machine types (e.g. having USO* by default ON), will fail to boot on an old kernel that doesn't support USO*, but ask the users to turn off USO* features explicitly in the virtio-net devices?

What kernel version are we talking about where there will be incompatibility ? Is it old enough that it pre-dates our platform support matrix requirements ? Ubuntu 22.04 and RHEL-9 are currently our targets with the oldest kernels that we need to retain compatibility with as the bare min. I would expect machine types to work on these old platforms without users to having to manually disable default set features.

Quoted 217 lines

Thanks,

Quoted 214 lines
---
 hw/core/machine.c              |   1 +
 hw/net/virtio-net.c            | 153 +++++++++++++++++++++++++--------
 include/hw/virtio/virtio-net.h |   1 +
 3 files changed, 119 insertions(+), 36 deletions(-)
hw/core/machine.c +1 -0
index 681adbb7ac..a9e43c4990 100644
@@ -40,6 +40,7 @@
 
 GlobalProperty hw_compat_10_1[] = {
     { TYPE_ACPI_GED, "x-has-hest-addr", "false" },
+    { TYPE_VIRTIO_NET, "strict-peer-feature-check", "false"},
 };
 const size_t hw_compat_10_1_len = G_N_ELEMENTS(hw_compat_10_1);
 
hw/net/virtio-net.c +117 -36
index 33116712eb..3acc5ed4a6 100644
@@ -3090,53 +3090,120 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     virtio_add_feature_ex(features, VIRTIO_NET_F_MAC);
 
     if (!peer_has_vnet_hdr(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HASH_REPORT)) {
+                error_setg(errp, "virtio_net: peer doesn't support vnet hdr");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
 
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
     }
 
     if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_UFO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_UFO)) {
+                error_setg(errp, "virtio_net: peer doesn't support UFO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        }
     }
     if (!peer_has_uso(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6)) {
+                error_setg(errp, "virtio_net: peer doesn't support USO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        }
     }
 
     if (!peer_has_tunnel(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM)) {
+                error_setg(errp, "virtio_net: peer doesn't support tunnel GSO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        }
     }
 
     if (!get_vhost_net(nc->peer)) {
         if (!use_own_hash) {
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check) {
+                if (virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT) |
+                    virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                    error_setg(errp,
+                               "virtio_net: peer doesn't support RSS/HASH_REPORT");
+                    return;
+                }
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         } else if (virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
             virtio_net_load_ebpf(n, errp);
         }
@@ -3145,14 +3212,26 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     }
 
     if (!use_peer_hash) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        if (n->strict_peer_feature_check &&
+            virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT)) {
+            error_setg(errp, "virtio_net: peer doesn't HASH_REPORT");
+            return;
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
 
         if (!use_own_hash || !virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
             if (!virtio_net_load_ebpf(n, errp)) {
                 return;
             }
 
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check &&
+                virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                error_setg(errp, "virtio_net: fail to attach eBPF for RSS");
+                return;
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         }
     }
 
@@ -4313,6 +4392,8 @@ static const Property virtio_net_properties[] = {
                                host_features_ex,
                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM,
                                false),
+    DEFINE_PROP_BOOL("strict-peer-feature-check", VirtIONet,
+                     strict_peer_feature_check, true),
 };
 
Quoted 20 lines
Quoted 16 lines
hw/net/virtio-net.c +0 -0
 static void virtio_net_class_init(ObjectClass *klass, const void *data)
include/hw/virtio/virtio-net.h +1 -0
index 5b8ab7bda7..abd4ca4bb0 100644
@@ -222,6 +222,7 @@ struct VirtIONet {
     /* primary failover device is hidden*/
     bool failover_primary_hidden;
     bool failover;
+    bool strict_peer_feature_check;
     DeviceListener primary_listener;
     QDict *primary_opts;
     bool primary_opts_from_json;
Signature · 1 line
2.34.1
Signature · 1 line
Peter Xu

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#5 lore raw
Quoted 22 lines · Daniel P. Berrangé
Quoted 12 lines · Peter Xu
Quoted 11 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

Quoted 8 lines
Quoted 1 line

Jason, thanks for help looking into the problem!

Am I right that after this patch applied, whenever a new QEMU boots with the new machine types (e.g. having USO* by default ON), will fail to boot on an old kernel that doesn't support USO*, but ask the users to turn off USO* features explicitly in the virtio-net devices?

Quoted 8 lines

What kernel version are we talking about where there will be incompatibility ? Is it old enough that it pre-dates our platform support matrix requirements ? Ubuntu 22.04 and RHEL-9 are currently our targets with the oldest kernels that we need to retain compatibility with as the bare min. I would expect machine types to work on these old platforms without users to having to manually disable default set features.

Jason's proposal should have kept the behavior for old machine types so the strict checks are bypassed, so at least existing running VMs with old machine types should not be affected on booting.

New machine types may suffer from this indeed, that when running on old kernels it may needs some tweak on cmdlines.

There's another alternative, which we can introduce an option to allow QEMU boot but forbidding migration (or at least show a warning to user that migration may not work properly). Then everything can be auto-probed like before, because migration ABI is not necessary.

Personally, I think Jason's proposal is a good trade-off we can consider, if we think migration should by default supported on any QEMUs that would boot up properly.

Thanks,

Signature · 1 line
Peter Xu
#6 lore raw
In reply to Jason Wang
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

If you want to keep this off by default, and have management enable this if it knows what it's doing, then I don't really care.

Quoted 229 lines
---
 hw/core/machine.c              |   1 +
 hw/net/virtio-net.c            | 153 +++++++++++++++++++++++++--------
 include/hw/virtio/virtio-net.h |   1 +
 3 files changed, 119 insertions(+), 36 deletions(-)
hw/core/machine.c +1 -0
index 681adbb7ac..a9e43c4990 100644
@@ -40,6 +40,7 @@
 
 GlobalProperty hw_compat_10_1[] = {
     { TYPE_ACPI_GED, "x-has-hest-addr", "false" },
+    { TYPE_VIRTIO_NET, "strict-peer-feature-check", "false"},
 };
 const size_t hw_compat_10_1_len = G_N_ELEMENTS(hw_compat_10_1);
 
hw/net/virtio-net.c +117 -36
index 33116712eb..3acc5ed4a6 100644
@@ -3090,53 +3090,120 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     virtio_add_feature_ex(features, VIRTIO_NET_F_MAC);
 
     if (!peer_has_vnet_hdr(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
-
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_ECN) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HASH_REPORT)) {
+                error_setg(errp, "virtio_net: peer doesn't support vnet hdr");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
 
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
     }
 
     if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_UFO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_UFO)) {
+                error_setg(errp, "virtio_net: peer doesn't support UFO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO);
+        }
     }
     if (!peer_has_uso(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_USO) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO4) |
+                virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_USO6)) {
+                error_setg(errp, "virtio_net: peer doesn't support USO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6);
+        }
     }
 
     if (!peer_has_tunnel(n)) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
-        virtio_clear_feature_ex(features,
-                                VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        if (n->strict_peer_feature_check) {
+            if (virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) |
+                virtio_has_feature_ex(features,
+                                      VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM)) {
+                error_setg(errp, "virtio_net: peer doesn't support tunnel GSO");
+                return;
+            }
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM);
+            virtio_clear_feature_ex(features,
+                                    VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM);
+        }
     }
 
     if (!get_vhost_net(nc->peer)) {
         if (!use_own_hash) {
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check) {
+                if (virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT) |
+                    virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                    error_setg(errp,
+                               "virtio_net: peer doesn't support RSS/HASH_REPORT");
+                    return;
+                }
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         } else if (virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
             virtio_net_load_ebpf(n, errp);
         }
@@ -3145,14 +3212,26 @@ static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features,
     }
 
     if (!use_peer_hash) {
-        virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        if (n->strict_peer_feature_check &&
+            virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT)) {
+            error_setg(errp, "virtio_net: peer doesn't HASH_REPORT");
+            return;
+        } else {
+            virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT);
+        }
 
         if (!use_own_hash || !virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
             if (!virtio_net_load_ebpf(n, errp)) {
                 return;
             }
 
-            virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            if (n->strict_peer_feature_check &&
+                virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) {
+                error_setg(errp, "virtio_net: fail to attach eBPF for RSS");
+                return;
+            } else {
+                virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS);
+            }
         }
     }
 
@@ -4313,6 +4392,8 @@ static const Property virtio_net_properties[] = {
                                host_features_ex,
                                VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM,
                                false),
+    DEFINE_PROP_BOOL("strict-peer-feature-check", VirtIONet,
+                     strict_peer_feature_check, true),
 };
 
 static void virtio_net_class_init(ObjectClass *klass, const void *data)
include/hw/virtio/virtio-net.h +1 -0
index 5b8ab7bda7..abd4ca4bb0 100644
@@ -222,6 +222,7 @@ struct VirtIONet {
     /* primary failover device is hidden*/
     bool failover_primary_hidden;
     bool failover;
+    bool strict_peer_feature_check;
     DeviceListener primary_listener;
     QDict *primary_opts;
     bool primary_opts_from_json;
Signature · 1 line
2.34.1
#7 lore raw
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Thanks,

Quoted 5 lines

If you want to keep this off by default, and have management enable this if it knows what it's doing, then I don't really care.

Signature · 1 line
Peter Xu
#8 lore raw
Quoted 26 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

Quoted 8 lines

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

Quoted 8 lines
Quoted 5 lines

If you want to keep this off by default, and have management enable this if it knows what it's doing, then I don't really care.

Signature · 1 line
Peter Xu
#9 lore raw
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Thanks,

Signature · 1 line
Peter Xu
#10 lore raw
Quoted 51 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

Quoted 10 lines

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Thanks,

Signature · 1 line
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

first, formulate what exactly do you want to enable.

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Signature · 1 line
MST
#11 lore raw
Quoted 3 lines · Michael S. Tsirkin

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

I agree this is not pretty.

The very original proposal was having extra features to be OFF by default, only allow explicit selections to enable them when the mgmt / user is aware of the possible hosts to run on top. That'll guarantee:

(1) explicit failure whenever some unsupported cap is chosen on boot,

(2) default setup should always assume no kernel dependency hence booting should be all fine,

(3) since all features will be by default OFF or selected by the user with explicit cmdlines, VM ABI is guaranteed so that migration will work.

But unfortunately that proposal was rejected.

Quoted 7 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

This is indeed a good question. If with strict checks maybe we would at least want to make sure we throw explicit messages to let user know what to turn off.

Quoted 8 lines

first, formulate what exactly do you want to enable.

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Yes I think that's the case.

That's also why I think the very original proposal still makes sense (having all defaults OFF when dependent on kernel), because only the mgmt knows the details about the cluster, so it may make more sense to select from the top which has the full knowledge base, explicitly enable some sets of features (not only network, but also CPU feature bits and else). Then the mgmt boots the VM, also knows where it can migrate explicitly.

If all things are hidden then the mgmt is almost out of control of this.

That was rejected because there's the need to by default enable new features if ever possible. In that case, IMHO Jason's soluion is spot on where it sits in the middle ground of both, allowing both to happen (auto-enable of new feats, while keeping VM ABI stablility).

So IIUC there will be a cluster, it may contain different groups of hosts, each group should have similar setups so that VMs can freely migrate between each other within the same group (but may not easily migratable across groups?). But I don't think I know well on that part in practise.

Dan might be a great source of input from that level.

Thanks,

Signature · 1 line
Peter Xu
author
#12 lore raw
Quoted 45 lines · Peter Xu
Quoted 3 lines · Michael S. Tsirkin

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

I agree this is not pretty.

The very original proposal was having extra features to be OFF by default, only allow explicit selections to enable them when the mgmt / user is aware of the possible hosts to run on top. That'll guarantee:

(1) explicit failure whenever some unsupported cap is chosen on boot,

(2) default setup should always assume no kernel dependency hence booting should be all fine,

(3) since all features will be by default OFF or selected by the user with explicit cmdlines, VM ABI is guaranteed so that migration will work.

But unfortunately that proposal was rejected.

Quoted 7 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

This is indeed a good question. If with strict checks maybe we would at least want to make sure we throw explicit messages to let user know what to turn off.

Quoted 8 lines

first, formulate what exactly do you want to enable.

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Yes I think that's the case.

Quoted 8 lines

That's also why I think the very original proposal still makes sense (having all defaults OFF when dependent on kernel), because only the mgmt knows the details about the cluster, so it may make more sense to select from the top which has the full knowledge base, explicitly enable some sets of features (not only network, but also CPU feature bits and else). Then the mgmt boots the VM, also knows where it can migrate explicitly.

If all things are hidden then the mgmt is almost out of control of this.

+1

Quoted 5 lines

That was rejected because there's the need to by default enable new features if ever possible. In that case, IMHO Jason's soluion is spot on where it sits in the middle ground of both, allowing both to happen (auto-enable of new feats, while keeping VM ABI stablility).

Yes.

Quoted 5 lines

So IIUC there will be a cluster, it may contain different groups of hosts, each group should have similar setups so that VMs can freely migrate between each other within the same group (but may not easily migratable across groups?). But I don't think I know well on that part in practise.

Towards this, we may need to develop tools somewhere to report TAP capability. Or as replied in another thread, developing software fallback for new features, but it seems a burden.

Quoted 8 lines

Dan might be a great source of input from that level.

Thanks,

--
Peter Xu

Thanks

#13 lore raw
Quoted 8 lines · Jason Wang
Quoted 4 lines

So IIUC there will be a cluster, it may contain different groups of hosts, each group should have similar setups so that VMs can freely migrate between each other within the same group (but may not easily migratable across groups?). But I don't think I know well on that part in practise.

Towards this, we may need to develop tools somewhere to report TAP capability. Or as replied in another thread, developing software fallback for new features, but it seems a burden.

Or more generally, host capability from QEMU POV.

Signature · 1 line
MST
author
#14 lore raw
Quoted 7 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang
Quoted 4 lines

So IIUC there will be a cluster, it may contain different groups of hosts, each group should have similar setups so that VMs can freely migrate between each other within the same group (but may not easily migratable across groups?). But I don't think I know well on that part in practise.

Quoted 5 lines
Quoted 3 lines

Towards this, we may need to develop tools somewhere to report TAP capability. Or as replied in another thread, developing software fallback for new features, but it seems a burden.

Or more generally, host capability from QEMU POV.

Or you mean managment POV actually, for example TAP is usually created by libvirt.

Thanks

Quoted 4 lines

--
MST

#15 lore raw
Quoted 12 lines · Jason Wang
Quoted 11 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang
Quoted 4 lines

So IIUC there will be a cluster, it may contain different groups of hosts, each group should have similar setups so that VMs can freely migrate between each other within the same group (but may not easily migratable across groups?). But I don't think I know well on that part in practise.

Towards this, we may need to develop tools somewhere to report TAP capability. Or as replied in another thread, developing software fallback for new features, but it seems a burden.

Quoted 6 lines
Quoted 1 line

Or more generally, host capability from QEMU POV.

Or you mean managment POV actually, for example TAP is usually created by libvirt.

Thanks

So what you propose is really this:

1- create tap
2- run qemu check that it did not fail
3- if it fails guess what the right set of flags is to make it not fail
and switch to that

and I am saying qemu should help with 3.

Quoted 4 lines
Quoted 4 lines

--
MST

#16 lore raw
In reply to Peter Xu
Quoted 10 lines · Peter Xu
Quoted 3 lines · Michael S. Tsirkin

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

I agree this is not pretty.

The very original proposal was having extra features to be OFF by default, only allow explicit selections to enable them when the mgmt / user is aware of the possible hosts to run on top.

Could it maybe be tied to the "-nodefaults" option of QEMU? If you run QEMU with "-nodefaults" (which you should do when planning a migration later), these extra features that depend on the kernel version stay OFF. If you run QEMU without "-nodefaults", QEMU could enable them if supported by the kernel. So that would benefit both, the people running QEMU via management layers (using -nodefaults), and the people who just want to quickly launch QEMU on the command line. WDYT?

Thomas

#17 lore raw

Hello all,

My apologies for the slow reply; I have been heavily involved in other tasks recently.

I wanted to chime in to confirm that, as a Cloud Service Provider (CSP), we rely heavily on live migration, particularly during the rollout of new host operating system versions or for resource balancing across our infrastructure. Consequently, it is a critical requirement for us that the live migration process remains robust and does not experience failures simply because new features are automatically enabled by default when running on a newer kernel version.

From the CSP perspective, having a strict feature check that results in a failure at boot (or feature negotiation) seems significantly preferable to the previous behavior of silently clearing features and only failing much later during a migration attempt. A strict check provides immediate feedback that the requested feature set is incompatible with the peer/environment, allowing us to address the configuration issue proactively before the VM is put into production or before a migration is attempted.

I must admit I don't know the code base well enough to comment on the technical implementation, but the principle behind the proposed strict check appears to align well with our operational needs for managing live migration compatibility and stability.

Thank you very much, Jason, for proposing and working on this solution.

Best regards,
Jinpu

Quoted 23 lines · Thomas Huth
Quoted 10 lines · Peter Xu
Quoted 3 lines · Michael S. Tsirkin

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

I agree this is not pretty.

The very original proposal was having extra features to be OFF by default, only allow explicit selections to enable them when the mgmt / user is aware of the possible hosts to run on top.

Could it maybe be tied to the "-nodefaults" option of QEMU? If you run QEMU with "-nodefaults" (which you should do when planning a migration later), these extra features that depend on the kernel version stay OFF. If you run QEMU without "-nodefaults", QEMU could enable them if supported by the kernel. So that would benefit both, the people running QEMU via management layers (using -nodefaults), and the people who just want to quickly launch QEMU on the command line. WDYT?

Thomas

#18 lore raw
In reply to Thomas Huth
Quoted 12 lines · Thomas Huth
Quoted 10 lines · Peter Xu
Quoted 3 lines · Michael S. Tsirkin

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

I agree this is not pretty.

The very original proposal was having extra features to be OFF by default, only allow explicit selections to enable them when the mgmt / user is aware of the possible hosts to run on top.

Quoted 7 lines

Could it maybe be tied to the "-nodefaults" option of QEMU? If you run QEMU with "-nodefaults" (which you should do when planning a migration later), these extra features that depend on the kernel version stay OFF. If you run QEMU without "-nodefaults", QEMU could enable them if supported by the kernel. So that would benefit both, the people running QEMU via management layers (using -nodefaults), and the people who just want to quickly launch QEMU on the command line. WDYT?

Are the "default set of devices" when without -nodefaults more or less stable (aka, still live migratable)? If so, I wonder if there're still people relying on migrations but using default devices.

The other question is, such proposal also means auto-probe will be OFF for all serious users. I am personally OK with such, however it means it'll also reduce the test coverage that Michael was looking for on new network features, when QEMU is running on new kernels.

Thanks,

Signature · 1 line
Peter Xu
author
#19 lore raw
In reply to Michael S. Tsirkin
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Quoted 7 lines
Quoted 4 lines

Thanks,

--
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

It doesn't:

1) the strict feature check will be only enabled in new machine types
2) if kernel ABI is stable, qemu will keep working after upgrading kernel even with strict check otherwise it would be a bug of kernel

So I don't see it breaking anything if we make it start to work at 11.0?

Quoted 5 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

Peter has given the example of how hard we can define gracefulness (e.g migrate from a kernel w/ USO to a kernel w/o USO) and fix.

Maybe we can think of a usersapce fallback to emulation of USO or others, but I'm not sure if it's an overkill.

Quoted 4 lines

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

It's the first step as it's much better than silently clearing the feature which may confuse both user and migration. We can use warnings instead of errors but I'm not sure how much it can help.

Quoted 8 lines

first, formulate what exactly do you want to enable.

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Mostly, it should work as a CPU cluster. So it's the responsibility of the management layer, maybe we can develop some tool to report this or via qemu introspection ("query-tap" ?). Or if the management can do this now, we don't even need to bother (or it can help to uncover bugs). Anyhow, clearing a feature silently is not good and can cover bugs of various layers.

Note that this issue is not specific to TAP, we may meet this for vDPA/VFIO live migration as well. Basically, it should be the responsibility of the management layer to deal with those migration compatibility policies instead of using hard coded policies inside Qemu. For qemu, it can simply error out when there's a mismatch between features that are supported and features that are asked to enable. We've suffered a lot in the past when trying to deal with this by Qemu.

Thanks

Quoted 6 lines

--
MST

#20 lore raw
Quoted 68 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Quoted 7 lines
Quoted 4 lines

Thanks,

--
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

Quoted 7 lines

It doesn't:

1) the strict feature check will be only enabled in new machine types
2) if kernel ABI is stable, qemu will keep working after upgrading kernel even with strict check otherwise it would be a bug of kernel

So I don't see it breaking anything if we make it start to work at 11.0?

Using QEMU from git suddenly requires upgrading the kernel or figuring out obscure flags? Ugh.

Quoted 14 lines
Quoted 5 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

Peter has given the example of how hard we can define gracefulness (e.g migrate from a kernel w/ USO to a kernel w/o USO) and fix.

Maybe we can think of a usersapce fallback to emulation of USO or others, but I'm not sure if it's an overkill.

Quoted 2 lines
Quoted 6 lines
Quoted 2 lines

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

It's the first step as it's much better than silently clearing the feature which may confuse both user and migration. We can use warnings instead of errors but I'm not sure how much it can help.

Well with this first step we have successfully blamed the user and the second step won't ever be taken.

Quoted 10 lines
Quoted 8 lines

first, formulate what exactly do you want to enable.

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Mostly, it should work as a CPU cluster.

the reason it kinda works with CPU cluster is simply because there is a final set of CPU models and you can not easily switch your CPU to a different model.

Quoted 16 lines

So it's the responsibility of
the management layer, maybe we can develop some tool to report this or via qemu introspection ("query-tap" ?). Or if the management can do this now, we don't even need to bother (or it can help to uncover bugs). Anyhow, clearing a feature silently is not good and can cover bugs of various layers.

Note that this issue is not specific to TAP, we may meet this for vDPA/VFIO live migration as well. Basically, it should be the responsibility of the management layer to deal with those migration compatibility policies instead of using hard coded policies inside Qemu. For qemu, it can simply error out when there's a mismatch between features that are supported and features that are asked to enable. We've suffered a lot in the past when trying to deal with this by Qemu.

Quoted 1 line

Thanks

Yes but QEMU currently gives management no tools to figure out what is important for it.

Quoted 6 lines
Quoted 6 lines

--
MST

author
#21 lore raw
Quoted 72 lines · Michael S. Tsirkin
Quoted 70 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Quoted 7 lines
Quoted 4 lines

Thanks,

--
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

It doesn't:

Quoted 8 lines
Quoted 5 lines

1) the strict feature check will be only enabled in new machine types
2) if kernel ABI is stable, qemu will keep working after upgrading kernel even with strict check otherwise it would be a bug of kernel

So I don't see it breaking anything if we make it start to work at 11.0?

Using QEMU from git suddenly requires upgrading the kernel or figuring out obscure flags? Ugh.

Only the setups are buggy that might meet this.

Quoted 19 lines
Quoted 19 lines
Quoted 7 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

Peter has given the example of how hard we can define gracefulness (e.g migrate from a kernel w/ USO to a kernel w/o USO) and fix.

Maybe we can think of a usersapce fallback to emulation of USO or others, but I'm not sure if it's an overkill.

Quoted 4 lines

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

Quoted 7 lines
Quoted 3 lines

It's the first step as it's much better than silently clearing the feature which may confuse both user and migration. We can use warnings instead of errors but I'm not sure how much it can help.

Well with this first step we have successfully blamed the user and the second step won't ever be taken.

Are you suggesting to fix the management? E.g patching libvirt to probe tap features?

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

first, formulate what exactly do you want to enable.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Mostly, it should work as a CPU cluster.

the reason it kinda works with CPU cluster is simply because there is a final set of CPU models and you can not easily switch your CPU to a different model.

We can define a set of TAP features as well, but I'm not sure it's worthwhile to do this.

Quoted 17 lines
Quoted 17 lines

So it's the responsibility of
the management layer, maybe we can develop some tool to report this or via qemu introspection ("query-tap" ?). Or if the management can do this now, we don't even need to bother (or it can help to uncover bugs). Anyhow, clearing a feature silently is not good and can cover bugs of various layers.

Note that this issue is not specific to TAP, we may meet this for vDPA/VFIO live migration as well. Basically, it should be the responsibility of the management layer to deal with those migration compatibility policies instead of using hard coded policies inside Qemu. For qemu, it can simply error out when there's a mismatch between features that are supported and features that are asked to enable. We've suffered a lot in the past when trying to deal with this by Qemu.

Quoted 4 lines
Quoted 1 line

Thanks

Yes but QEMU currently gives management no tools to figure out what is important for it.

Using Qemu might be problematic as usually it doesn't not have privilege.

We can extend iproute, or a dedicated tool or ask libvirt to do this. If libvirt could do the probe by itself, could we start from that?

Thanks

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

--
MST

#22 lore raw
Quoted 77 lines · Jason Wang
Quoted 76 lines · Michael S. Tsirkin
Quoted 74 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Quoted 7 lines
Quoted 4 lines

Thanks,

--
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

It doesn't:

1) the strict feature check will be only enabled in new machine types
2) if kernel ABI is stable, qemu will keep working after upgrading kernel even with strict check otherwise it would be a bug of kernel

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't see it breaking anything if we make it start to work at 11.0?

Using QEMU from git suddenly requires upgrading the kernel or figuring out obscure flags? Ugh.

Only the setups are buggy that might meet this.

I do git pull on qemu and have an old kernel. My setup just became buggy. No?

Quoted 24 lines
Quoted 24 lines
Quoted 22 lines
Quoted 7 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

Peter has given the example of how hard we can define gracefulness (e.g migrate from a kernel w/ USO to a kernel w/o USO) and fix.

Maybe we can think of a usersapce fallback to emulation of USO or others, but I'm not sure if it's an overkill.

Quoted 4 lines

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

It's the first step as it's much better than silently clearing the feature which may confuse both user and migration. We can use warnings instead of errors but I'm not sure how much it can help.

Quoted 5 lines
Quoted 2 lines

Well with this first step we have successfully blamed the user and the second step won't ever be taken.

Are you suggesting to fix the management? E.g patching libvirt to probe tap features?

host features generally.

Quoted 41 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

first, formulate what exactly do you want to enable.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Mostly, it should work as a CPU cluster.

the reason it kinda works with CPU cluster is simply because there is a final set of CPU models and you can not easily switch your CPU to a different model.

We can define a set of TAP features as well, but I'm not sure it's worthwhile to do this.

Quoted 17 lines
Quoted 17 lines

So it's the responsibility of
the management layer, maybe we can develop some tool to report this or via qemu introspection ("query-tap" ?). Or if the management can do this now, we don't even need to bother (or it can help to uncover bugs). Anyhow, clearing a feature silently is not good and can cover bugs of various layers.

Note that this issue is not specific to TAP, we may meet this for vDPA/VFIO live migration as well. Basically, it should be the responsibility of the management layer to deal with those migration compatibility policies instead of using hard coded policies inside Qemu. For qemu, it can simply error out when there's a mismatch between features that are supported and features that are asked to enable. We've suffered a lot in the past when trying to deal with this by Qemu.

Quoted 4 lines
Quoted 1 line

Thanks

Yes but QEMU currently gives management no tools to figure out what is important for it.

Quoted 6 lines

Using Qemu might be problematic as usually it doesn't not have privilege.

We can extend iproute, or a dedicated tool or ask libvirt to do this. If libvirt could do the probe by itself, could we start from that?

Thanks

All I am saying is that I want to see how is management supposed to know what to enable.

qemu already probes tap features. To me, it seems natural for management to do the probing through qemu.
in fact your patch is a way to do that, is it not? what it lacks though is a structured way to tell management how to fix the problem.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

--
MST

author
#23 lore raw
Quoted 169 lines · Michael S. Tsirkin
Quoted 77 lines · Jason Wang
Quoted 76 lines · Michael S. Tsirkin
Quoted 74 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 57 lines · Peter Xu
Quoted 34 lines · Michael S. Tsirkin
Quoted 33 lines · Peter Xu
Quoted 21 lines · Michael S. Tsirkin
Quoted 5 lines · Jason Wang

We used to clear features silently in virtio_net_get_features() even if it is required. This complicates the live migration compatibility as the management layer may think the feature is enabled but in fact not.

Quoted 7 lines

Let's add a strict feature check to make sure if there's a mismatch between the required feature and peer, fail the get_features() immediately instead of waiting until the migration to fail. This offload the migration compatibility completely to the management layer.

This is not really useful - how do users know how to tweak their command lines?
We discussed this many times.
To try and solve this you need a tool that will tell you how to start VM on X to make it migrateable to Y or Z.

Quoted 3 lines

More importantly,
migration is a niche thing and breaking booting perfectly good VMs just for that seems wrong.

IMHO Jason's proposal is useful in that it now provides a way to provide ABI stablility but allows auto-ON to exist.

If we think migration is optional, we could add a migration blocker where strict check flag is set to OFF, as I mentioned in the email reply to Dan. As that implies the VM ABI is not guaranteed.

Quoted 5 lines
Quoted 1 line

Thanks,

All you have to do is avoid changing the kernel and ABI is stable. Downstreams already do this.

But the whole point of migration is allowing VMs to move between hosts.. hence AFAIU kernel can change.

Downstream will still have problem if some network features will be optionally supported in some of the RHEL-N branches, because machine types are defined the same in any RHEL-N, so IIUC it's also possible a VM booting on a latest RHEL-X.Y qemu/kernel hit issues migrating back to an older RHEL-X.(Y-1) qemu/kernel if RHEL-X.(Y-1) kernel doesn't have the network feature available..

It's also not good IMHO to only fix downstream but having upstream face such problems, even if there's a downstream fix...

This thread was revived only because Jinpu hit similar issues. IMHO we should still try to provide a generic solution upstream for everyone.

Quoted 7 lines
Quoted 4 lines

Thanks,

--
Peter Xu

failing to start a perfectly good qemu which used to work because you changed kernels is better than failing to migrate how?

It doesn't:

1) the strict feature check will be only enabled in new machine types
2) if kernel ABI is stable, qemu will keep working after upgrading kernel even with strict check otherwise it would be a bug of kernel

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

So I don't see it breaking anything if we make it start to work at 11.0?

Using QEMU from git suddenly requires upgrading the kernel or figuring out obscure flags? Ugh.

Only the setups are buggy that might meet this.

I do git pull on qemu and have an old kernel. My setup just became buggy. No?

Quoted 24 lines
Quoted 24 lines
Quoted 22 lines
Quoted 7 lines

graceful downgrade with old kernels is the basics of good userspace behaviour and has been for decades.

Peter has given the example of how hard we can define gracefulness (e.g migrate from a kernel w/ USO to a kernel w/o USO) and fix.

Maybe we can think of a usersapce fallback to emulation of USO or others, but I'm not sure if it's an overkill.

Quoted 4 lines

sure, let's work on a solution, just erroring out is more about blaming the user. what is the user supposed to do when qemu fails to start?

It's the first step as it's much better than silently clearing the feature which may confuse both user and migration. We can use warnings instead of errors but I'm not sure how much it can help.

Quoted 5 lines
Quoted 2 lines

Well with this first step we have successfully blamed the user and the second step won't ever be taken.

Are you suggesting to fix the management? E.g patching libvirt to probe tap features?

host features generally.

Quoted 46 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

first, formulate what exactly do you want to enable.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

for example, you have a set of boxes and you want a set of flags to supply to guarantee qemu can migrate between them. is that it?

Mostly, it should work as a CPU cluster.

the reason it kinda works with CPU cluster is simply because there is a final set of CPU models and you can not easily switch your CPU to a different model.

We can define a set of TAP features as well, but I'm not sure it's worthwhile to do this.

Quoted 17 lines
Quoted 17 lines

So it's the responsibility of
the management layer, maybe we can develop some tool to report this or via qemu introspection ("query-tap" ?). Or if the management can do this now, we don't even need to bother (or it can help to uncover bugs). Anyhow, clearing a feature silently is not good and can cover bugs of various layers.

Note that this issue is not specific to TAP, we may meet this for vDPA/VFIO live migration as well. Basically, it should be the responsibility of the management layer to deal with those migration compatibility policies instead of using hard coded policies inside Qemu. For qemu, it can simply error out when there's a mismatch between features that are supported and features that are asked to enable. We've suffered a lot in the past when trying to deal with this by Qemu.

Quoted 4 lines
Quoted 1 line

Thanks

Yes but QEMU currently gives management no tools to figure out what is important for it.

Using Qemu might be problematic as usually it doesn't not have privilege.

We can extend iproute, or a dedicated tool or ask libvirt to do this. If libvirt could do the probe by itself, could we start from that?

Quoted 6 lines
Quoted 1 line

Thanks

All I am saying is that I want to see how is management supposed to know what to enable.

qemu already probes tap features.

Only part of the features.

Quoted 3 lines

To me, it seems natural
for management to do the probing through qemu. in fact your patch is a way to do that, is it not?

Yes and no.

Quoted 2 lines

what it lacks though is a structured way to tell management how to fix the problem.

Probing through management seems to be better. For example it can calculate the cluster in advance without the need to launch qemu everywhere.

Or consider the case when USO is not supported by the kernel in the destination, even if qemu reports this, I'm not sure what is expected to be done in the management layer?

Thanks

Quoted 13 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 11 lines

--
MST

#24 lore raw
Quoted 3 lines · Jason Wang
Quoted 1 line

qemu already probes tap features.

Only part of the features.

the part we care about?

Quoted 4 lines
Quoted 3 lines

To me, it seems natural
for management to do the probing through qemu. in fact your patch is a way to do that, is it not?

Quoted 8 lines

Yes and no.

Quoted 2 lines

what it lacks though is a structured way to tell management how to fix the problem.

Probing through management seems to be better. For example it can calculate the cluster in advance without the need to launch qemu everywhere.

it is basically replicating qemu code then.

what's the big deal to launch qemu?

Quoted 5 lines

Or consider the case when USO is not supported by the kernel in the destination, even if qemu reports this, I'm not sure what is expected to be done in the management layer?

Thanks

reports what?

Signature · 1 line
MST
author Acked-by Tested-by Lei Yang Reviewed-by Michael S. Tsirkin
#25 lore raw
Quoted 8 lines · Michael S. Tsirkin
Quoted 3 lines · Jason Wang
Quoted 1 line

qemu already probes tap features.

Only part of the features.

the part we care about?

Yes and technically Qemu can probe all.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

To me, it seems natural
for management to do the probing through qemu. in fact your patch is a way to do that, is it not?

Yes and no.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

what it lacks though is a structured way to tell management how to fix the problem.

Probing through management seems to be better. For example it can calculate the cluster in advance without the need to launch qemu everywhere.

it is basically replicating qemu code then.

Yes but libvirt has duplicated somehow, e.g create and destroy TAP and it even uses TUNGETFEATURES in virNetDevMacVLanTapSetup(). But I'm not even sure this is the work of the libvirt. I think it should be the job of the one who is in charge of managing the cpu cluster.

Quoted 2 lines

what's the big deal to launch qemu?

It looks more heavyweight than probing by libvirt but I'm not sure, we can listen to libvirt guys.

Quoted 10 lines
Quoted 8 lines

Or consider the case when USO is not supported by the kernel in the destination, even if qemu reports this, I'm not sure what is expected to be done in the management layer?

Thanks

reports what?

USO is not supported by this kernel.

Btw, to not make things worse, I would revert this until we find a solution. Do you agree?

commit 1c79ab6937ae938d3dfd4da1c01afc7eb599857e

Author: Paolo Abeni <[email protected]>
Date:   Fri Oct 10 16:12:57 2025 +0200

virtio-net: Advertise UDP tunnel GSO support by default

Allow bidirectional aggregated traffic for UDP encapsulated flows.

Add the needed compatibility entries to avoid migration issues vs older QEMU instances.

Message-Id:
<9c500fbcd2cf29afd1826b1ac906f9d5beac3601.1760104079.git.pabeni@redhat.com>

Otherwise we will suffer from a similar issue soon.

Thanks

Quoted 4 lines

--
MST