thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-iotests-Improve-and-rename-test-291-to-qemu-img-bitm.patch

a83cc2
From a6ab9f3d290c2ff3c2fc0187c69cf8cf69feff40 Mon Sep 17 00:00:00 2001
a83cc2
From: Eric Blake <eblake@redhat.com>
a83cc2
Date: Fri, 6 Aug 2021 15:07:47 -0400
a83cc2
Subject: [PATCH 24/39] iotests: Improve and rename test 291 to qemu-img-bitmap
a83cc2
MIME-Version: 1.0
a83cc2
Content-Type: text/plain; charset=UTF-8
a83cc2
Content-Transfer-Encoding: 8bit
a83cc2
a83cc2
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
RH-MergeRequest: 35: Synchronize with RHEL-AV 8.5 release 28 to RHEL 9
a83cc2
RH-Commit: [1/4] bf400ceb9ef48b81c5f7cade97bc1cbf7bc4842c (mrezanin/centos-src-qemu-kvm)
a83cc2
RH-Bugzilla: 1957194
a83cc2
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
a83cc2
a83cc2
Enhance the test to demonstrate existing less-than-stellar behavior of
a83cc2
qemu-img with a qcow2 image containing an inconsistent bitmap: we
a83cc2
don't diagnose the problem until after copying the entire image (a
a83cc2
potentially long time), and when we do diagnose the failure, we still
a83cc2
end up leaving an empty bitmap in the destination.  This mess will be
a83cc2
cleaned up in the next patch.
a83cc2
a83cc2
While at it, rename the test now that we support useful iotest names,
a83cc2
and fix a missing newline in the error message thus exposed.
a83cc2
a83cc2
Signed-off-by: Eric Blake <eblake@redhat.com>
a83cc2
Message-Id: <20210709153951.2801666-2-eblake@redhat.com>
a83cc2
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
a83cc2
Reviewed-by: Nir Soffer <nsoffer@redhat.com>
a83cc2
a83cc2
(cherry picked from commit 94075c28eea0755173939dfaf1eae688b224a74e)
a83cc2
Conflicts:
a83cc2
	tests/qemu-iotests/tests/qemu-img-bitmaps.out - commit 8417e1378c not backported
a83cc2
Signed-off-by: Eric Blake <eblake@redhat.com>
a83cc2
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
a83cc2
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
a83cc2
---
a83cc2
 block/dirty-bitmap.c                          |  2 +-
a83cc2
 .../{291 => tests/qemu-img-bitmaps}           | 21 +++++++-
a83cc2
 .../{291.out => tests/qemu-img-bitmaps.out}   | 49 ++++++++++++++++++-
a83cc2
 3 files changed, 69 insertions(+), 3 deletions(-)
a83cc2
 rename tests/qemu-iotests/{291 => tests/qemu-img-bitmaps} (87%)
a83cc2
 rename tests/qemu-iotests/{291.out => tests/qemu-img-bitmaps.out} (75%)
a83cc2
a83cc2
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
a83cc2
index 68d295d6e3..0ef46163e3 100644
a83cc2
--- a/block/dirty-bitmap.c
a83cc2
+++ b/block/dirty-bitmap.c
a83cc2
@@ -193,7 +193,7 @@ int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap *bitmap, uint32_t flags,
a83cc2
         error_setg(errp, "Bitmap '%s' is inconsistent and cannot be used",
a83cc2
                    bitmap->name);
a83cc2
         error_append_hint(errp, "Try block-dirty-bitmap-remove to delete"
a83cc2
-                          " this bitmap from disk");
a83cc2
+                          " this bitmap from disk\n");
a83cc2
         return -1;
a83cc2
     }
a83cc2
 
a83cc2
diff --git a/tests/qemu-iotests/291 b/tests/qemu-iotests/tests/qemu-img-bitmaps
a83cc2
similarity index 87%
a83cc2
rename from tests/qemu-iotests/291
a83cc2
rename to tests/qemu-iotests/tests/qemu-img-bitmaps
a83cc2
index 20efb080a6..409c4497a3 100755
a83cc2
--- a/tests/qemu-iotests/291
a83cc2
+++ b/tests/qemu-iotests/tests/qemu-img-bitmaps
a83cc2
@@ -3,7 +3,7 @@
a83cc2
 #
a83cc2
 # Test qemu-img bitmap handling
a83cc2
 #
a83cc2
-# Copyright (C) 2018-2020 Red Hat, Inc.
a83cc2
+# Copyright (C) 2018-2021 Red Hat, Inc.
a83cc2
 #
a83cc2
 # This program is free software; you can redistribute it and/or modify
a83cc2
 # it under the terms of the GNU General Public License as published by
a83cc2
@@ -27,11 +27,13 @@ status=1 # failure is the default!
a83cc2
 _cleanup()
a83cc2
 {
a83cc2
     _cleanup_test_img
a83cc2
+    _rm_test_img "$TEST_IMG.copy"
a83cc2
     nbd_server_stop
a83cc2
 }
a83cc2
 trap "_cleanup; exit \$status" 0 1 2 3 15
a83cc2
 
a83cc2
 # get standard environment, filters and checks
a83cc2
+cd ..
a83cc2
 . ./common.rc
a83cc2
 . ./common.filter
a83cc2
 . ./common.nbd
a83cc2
@@ -129,6 +131,23 @@ $QEMU_IMG map --output=json --image-opts \
a83cc2
 
a83cc2
 nbd_server_stop
a83cc2
 
a83cc2
+echo
a83cc2
+echo "=== Check handling of inconsistent bitmap ==="
a83cc2
+echo
a83cc2
+
a83cc2
+# Prepare image with corrupted bitmap
a83cc2
+$QEMU_IO -c abort "$TEST_IMG" 2>/dev/null
a83cc2
+$QEMU_IMG bitmap --add "$TEST_IMG" b4
a83cc2
+$QEMU_IMG bitmap --remove "$TEST_IMG" b1
a83cc2
+_img_info --format-specific | _filter_irrelevant_img_info
a83cc2
+echo
a83cc2
+$QEMU_IMG convert --bitmaps -O qcow2 "$TEST_IMG" "$TEST_IMG.copy" &&
a83cc2
+    echo "unexpected success"
a83cc2
+# Bug - even though we failed at conversion, we left a file around with
a83cc2
+# a bitmap marked as not corrupt
a83cc2
+TEST_IMG=$TEST_IMG.copy _img_info --format-specific \
a83cc2
+    | _filter_irrelevant_img_info
a83cc2
+
a83cc2
 # success, all done
a83cc2
 echo '*** done'
a83cc2
 rm -f $seq.full
a83cc2
diff --git a/tests/qemu-iotests/291.out b/tests/qemu-iotests/tests/qemu-img-bitmaps.out
a83cc2
similarity index 75%
a83cc2
rename from tests/qemu-iotests/291.out
a83cc2
rename to tests/qemu-iotests/tests/qemu-img-bitmaps.out
a83cc2
index 23411c0ff4..543b028da6 100644
a83cc2
--- a/tests/qemu-iotests/291.out
a83cc2
+++ b/tests/qemu-iotests/tests/qemu-img-bitmaps.out
a83cc2
@@ -1,4 +1,4 @@
a83cc2
-QA output created by 291
a83cc2
+QA output created by qemu-img-bitmaps
a83cc2
 
a83cc2
 === Initial image setup ===
a83cc2
 
a83cc2
@@ -115,4 +115,51 @@ Format specific information:
a83cc2
 [{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
a83cc2
 { "start": 2097152, "length": 1048576, "depth": 0, "zero": false, "data": false},
a83cc2
 { "start": 3145728, "length": 7340032, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
a83cc2
+
a83cc2
+=== Check handling of inconsistent bitmap ===
a83cc2
+
a83cc2
+image: TEST_DIR/t.IMGFMT
a83cc2
+file format: IMGFMT
a83cc2
+virtual size: 10 MiB (10485760 bytes)
a83cc2
+cluster_size: 65536
a83cc2
+backing file: TEST_DIR/t.IMGFMT.base
a83cc2
+backing file format: IMGFMT
a83cc2
+Format specific information:
a83cc2
+    bitmaps:
a83cc2
+        [0]:
a83cc2
+            flags:
a83cc2
+                [0]: in-use
a83cc2
+                [1]: auto
a83cc2
+            name: b2
a83cc2
+            granularity: 65536
a83cc2
+        [1]:
a83cc2
+            flags:
a83cc2
+                [0]: in-use
a83cc2
+            name: b0
a83cc2
+            granularity: 65536
a83cc2
+        [2]:
a83cc2
+            flags:
a83cc2
+                [0]: auto
a83cc2
+            name: b4
a83cc2
+            granularity: 65536
a83cc2
+    corrupt: false
a83cc2
+
a83cc2
+qemu-img: Failed to populate bitmap b0: Bitmap 'b0' is inconsistent and cannot be used
a83cc2
+Try block-dirty-bitmap-remove to delete this bitmap from disk
a83cc2
+image: TEST_DIR/t.IMGFMT.copy
a83cc2
+file format: IMGFMT
a83cc2
+virtual size: 10 MiB (10485760 bytes)
a83cc2
+cluster_size: 65536
a83cc2
+Format specific information:
a83cc2
+    bitmaps:
a83cc2
+        [0]:
a83cc2
+            flags:
a83cc2
+            name: b0
a83cc2
+            granularity: 65536
a83cc2
+        [1]:
a83cc2
+            flags:
a83cc2
+                [0]: auto
a83cc2
+            name: b4
a83cc2
+            granularity: 65536
a83cc2
+    corrupt: false
a83cc2
 *** done
a83cc2
-- 
a83cc2
2.27.0
a83cc2