Blame SOURCES/kvm-qcow2-Use-qcow2_signal_corruption-for-overlaps.patch

9ae3a8
From e7eca18cb5fec2c7c99b8e0335d630cc368f712b Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Sat, 13 Jun 2015 16:22:03 +0200
9ae3a8
Subject: [PATCH 09/42] qcow2: Use qcow2_signal_corruption() for overlaps
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
Message-id: <1434212556-3927-10-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 66028
9ae3a8
O-Subject: [RHEL-7.2 qemu-kvm PATCH 09/42] qcow2: Use qcow2_signal_corruption() for overlaps
9ae3a8
Bugzilla: 1129893
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
BZ: 1129893
9ae3a8
9ae3a8
Use the new function in case of a failed overlap check.
9ae3a8
9ae3a8
This changes output in case of corruption, so adapt iotest 060's
9ae3a8
reference output accordingly.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Reviewed-by: BenoƮt Canet <benoit.canet@nodalink.com>
9ae3a8
Message-id: 1409926039-29044-4-git-send-email-mreitz@redhat.com
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit adb435522b86b3fca2324cb8c94e17b55ae071f1)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Conflicts:
9ae3a8
	block/qcow2-refcount.c
9ae3a8
9ae3a8
qcow2_pre_write_overlap_check() did not use qapi_event_send_*()
9ae3a8
downstream, but that code is being removed anyway.
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
---
9ae3a8
 block/qcow2-refcount.c     | 21 +++------------------
9ae3a8
 tests/qemu-iotests/060.out | 10 +++++-----
9ae3a8
 2 files changed, 8 insertions(+), 23 deletions(-)
9ae3a8
9ae3a8
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
9ae3a8
index 6fa6daf..dbcc4c6 100644
9ae3a8
--- a/block/qcow2-refcount.c
9ae3a8
+++ b/block/qcow2-refcount.c
9ae3a8
@@ -26,7 +26,6 @@
9ae3a8
 #include "block/block_int.h"
9ae3a8
 #include "block/qcow2.h"
9ae3a8
 #include "qemu/range.h"
9ae3a8
-#include "qapi/qmp/types.h"
9ae3a8
 
9ae3a8
 static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size);
9ae3a8
 static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
9ae3a8
@@ -1795,25 +1794,11 @@ int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset,
9ae3a8
         return ret;
9ae3a8
     } else if (ret > 0) {
9ae3a8
         int metadata_ol_bitnr = ffs(ret) - 1;
9ae3a8
-        char *message;
9ae3a8
-        QObject *data;
9ae3a8
-
9ae3a8
         assert(metadata_ol_bitnr < QCOW2_OL_MAX_BITNR);
9ae3a8
 
9ae3a8
-        fprintf(stderr, "qcow2: Preventing invalid write on metadata (overlaps "
9ae3a8
-                "with %s); image marked as corrupt.\n",
9ae3a8
-                metadata_ol_names[metadata_ol_bitnr]);
9ae3a8
-        message = g_strdup_printf("Prevented %s overwrite",
9ae3a8
-                metadata_ol_names[metadata_ol_bitnr]);
9ae3a8
-        data = qobject_from_jsonf("{ 'device': %s, 'msg': %s, 'offset': %"
9ae3a8
-                PRId64 ", 'size': %" PRId64 ", 'fatal': true }",
9ae3a8
-                bs->device_name, message, offset, size);
9ae3a8
-        monitor_protocol_event(QEVENT_BLOCK_IMAGE_CORRUPTED, data);
9ae3a8
-        g_free(message);
9ae3a8
-        qobject_decref(data);
9ae3a8
-
9ae3a8
-        qcow2_mark_corrupt(bs);
9ae3a8
-        bs->drv = NULL; /* make BDS unusable */
9ae3a8
+        qcow2_signal_corruption(bs, true, offset, size, "Preventing invalid "
9ae3a8
+                                "write on metadata (overlaps with %s)",
9ae3a8
+                                metadata_ol_names[metadata_ol_bitnr]);
9ae3a8
         return -EIO;
9ae3a8
     }
9ae3a8
 
9ae3a8
diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out
9ae3a8
index c27c952..30806da 100644
9ae3a8
--- a/tests/qemu-iotests/060.out
9ae3a8
+++ b/tests/qemu-iotests/060.out
9ae3a8
@@ -8,7 +8,7 @@ ERROR cluster 3 refcount=1 reference=3
9ae3a8
 1 errors were found on the image.
9ae3a8
 Data may be corrupted, or further writes to the image may corrupt it.
9ae3a8
 incompatible_features     0x0
9ae3a8
-qcow2: Preventing invalid write on metadata (overlaps with active L1 table); image marked as corrupt.
9ae3a8
+qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with active L1 table); further corruption events will be suppressed
9ae3a8
 write failed: Input/output error
9ae3a8
 incompatible_features     0x2
9ae3a8
 qemu-io: can't open device TEST_DIR/t.IMGFMT: IMGFMT: Image is corrupt; cannot be opened read/write
9ae3a8
@@ -24,7 +24,7 @@ ERROR cluster 2 refcount=1 reference=2
9ae3a8
 2 errors were found on the image.
9ae3a8
 Data may be corrupted, or further writes to the image may corrupt it.
9ae3a8
 incompatible_features     0x0
9ae3a8
-qcow2: Preventing invalid write on metadata (overlaps with refcount block); image marked as corrupt.
9ae3a8
+qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with refcount block); further corruption events will be suppressed
9ae3a8
 write failed: Input/output error
9ae3a8
 incompatible_features     0x2
9ae3a8
 Repairing refcount block 0 refcount=2
9ae3a8
@@ -56,7 +56,7 @@ Data may be corrupted, or further writes to the image may corrupt it.
9ae3a8
 1 leaked clusters were found on the image.
9ae3a8
 This means waste of disk space, but no harm to data.
9ae3a8
 incompatible_features     0x0
9ae3a8
-qcow2: Preventing invalid write on metadata (overlaps with inactive L2 table); image marked as corrupt.
9ae3a8
+qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with inactive L2 table); further corruption events will be suppressed
9ae3a8
 write failed: Input/output error
9ae3a8
 incompatible_features     0x2
9ae3a8
 Repairing cluster 4 refcount=1 reference=2
9ae3a8
@@ -88,7 +88,7 @@ wrote 65536/65536 bytes at offset 536870912
9ae3a8
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
 discard 65536/65536 bytes at offset 0
9ae3a8
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
-qcow2: Preventing invalid write on metadata (overlaps with active L2 table); image marked as corrupt.
9ae3a8
+qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with active L2 table); further corruption events will be suppressed
9ae3a8
 blkdebug: Suspended request '0'
9ae3a8
 write failed: Input/output error
9ae3a8
 blkdebug: Resuming request '0'
9ae3a8
@@ -99,6 +99,6 @@ aio_write failed: No medium found
9ae3a8
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
9ae3a8
 wrote 65536/65536 bytes at offset 0
9ae3a8
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
-qcow2: Preventing invalid write on metadata (overlaps with qcow2_header); image marked as corrupt.
9ae3a8
+qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed
9ae3a8
 write failed: Input/output error
9ae3a8
 *** done
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8