From patchwork Fri Jul 8 13:43:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 103849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5FBD4B6EE8 for ; Fri, 8 Jul 2011 23:54:36 +1000 (EST) Received: from localhost ([::1]:47164 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfBVn-0006bm-VW for incoming@patchwork.ozlabs.org; Fri, 08 Jul 2011 09:54:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:46178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfBLe-0004d8-8b for qemu-devel@nongnu.org; Fri, 08 Jul 2011 09:44:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfBLd-0001as-0N for qemu-devel@nongnu.org; Fri, 08 Jul 2011 09:44:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfBLc-0001aj-Ig for qemu-devel@nongnu.org; Fri, 08 Jul 2011 09:44:00 -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 p68Dhxl5030052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Jul 2011 09:43:59 -0400 Received: from rincewind.home.kraxel.org (vpn1-4-123.ams2.redhat.com [10.36.4.123]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p68DhwI2004418; Fri, 8 Jul 2011 09:43:59 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 83C1041619; Fri, 8 Jul 2011 15:43:57 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 8 Jul 2011 15:43:57 +0200 Message-Id: <1310132637-20611-1-git-send-email-kraxel@redhat.com> In-Reply-To: <1310115239-19288-1-git-send-email-kraxel@redhat.com> References: <1310115239-19288-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 4/3] vmstate: complain about devices without vmstate 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 Signed-off-by: Gerd Hoffmann --- hw/hw.h | 2 ++ hw/qdev.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/hw/hw.h b/hw/hw.h index 1eb3486..6d6c493 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -336,6 +336,8 @@ struct VMStateDescription { const VMStateSubsection *subsections; }; +#define VMSD_NONE ((const VMStateDescription*)1) + extern const VMStateInfo vmstate_info_bool; extern const VMStateInfo vmstate_info_int8; diff --git a/hw/qdev.c b/hw/qdev.c index 292b52f..fafbbae 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -283,7 +283,12 @@ int qdev_init(DeviceState *dev) qdev_free(dev); return rc; } - if (dev->info->vmsd) { + if (dev->info->vmsd == NULL) { + /* TODO: fixup qemu source code, then make this an assert() */ + error_report("WARNING: device %s has no vmstate\n", dev->info->name); + } else if (dev->info->vmsd == VMSD_NONE) { + /* device doesn't need vmstate */; + } else { vmstate_register_with_alias_id(dev, -1, dev->info->vmsd, dev, dev->instance_id_alias, dev->alias_required_for_version);