From patchwork Tue May 7 10:22:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 242110 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 F12402C0214 for ; Tue, 7 May 2013 20:22:52 +1000 (EST) Received: from localhost ([::1]:54584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZf2p-00031O-66 for incoming@patchwork.ozlabs.org; Tue, 07 May 2013 06:22:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40964) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZf2Y-000314-BE for qemu-devel@nongnu.org; Tue, 07 May 2013 06:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UZf2V-00079e-5c for qemu-devel@nongnu.org; Tue, 07 May 2013 06:22:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44129) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UZf2U-00079Q-SS for qemu-devel@nongnu.org; Tue, 07 May 2013 06:22:31 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r47AMTeR000604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 7 May 2013 06:22:29 -0400 Received: from redhat.com (vpn-201-165.tlv.redhat.com [10.35.201.165]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r47AMQ02009716; Tue, 7 May 2013 06:22:26 -0400 Date: Tue, 7 May 2013 13:22:23 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <20130507102223.GA16878@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , Anthony Liguori , Jason Wang , Stefan Hajnoczi , fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH] virtio-net: require that config size is initialized 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 All buses do this, and if they don't they get subtle bugs related to cross version migration. Let's add an assert to catch these bugs early. Signed-off-by: Michael S. Tsirkin --- Just a cleanup so not 1.5 material. Seems to work fine here - any opinions? hw/net/virtio-net.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 908e7b8..f0a9272 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1282,6 +1282,8 @@ static int virtio_net_device_init(VirtIODevice *vdev) DeviceState *qdev = DEVICE(vdev); VirtIONet *n = VIRTIO_NET(vdev); + /* Verify that config size has been initialized */ + assert(n->config_size != (size_t)-1); virtio_init(VIRTIO_DEVICE(n), "virtio-net", VIRTIO_ID_NET, n->config_size); @@ -1386,10 +1388,9 @@ static void virtio_net_instance_init(Object *obj) VirtIONet *n = VIRTIO_NET(obj); /* - * The default config_size is sizeof(struct virtio_net_config). - * Can be overriden with virtio_net_set_config_size. + * The config_size must be set later with virtio_net_set_config_size. */ - n->config_size = sizeof(struct virtio_net_config); + n->config_size = (size_t)-1; } static Property virtio_net_properties[] = {