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 <afaer...@suse.de> > > Cc: Alexander Graf <ag...@suse.de> > > Cc: Jason Baron <jba...@redhat.com> > > Cc: Kevin Wolf <kw...@redhat.com> > > Cc: Juan Quintela <quint...@redhat.com> > > Cc: Igor Mitsyanko <i.mitsya...@samsung.com> > > --- > > 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), \