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