From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWXuu-0007iB-EP for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWXuq-000249-AS for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:51:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58937) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWXuq-00023y-33 for qemu-devel@nongnu.org; Mon, 31 Aug 2015 18:51:04 -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> <55E4D79E.2020506@redhat.com> From: Eric Blake Message-ID: <55E4DA51.4030106@redhat.com> Date: Mon, 31 Aug 2015 16:50:57 -0600 MIME-Version: 1.0 In-Reply-To: <55E4D79E.2020506@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lvhnuJet2dXu1nTwBMiLxfBk4dJ4hfFM8" 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, den@openvz.org, pbonzini@redhat.com, jsnow@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --lvhnuJet2dXu1nTwBMiLxfBk4dJ4hfFM8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/31/2015 04:39 PM, Eric Blake wrote: >>>> +++ 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.. >=20 > 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 hav= e > broken our bitmaps) This code is attempting to do the error recovery if an older qemu opened the file for writing and thus cleared the unknown bit. But silently dropping the probably-corrupt bitmaps is not nice; an error message would be nicer, as well as requiring an explicit 'qemu-img check -r' as the way to recover the space occupied by the bitmaps. And thinking about it a bit more, I wonder if we should (independently) add a new safety flag into qemu and/or qemu-img, which allows the user the option to refuse to open a file read-write if the file contains an autoclear flag that is not recognized, rather than the current default of opening the file anyways and clearing the bit. The default behavior is safe but may cause data loss (where presumably the lost data is not that important, or we would have made it an incompatible feature bit instead of an autoclear bit), so the safety flag would give users a bit more control on whether they are okay with modifying a file knowing that the modifications will clear the feature. But I guess 'qemu-img info' already knows how to report unknown autoclear bits (thanks to the feature name table extension header) in a read-only manner, so it is already possible to do a read-only probe of a file to see if it contains unknown autoclear bits before doing a read-write open; and maybe we don't need a safety flag after all. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --lvhnuJet2dXu1nTwBMiLxfBk4dJ4hfFM8 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/ iQEcBAEBCAAGBQJV5NpRAAoJEKeha0olJ0NqwfYH/jk7wafaYQpPngTDpKWqZLB1 +E8SF2NjfkKpNSnsMHJt1eZ6REQpkTUG/pyF9Qh3UZz7MYAR/SxwIrgHHouvfxBp 7HRO44+3pdibwRKRdFWD5RTISgMvN3+F66M1WabHfWMlHOCGBQMarhWDFKut6KvM p1gTDMARuf4M1GkdnGlY8LOjHgR2zqb1GMSqfji/LpLLIplnMuPXvfkIuoXySzpk qIypTgLQpdsZk3HpSKu2dZQC3v/yVzBWPEz1u/J8HR75MeS3yQ22/KKSxH8yIZiy 4UPcBrwhx4Z9C8z6E0zddLxgOwZY4y5JbNM9GE+iqfFYn4Wi+SXwwklpzOuqBtU= =U3jM -----END PGP SIGNATURE----- --lvhnuJet2dXu1nTwBMiLxfBk4dJ4hfFM8--