From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEFyz-0004wT-8M for qemu-devel@nongnu.org; Tue, 27 Aug 2013 05:54:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VEFys-00071u-Kn for qemu-devel@nongnu.org; Tue, 27 Aug 2013 05:54:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:27262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VEFys-00071n-BF for qemu-devel@nongnu.org; Tue, 27 Aug 2013 05:54:34 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7R9sXPP015742 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 27 Aug 2013 05:54:33 -0400 Date: Tue, 27 Aug 2013 11:54:46 +0200 From: Kevin Wolf Message-ID: <20130827095445.GA648@dhcp-200-207.str.redhat.com> References: <1377522260-16676-1-git-send-email-mreitz@redhat.com> <1377522260-16676-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1377522260-16676-2-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH 1/5] qcow2: Add corrupt bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Am 26.08.2013 um 15:04 hat Max Reitz geschrieben: > This adds an incompatible bit indicating corruption to qcow2. Any image > with this bit set may not be written to unless for repairing (and > subsequently clearing the bit if the repair has been successful). > > Signed-off-by: Max Reitz > --- > block/qcow2.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ > block/qcow2.h | 7 ++++++- > docs/specs/qcow2.txt | 7 ++++++- > include/block/block.h | 2 ++ > qemu-img.c | 2 +- > tests/qemu-iotests/031.out | 12 ++++++------ > tests/qemu-iotests/036.out | 2 +- > 7 files changed, 66 insertions(+), 10 deletions(-) > > diff --git a/block/qcow2.c b/block/qcow2.c > index 3376901..1d0d7ca 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -272,6 +272,37 @@ static int qcow2_mark_clean(BlockDriverState *bs) > return 0; > } > > +/* > + * Marks the image as corrupt. > + */ > +int qcow2_mark_corrupt(BlockDriverState *bs) > +{ > + BDRVQcowState *s = bs->opaque; > + > + s->incompatible_features |= QCOW2_INCOMPAT_CORRUPT; > + return qcow2_update_header(bs); > +} > + > +/* > + * Marks the image as consistent, i.e., unsets the corrupt bit, and flushes > + * before if necessary. > + */ > +int qcow2_mark_consistent(BlockDriverState *bs) > +{ > + BDRVQcowState *s = bs->opaque; > + > + if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { > + int ret = bdrv_flush(bs); > + if (ret < 0) { > + return ret; > + } > + > + s->incompatible_features &= ~QCOW2_INCOMPAT_CORRUPT; > + return qcow2_update_header(bs); > + } > + return 0; > +} > + > static int qcow2_check(BlockDriverState *bs, BdrvCheckResult *result, > BdrvCheckMode fix) > { > @@ -402,6 +433,14 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags) > goto fail; > } > > + if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { > + /* Corrupt images may not be written to unless they are being repaired */ > + if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_REPAIR)) { Isn't BDRV_O_REPAIR equivalent to BDRV_O_CHECK && BDRV_O_RDWR, or is there an advantage in using a new bit? Looks good otherwise. Kevin