From patchwork Fri Aug 24 16:28:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 179872 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 BFCF92C00D7 for ; Sat, 25 Aug 2012 02:28:45 +1000 (EST) Received: from localhost ([::1]:35397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4wkV-00012Q-Ri for incoming@patchwork.ozlabs.org; Fri, 24 Aug 2012 12:28:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4wkE-0000xU-HM for qemu-devel@nongnu.org; Fri, 24 Aug 2012 12:28:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T4wkC-0002oz-Ta for qemu-devel@nongnu.org; Fri, 24 Aug 2012 12:28:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63135) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T4wkC-0002ot-KZ for qemu-devel@nongnu.org; Fri, 24 Aug 2012 12:28:24 -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 q7OGSN6j019246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 24 Aug 2012 12:28:23 -0400 Received: from redhat.com (dhcp-185-114.bos.redhat.com [10.16.185.114]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7OGSNKO020856; Fri, 24 Aug 2012 12:28:23 -0400 Date: Fri, 24 Aug 2012 12:28:22 -0400 From: Jason Baron To: Andreas =?iso-8859-1?Q?F=E4rber?= Message-ID: <20120824162822.GA6197@redhat.com> References: <1344517195-3462-1-git-send-email-afaerber@suse.de> <20120809144922.GA15422@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120809144922.GA15422@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id q7OGSN6j019246 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Alexander Graf , Igor Mitsyanko , qemu-devel@nongnu.org, Juan Quintela Subject: Re: [Qemu-devel] [RFC v2] ahci: Add support for migration 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 On Thu, Aug 09, 2012 at 10:49:23AM -0400, Jason Baron wrote: > On Thu, Aug 09, 2012 at 02:59:54PM +0200, Andreas Färber wrote: > > Define generic VMState for AHCI and reuse it together with PCI for ICH > > and on its own for the SysBus version. > > > > Note: ICH9 initializes AHCI with 6 ports, which dynamically allocates > > 6 AHCIDevice structs. Thus we change the ports field type to uint32_t > > for compatibility with VMState macros. > > > > Signed-off-by: Andreas Färber > > Cc: Alexander Graf > > Cc: Jason Baron > > Cc: Kevin Wolf > > Cc: Juan Quintela > > Cc: Igor Mitsyanko > > --- > > hw/ide/ahci.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- > > hw/ide/ahci.h | 12 +++++++++++- > > hw/ide/ich.c | 11 ++++++++--- > > 3 files changed, 64 insertions(+), 5 deletions(-) > > > > Thanks for doing this. My migration on q35 completes, but the disk is > not accessible. Didn't test piix. Console output below. > Hi Andreas, The below patch (ont top of you patch) makes ahci migration work for me, very lightly tested at this point. Thanks, -Jason diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 06c236f..61d1cdb 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -1225,15 +1225,33 @@ static const VMStateDescription vmstate_ahci_device = { VMSTATE_UINT32(port_regs.scr_err, AHCIDevice), VMSTATE_UINT32(port_regs.scr_act, AHCIDevice), VMSTATE_UINT32(port_regs.cmd_issue, AHCIDevice), + VMSTATE_INT32(port_no, AHCIDevice), VMSTATE_END_OF_LIST() }, }; +static int ahci_state_post_load(void *opaque, int version_id) +{ + int i; + AHCIState *s = opaque; + + for (i = 0; i < s->ports; i++) { + AHCIPortRegs *pr = &s->dev[i].port_regs; + map_page(&s->dev[i].lst, + ((uint64_t)pr->lst_addr_hi << 32) | pr->lst_addr, 1024); + map_page(&s->dev[i].res_fis, + ((uint64_t)pr->fis_addr_hi << 32) | pr->fis_addr, 256); + } + + return 0; +} + const VMStateDescription vmstate_ahci = { .name = "ahci", .version_id = 1, + .post_load = ahci_state_post_load, .fields = (VMStateField []) { - VMSTATE_STRUCT_VARRAY_UINT32(dev, AHCIState, ports, 0, + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(dev, AHCIState, ports, 0, vmstate_ahci_device, AHCIDevice), VMSTATE_UINT32(control_regs.cap, AHCIState), VMSTATE_UINT32(control_regs.ghc, AHCIState), diff --git a/vmstate.h b/vmstate.h index 5bd2b76..2a5cf51 100644 --- a/vmstate.h +++ b/vmstate.h @@ -349,6 +349,16 @@ extern const VMStateInfo vmstate_info_unused_buffer; .offset = offsetof(_state, _field), \ } +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _version, _vmsd, _type) { \ + .name = (stringify(_field)), \ + .num_offset = vmstate_offset_value(_state, _field_num, uint32_t), \ + .version_id = (_version), \ + .vmsd = &(_vmsd), \ + .size = sizeof(_type), \ + .flags = VMS_POINTER | VMS_STRUCT | VMS_VARRAY_UINT32, \ + .offset = offsetof(_state, _field), \ +} + #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \