diff mbox

virtio-net: correctly advertise host features

Message ID 1415858145-23461-1-git-send-email-jasowang@redhat.com
State New
Headers show

Commit Message

Jason Wang Nov. 13, 2014, 5:55 a.m. UTC
We should not advertise the feature that depends on ctrl vq is it was not
enabled. And not advertise the VIRTIO_NET_F_CTRL_RX_EXTRA is
VIRTIO_NET_F_CTRL_RX is not enabled.

Otherwise, this may confuse guest driver and lead unexpected bugs.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/virtio-net.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Stefan Hajnoczi Nov. 13, 2014, 11:30 a.m. UTC | #1
On Thu, Nov 13, 2014 at 01:55:45PM +0800, Jason Wang wrote:
> We should not advertise the feature that depends on ctrl vq is it was not
> enabled. And not advertise the VIRTIO_NET_F_CTRL_RX_EXTRA is

s/is/if/

> VIRTIO_NET_F_CTRL_RX is not enabled.

s/is/it/

These can be fixed up while merging.
diff mbox

Patch

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9b88775..553f5a4 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -465,6 +465,21 @@  static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
         features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
     }
 
+    if (!(features & (0x1 << VIRTIO_NET_F_CTRL_VQ))) {
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_GUEST_OFFLOADS);
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_RX);
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_VLAN);
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_RX_EXTRA);
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_MAC_ADDR);
+        features &= ~(0x1 << VIRTIO_NET_F_GUEST_ANNOUNCE);
+        features &= ~(0x1 << VIRTIO_NET_F_MQ);
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_MAC_ADDR);
+    }
+
+    if (!(features & (0x1 << VIRTIO_NET_F_CTRL_RX))) {
+        features &= ~(0x1 << VIRTIO_NET_F_CTRL_RX_EXTRA);
+    }
+
     if (!get_vhost_net(nc->peer)) {
         return features;
     }