yeahuh / rpms / qemu-kvm

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