From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVGyr-0007fF-U1 for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:52:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVGyq-000669-JL for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:52:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53787) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVGyq-00065x-49 for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:52:36 -0400 Message-ID: <5178E0B8.3030503@redhat.com> Date: Thu, 25 Apr 2013 15:52:24 +0800 From: Jason Wang MIME-Version: 1.0 References: <1366870889-950-1-git-send-email-jasowang@redhat.com> <20130425065953.GB7299@redhat.com> <5178D514.5090600@redhat.com> <20130425070656.GA7485@redhat.com> In-Reply-To: <20130425070656.GA7485@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, Jesse Larrew On 04/25/2013 03:06 PM, Michael S. Tsirkin wrote: > On Thu, Apr 25, 2013 at 03:02:44PM +0800, Jason Wang wrote: >> On 04/25/2013 02:59 PM, Michael S. Tsirkin wrote: >>> On Thu, Apr 25, 2013 at 02:21:29PM +0800, Jason Wang wrote: >>>> 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 >>>> --- >>>> 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; >>> This would be cleaner: >>> host_features |= (1 << VIRTIO_NET_F_MAC); >>> >>> no need for a comment then. >> Sure, will send V2. > Maybe ass assert(config_size) in core just to make sure > other devices do not have this bug. Prepare a patch for this, will send soon. >>>> 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