]> Git Repo - qemu.git/blob - tests/qemu-iotests/252
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[qemu.git] / tests / qemu-iotests / 252
1 #!/usr/bin/env bash
2 #
3 # Tests for rebasing COW images that require zero cluster support
4 #
5 # Copyright (C) 2019 Red Hat, Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 # creator
22 [email protected]
23
24 seq=$(basename $0)
25 echo "QA output created by $seq"
26
27 status=1        # failure is the default!
28
29 _cleanup()
30 {
31     _cleanup_test_img
32     rm -f "$TEST_IMG.base_new"
33 }
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39 . ./common.pattern
40
41 # Currently only qcow2 and qed support rebasing, and only qcow2 v3 has
42 # zero cluster support
43 _supported_fmt qcow2
44 _unsupported_imgopts 'compat=0.10'
45 _supported_proto file
46 _supported_os Linux
47
48 CLUSTER_SIZE=65536
49
50 echo
51 echo "=== Test rebase without input base ==="
52 echo
53
54 # Cluster allocations to be tested:
55 #
56 # Backing (new) 11 -- 11 -- 11 --
57 # COW image     22 22 11 11 -- --
58 #
59 # Expected result:
60 #
61 # COW image     22 22 11 11 00 --
62 #
63 # (Cluster 2 might be "--" after the rebase, too, but rebase just
64 #  compares the new backing file to the old one and disregards the
65 #  overlay.  Therefore, it will never discard overlay clusters.)
66
67 _make_test_img $((6 * CLUSTER_SIZE))
68 TEST_IMG="$TEST_IMG.base_new" _make_test_img $((6 * CLUSTER_SIZE))
69
70 echo
71
72 $QEMU_IO "$TEST_IMG" \
73     -c "write -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
74     -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
75     | _filter_qemu_io
76
77 $QEMU_IO "$TEST_IMG.base_new" \
78     -c "write -P 0x11 $((0 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
79     -c "write -P 0x11 $((2 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
80     -c "write -P 0x11 $((4 * CLUSTER_SIZE)) $CLUSTER_SIZE" \
81     | _filter_qemu_io
82
83 echo
84
85 # This should be a no-op
86 $QEMU_IMG rebase -b "" "$TEST_IMG"
87
88 # Verify the data is correct
89 $QEMU_IO "$TEST_IMG" \
90     -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
91     -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
92     -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
93     | _filter_qemu_io
94
95 echo
96
97 # Verify the allocation status (first four cluster should be allocated
98 # in TEST_IMG, clusters 4 and 5 should be unallocated (marked as zero
99 # clusters here because there is no backing file))
100 $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
101
102 echo
103
104 $QEMU_IMG rebase -b "$TEST_IMG.base_new" "$TEST_IMG"
105
106 # Verify the data is correct
107 $QEMU_IO "$TEST_IMG" \
108     -c "read -P 0x22 $((0 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
109     -c "read -P 0x11 $((2 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
110     -c "read -P 0x00 $((4 * CLUSTER_SIZE)) $((2 * CLUSTER_SIZE))" \
111     | _filter_qemu_io
112
113 echo
114
115 # Verify the allocation status (first four cluster should be allocated
116 # in TEST_IMG, cluster 4 should be zero, and cluster 5 should be
117 # unallocated (signified by '"depth": 1'))
118 $QEMU_IMG map --output=json "$TEST_IMG" | _filter_qemu_img_map
119
120
121 # success, all done
122 echo "*** done"
123 rm -f $seq.full
124 status=0
This page took 0.032475 seconds and 4 git commands to generate.