From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQzpj-0003Ob-6d for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:22:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQzpe-0002u5-4c for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:22:19 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:59794 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQzpd-0002ts-Qm for qemu-devel@nongnu.org; Mon, 08 Sep 2014 10:22:14 -0400 Date: Mon, 8 Sep 2014 16:21:22 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140908142122.GE22582@irqsave.net> References: <1409926039-29044-1-git-send-email-mreitz@redhat.com> <1409926039-29044-4-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1409926039-29044-4-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 3/5] qcow2: Use qcow2_signal_corruption() for overlaps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi The Friday 05 Sep 2014 =E0 16:07:17 (+0200), Max Reitz wrote : > Use the new function in case of a failed overlap check. >=20 > This changes output in case of corruption, so adapt iotest 060's > reference output accordingly. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 24 +++--------------------- > tests/qemu-iotests/060.out | 10 +++++----- > 2 files changed, 8 insertions(+), 26 deletions(-) >=20 > diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c > index 0bd75d2..b9d421e 100644 > --- a/block/qcow2-refcount.c > +++ b/block/qcow2-refcount.c > @@ -26,8 +26,6 @@ > #include "block/block_int.h" > #include "block/qcow2.h" > #include "qemu/range.h" > -#include "qapi/qmp/types.h" > -#include "qapi-event.h" > =20 > static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t siz= e); > static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *b= s, > @@ -1838,27 +1836,11 @@ int qcow2_pre_write_overlap_check(BlockDriverSt= ate *bs, int ign, int64_t offset, > return ret; > } else if (ret > 0) { > int metadata_ol_bitnr =3D ffs(ret) - 1; > - char *message; > - > assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR); > =20 > - fprintf(stderr, "qcow2: Preventing invalid write on metadata (= overlaps " > - "with %s); image marked as corrupt.\n", > - metadata_ol_names[metadata_ol_bitnr]); > - message =3D g_strdup_printf("Prevented %s overwrite", > - metadata_ol_names[metadata_ol_bitnr]); > - qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs)= , > - message, > - true, > - offset, > - true, > - size, > - true, > - &error_abort); > - g_free(message); > - > - qcow2_mark_corrupt(bs); > - bs->drv =3D NULL; /* make BDS unusable */ > + qcow2_signal_corruption(bs, true, offset, size, "Preventing in= valid " > + "write on metadata (overlaps with %s)"= , > + metadata_ol_names[metadata_ol_bitnr]); > return -EIO; > } > =20 > diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out > index c27c952..30806da 100644 > --- a/tests/qemu-iotests/060.out > +++ b/tests/qemu-iotests/060.out > @@ -8,7 +8,7 @@ ERROR cluster 3 refcount=3D1 reference=3D3 > 1 errors were found on the image. > Data may be corrupted, or further writes to the image may corrupt it. > incompatible_features 0x0 > -qcow2: Preventing invalid write on metadata (overlaps with active L1 t= able); image marked as corrupt. > +qcow2: Marking image as corrupt: Preventing invalid write on metadata = (overlaps with active L1 table); further corruption events will be suppre= ssed > write failed: Input/output error > incompatible_features 0x2 > qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt= ; cannot be opened read/write > @@ -24,7 +24,7 @@ ERROR cluster 2 refcount=3D1 reference=3D2 > 2 errors were found on the image. > Data may be corrupted, or further writes to the image may corrupt it. > incompatible_features 0x0 > -qcow2: Preventing invalid write on metadata (overlaps with refcount bl= ock); image marked as corrupt. > +qcow2: Marking image as corrupt: Preventing invalid write on metadata = (overlaps with refcount block); further corruption events will be suppres= sed > write failed: Input/output error > incompatible_features 0x2 > Repairing refcount block 0 refcount=3D2 > @@ -56,7 +56,7 @@ Data may be corrupted, or further writes to the image= may corrupt it. > 1 leaked clusters were found on the image. > This means waste of disk space, but no harm to data. > incompatible_features 0x0 > -qcow2: Preventing invalid write on metadata (overlaps with inactive L2= table); image marked as corrupt. > +qcow2: Marking image as corrupt: Preventing invalid write on metadata = (overlaps with inactive L2 table); further corruption events will be supp= ressed > write failed: Input/output error > incompatible_features 0x2 > Repairing cluster 4 refcount=3D1 reference=3D2 > @@ -88,7 +88,7 @@ wrote 65536/65536 bytes at offset 536870912 > 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > discard 65536/65536 bytes at offset 0 > 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -qcow2: Preventing invalid write on metadata (overlaps with active L2 t= able); image marked as corrupt. > +qcow2: Marking image as corrupt: Preventing invalid write on metadata = (overlaps with active L2 table); further corruption events will be suppre= ssed > blkdebug: Suspended request '0' > write failed: Input/output error > blkdebug: Resuming request '0' > @@ -99,6 +99,6 @@ aio_write failed: No medium found > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864=20 > wrote 65536/65536 bytes at offset 0 > 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -qcow2: Preventing invalid write on metadata (overlaps with qcow2_heade= r); image marked as corrupt. > +qcow2: Marking image as corrupt: Preventing invalid write on metadata = (overlaps with qcow2_header); further corruption events will be suppresse= d > write failed: Input/output error > *** done > --=20 > 2.1.0 >=20 >=20 Reviewed-by: Beno=EEt Canet