From patchwork Thu Apr 25 07:26:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 239410 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 84CD42C0107 for ; Thu, 25 Apr 2013 17:36:58 +1000 (EST) Received: from localhost ([::1]:48881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVGjg-0008Kt-Pt for incoming@patchwork.ozlabs.org; Thu, 25 Apr 2013 03:36:56 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVGjQ-0008Kh-Eh for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:36:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVGjP-0000jW-1A for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:36:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVGjO-0000jP-QE for qemu-devel@nongnu.org; Thu, 25 Apr 2013 03:36:38 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3P7aaDr018344 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 25 Apr 2013 03:36:36 -0400 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3P7aULt005447; Thu, 25 Apr 2013 03:36:32 -0400 From: Jason Wang To: aliguori@us.ibm.com, qemu-devel@nongnu.org Date: Thu, 25 Apr 2013 15:26:54 +0800 Message-Id: <1366874814-2658-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , Jesse Larrew , mst@redhat.com Subject: [Qemu-devel] [PATCH v2] virtio-net: count VIRTIO_NET_F_MAC when calculating config_len X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin --- Changes from V1: - Set VIRTIO_NET_F_MAC bit in host_features instead of initializing config_size --- hw/net/virtio-net.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1662f46..d4533d5 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);