Received: from eggs.gnu.org ([2001:4830:134:3::10]:59953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQCqS-00014a-4v for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:12:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQCqM-0006iv-3Y for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:12:51 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:44895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQCqL-0006ir-Rj for qemu-devel@nongnu.org; Thu, 21 Jul 2016 08:12:46 -0400 Date: Thu, 21 Jul 2016 08:12:43 -0400 (EDT) From: Paolo Bonzini Message-ID: <559834123.9435733.1469103163593.JavaMail.zimbra@redhat.com> In-Reply-To: <1469102746-20588-1-git-send-email-lvivier@redhat.com> References: <1469102746-20588-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] spapr: fix spapr-nvram migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, thuth@redhat.com, dgibson@redhat.com > When spapr-nvram is backed by a file using pflash interface, > migration fails on the destination guest with assert: > > bdrv_co_pwritev: Assertion `!(bs->open_flags & 0x0800)' failed. > > This avoids the problem by delaying the pflash update until after > the device loads complete. > > This fix is similar to the one for the pflash_cfi01 migration: > > 90c647d Fix pflash migration > > Signed-off-by: Laurent Vivier > --- > hw/nvram/spapr_nvram.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) > > diff --git a/hw/nvram/spapr_nvram.c b/hw/nvram/spapr_nvram.c > index 019f25d..4de5f70 100644 > --- a/hw/nvram/spapr_nvram.c > +++ b/hw/nvram/spapr_nvram.c > @@ -39,6 +39,7 @@ typedef struct sPAPRNVRAM { > uint32_t size; > uint8_t *buf; > BlockBackend *blk; > + VMChangeStateEntry *vmstate; > } sPAPRNVRAM; > > #define TYPE_VIO_SPAPR_NVRAM "spapr-nvram" Reviewed-by: Paolo Bonzini Perhaps spapr_nvram.c should have been in hw/block, or pflash should be moved to hw/nvram. Paolo > @@ -185,19 +186,25 @@ static int spapr_nvram_pre_load(void *opaque) > return 0; > } > > +static void postload_update_cb(void *opaque, int running, RunState state) > +{ > + sPAPRNVRAM *nvram = opaque; > + > + /* This is called after bdrv_invalidate_cache_all. */ > + > + qemu_del_vm_change_state_handler(nvram->vmstate); > + nvram->vmstate = NULL; > + > + blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0); > +} > + > static int spapr_nvram_post_load(void *opaque, int version_id) > { > sPAPRNVRAM *nvram = VIO_SPAPR_NVRAM(opaque); > > if (nvram->blk) { > - int alen = blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0); > - > - if (alen < 0) { > - return alen; > - } > - if (alen != nvram->size) { > - return -1; > - } > + nvram->vmstate = > qemu_add_vm_change_state_handler(postload_update_cb, > + nvram); > } > > return 0; > -- > 2.5.5 > >