From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBV5Y-0004df-In for qemu-devel@nongnu.org; Fri, 10 Jun 2016 18:39:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBV5W-0002pV-E0 for qemu-devel@nongnu.org; Fri, 10 Jun 2016 18:39:39 -0400 References: <1465574722-27656-1-git-send-email-kwolf@redhat.com> <1465574722-27656-6-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <575B41A1.5030702@redhat.com> Date: Fri, 10 Jun 2016 16:39:29 -0600 MIME-Version: 1.0 In-Reply-To: <1465574722-27656-6-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="OXItxtaWbip0cIrkR4o3wt0Vd9NDOE4BM" Subject: Re: [Qemu-devel] [PATCH 5/6] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: mreitz@redhat.com, qemu-devel@nongnu.org, famz@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --OXItxtaWbip0cIrkR4o3wt0Vd9NDOE4BM Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/10/2016 10:05 AM, Kevin Wolf wrote: > We don't really want to go through the block layer in order to read fro= m > or write to the vmstate in a qcow2 image. Doing so required a few ugly > hacks like saving and restoring the old image size (because writing to > vmstate offsets would increase the image size) or disabling the "reads > after EOF =3D zeroes" logic. When calling the right functions directly,= > these hacks aren't necessary any more. >=20 > Note that .bdrv_vmstate_load/save() return 0 instead of the number of > bytes in case of success now. >=20 > Signed-off-by: Kevin Wolf > --- > block/qcow2.c | 24 ++++-------------------- > 1 file changed, 4 insertions(+), 20 deletions(-) >=20 > +++ b/block/qcow2.c > @@ -2903,36 +2903,20 @@ static int qcow2_save_vmstate(BlockDriverState = *bs, QEMUIOVector *qiov, > int64_t pos) > { > BDRVQcow2State *s =3D bs->opaque; > - int64_t total_sectors =3D bs->total_sectors; > - bool zero_beyond_eof =3D bs->zero_beyond_eof; > - int ret; > =20 > BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); > - bs->zero_beyond_eof =3D false; > - ret =3D bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov); > - bs->zero_beyond_eof =3D zero_beyond_eof; > - > - /* bdrv_co_do_writev will have increased the total_sectors value t= o include > - * the VM state - the VM state is however not an actual part of th= e block > - * device, therefore, we need to restore the old value. */ > - bs->total_sectors =3D total_sectors; > - > - return ret; > + return bs->drv->bdrv_co_pwritev(bs, qcow2_vm_state_offset(s) + pos= , > + qiov->size, qiov, 0); > } bs->drv->bdrv_co_pwritev() is an optional interface; not all the drivers have it yet. Should you be asserting that it exists, and/or returning an error if it does not? > =20 > static int qcow2_load_vmstate(BlockDriverState *bs, QEMUIOVector *qiov= , > int64_t pos) > { > BDRVQcow2State *s =3D bs->opaque; > - bool zero_beyond_eof =3D bs->zero_beyond_eof; > - int ret; > =20 > BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD); > - bs->zero_beyond_eof =3D false; > - ret =3D bdrv_preadv(bs, qcow2_vm_state_offset(s) + pos, qiov); > - bs->zero_beyond_eof =3D zero_beyond_eof; > - > - return ret; > + return bs->drv->bdrv_co_preadv(bs, qcow2_vm_state_offset(s) + pos,= > + qiov->size, qiov, 0); Ditto. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --OXItxtaWbip0cIrkR4o3wt0Vd9NDOE4BM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXW0GhAAoJEKeha0olJ0Nqh5cH/12r0ehKMUJ86GEFzeeJ2mDP ghCRJIY6/aNngLhy3h4cmHE2/AxyYkX3Kd7/GfV+jKKzYaiBN0JgaSOiysQqjQ0x byph/5Qrz70m1sGRsxZDPlMVN9dVIa63w8RXdZLglJrkGMRAwGaBszmF+ows6Qp9 j3nhJjVbHHFvZ3bXvGLpwH5iG9q9PolMiiGUOWMKGmRcPGed8GlV/BFMbDHDdzAs Tb/vN6aZRvzXDQYp5jApA+UksCmHPSkuCWs7VUs61jmhPHRhxNY3qWch0ACE6oWd W4U0WcgcJ4tnAcvPaMKAb0d8b3Tkq9rLotZKggcguxlj4ntXAeKjlyWFqOO4uME= =jiR0 -----END PGP SIGNATURE----- --OXItxtaWbip0cIrkR4o3wt0Vd9NDOE4BM--