ae23c9
From 425f93585b5a8f45198e91acce68bc0e921c0bf5 Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 18:00:54 +0200
ae23c9
Subject: [PATCH 057/268] qcow2: Do not mark inactive images corrupt
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618180055.22739-3-mreitz@redhat.com>
ae23c9
Patchwork-id: 80793
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/3] qcow2: Do not mark inactive images corrupt
ae23c9
Bugzilla: 1588039
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
ae23c9
When signaling a corruption on a read-only image, qcow2 already makes
ae23c9
fatal events non-fatal (i.e., they will not result in the image being
ae23c9
closed, and the image header's corrupt flag will not be set).  This is
ae23c9
necessary because we cannot set the corrupt flag on read-only images,
ae23c9
and it is possible because further corruption of read-only images is
ae23c9
impossible.
ae23c9
ae23c9
Inactive images are effectively read-only, too, so we should do the same
ae23c9
for them.  bdrv_is_writable() can tell us whether an image can actually
ae23c9
be written to, so use its result instead of !bs->read_only.
ae23c9
ae23c9
(Otherwise, the assert(!(bs->open_flags & BDRV_O_INACTIVE)) in
ae23c9
bdrv_co_pwritev() will fail, crashing qemu.)
ae23c9
ae23c9
Cc: qemu-stable@nongnu.org
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: 20180606193702.7113-3-mreitz@redhat.com
ae23c9
Reviewed-by: John Snow <jsnow@redhat.com>
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit ddf3b47ef4b5ed0bf6558d4c2c8ae130b8d8a580)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/qcow2.c | 2 +-
ae23c9
 1 file changed, 1 insertion(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/block/qcow2.c b/block/qcow2.c
ae23c9
index 35842c5..26a6a7f 100644
ae23c9
--- a/block/qcow2.c
ae23c9
+++ b/block/qcow2.c
ae23c9
@@ -4383,7 +4383,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
ae23c9
     char *message;
ae23c9
     va_list ap;
ae23c9
 
ae23c9
-    fatal = fatal && !bs->read_only;
ae23c9
+    fatal = fatal && bdrv_is_writable(bs);
ae23c9
 
ae23c9
     if (s->signaled_corruption &&
ae23c9
         (!fatal || (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT)))
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9