qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len
@ 2013-04-25  6:21 Jason Wang
  2013-04-25  6:59 ` Michael S. Tsirkin
  0 siblings, 1 reply; 26+ messages in thread
From: Jason Wang @ 2013-04-25  6:21 UTC (permalink / raw)
  To: aliguori, qemu-devel; +Cc: Jason Wang, Jesse Larrew, mst

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 <jlarrew@linux.vnet.ibm.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/virtio-net.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 70c8fce..33a70ef 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1264,7 +1264,8 @@ 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;
+    /* VIRTIO_NET_F_MAC can't be disabled from qemu side */
+    int i, config_size = feature_sizes[0].end;
     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);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-05-02  9:05 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-25  6:21 [Qemu-devel] [PATCH] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len Jason Wang
2013-04-25  6:59 ` Michael S. Tsirkin
2013-04-25  7:02   ` Jason Wang
2013-04-25  7:06     ` Michael S. Tsirkin
2013-04-25  7:52       ` Jason Wang
2013-04-29 14:42   ` Jesse Larrew
2013-04-29 14:55     ` KONRAD Frédéric
2013-04-29 15:14       ` Jesse Larrew
2013-04-29 15:29         ` KONRAD Frédéric
2013-04-29 15:55           ` Jesse Larrew
2013-04-29 16:02             ` Michael S. Tsirkin
2013-04-29 16:14               ` KONRAD Frédéric
2013-04-29 16:21                 ` Michael S. Tsirkin
2013-04-29 16:30                   ` Michael S. Tsirkin
2013-04-29 16:41                     ` KONRAD Frédéric
2013-04-29 17:01                       ` Michael S. Tsirkin
2013-04-29 17:23                         ` KONRAD Frédéric
2013-04-29 17:52                           ` Michael S. Tsirkin
2013-04-29 18:01                             ` KONRAD Frédéric
2013-04-29 18:15                               ` Michael S. Tsirkin
2013-04-29 18:45                                 ` KONRAD Frédéric
2013-04-29 20:09                                   ` Michael S. Tsirkin
2013-04-30  8:47                                     ` KONRAD Frédéric
2013-04-30  9:02                                       ` Michael S. Tsirkin
2013-05-02  9:02                                         ` Cornelia Huck
2013-05-02  8:59                                     ` Cornelia Huck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).