|
|
77c23f |
From eccae2f252513d2965ef919022c3ed068da275bd Mon Sep 17 00:00:00 2001
|
|
|
77c23f |
From: Eric Blake <eblake@redhat.com>
|
|
|
77c23f |
Date: Tue, 2 Jun 2020 02:34:20 +0100
|
|
|
77c23f |
Subject: [PATCH 15/26] iotests: Add test 291 to for qemu-img bitmap coverage
|
|
|
77c23f |
|
|
|
77c23f |
RH-Author: Eric Blake <eblake@redhat.com>
|
|
|
77c23f |
Message-id: <20200602023420.2133649-13-eblake@redhat.com>
|
|
|
77c23f |
Patchwork-id: 97079
|
|
|
77c23f |
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 12/12] iotests: Add test 291 to for qemu-img bitmap coverage
|
|
|
77c23f |
Bugzilla: 1779893 1779904
|
|
|
77c23f |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
77c23f |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
77c23f |
|
|
|
77c23f |
Add a new test covering the 'qemu-img bitmap' subcommand, as well as
|
|
|
77c23f |
'qemu-img convert --bitmaps', both added in recent patches.
|
|
|
77c23f |
|
|
|
77c23f |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
77c23f |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
77c23f |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
77c23f |
Message-Id: <20200521192137.1120211-6-eblake@redhat.com>
|
|
|
77c23f |
(cherry picked from commit cf2d1203dcfc2bf964453d83a2302231ce77f2dc)
|
|
|
77c23f |
|
|
|
77c23f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
77c23f |
|
|
|
77c23f |
Conflicts:
|
|
|
77c23f |
tests/qemu-iotests/group - context: other tests not backported
|
|
|
77c23f |
tests/qemu-iotests/291.out - zstd compression not backported
|
|
|
77c23f |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
77c23f |
|
|
|
77c23f |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
77c23f |
---
|
|
|
77c23f |
tests/qemu-iotests/291 | 112 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
77c23f |
tests/qemu-iotests/291.out | 78 +++++++++++++++++++++++++++++++
|
|
|
77c23f |
tests/qemu-iotests/group | 1 +
|
|
|
77c23f |
3 files changed, 191 insertions(+)
|
|
|
77c23f |
create mode 100755 tests/qemu-iotests/291
|
|
|
77c23f |
create mode 100644 tests/qemu-iotests/291.out
|
|
|
77c23f |
|
|
|
77c23f |
diff --git a/tests/qemu-iotests/291 b/tests/qemu-iotests/291
|
|
|
77c23f |
new file mode 100755
|
|
|
77c23f |
index 0000000..3ca83b9
|
|
|
77c23f |
--- /dev/null
|
|
|
77c23f |
+++ b/tests/qemu-iotests/291
|
|
|
77c23f |
@@ -0,0 +1,112 @@
|
|
|
77c23f |
+#!/usr/bin/env bash
|
|
|
77c23f |
+#
|
|
|
77c23f |
+# Test qemu-img bitmap handling
|
|
|
77c23f |
+#
|
|
|
77c23f |
+# Copyright (C) 2018-2020 Red Hat, Inc.
|
|
|
77c23f |
+#
|
|
|
77c23f |
+# This program is free software; you can redistribute it and/or modify
|
|
|
77c23f |
+# it under the terms of the GNU General Public License as published by
|
|
|
77c23f |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
77c23f |
+# (at your option) any later version.
|
|
|
77c23f |
+#
|
|
|
77c23f |
+# This program is distributed in the hope that it will be useful,
|
|
|
77c23f |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
77c23f |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
77c23f |
+# GNU General Public License for more details.
|
|
|
77c23f |
+#
|
|
|
77c23f |
+# You should have received a copy of the GNU General Public License
|
|
|
77c23f |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
77c23f |
+#
|
|
|
77c23f |
+
|
|
|
77c23f |
+seq="$(basename $0)"
|
|
|
77c23f |
+echo "QA output created by $seq"
|
|
|
77c23f |
+
|
|
|
77c23f |
+status=1 # failure is the default!
|
|
|
77c23f |
+
|
|
|
77c23f |
+_cleanup()
|
|
|
77c23f |
+{
|
|
|
77c23f |
+ _cleanup_test_img
|
|
|
77c23f |
+ nbd_server_stop
|
|
|
77c23f |
+}
|
|
|
77c23f |
+trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
77c23f |
+
|
|
|
77c23f |
+# get standard environment, filters and checks
|
|
|
77c23f |
+. ./common.rc
|
|
|
77c23f |
+. ./common.filter
|
|
|
77c23f |
+. ./common.nbd
|
|
|
77c23f |
+
|
|
|
77c23f |
+_supported_fmt qcow2
|
|
|
77c23f |
+_supported_proto file
|
|
|
77c23f |
+_supported_os Linux
|
|
|
77c23f |
+_require_command QEMU_NBD
|
|
|
77c23f |
+
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+echo "=== Initial image setup ==="
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+
|
|
|
77c23f |
+# Create backing image with one bitmap
|
|
|
77c23f |
+TEST_IMG="$TEST_IMG.base" _make_test_img 10M
|
|
|
77c23f |
+$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG.base" b0
|
|
|
77c23f |
+$QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG.base" | _filter_qemu_io
|
|
|
77c23f |
+
|
|
|
77c23f |
+# Create initial image and populate two bitmaps: one active, one inactive.
|
|
|
77c23f |
+ORIG_IMG=$TEST_IMG
|
|
|
77c23f |
+TEST_IMG=$TEST_IMG.orig
|
|
|
77c23f |
+_make_test_img -b "$ORIG_IMG.base" -F $IMGFMT 10M
|
|
|
77c23f |
+$QEMU_IO -c 'w 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
|
|
|
77c23f |
+$QEMU_IMG bitmap --add -g 512k -f $IMGFMT "$TEST_IMG" b1
|
|
|
77c23f |
+$QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b2
|
|
|
77c23f |
+$QEMU_IO -c 'w 3M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
|
|
|
77c23f |
+$QEMU_IMG bitmap --clear -f $IMGFMT "$TEST_IMG" b1
|
|
|
77c23f |
+$QEMU_IO -c 'w 1M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
|
|
|
77c23f |
+$QEMU_IMG bitmap --disable -f $IMGFMT "$TEST_IMG" b1
|
|
|
77c23f |
+$QEMU_IMG bitmap --enable -f $IMGFMT "$TEST_IMG" b2
|
|
|
77c23f |
+$QEMU_IO -c 'w 2M 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
|
|
|
77c23f |
+
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+echo "=== Bitmap preservation not possible to non-qcow2 ==="
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+
|
|
|
77c23f |
+TEST_IMG=$ORIG_IMG
|
|
|
77c23f |
+$QEMU_IMG convert --bitmaps -O raw "$TEST_IMG.orig" "$TEST_IMG" &&
|
|
|
77c23f |
+ echo "unexpected success"
|
|
|
77c23f |
+
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+echo "=== Convert with bitmap preservation ==="
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+
|
|
|
77c23f |
+# Only bitmaps from the active layer are copied
|
|
|
77c23f |
+$QEMU_IMG convert --bitmaps -O qcow2 "$TEST_IMG.orig" "$TEST_IMG"
|
|
|
77c23f |
+$QEMU_IMG info "$TEST_IMG" | _filter_img_info --format-specific
|
|
|
77c23f |
+# But we can also merge in bitmaps from other layers. This test is a bit
|
|
|
77c23f |
+# contrived to cover more code paths, in reality, you could merge directly
|
|
|
77c23f |
+# into b0 without going through tmp
|
|
|
77c23f |
+$QEMU_IMG bitmap --add --disable -f $IMGFMT "$TEST_IMG" b0
|
|
|
77c23f |
+$QEMU_IMG bitmap --add --merge b0 -b "$TEST_IMG.base" -F $IMGFMT \
|
|
|
77c23f |
+ -f $IMGFMT "$TEST_IMG" tmp
|
|
|
77c23f |
+$QEMU_IMG bitmap --merge tmp -f $IMGFMT "$TEST_IMG" b0
|
|
|
77c23f |
+$QEMU_IMG bitmap --remove --image-opts \
|
|
|
77c23f |
+ driver=$IMGFMT,file.driver=file,file.filename="$TEST_IMG" tmp
|
|
|
77c23f |
+$QEMU_IMG info "$TEST_IMG" | _filter_img_info --format-specific
|
|
|
77c23f |
+
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+echo "=== Check bitmap contents ==="
|
|
|
77c23f |
+echo
|
|
|
77c23f |
+
|
|
|
77c23f |
+# x-dirty-bitmap is a hack for reading bitmaps; it abuses block status to
|
|
|
77c23f |
+# report "data":false for portions of the bitmap which are set
|
|
|
77c23f |
+IMG="driver=nbd,server.type=unix,server.path=$nbd_unix_socket"
|
|
|
77c23f |
+nbd_server_start_unix_socket -r -f qcow2 -B b0 "$TEST_IMG"
|
|
|
77c23f |
+$QEMU_IMG map --output=json --image-opts \
|
|
|
77c23f |
+ "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b0" | _filter_qemu_img_map
|
|
|
77c23f |
+nbd_server_start_unix_socket -r -f qcow2 -B b1 "$TEST_IMG"
|
|
|
77c23f |
+$QEMU_IMG map --output=json --image-opts \
|
|
|
77c23f |
+ "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b1" | _filter_qemu_img_map
|
|
|
77c23f |
+nbd_server_start_unix_socket -r -f qcow2 -B b2 "$TEST_IMG"
|
|
|
77c23f |
+$QEMU_IMG map --output=json --image-opts \
|
|
|
77c23f |
+ "$IMG,x-dirty-bitmap=qemu:dirty-bitmap:b2" | _filter_qemu_img_map
|
|
|
77c23f |
+
|
|
|
77c23f |
+# success, all done
|
|
|
77c23f |
+echo '*** done'
|
|
|
77c23f |
+rm -f $seq.full
|
|
|
77c23f |
+status=0
|
|
|
77c23f |
diff --git a/tests/qemu-iotests/291.out b/tests/qemu-iotests/291.out
|
|
|
77c23f |
new file mode 100644
|
|
|
77c23f |
index 0000000..14e5cfc
|
|
|
77c23f |
--- /dev/null
|
|
|
77c23f |
+++ b/tests/qemu-iotests/291.out
|
|
|
77c23f |
@@ -0,0 +1,78 @@
|
|
|
77c23f |
+QA output created by 291
|
|
|
77c23f |
+
|
|
|
77c23f |
+=== Initial image setup ===
|
|
|
77c23f |
+
|
|
|
77c23f |
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=10485760
|
|
|
77c23f |
+wrote 1048576/1048576 bytes at offset 3145728
|
|
|
77c23f |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
77c23f |
+Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=10485760 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
|
|
|
77c23f |
+wrote 1048576/1048576 bytes at offset 0
|
|
|
77c23f |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
77c23f |
+wrote 1048576/1048576 bytes at offset 3145728
|
|
|
77c23f |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
77c23f |
+wrote 1048576/1048576 bytes at offset 1048576
|
|
|
77c23f |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
77c23f |
+wrote 1048576/1048576 bytes at offset 2097152
|
|
|
77c23f |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
77c23f |
+
|
|
|
77c23f |
+=== Bitmap preservation not possible to non-qcow2 ===
|
|
|
77c23f |
+
|
|
|
77c23f |
+qemu-img: Format driver 'raw' does not support bitmaps
|
|
|
77c23f |
+
|
|
|
77c23f |
+=== Convert with bitmap preservation ===
|
|
|
77c23f |
+
|
|
|
77c23f |
+image: TEST_DIR/t.IMGFMT
|
|
|
77c23f |
+file format: IMGFMT
|
|
|
77c23f |
+virtual size: 10 MiB (10485760 bytes)
|
|
|
77c23f |
+disk size: 4.39 MiB
|
|
|
77c23f |
+Format specific information:
|
|
|
77c23f |
+ compat: 1.1
|
|
|
77c23f |
+ lazy refcounts: false
|
|
|
77c23f |
+ bitmaps:
|
|
|
77c23f |
+ [0]:
|
|
|
77c23f |
+ flags:
|
|
|
77c23f |
+ name: b1
|
|
|
77c23f |
+ granularity: 524288
|
|
|
77c23f |
+ [1]:
|
|
|
77c23f |
+ flags:
|
|
|
77c23f |
+ [0]: auto
|
|
|
77c23f |
+ name: b2
|
|
|
77c23f |
+ granularity: 65536
|
|
|
77c23f |
+ refcount bits: 16
|
|
|
77c23f |
+ corrupt: false
|
|
|
77c23f |
+image: TEST_DIR/t.IMGFMT
|
|
|
77c23f |
+file format: IMGFMT
|
|
|
77c23f |
+virtual size: 10 MiB (10485760 bytes)
|
|
|
77c23f |
+disk size: 4.48 MiB
|
|
|
77c23f |
+Format specific information:
|
|
|
77c23f |
+ compat: 1.1
|
|
|
77c23f |
+ lazy refcounts: false
|
|
|
77c23f |
+ bitmaps:
|
|
|
77c23f |
+ [0]:
|
|
|
77c23f |
+ flags:
|
|
|
77c23f |
+ name: b1
|
|
|
77c23f |
+ granularity: 524288
|
|
|
77c23f |
+ [1]:
|
|
|
77c23f |
+ flags:
|
|
|
77c23f |
+ [0]: auto
|
|
|
77c23f |
+ name: b2
|
|
|
77c23f |
+ granularity: 65536
|
|
|
77c23f |
+ [2]:
|
|
|
77c23f |
+ flags:
|
|
|
77c23f |
+ name: b0
|
|
|
77c23f |
+ granularity: 65536
|
|
|
77c23f |
+ refcount bits: 16
|
|
|
77c23f |
+ corrupt: false
|
|
|
77c23f |
+
|
|
|
77c23f |
+=== Check bitmap contents ===
|
|
|
77c23f |
+
|
|
|
77c23f |
+[{ "start": 0, "length": 3145728, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
|
77c23f |
+{ "start": 3145728, "length": 1048576, "depth": 0, "zero": false, "data": false},
|
|
|
77c23f |
+{ "start": 4194304, "length": 6291456, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
77c23f |
+[{ "start": 0, "length": 1048576, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
|
77c23f |
+{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": false},
|
|
|
77c23f |
+{ "start": 2097152, "length": 8388608, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
77c23f |
+[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true, "offset": OFFSET},
|
|
|
77c23f |
+{ "start": 2097152, "length": 1048576, "depth": 0, "zero": false, "data": false},
|
|
|
77c23f |
+{ "start": 3145728, "length": 7340032, "depth": 0, "zero": false, "data": true, "offset": OFFSET}]
|
|
|
77c23f |
+*** done
|
|
|
77c23f |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
77c23f |
index 9c565cf..033b54d 100644
|
|
|
77c23f |
--- a/tests/qemu-iotests/group
|
|
|
77c23f |
+++ b/tests/qemu-iotests/group
|
|
|
77c23f |
@@ -290,3 +290,4 @@
|
|
|
77c23f |
280 rw migration quick
|
|
|
77c23f |
281 rw quick
|
|
|
77c23f |
284 rw
|
|
|
77c23f |
+291 rw quick
|
|
|
77c23f |
--
|
|
|
77c23f |
1.8.3.1
|
|
|
77c23f |
|