From patchwork Thu Oct 4 19:15:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 189312 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 F3F8C2C03F0 for ; Fri, 5 Oct 2012 06:36:39 +1000 (EST) Received: from localhost ([::1]:49443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJqtG-00038k-Bk for incoming@patchwork.ozlabs.org; Thu, 04 Oct 2012 15:15:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJqsl-000217-Hh for qemu-devel@nongnu.org; Thu, 04 Oct 2012 15:14:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TJqse-0003kD-GY for qemu-devel@nongnu.org; Thu, 04 Oct 2012 15:14:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TJqse-0003ib-61 for qemu-devel@nongnu.org; Thu, 04 Oct 2012 15:14:44 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q94JEgUa004843 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Oct 2012 15:14:42 -0400 Received: from blackpad.lan.raisama.net (vpn1-7-183.gru2.redhat.com [10.97.7.183]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q94JEf5p021671; Thu, 4 Oct 2012 15:14:42 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 63B25203627; Thu, 4 Oct 2012 16:15:42 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 4 Oct 2012 16:15:26 -0300 Message-Id: <1349378133-25644-7-git-send-email-ehabkost@redhat.com> In-Reply-To: <1349378133-25644-1-git-send-email-ehabkost@redhat.com> References: <1349378133-25644-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori , Paolo Bonzini Subject: [Qemu-devel] [RFC 06/13] qdev-core: isolate vmstate handling into separate functions 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 Those functions will eventually be moved somewhere else, and won't get included on *-user. Signed-off-by: Eduardo Habkost --- hw/qdev-core.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/qdev-core.c b/hw/qdev-core.c index c3c4d77..242347f 100644 --- a/hw/qdev-core.c +++ b/hw/qdev-core.c @@ -40,6 +40,22 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *dev) return dc->vmsd; } +static void qdev_init_vmstate(DeviceState *dev) +{ + if (qdev_get_vmsd(dev)) { + vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, + dev->instance_id_alias, + dev->alias_required_for_version); + } +} + +static void qdev_finalize_vmstate(DeviceState *dev) +{ + if (qdev_get_vmsd(dev)) { + vmstate_unregister(dev, qdev_get_vmsd(dev), dev); + } +} + const char *qdev_fw_name(DeviceState *dev) { DeviceClass *dc = DEVICE_GET_CLASS(dev); @@ -131,11 +147,7 @@ int qdev_init(DeviceState *dev) g_free(name); } - if (qdev_get_vmsd(dev)) { - vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev, - dev->instance_id_alias, - dev->alias_required_for_version); - } + qdev_init_vmstate(dev); dev->state = DEV_STATE_INITIALIZED; if (dev->hotplugged) { device_reset(dev); @@ -608,9 +620,7 @@ static void device_finalize(Object *obj) bus = QLIST_FIRST(&dev->child_bus); qbus_free(bus); } - if (qdev_get_vmsd(dev)) { - vmstate_unregister(dev, qdev_get_vmsd(dev), dev); - } + qdev_finalize_vmstate(dev); if (dc->exit) { dc->exit(dev); }