All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Kevin Wolf <kwolf@redhat.com>, Alexander Graf <agraf@suse.de>,
	Igor Mitsyanko <i.mitsyanko@samsung.com>,
	qemu-devel@nongnu.org, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [RFC v2] ahci: Add support for migration
Date: Fri, 24 Aug 2012 12:28:22 -0400	[thread overview]
Message-ID: <20120824162822.GA6197@redhat.com> (raw)
In-Reply-To: <20120809144922.GA15422@redhat.com>

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 <afaerber@suse.de>
> > Cc: Alexander Graf <agraf@suse.de>
> > Cc: Jason Baron <jbaron@redhat.com>
> > Cc: Kevin Wolf <kwolf@redhat.com>
> > Cc: Juan Quintela <quintela@redhat.com>
> > Cc: Igor Mitsyanko <i.mitsyanko@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),                                      \

  reply	other threads:[~2012-08-24 16:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-09 12:59 [Qemu-devel] [RFC v2] ahci: Add support for migration Andreas Färber
2012-08-09 14:49 ` Jason Baron
2012-08-24 16:28   ` Jason Baron [this message]
2012-08-26  4:50     ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120824162822.GA6197@redhat.com \
    --to=jbaron@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=i.mitsyanko@samsung.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.