From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43314) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQUXJ-0000DV-IH for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQUXE-00048m-99 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:16 -0400 Received: from ozlabs.org ([103.22.144.67]:49520) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQUXD-00048S-U6 for qemu-devel@nongnu.org; Fri, 22 Jul 2016 03:06:12 -0400 Date: Fri, 22 Jul 2016 16:47:50 +1000 From: David Gibson Message-ID: <20160722064750.GV15941@voom.fritz.box> References: <1469102746-20588-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="59coWm5189RNS6mf" Content-Disposition: inline In-Reply-To: <1469102746-20588-1-git-send-email-lvivier@redhat.com> 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, pbonzini@redhat.com --59coWm5189RNS6mf Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 21, 2016 at 02:05:46PM +0200, Laurent Vivier wrote: > When spapr-nvram is backed by a file using pflash interface, > migration fails on the destination guest with assert: >=20 > bdrv_co_pwritev: Assertion `!(bs->open_flags & 0x0800)' failed. >=20 > This avoids the problem by delaying the pflash update until after > the device loads complete. >=20 > This fix is similar to the one for the pflash_cfi01 migration: >=20 > 90c647d Fix pflash migration >=20 > Signed-off-by: Laurent Vivier It's a bit sad we lose the error checking, but I can't see any easy way around that, so I've applied to ppc-for-2.7. > --- > hw/nvram/spapr_nvram.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) >=20 > 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; > =20 > #define TYPE_VIO_SPAPR_NVRAM "spapr-nvram" > @@ -185,19 +186,25 @@ static int spapr_nvram_pre_load(void *opaque) > return 0; > } > =20 > +static void postload_update_cb(void *opaque, int running, RunState state) > +{ > + sPAPRNVRAM *nvram =3D opaque; > + > + /* This is called after bdrv_invalidate_cache_all. */ > + > + qemu_del_vm_change_state_handler(nvram->vmstate); > + nvram->vmstate =3D NULL; > + > + blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, 0); > +} > + > static int spapr_nvram_post_load(void *opaque, int version_id) > { > sPAPRNVRAM *nvram =3D VIO_SPAPR_NVRAM(opaque); > =20 > if (nvram->blk) { > - int alen =3D blk_pwrite(nvram->blk, 0, nvram->buf, nvram->size, = 0); > - > - if (alen < 0) { > - return alen; > - } > - if (alen !=3D nvram->size) { > - return -1; > - } > + nvram->vmstate =3D qemu_add_vm_change_state_handler(postload_upd= ate_cb, > + nvram); > } > =20 > return 0; --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --59coWm5189RNS6mf Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXkcGVAAoJEGw4ysog2bOS7TwQAI6RayOcpifPSRTA2zZvMOEX hWytddGH6G27I9E/qfp2kfyPJ0fJhYEFtVnNCWg9bMARyBh8xyP9ld4seSUsSK9E WRwwql/7uzLSBcl7tZHA77kKAc/Oi/8CO1tBqGRO1NxZ1cwpbKkAEwC3fsL4hQnC 8W/hbNNi8v0NuMCvMR7mSGkL3stnsNJUp1Tr8OCCK3wKq6t1qmy7+GrR30Ca50Iu +eOM7lvN/eIy0rZEcsxDgouHUANcl/szCGFfposoorbKFcSjpXAFyWb1+EvFEPe4 w7GwO5KMmSnqtobZ4VjDS+bR5aWB0oMYH5XRmxAIn+GBCwuvlKexrFyTaVEfuSSX 6ZxxRR4NMNDoa8B7AS6rJrs1tdBG+M3hr7QIchgyHIESG3nXsDrscAkbRiIywB5w UjjGDt5y+j+enr6wMfZn3D7qUKkhBqJ498yxlLh6MtrHSFdZ8zGUuz1wuoYmNXOG JkSn/6XH+1nSf0n5m4wJz/Iyypu8rPfO7ImbUWjNbCjarXPy46pw6G7mbFd2raXv eni2+6MHd+2eUHtF+W2jNcJrUTor907WTXYAdmUGxYH0Pxad8ihyDzQ0C0fE1kxj FiOuoNnfNGBSCD1yo9QFe28hp5ovuayAeF6QFViYFMeBJ80el9Nd/fBChFLGaLcK BxRo18VjjkKTaAoc9F33 =WSin -----END PGP SIGNATURE----- --59coWm5189RNS6mf--