From patchwork Fri Aug 28 13:28:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 32371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 5E735B6F31 for ; Sat, 29 Aug 2009 00:21:22 +1000 (EST) Received: from localhost ([127.0.0.1]:60218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mh2Ej-00017A-Fy for incoming@patchwork.ozlabs.org; Fri, 28 Aug 2009 10:15:29 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mh1Y1-0004yT-Tc for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:31:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mh1Xv-0004nW-DV for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:31:19 -0400 Received: from [199.232.76.173] (port=38623 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mh1Xu-0004mT-9e for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:31:14 -0400 Received: from mx20.gnu.org ([199.232.41.8]:54277) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mh1Xt-0004sY-W0 for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:31:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mh1Xt-00049y-9N for qemu-devel@nongnu.org; Fri, 28 Aug 2009 09:31:13 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7SDVChA023379 for ; Fri, 28 Aug 2009 09:31:12 -0400 Received: from localhost.localdomain (vpn2-8-216.ams2.redhat.com [10.36.8.216]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7SDUpnu030148; Fri, 28 Aug 2009 09:31:11 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 28 Aug 2009 15:28:26 +0200 Message-Id: <30b185f0aab7e4e4481e471228abfc62acf5134f.1251465671.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Detected-Operating-System: by mx20.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 15/16] i440fx: use new vmstate infrastructure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Juan Quintela --- hw/piix_pci.c | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-) diff --git a/hw/piix_pci.c b/hw/piix_pci.c index a044883..5c33741 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -154,21 +154,11 @@ static void i440fx_write_config(PCIDevice *dev, i440fx_update_memory_mappings(d); } -static void i440fx_save(QEMUFile* f, void *opaque) -{ - PCII440FXState *d = opaque; - - pci_device_save(&d->dev, f); - qemu_put_8s(f, &d->smm_enabled); -} - -static int i440fx_load(QEMUFile* f, void *opaque, int version_id) +static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) { PCII440FXState *d = opaque; int ret, i; - if (version_id > 3) - return -EINVAL; ret = pci_device_load(&d->dev, f); if (ret < 0) return ret; @@ -182,6 +172,28 @@ static int i440fx_load(QEMUFile* f, void *opaque, int version_id) return 0; } +static int i440fx_after_load(void *opaque) +{ + PCII440FXState *d = opaque; + + i440fx_update_memory_mappings(d); + return 0; +} + +static const VMStateDescription vmstate_i440fx = { + .name = "I440FX", + .version_id = 3, + .minimum_version_id = 3, + .minimum_version_id_old = 1, + .load_state_old = i440fx_load_old, + .run_after_load = i440fx_after_load, + .fields = (VMStateField []) { + VMSTATE_PCI_DEVICE(dev, PCII440FXState), + VMSTATE_UINT8(smm_enabled, PCII440FXState), + VMSTATE_END_OF_LIST() + } +}; + static int i440fx_pcihost_initfn(SysBusDevice *dev) { I440FXState *s = FROM_SYSBUS(I440FXState, dev); @@ -210,7 +222,7 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[0x72] = 0x02; /* SMRAM */ - register_savevm("I440FX", 0, 3, i440fx_save, i440fx_load, d); + vmstate_register(0, &vmstate_i440fx, d); return 0; }