Blame SOURCES/kvm-iotests-Split-214-off-of-122.patch

1bdc94
From 6de5873f52d3fac1aef3091c1e283530e37c4b02 Mon Sep 17 00:00:00 2001
1bdc94
From: Max Reitz <mreitz@redhat.com>
1bdc94
Date: Mon, 18 Jun 2018 16:12:03 +0200
1bdc94
Subject: [PATCH 27/54] iotests: Split 214 off of 122
1bdc94
1bdc94
RH-Author: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: <20180618161212.14444-2-mreitz@redhat.com>
1bdc94
Patchwork-id: 80761
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 01/10] iotests: Split 214 off of 122
1bdc94
Bugzilla: 1518738
1bdc94
RH-Acked-by: John Snow <jsnow@redhat.com>
1bdc94
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
1bdc94
Commit abd3622cc03cf41ed542126a540385f30a4c0175 added a case to 122
1bdc94
regarding how the qcow2 driver handles an incorrect compressed data
1bdc94
length value.  This does not really fit into 122, as that file is
1bdc94
supposed to contain qemu-img convert test cases, which this case is not.
1bdc94
So this patch splits it off into its own file; maybe we will even get
1bdc94
more qcow2-only compression tests in the future.
1bdc94
1bdc94
Also, that test case does not work with refcount_bits=1, so mark that
1bdc94
option as unsupported.
1bdc94
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Message-id: 20180406164108.26118-1-mreitz@redhat.com
1bdc94
Reviewed-by: Eric Blake <eblake@redhat.com>
1bdc94
Signed-off-by: Alberto Garcia <berto@igalia.com>
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
(cherry picked from commit 6cba5377f54d7ea859a29c1877785e7101794683)
1bdc94
Signed-off-by: Max Reitz <mreitz@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 tests/qemu-iotests/122     | 47 ----------------------
1bdc94
 tests/qemu-iotests/122.out | 33 ----------------
1bdc94
 tests/qemu-iotests/214     | 97 ++++++++++++++++++++++++++++++++++++++++++++++
1bdc94
 tests/qemu-iotests/214.out | 35 +++++++++++++++++
1bdc94
 tests/qemu-iotests/group   |  1 +
1bdc94
 5 files changed, 133 insertions(+), 80 deletions(-)
1bdc94
 create mode 100755 tests/qemu-iotests/214
1bdc94
 create mode 100644 tests/qemu-iotests/214.out
1bdc94
1bdc94
diff --git a/tests/qemu-iotests/122 b/tests/qemu-iotests/122
1bdc94
index 6cf4fcb..45b359c 100755
1bdc94
--- a/tests/qemu-iotests/122
1bdc94
+++ b/tests/qemu-iotests/122
1bdc94
@@ -130,53 +130,6 @@ $QEMU_IO -c "read -P 0    1024k 1022k" "$TEST_IMG" 2>&1 | _filter_qemu_io | _fil
1bdc94
 
1bdc94
 
1bdc94
 echo
1bdc94
-echo "=== Corrupted size field in compressed cluster descriptor ==="
1bdc94
-echo
1bdc94
-# Create an empty image and fill half of it with compressed data.
1bdc94
-# The L2 entries of the two compressed clusters are located at
1bdc94
-# 0x800000 and 0x800008, their original values are 0x4008000000a00000
1bdc94
-# and 0x4008000000a00802 (5 sectors for compressed data each).
1bdc94
-_make_test_img 8M -o cluster_size=2M
1bdc94
-$QEMU_IO -c "write -c -P 0x11 0 2M" -c "write -c -P 0x11 2M 2M" "$TEST_IMG" \
1bdc94
-         2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-
1bdc94
-# Reduce size of compressed data to 4 sectors: this corrupts the image.
1bdc94
-poke_file "$TEST_IMG" $((0x800000)) "\x40\x06"
1bdc94
-$QEMU_IO -c "read  -P 0x11 0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-
1bdc94
-# 'qemu-img check' however doesn't see anything wrong because it
1bdc94
-# doesn't try to decompress the data and the refcounts are consistent.
1bdc94
-# TODO: update qemu-img so this can be detected.
1bdc94
-_check_test_img
1bdc94
-
1bdc94
-# Increase size of compressed data to the maximum (8192 sectors).
1bdc94
-# This makes QEMU read more data (8192 sectors instead of 5, host
1bdc94
-# addresses [0xa00000, 0xdfffff]), but the decompression algorithm
1bdc94
-# stops once we have enough to restore the uncompressed cluster, so
1bdc94
-# the rest of the data is ignored.
1bdc94
-poke_file "$TEST_IMG" $((0x800000)) "\x7f\xfe"
1bdc94
-# Do it also for the second compressed cluster (L2 entry at 0x800008).
1bdc94
-# In this case the compressed data would span 3 host clusters
1bdc94
-# (host addresses: [0xa00802, 0xe00801])
1bdc94
-poke_file "$TEST_IMG" $((0x800008)) "\x7f\xfe"
1bdc94
-
1bdc94
-# Here the image is too small so we're asking QEMU to read beyond the
1bdc94
-# end of the image.
1bdc94
-$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-# But if we grow the image we won't be reading beyond its end anymore.
1bdc94
-$QEMU_IO -c "write -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-
1bdc94
-# The refcount data is however wrong because due to the increased size
1bdc94
-# of the compressed data it now reaches the following host clusters.
1bdc94
-# This can be repaired by qemu-img check by increasing the refcount of
1bdc94
-# those clusters.
1bdc94
-# TODO: update qemu-img to correct the compressed cluster size instead.
1bdc94
-_check_test_img -r all
1bdc94
-$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-$QEMU_IO -c "read  -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
-
1bdc94
-echo
1bdc94
 echo "=== Full allocation with -S 0 ==="
1bdc94
 echo
1bdc94
 
1bdc94
diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out
1bdc94
index a6b7fe0..47d8656 100644
1bdc94
--- a/tests/qemu-iotests/122.out
1bdc94
+++ b/tests/qemu-iotests/122.out
1bdc94
@@ -99,39 +99,6 @@ read 1024/1024 bytes at offset 1047552
1bdc94
 read 1046528/1046528 bytes at offset 1048576
1bdc94
 1022 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
 
1bdc94
-=== Corrupted size field in compressed cluster descriptor ===
1bdc94
-
1bdc94
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=8388608
1bdc94
-wrote 2097152/2097152 bytes at offset 0
1bdc94
-2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-wrote 2097152/2097152 bytes at offset 2097152
1bdc94
-2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-read failed: Input/output error
1bdc94
-No errors were found on the image.
1bdc94
-read 4194304/4194304 bytes at offset 0
1bdc94
-4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-wrote 4194304/4194304 bytes at offset 4194304
1bdc94
-4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-read 4194304/4194304 bytes at offset 0
1bdc94
-4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-ERROR cluster 6 refcount=1 reference=3
1bdc94
-ERROR cluster 7 refcount=1 reference=2
1bdc94
-Repairing cluster 6 refcount=1 reference=3
1bdc94
-Repairing cluster 7 refcount=1 reference=2
1bdc94
-Repairing OFLAG_COPIED data cluster: l2_entry=8000000000c00000 refcount=3
1bdc94
-Repairing OFLAG_COPIED data cluster: l2_entry=8000000000e00000 refcount=2
1bdc94
-The following inconsistencies were found and repaired:
1bdc94
-
1bdc94
-    0 leaked clusters
1bdc94
-    4 corruptions
1bdc94
-
1bdc94
-Double checking the fixed image now...
1bdc94
-No errors were found on the image.
1bdc94
-read 4194304/4194304 bytes at offset 0
1bdc94
-4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-read 4194304/4194304 bytes at offset 4194304
1bdc94
-4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
-
1bdc94
 === Full allocation with -S 0 ===
1bdc94
 
1bdc94
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
1bdc94
diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214
1bdc94
new file mode 100755
1bdc94
index 0000000..c46ca2a
1bdc94
--- /dev/null
1bdc94
+++ b/tests/qemu-iotests/214
1bdc94
@@ -0,0 +1,97 @@
1bdc94
+#!/bin/bash
1bdc94
+#
1bdc94
+# Test qcow2 image compression
1bdc94
+#
1bdc94
+# Copyright (C) 2018 Igalia, S.L.
1bdc94
+# Author: Alberto Garcia <berto@igalia.com>
1bdc94
+#
1bdc94
+# This program is free software; you can redistribute it and/or modify
1bdc94
+# it under the terms of the GNU General Public License as published by
1bdc94
+# the Free Software Foundation; either version 2 of the License, or
1bdc94
+# (at your option) any later version.
1bdc94
+#
1bdc94
+# This program is distributed in the hope that it will be useful,
1bdc94
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1bdc94
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1bdc94
+# GNU General Public License for more details.
1bdc94
+#
1bdc94
+# You should have received a copy of the GNU General Public License
1bdc94
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
1bdc94
+#
1bdc94
+
1bdc94
+seq=$(basename "$0")
1bdc94
+echo "QA output created by $seq"
1bdc94
+
1bdc94
+here=$PWD
1bdc94
+status=1	# failure is the default!
1bdc94
+
1bdc94
+_cleanup()
1bdc94
+{
1bdc94
+    _cleanup_test_img
1bdc94
+}
1bdc94
+trap "_cleanup; exit \$status" 0 1 2 3 15
1bdc94
+
1bdc94
+# get standard environment, filters and checks
1bdc94
+. ./common.rc
1bdc94
+. ./common.filter
1bdc94
+
1bdc94
+_supported_fmt qcow2
1bdc94
+_supported_proto file
1bdc94
+_supported_os Linux
1bdc94
+
1bdc94
+# Repairing the corrupted image requires qemu-img check to store a
1bdc94
+# refcount up to 3, which requires at least two refcount bits.
1bdc94
+_unsupported_imgopts 'refcount_bits=1[^0-9]'
1bdc94
+
1bdc94
+
1bdc94
+echo
1bdc94
+echo "=== Corrupted size field in compressed cluster descriptor ==="
1bdc94
+echo
1bdc94
+# Create an empty image and fill half of it with compressed data.
1bdc94
+# The L2 entries of the two compressed clusters are located at
1bdc94
+# 0x800000 and 0x800008, their original values are 0x4008000000a00000
1bdc94
+# and 0x4008000000a00802 (5 sectors for compressed data each).
1bdc94
+_make_test_img 8M -o cluster_size=2M
1bdc94
+$QEMU_IO -c "write -c -P 0x11 0 2M" -c "write -c -P 0x11 2M 2M" "$TEST_IMG" \
1bdc94
+         2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+
1bdc94
+# Reduce size of compressed data to 4 sectors: this corrupts the image.
1bdc94
+poke_file "$TEST_IMG" $((0x800000)) "\x40\x06"
1bdc94
+$QEMU_IO -c "read  -P 0x11 0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+
1bdc94
+# 'qemu-img check' however doesn't see anything wrong because it
1bdc94
+# doesn't try to decompress the data and the refcounts are consistent.
1bdc94
+# TODO: update qemu-img so this can be detected.
1bdc94
+_check_test_img
1bdc94
+
1bdc94
+# Increase size of compressed data to the maximum (8192 sectors).
1bdc94
+# This makes QEMU read more data (8192 sectors instead of 5, host
1bdc94
+# addresses [0xa00000, 0xdfffff]), but the decompression algorithm
1bdc94
+# stops once we have enough to restore the uncompressed cluster, so
1bdc94
+# the rest of the data is ignored.
1bdc94
+poke_file "$TEST_IMG" $((0x800000)) "\x7f\xfe"
1bdc94
+# Do it also for the second compressed cluster (L2 entry at 0x800008).
1bdc94
+# In this case the compressed data would span 3 host clusters
1bdc94
+# (host addresses: [0xa00802, 0xe00801])
1bdc94
+poke_file "$TEST_IMG" $((0x800008)) "\x7f\xfe"
1bdc94
+
1bdc94
+# Here the image is too small so we're asking QEMU to read beyond the
1bdc94
+# end of the image.
1bdc94
+$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+# But if we grow the image we won't be reading beyond its end anymore.
1bdc94
+$QEMU_IO -c "write -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+
1bdc94
+# The refcount data is however wrong because due to the increased size
1bdc94
+# of the compressed data it now reaches the following host clusters.
1bdc94
+# This can be repaired by qemu-img check by increasing the refcount of
1bdc94
+# those clusters.
1bdc94
+# TODO: update qemu-img to correct the compressed cluster size instead.
1bdc94
+_check_test_img -r all
1bdc94
+$QEMU_IO -c "read  -P 0x11  0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+$QEMU_IO -c "read  -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir
1bdc94
+
1bdc94
+# success, all done
1bdc94
+echo '*** done'
1bdc94
+rm -f $seq.full
1bdc94
+status=0
1bdc94
diff --git a/tests/qemu-iotests/214.out b/tests/qemu-iotests/214.out
1bdc94
new file mode 100644
1bdc94
index 0000000..0fcd8dc
1bdc94
--- /dev/null
1bdc94
+++ b/tests/qemu-iotests/214.out
1bdc94
@@ -0,0 +1,35 @@
1bdc94
+QA output created by 214
1bdc94
+
1bdc94
+=== Corrupted size field in compressed cluster descriptor ===
1bdc94
+
1bdc94
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=8388608
1bdc94
+wrote 2097152/2097152 bytes at offset 0
1bdc94
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+wrote 2097152/2097152 bytes at offset 2097152
1bdc94
+2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+read failed: Input/output error
1bdc94
+No errors were found on the image.
1bdc94
+read 4194304/4194304 bytes at offset 0
1bdc94
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+wrote 4194304/4194304 bytes at offset 4194304
1bdc94
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+read 4194304/4194304 bytes at offset 0
1bdc94
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+ERROR cluster 6 refcount=1 reference=3
1bdc94
+ERROR cluster 7 refcount=1 reference=2
1bdc94
+Repairing cluster 6 refcount=1 reference=3
1bdc94
+Repairing cluster 7 refcount=1 reference=2
1bdc94
+Repairing OFLAG_COPIED data cluster: l2_entry=8000000000c00000 refcount=3
1bdc94
+Repairing OFLAG_COPIED data cluster: l2_entry=8000000000e00000 refcount=2
1bdc94
+The following inconsistencies were found and repaired:
1bdc94
+
1bdc94
+    0 leaked clusters
1bdc94
+    4 corruptions
1bdc94
+
1bdc94
+Double checking the fixed image now...
1bdc94
+No errors were found on the image.
1bdc94
+read 4194304/4194304 bytes at offset 0
1bdc94
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+read 4194304/4194304 bytes at offset 4194304
1bdc94
+4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
1bdc94
+*** done
1bdc94
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
1bdc94
index 3a89aed..ba7a2d1 100644
1bdc94
--- a/tests/qemu-iotests/group
1bdc94
+++ b/tests/qemu-iotests/group
1bdc94
@@ -212,4 +212,5 @@
1bdc94
 211 rw auto quick
1bdc94
 212 rw auto quick
1bdc94
 213 rw auto quick
1bdc94
+214 rw auto
1bdc94
 218 rw auto quick
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94