2 # group: rw auto backing quick
4 # Tests for rebasing COW images that require zero cluster support
6 # Copyright (C) 2019 Red Hat, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 owner
=hreitz@redhat.com
26 echo "QA output created by $seq"
28 status
=1 # failure is the default!
33 _rm_test_img
"$TEST_IMG.base_new"
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
42 # Currently only qcow2 and qed support rebasing, and only qcow2 v3 has
43 # zero cluster support
45 _unsupported_imgopts
'compat=0.10'
46 _supported_proto
file fuse
52 echo "=== Test rebase without input base ==="
55 # Cluster allocations to be tested:
57 # Backing (new) 11 -- 11 -- 11 --
58 # COW image 22 22 11 11 -- --
62 # COW image 22 22 11 11 00 --
64 # (Cluster 2 might be "--" after the rebase, too, but rebase just
65 # compares the new backing file to the old one and disregards the
66 # overlay. Therefore, it will never discard overlay clusters.)
68 _make_test_img $
((6 * CLUSTER_SIZE
))
69 TEST_IMG
="$TEST_IMG.base_new" _make_test_img $
((6 * CLUSTER_SIZE
))
73 $QEMU_IO "$TEST_IMG" \
74 -c "write -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
75 -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
78 $QEMU_IO "$TEST_IMG.base_new" \
79 -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
80 -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
81 -c "write -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
86 # This should be a no-op
87 $QEMU_IMG rebase
-b "" "$TEST_IMG"
89 # Verify the data is correct
90 $QEMU_IO "$TEST_IMG" \
91 -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
92 -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
93 -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
98 # Verify the allocation status (first four cluster should be allocated
99 # in TEST_IMG, clusters 4 and 5 should be unallocated (marked as zero
100 # clusters here because there is no backing file))
101 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map
105 $QEMU_IMG rebase
-b "$TEST_IMG.base_new" -F $IMGFMT "$TEST_IMG"
107 # Verify the data is correct
108 $QEMU_IO "$TEST_IMG" \
109 -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
110 -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
111 -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
116 # Verify the allocation status (first four cluster should be allocated
117 # in TEST_IMG, cluster 4 should be zero, and cluster 5 should be
118 # unallocated (signified by '"depth": 1'))
119 $QEMU_IMG map
--output=json
"$TEST_IMG" | _filter_qemu_img_map