Skip to contentSkip to conversation

virtio-net: clear guest_announce feature if no cvq backend

PATCH In review Eugenio Pérez 4 participants 6 messages Jan 24, 2023 – Feb 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-net: clear guest_announce feature if no cvq backend

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/net/virtio-net.c +15 -0
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
         features |= (1ULL << VIRTIO_NET_F_MTU);
     }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
     return features;
 }
 
Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eugenio Pérez

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

Could you now simplify the tests in virtio_net_announce() and virtio_net_post_load_device() to look only for the presence of GUEST_ANNOUNCE, given that you can now presume that it implies CTRL_VQ?

But anyway:

Quoted 40 lines

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/net/virtio-net.c +15 -0
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
         features |= (1ULL << VIRTIO_NET_F_MTU);
     }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
     return features;
 }
Signature · 1 line
Why stay in college? Why go to night school?
#2 lore raw
Quoted 5 lines · David Edmondson
Quoted 3 lines · Eugenio Pérez

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

Quoted 8 lines
Quoted 3 lines

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

Could you now simplify the tests in virtio_net_announce() and virtio_net_post_load_device() to look only for the presence of GUEST_ANNOUNCE, given that you can now presume that it implies CTRL_VQ?

That's a good question. As far as I know qemu emits an error if only GUEST_ANNOUNCE is given in a purely emulated device.

At this moment vhost-kernel and vhost-vdpa do not handle it, but vhost-user do. Would it be beneficial to preserve previous behavior and passthrough the features? I guess not, so I think we could simplify those functions on top of this series.

Quoted 4 lines

But anyway:

Thanks for the review!

Quoted 43 lines
Quoted 30 lines

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/net/virtio-net.c +7 -0
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
         features |= (1ULL << VIRTIO_NET_F_MTU);
     }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, · line 839

Quoted 10 lines
hw/net/virtio-net.c +8 -0
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
     return features;
 }

--
Why stay in college? Why go to night school?

Reviewed-by Tested-by
#3 lore raw
Quoted 24 lines · Eugenio Perez Martin

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 11 lines · David Edmondson
Quoted 6 lines · Eugenio Pérez

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

Could you now simplify the tests in virtio_net_announce() and virtio_net_post_load_device() to look only for the presence of GUEST_ANNOUNCE, given that you can now presume that it implies CTRL_VQ?

That's a good question. As far as I know qemu emits an error if only GUEST_ANNOUNCE is given in a purely emulated device.

At this moment vhost-kernel and vhost-vdpa do not handle it, but vhost-user do. Would it be beneficial to preserve previous behavior and passthrough the features? I guess not, so I think we could simplify those functions on top of this series.

Quoted 48 lines
Quoted 4 lines

But anyway:

Thanks for the review!

Quoted 42 lines
Quoted 30 lines

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
  hw/net/virtio-net.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
hw/net/virtio-net.c +7 -0
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
          features |= (1ULL << VIRTIO_NET_F_MTU);
      }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *

hw/net/virtio-net.c static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features, · line 839

Quoted 10 lines
hw/net/virtio-net.c +8 -0
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
      return features;
  }

--
Why stay in college? Why go to night school?

#4 lore raw
In reply to Eugenio Pérez
Quoted 8 lines · Eugenio Pérez

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

Quoted 8 lines

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Friendly ping about this patch, as it fell through the cracks if I'm not wrong.

Thanks!

Quoted 37 lines
Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/net/virtio-net.c +15 -1
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
         features |= (1ULL << VIRTIO_NET_F_MTU);
     }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
     return features;
 }
 
--

2.31.1

Tested-by
#5 lore raw

QE uses the sim_vdpa device to test this patch and add "ctrl_vq=off" in the qemu command line. Guest can find this device, there are no any error messages in guest dmesg, and can migrate successfully.

Quoted 61 lines · Eugenio Perez Martin <[email protected]> 于2023年2月14日周二 14:53写道:
Quoted 8 lines · Eugenio Pérez

Since GUEST_ANNOUNCE is emulated the feature bit could be set without backend support. This happens in the vDPA case.

However, backend vDPA parent may not have CVQ support. This causes an incoherent feature set, and the driver may refuse to start. This happens in virtio-net Linux driver.

Quoted 8 lines

This may be solved differently in the future. Qemu is able to emulate a CVQ just for guest_announce purposes, helping guest to notify the new location with vDPA devices that does not support it. However, this is left as a TODO as it is way more complex to backport.

Tested with vdpa_net_sim, toggling manually VIRTIO_NET_F_CTRL_VQ in the driver and migrating it with x-svq=on.

Friendly ping about this patch, as it fell through the cracks if I'm not wrong.

Thanks!

Quoted 37 lines
Fixes 980003debddd ("vdpa: do not handle VIRTIO_NET_F_GUEST_ANNOUNCE in vhost-vdpa")
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
hw/net/virtio-net.c +15 -1
index 3ae909041a..09d5c7a664 100644
@@ -820,6 +820,21 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
         features |= (1ULL << VIRTIO_NET_F_MTU);
     }
 
+    /*
+     * Since GUEST_ANNOUNCE is emulated the feature bit could be set without
+     * enabled. This happens in the vDPA case.
+     *
+     * Make sure the feature set is not incoherent, as the driver could refuse
+     * to start.
+     *
+     * TODO: QEMU is able to emulate a CVQ just for guest_announce purposes,
+     * helping guest to notify the new location with vDPA devices that does not
+     * support it.
+     */
+    if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ)) {
+        virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE);
+    }
+
     return features;
 }
 
--

2.31.1