From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWXjk-00039o-6Y for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWXjg-0004LH-57 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:39:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38596) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWXjf-0004Kt-US for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:39:32 -0400 References: <1433776886-27239-1-git-send-email-vsementsov@virtuozzo.com> <1433776886-27239-7-git-send-email-vsementsov@virtuozzo.com> <20150609155014.GF3181@stefanha-thinkpad.redhat.com> <55DEC00C.8010100@virtuozzo.com> From: Eric Blake Message-ID: <55E4D79E.2020506@redhat.com> Date: Mon, 31 Aug 2015 16:39:26 -0600 MIME-Version: 1.0 In-Reply-To: <55DEC00C.8010100@virtuozzo.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BerWbLnRxOihmcFEk4FmVS83RnWWWk3R4" Subject: Re: [Qemu-devel] [PATCH 6/8] qcow2: add autoclear bit for dirty bitmaps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi Cc: kwolf@redhat.com, qemu-devel@nongnu.org, Vladimir Sementsov-Ogievskiy , stefanha@redhat.com, pbonzini@redhat.com, den@openvz.org, jsnow@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BerWbLnRxOihmcFEk4FmVS83RnWWWk3R4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/27/2015 01:45 AM, Vladimir Sementsov-Ogievskiy wrote: > On 09.06.2015 18:50, Stefan Hajnoczi wrote: >> On Mon, Jun 08, 2015 at 06:21:24PM +0300, Vladimir Sementsov-Ogievskiy= >> wrote: >>> diff --git a/block/qcow2.c b/block/qcow2.c >>> index 406e55d..f85a55a 100644 >>> --- a/block/qcow2.c >>> +++ b/block/qcow2.c >>> @@ -182,6 +182,14 @@ static int >>> qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, >>> return ret; >>> } >>> + if (!(s->autoclear_features & >>> QCOW2_AUTOCLEAR_DIRTY_BITMAPS) && >>> + s->nb_dirty_bitmaps > 0) { >>> + ret =3D qcow2_delete_all_dirty_bitmaps(bs, errp); >>> + if (ret < 0) { >>> + return ret; >>> + } >>> + } >>> + >> What if the file is read-only? >> >> We shouldn't modify the file in qcow2_read_extensions(). > But where? In qcow2_open? Or nowhere? I think auto clear extensions > should be cleared automatically.. Autoclear bits should be cleared ONLY when opening a file for writing, and ONLY if the version of qemu[-img] opening the file does not recognize what the bit controls (or if it does recognize the bit, but is about to perform a semantic action that violates what the bit represents)= =2E We should already be clearing all unrecognized autoclear bits upon opening a file for writing (if not, that's a bug in the current implementation), when executing older qemu[-img]. And after your patch series, we know how to handle dirty bitmaps, so the dirty bitmap autoclear bit should no longer be cleared automatically (it is no longer in the mask of unrecognized autoclear bits). So all we have to do now that we are new-enough qemu[-img] is: 1. be sure to set the autoclear bit any time we write a dirty bitmap (the image can no longer be safely written by an older qemu[-img], because those older executables don't know how to interpret the dirty bitmap extension header and might try to overwrite a cluster that we have tied up in a dirty bitmap) 2. clear the bit if we are removing the last dirty bitmap from an image (optimization that is not strictly necessary; but lets older qemu[-img] once again be able to write to the file without the risk of corrupting it= ) 3. add in error reporting in case the autoclear bit is clear but the dirty bitmap header extension is present with a non-zero number of bitmaps (the autoclear bit served its purpose: an older qemu[-img] has opened the file for writing since new qemu last handled it, and may have broken our bitmaps) Since opening a file read-only cannot (further) corrupt the image, it also does not need to clear any autoclear bits. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --BerWbLnRxOihmcFEk4FmVS83RnWWWk3R4 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/ iQEcBAEBCAAGBQJV5NeeAAoJEKeha0olJ0NqgT0IAKXfjcsMpqpraaNBCg3fwjLh 5ql0dys7ujHb6NUvD8d306MIC+beJm9GABz5VlF5UhNSZvEi6E7oeDHhZmu2a9Jo 09VninJ5gwM/gIVaTczMgqw4cxM/rBRX+VQQc0R8os6r2uHMn9Yt2D1RoLl2bytt OZ/zL4b12bGxlAqwAWyyKCGlDKT5Z6U75NwOALenGlgiShzFvpzsXVJysb1r3Xlh 2nM9J39yuYZfq8iKh5vKhlsJX3Pj8QGPIVr8FLlILVugz9rRQkJ4r1ydQe/PWTw6 K3Ly0Yus8o5c05XoNBGtrX4phNXgISV8v6jCsrR3dZlGoPJOitfegneOjMtl9us= =sIMk -----END PGP SIGNATURE----- --BerWbLnRxOihmcFEk4FmVS83RnWWWk3R4--