From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XonNw-0001gT-NH for qemu-devel@nongnu.org; Thu, 13 Nov 2014 00:56:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XonNq-00065R-JG for qemu-devel@nongnu.org; Thu, 13 Nov 2014 00:56:00 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XonNq-00064R-Br for qemu-devel@nongnu.org; Thu, 13 Nov 2014 00:55:54 -0500 From: Jason Wang Date: Thu, 13 Nov 2014 13:55:45 +0800 Message-Id: <1415858145-23461-1-git-send-email-jasowang@redhat.com> Subject: [Qemu-devel] [PATCH] virtio-net: correctly advertise host features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@amazon.com, mst@redhat.com, qemu-devel@nongnu.org Cc: Jason Wang 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 --- hw/net/virtio-net.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } -- 1.9.1