]>
Commit | Line | Data |
---|---|---|
11a82d14 | 1 | #!/usr/bin/env bash |
52280eac KW |
2 | # |
3 | # qcow2 error path testing | |
4 | # | |
5 | # Copyright (C) 2010 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 | owner=kwolf@redhat.com | |
23 | ||
24 | seq=`basename $0` | |
25 | echo "QA output created by $seq" | |
26 | ||
52280eac KW |
27 | status=1 # failure is the default! |
28 | ||
29 | _cleanup() | |
30 | { | |
31 | _cleanup_test_img | |
fef9c191 | 32 | rm "$TEST_DIR/blkdebug.conf" |
52280eac KW |
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 supports rebasing | |
42 | _supported_fmt qcow2 | |
1f7bf7d0 | 43 | _supported_proto file |
f210a83c FZ |
44 | _default_cache_mode "writethrough" |
45 | _supported_cache_modes "writethrough" "none" | |
5262caa7 HR |
46 | # The refcount table tests expect a certain minimum width for refcount entries |
47 | # (so that the refcount table actually needs to grow); that minimum is 16 bits, | |
48 | # being the default refcount entry width. | |
49 | # 32 and 64 bits do not work either, however, due to different leaked cluster | |
50 | # count on error. | |
51 | # Thus, the only remaining option is refcount_bits=16. | |
52 | _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' | |
52280eac KW |
53 | |
54 | echo "Errors while writing 128 kB" | |
55 | echo | |
56 | ||
57 | CLUSTER_SIZE=1024 | |
58 | ||
59 | BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG" | |
60 | ||
61 | for event in \ | |
62 | l1_update \ | |
63 | \ | |
64 | l2_load \ | |
65 | l2_update \ | |
5be5b776 | 66 | l2_alloc_write \ |
52280eac KW |
67 | \ |
68 | write_aio \ | |
69 | \ | |
70 | refblock_load \ | |
71 | refblock_update_part \ | |
72 | refblock_alloc \ | |
73 | \ | |
74 | cluster_alloc \ | |
75 | ||
76 | do | |
77 | ||
78 | for errno in 5 28; do | |
79 | for imm in off; do | |
80 | for once in on off; do | |
81 | for vmstate in "" "-b"; do | |
82 | ||
fef9c191 | 83 | cat > "$TEST_DIR/blkdebug.conf" <<EOF |
52280eac KW |
84 | [inject-error] |
85 | event = "$event" | |
86 | errno = "$errno" | |
87 | immediately = "$imm" | |
88 | once ="$once" | |
89 | EOF | |
90 | ||
91 | _make_test_img 1G | |
92 | ||
93 | echo | |
94 | echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" | |
92ab69b6 KW |
95 | |
96 | # We want to catch a simple L2 update, not the allocation of the first L2 table | |
97 | if [ "$event" == "l2_update" ]; then | |
fef9c191 | 98 | $QEMU_IO -c "write $vmstate 0 512" "$TEST_IMG" > /dev/null 2>&1 |
92ab69b6 KW |
99 | fi |
100 | ||
fef9c191 | 101 | $QEMU_IO -c "write $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io |
52280eac KW |
102 | |
103 | # l2_load is not called on allocation, so issue a second write | |
104 | # Reads are another path to trigger l2_load, so do a read, too | |
105 | if [ "$event" == "l2_load" ]; then | |
fef9c191 JC |
106 | $QEMU_IO -c "write $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io |
107 | $QEMU_IO -c "read $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io | |
52280eac KW |
108 | fi |
109 | ||
c6bb9ad1 | 110 | _check_test_img 2>&1 | grep -v "refcount=1 reference=0" |
52280eac KW |
111 | |
112 | done | |
113 | done | |
114 | done | |
115 | done | |
116 | done | |
117 | ||
118 | ||
119 | echo | |
82481694 | 120 | echo === Refcount table growth tests === |
52280eac KW |
121 | echo |
122 | CLUSTER_SIZE=512 | |
123 | ||
124 | ||
125 | for event in \ | |
5be5b776 EB |
126 | refblock_alloc_hookup \ |
127 | refblock_alloc_write \ | |
128 | refblock_alloc_write_blocks \ | |
129 | refblock_alloc_write_table \ | |
130 | refblock_alloc_switch_table \ | |
52280eac KW |
131 | |
132 | do | |
133 | ||
134 | # This one takes a while, so let's test only one error code (ENOSPC should | |
135 | # never be generated by qemu, so it's probably a good choice) | |
136 | for errno in 28; do | |
137 | for imm in off; do | |
138 | for once in on off; do | |
139 | for vmstate in "" "-b"; do | |
140 | ||
fef9c191 | 141 | cat > "$TEST_DIR/blkdebug.conf" <<EOF |
52280eac KW |
142 | [inject-error] |
143 | event = "$event" | |
144 | errno = "$errno" | |
145 | immediately = "$imm" | |
146 | once = "$once" | |
147 | EOF | |
148 | ||
149 | _make_test_img 1G | |
150 | ||
151 | echo | |
152 | echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate" | |
fef9c191 | 153 | $QEMU_IO -c "write $vmstate 0 64M" "$BLKDBG_TEST_IMG" | _filter_qemu_io |
52280eac | 154 | |
c6bb9ad1 | 155 | _check_test_img 2>&1 | grep -v "refcount=1 reference=0" |
52280eac KW |
156 | |
157 | done | |
158 | done | |
159 | done | |
160 | done | |
161 | done | |
162 | ||
163 | echo | |
164 | echo === L1 growth tests === | |
165 | echo | |
166 | CLUSTER_SIZE=1024 | |
167 | ||
168 | ||
169 | for event in \ | |
5be5b776 EB |
170 | l1_grow_alloc_table \ |
171 | l1_grow_write_table \ | |
172 | l1_grow_activate_table \ | |
52280eac KW |
173 | |
174 | do | |
175 | ||
176 | for errno in 5 28; do | |
177 | for imm in off; do | |
178 | for once in on off; do | |
179 | ||
fef9c191 | 180 | cat > "$TEST_DIR/blkdebug.conf" <<EOF |
52280eac KW |
181 | [inject-error] |
182 | event = "$event" | |
183 | errno = "$errno" | |
184 | immediately = "$imm" | |
185 | once = "$once" | |
186 | EOF | |
187 | ||
188 | _make_test_img 1G | |
189 | ||
190 | echo | |
191 | echo "Event: $event; errno: $errno; imm: $imm; once: $once" | |
fef9c191 | 192 | $QEMU_IO -c "write -b 0 64k" "$BLKDBG_TEST_IMG" | _filter_qemu_io |
52280eac | 193 | |
c6bb9ad1 | 194 | _check_test_img 2>&1 | grep -v "refcount=1 reference=0" |
52280eac KW |
195 | |
196 | done | |
197 | done | |
198 | done | |
199 | done | |
200 | ||
ae376c62 KW |
201 | echo |
202 | echo === Avoid cluster leaks after temporary failure === | |
203 | echo | |
204 | ||
205 | cat > "$TEST_DIR/blkdebug.conf" <<EOF | |
206 | [inject-error] | |
207 | event = "write_aio" | |
208 | errno = "5" | |
209 | once = "on" | |
210 | EOF | |
211 | ||
212 | # After the failed first write, do a second write so that the updated refcount | |
213 | # block is actually written back | |
214 | _make_test_img 64M | |
215 | $QEMU_IO -c "write 0 1M" -c "write 0 1M" "$BLKDBG_TEST_IMG" | _filter_qemu_io | |
216 | _check_test_img | |
217 | ||
52280eac KW |
218 | # success, all done |
219 | echo "*** done" | |
220 | rm -f $seq.full | |
221 | status=0 |