From e9016ee2bda1b7757072b856b2196f691aee3388 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Thu, 25 Apr 2013 15:26:54 +0800 Subject: [PATCH] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len Commit 14f9b664 (hw/virtio-net.c: set config size using host features) tries to calculate config size based on the host features. But it forgets the VIRTIO_NET_F_MAC were always set for qemu later. This will lead a zero config len for virtio-net device when both VIRTIO_NET_F_STATUS and VIRTIO_NET_F_MQ were disabled form command line. Then qemu will crash when user tries to read the config of virtio-net. Fix this by counting VIRTIO_NET_F_MAC and make sure the config at least contains the mac address. Cc: Jesse Larrew Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Acked-by: Michael S. Tsirkin Message-id: 1366874814-2658-1-git-send-email-jasowang@redhat.com Signed-off-by: Anthony Liguori --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index b2d99f9cd1..908e7b809e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1266,6 +1266,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, void virtio_net_set_config_size(VirtIONet *n, uint32_t host_features) { int i, config_size = 0; + host_features |= (1 << VIRTIO_NET_F_MAC); for (i = 0; feature_sizes[i].flags != 0; i++) { if (host_features & feature_sizes[i].flags) { config_size = MAX(feature_sizes[i].end, config_size);