[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 08/17] iotests: Test non-self-referential qcow2 refbl
[Qemu-devel] [PULL 08/17] iotests: Test non-self-referential qcow2 refblocks
Mon, 16 Mar 2015 17:57:12 +0100
From: Max Reitz <address@hidden>
It is easy to create only self-referential refblocks, but there are
cases where that is impossible. This adds a test for two of those cases
(combined in a single test case).
Suggested-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
tests/qemu-iotests/115 | 95 ++++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/115.out | 8 ++++
tests/qemu-iotests/group | 1 +
3 files changed, 104 insertions(+)
create mode 100755 tests/qemu-iotests/115
create mode 100644 tests/qemu-iotests/115.out
diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115
new file mode 100755
@@ -0,0 +1,95 @@
+# Test case for non-self-referential qcow2 refcount blocks
+# Copyright (C) 2014 Red Hat, Inc.
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+echo "QA output created by $seq"
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+# get standard environment, filters and checks
+# This test relies on refcounts being 64 bits wide (which does not work with
+_unsupported_imgopts 'refcount_bits=\([^6]\|.\([^4]\|$\)\)' 'compat=0.10'
+echo '=== Testing large refcount and L1 table ==='
+# Create an image with an L1 table and a refcount table that each span twice
+# number of clusters which can be described by a single refblock; therefore, at
+# least two refblocks cannot count their own refcounts because all the clusters
+# they describe are part of the L1 table or refcount table.
+# One refblock can describe (with cluster_size=512 and refcount_bits=64)
+# 512/8 = 64 clusters, therefore the L1 table should cover 128 clusters, which
+# equals 128 * (512/8) = 8192 entries (actually, 8192 - 512/8 = 8129 would
+# suffice, but it does not really matter). 8192 L2 tables can in turn describe
+# 8192 * 512/8 = 524,288 clusters which cover a space of 256 MB.
+# Since with refcount_bits=64 every refcount block entry is 64 bits wide (just
+# like the L2 table entries), the same calculation applies to the refcount
+# as well; the difference is that while for the L1 table the guest disk size is
+# concerned, for the refcount table it is the image length that has to be at
+# least 256 MB. We can achieve that by using preallocation=metadata for an
+# which has a guest disk size of 256 MB.
+ _make_test_img 256M
+# We know for sure that the L1 and refcount tables do not overlap with any
+# structure because the metadata overlap checks would have caught that case.
+# Because qemu refuses to open qcow2 files whose L1 table does not cover the
+# whole guest disk size, it is definitely large enough. On the other hand, to
+# test whether the refcount table is large enough, we simply have to verify
+# indeed all the clusters are allocated, which is done by qemu-img check.
+# The final thing we need to test is whether the tables are actually covered by
+# refcount blocks; since all clusters of the tables are referenced, we can use
+# qemu-img check for that purpose, too.
+$QEMU_IMG check "$TEST_IMG" | \
+ sed -e 's/^.* = \([0-9]\+\.[0-9]\+% allocated\).*\(clusters\)$/\1 \2/' \
+ -e '/^Image end offset/d'
+# (Note that we cannot use _check_test_img because that function filters out
+# allocation status)
+# success, all done
+echo '*** done'
+rm -f $seq.full
diff --git a/tests/qemu-iotests/115.out b/tests/qemu-iotests/115.out
new file mode 100644
@@ -0,0 +1,8 @@
+QA output created by 115
+=== Testing large refcount and L1 table ===
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=268435456
+No errors were found on the image.
+100.00% allocated clusters
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 961c7cd..6262127 100644
@@ -119,6 +119,7 @@
112 rw auto
113 rw auto quick
114 rw auto quick
+115 rw auto
116 rw auto quick
121 rw auto
123 rw auto quick
- [Qemu-devel] [PULL 04/17] block: Fix block-set-write-threshold not to use funky error class, (continued)
- [Qemu-devel] [PULL 04/17] block: Fix block-set-write-threshold not to use funky error class, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 05/17] qemu-img: Avoid qerror_report_err() outside QMP handlers, again, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 10/17] migration: Convert bdrv_find to blk_by_name, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 06/17] qcow2: Respect new_block in alloc_refcount_block(), Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 09/17] monitor: Convert bdrv_find to blk_by_name, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 14/17] vpc: Ignore geometry for large images, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 16/17] block/vpc: rename footer->size -> footer->current_size, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 07/17] iotests: Add tests for refcount table growth, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 13/17] block/vpc: optimize vpc_co_get_block_status, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 12/17] block: Drop bdrv_find, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 08/17] iotests: Test non-self-referential qcow2 refblocks,
Kevin Wolf <=
- [Qemu-devel] [PULL 17/17] block/vpc: remove disabled code from get_sector_offset, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 11/17] blockdev: Convert bdrv_find to blk_by_name, Kevin Wolf, 2015/03/16
- [Qemu-devel] [PULL 15/17] block/vpc: make calculate_geometry spec conform, Kevin Wolf, 2015/03/16
- Re: [Qemu-devel] [PULL 00/17] Block patches for 2.3.0-rc0, Peter Maydell, 2015/03/17