yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests-Test-post-backing-convert-target-behavior.patch

ae23c9
From 79f400ed6efa42347cd551a4a2da3ba1688c431c Mon Sep 17 00:00:00 2001
ae23c9
From: Max Reitz <mreitz@redhat.com>
ae23c9
Date: Mon, 18 Jun 2018 18:04:51 +0200
ae23c9
Subject: [PATCH 074/268] iotests: Test post-backing convert target behavior
ae23c9
ae23c9
RH-Author: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: <20180618180451.23808-3-mreitz@redhat.com>
ae23c9
Patchwork-id: 80797
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 2/2] iotests: Test post-backing convert target behavior
ae23c9
Bugzilla: 1527898
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
ae23c9
This adds a test case to 122 for what happens when you convert to a
ae23c9
target with a backing file that is shorter than the target, and the
ae23c9
image format does not support efficient zero writes (as is the case with
ae23c9
qcow2 v2).
ae23c9
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Message-id: 20180501165750.19242-3-mreitz@redhat.com
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit 0682854f899d03c78befce9f5aae4a7e37655d25)
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/122     | 42 ++++++++++++++++++++++++++++++++++++++++++
ae23c9
 tests/qemu-iotests/122.out | 18 ++++++++++++++++++
ae23c9
 2 files changed, 60 insertions(+)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122
ae23c9
index 45b359c..d8c8ad7 100755
ae23c9
--- a/tests/qemu-iotests/122
ae23c9
+++ b/tests/qemu-iotests/122
ae23c9
@@ -77,6 +77,48 @@ $QEMU_IO -c "read -P 0 0 3M" "$TEST_IMG".orig 2>&1 | _filter_qemu_io | _filter_t
ae23c9
 
ae23c9
 
ae23c9
 echo
ae23c9
+echo "=== Converting to an overlay larger than its backing file ==="
ae23c9
+echo
ae23c9
+
ae23c9
+TEST_IMG="$TEST_IMG".base _make_test_img 256M
ae23c9
+# Needs to be at least how much an L2 table covers
ae23c9
+# (64 kB/entry * 64 kB / 8 B/entry = 512 MB)
ae23c9
+# That way, qcow2 will yield at least two status request responses.
ae23c9
+# With just a single response, it would always say "Allocated in the
ae23c9
+# backing file", so the optimization qemu-img convert tries to do is
ae23c9
+# done automatically.  Once it has to be queried twice, however (and
ae23c9
+# one of the queries is completely after the end of the backing file),
ae23c9
+# the block layer will automatically add a ZERO flag that qemu-img
ae23c9
+# convert used to follow up with a zero write to the target.
ae23c9
+# We do not want such a zero write, however, because we are past the
ae23c9
+# end of the backing file on the target as well, so we do not need to
ae23c9
+# write anything there.
ae23c9
+_make_test_img -b "$TEST_IMG".base 768M
ae23c9
+
ae23c9
+# Use compat=0.10 as the output so there is no zero cluster support
ae23c9
+$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -o compat=0.10 \
ae23c9
+    "$TEST_IMG" "$TEST_IMG".orig
ae23c9
+# See that nothing has been allocated past 64M
ae23c9
+$QEMU_IMG map "$TEST_IMG".orig | _filter_qemu_img_map
ae23c9
+
ae23c9
+echo
ae23c9
+
ae23c9
+# Just before the end of the backing file
ae23c9
+$QEMU_IO -c 'write -P 0x11 255M 1M' "$TEST_IMG".base 2>&1 | _filter_qemu_io
ae23c9
+# Somewhere in the second L2 table
ae23c9
+$QEMU_IO -c 'write -P 0x22 600M 1M' "$TEST_IMG" 2>&1 | _filter_qemu_io
ae23c9
+
ae23c9
+$QEMU_IMG convert -O $IMGFMT -B "$TEST_IMG".base -o compat=0.10 \
ae23c9
+    "$TEST_IMG" "$TEST_IMG".orig
ae23c9
+
ae23c9
+$QEMU_IMG map "$TEST_IMG".orig | _filter_qemu_img_map
ae23c9
+$QEMU_IO -c 'read -P 0x11 255M 1M' \
ae23c9
+         -c 'read -P 0x22 600M 1M' \
ae23c9
+         "$TEST_IMG".orig \
ae23c9
+    | _filter_qemu_io
ae23c9
+
ae23c9
+
ae23c9
+echo
ae23c9
 echo "=== Concatenate multiple source images ==="
ae23c9
 echo
ae23c9
 
ae23c9
diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out
ae23c9
index 47d8656..6c7ee1d 100644
ae23c9
--- a/tests/qemu-iotests/122.out
ae23c9
+++ b/tests/qemu-iotests/122.out
ae23c9
@@ -28,6 +28,24 @@ read 3145728/3145728 bytes at offset 0
ae23c9
 read 3145728/3145728 bytes at offset 0
ae23c9
 3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
 
ae23c9
+=== Converting to an overlay larger than its backing file ===
ae23c9
+
ae23c9
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=268435456
ae23c9
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=805306368 backing_file=TEST_DIR/t.IMGFMT.base
ae23c9
+Offset          Length          File
ae23c9
+
ae23c9
+wrote 1048576/1048576 bytes at offset 267386880
ae23c9
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
+wrote 1048576/1048576 bytes at offset 629145600
ae23c9
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
+Offset          Length          File
ae23c9
+0xff00000       0x100000        TEST_DIR/t.IMGFMT.base
ae23c9
+0x25800000      0x100000        TEST_DIR/t.IMGFMT.orig
ae23c9
+read 1048576/1048576 bytes at offset 267386880
ae23c9
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
+read 1048576/1048576 bytes at offset 629145600
ae23c9
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
ae23c9
+
ae23c9
 === Concatenate multiple source images ===
ae23c9
 
ae23c9
 Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=4194304
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9