cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests-Add-test-for-rebasing-with-relative-paths.patch

26ba25
From 165fabd12568ce69a14a541c762267f7a1d161d1 Mon Sep 17 00:00:00 2001
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
Date: Mon, 18 Jun 2018 17:48:33 +0200
26ba25
Subject: [PATCH 072/268] iotests: Add test for rebasing with relative paths
26ba25
26ba25
RH-Author: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: <20180618174833.19439-3-mreitz@redhat.com>
26ba25
Patchwork-id: 80789
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/2] iotests: Add test for rebasing with relative paths
26ba25
Bugzilla: 1569835
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Message-id: 20180509182002.8044-3-mreitz@redhat.com
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
(cherry picked from commit 28036a7f7044fddb79819e3c8fcb4ae5605c60e0)
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 tests/qemu-iotests/024     | 82 ++++++++++++++++++++++++++++++++++++++++++++--
26ba25
 tests/qemu-iotests/024.out | 30 +++++++++++++++++
26ba25
 2 files changed, 109 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
26ba25
index e0d77ce..4071ed6 100755
26ba25
--- a/tests/qemu-iotests/024
26ba25
+++ b/tests/qemu-iotests/024
26ba25
@@ -29,9 +29,14 @@ status=1	# failure is the default!
26ba25
 
26ba25
 _cleanup()
26ba25
 {
26ba25
-	_cleanup_test_img
26ba25
-	rm -f "$TEST_DIR/t.$IMGFMT.base_old"
26ba25
-	rm -f "$TEST_DIR/t.$IMGFMT.base_new"
26ba25
+    _cleanup_test_img
26ba25
+    rm -f "$TEST_DIR/t.$IMGFMT.base_old"
26ba25
+    rm -f "$TEST_DIR/t.$IMGFMT.base_new"
26ba25
+
26ba25
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT"
26ba25
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old"
26ba25
+    rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new"
26ba25
+    rmdir "$TEST_DIR/subdir" 2> /dev/null
26ba25
 }
26ba25
 trap "_cleanup; exit \$status" 0 1 2 3 15
26ba25
 
26ba25
@@ -123,6 +128,77 @@ io_pattern readv $((13 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
26ba25
 io_pattern readv $((14 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x11
26ba25
 io_pattern readv $((15 * CLUSTER_SIZE)) $CLUSTER_SIZE 0 1 0x00
26ba25
 
26ba25
+echo
26ba25
+echo "=== Test rebase in a subdirectory of the working directory ==="
26ba25
+echo
26ba25
+
26ba25
+# Clean up the old images beforehand so they do not interfere with
26ba25
+# this test
26ba25
+_cleanup
26ba25
+
26ba25
+mkdir "$TEST_DIR/subdir"
26ba25
+
26ba25
+# Relative to the overlay
26ba25
+BASE_OLD_OREL="t.$IMGFMT.base_old"
26ba25
+BASE_NEW_OREL="t.$IMGFMT.base_new"
26ba25
+
26ba25
+# Relative to $TEST_DIR (which is going to be our working directory)
26ba25
+OVERLAY_WREL="subdir/t.$IMGFMT"
26ba25
+
26ba25
+BASE_OLD="$TEST_DIR/subdir/$BASE_OLD_OREL"
26ba25
+BASE_NEW="$TEST_DIR/subdir/$BASE_NEW_OREL"
26ba25
+OVERLAY="$TEST_DIR/$OVERLAY_WREL"
26ba25
+
26ba25
+# Test done here:
26ba25
+#
26ba25
+# Backing (old): 11 11 -- 11
26ba25
+# Backing (new): -- 22 22 11
26ba25
+# Overlay:       -- -- -- --
26ba25
+#
26ba25
+# Rebasing works, we have verified that above.  Here, we just want to
26ba25
+# see that rebasing is done for the correct target backing file.
26ba25
+
26ba25
+TEST_IMG=$BASE_OLD _make_test_img 1M
26ba25
+TEST_IMG=$BASE_NEW _make_test_img 1M
26ba25
+TEST_IMG=$OVERLAY _make_test_img -b "$BASE_OLD_OREL" 1M
26ba25
+
26ba25
+echo
26ba25
+
26ba25
+$QEMU_IO "$BASE_OLD" \
26ba25
+    -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
26ba25
+    -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
26ba25
+    | _filter_qemu_io
26ba25
+
26ba25
+$QEMU_IO "$BASE_NEW" \
26ba25
+    -c "write -P 0x22 $((1 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
26ba25
+    -c "write -P 0x11 $((3 * CLUSTER_SIZE)) $((1 * CLUSTER_SIZE))" \
26ba25
+    | _filter_qemu_io
26ba25
+
26ba25
+echo
26ba25
+
26ba25
+pushd "$TEST_DIR" >/dev/null
26ba25
+$QEMU_IMG rebase -f "$IMGFMT" -b "$BASE_NEW_OREL" "$OVERLAY_WREL"
26ba25
+popd >/dev/null
26ba25
+
26ba25
+# Verify the backing path is correct
26ba25
+TEST_IMG=$OVERLAY _img_info | grep '^backing file'
26ba25
+
26ba25
+echo
26ba25
+
26ba25
+# Verify the data is correct
26ba25
+$QEMU_IO "$OVERLAY" \
26ba25
+    -c "read -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
26ba25
+    -c "read -P 0x11 $((1 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
26ba25
+    -c "read -P 0x00 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
26ba25
+    -c "read -P 0x11 $((3 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
26ba25
+    | _filter_qemu_io
26ba25
+
26ba25
+echo
26ba25
+
26ba25
+# Verify that cluster #3 is not allocated (because it is the same in
26ba25
+# $BASE_OLD and $BASE_NEW)
26ba25
+$QEMU_IMG map "$OVERLAY" | _filter_qemu_img_map
26ba25
+
26ba25
 
26ba25
 # success, all done
26ba25
 echo "*** done"
26ba25
diff --git a/tests/qemu-iotests/024.out b/tests/qemu-iotests/024.out
26ba25
index 33cfaf5..024dc78 100644
26ba25
--- a/tests/qemu-iotests/024.out
26ba25
+++ b/tests/qemu-iotests/024.out
26ba25
@@ -141,4 +141,34 @@ read 65536/65536 bytes at offset 917504
26ba25
 === IO: pattern 0x00
26ba25
 read 65536/65536 bytes at offset 983040
26ba25
 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+
26ba25
+=== Test rebase in a subdirectory of the working directory ===
26ba25
+
26ba25
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_old', fmt=IMGFMT size=1048576
26ba25
+Formatting 'TEST_DIR/subdir/t.IMGFMT.base_new', fmt=IMGFMT size=1048576
26ba25
+Formatting 'TEST_DIR/subdir/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=t.IMGFMT.base_old
26ba25
+
26ba25
+wrote 131072/131072 bytes at offset 0
26ba25
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+wrote 65536/65536 bytes at offset 196608
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+wrote 131072/131072 bytes at offset 65536
26ba25
+128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+wrote 65536/65536 bytes at offset 196608
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+
26ba25
+backing file: t.IMGFMT.base_new (actual path: TEST_DIR/subdir/t.IMGFMT.base_new)
26ba25
+
26ba25
+read 65536/65536 bytes at offset 0
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+read 65536/65536 bytes at offset 65536
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+read 65536/65536 bytes at offset 131072
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+read 65536/65536 bytes at offset 196608
26ba25
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
26ba25
+
26ba25
+Offset          Length          File
26ba25
+0               0x30000         TEST_DIR/subdir/t.IMGFMT
26ba25
+0x30000         0x10000         TEST_DIR/subdir/t.IMGFMT.base_new
26ba25
 *** done
26ba25
-- 
26ba25
1.8.3.1
26ba25