From mboxrd@z Thu Jan 1 00:00:00 1970 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 Date: Fri, 24 Aug 2012 12:28:22 -0400 From: Jason Baron 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20120809144922.GA15422@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC v2] ahci: Add support for migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: Kevin Wolf , Alexander Graf , Igor Mitsyanko , qemu-devel@nongnu.org, Juan Quintela 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=E4rber wrote: > > Define generic VMState for AHCI and reuse it together with PCI for IC= H > > and on its own for the SysBus version. > >=20 > > 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. > >=20 > > Signed-off-by: Andreas F=E4rber > > 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(-) > >=20 >=20 > Thanks for doing this. My migration on q35 completes, but the disk is > not accessible. Didn't test piix. Console output below. >=20 Hi Andreas, The below patch (ont top of you patch) makes ahci migration work for me, = very lightly tested at this point.=20 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_devi= ce =3D { 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() }, }; =20 +static int ahci_state_post_load(void *opaque, int version_id) +{ + int i; + AHCIState *s =3D opaque; + =20 + for (i =3D 0; i < s->ports; i++) { + AHCIPortRegs *pr =3D &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); + } + =20 + return 0; +} + const VMStateDescription vmstate_ahci =3D { .name =3D "ahci", .version_id =3D 1, + .post_load =3D ahci_state_post_load, .fields =3D (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 =3D offsetof(_state, _field), \ } =20 +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num,= _version, _vmsd, _type) { \ + .name =3D (stringify(_field)), \ + .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), = \ + .version_id =3D (_version), \ + .vmsd =3D &(_vmsd), \ + .size =3D sizeof(_type), \ + .flags =3D VMS_POINTER | VMS_STRUCT | VMS_VARRAY_UINT32, \ + .offset =3D offsetof(_state, _field), \ +} + #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _= size) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \