3 # qcow2 error path testing
5 # Copyright (C) 2010 Red Hat, Inc.
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.
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.
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/>.
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
34 rm "$TEST_DIR/blkdebug.conf"
36 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
43 # Currently only qcow2 supports rebasing
47 _default_cache_mode "writethrough"
48 _supported_cache_modes "writethrough" "none"
50 echo "Errors while writing 128 kB"
55 BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
67 refblock_update_part \
76 for once in on off; do
77 for vmstate in "" "-b"; do
79 cat > "$TEST_DIR/blkdebug.conf" <<EOF
90 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
92 # We want to catch a simple L2 update, not the allocation of the first L2 table
93 if [ "$event" == "l2_update" ]; then
94 $QEMU_IO -c "write $vmstate 0 512" "$TEST_IMG" > /dev/null 2>&1
97 $QEMU_IO -c "write $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io
99 # l2_load is not called on allocation, so issue a second write
100 # Reads are another path to trigger l2_load, so do a read, too
101 if [ "$event" == "l2_load" ]; then
102 $QEMU_IO -c "write $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io
103 $QEMU_IO -c "read $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io
106 _check_test_img 2>&1 | grep -v "refcount=1 reference=0"
116 echo === Refcout table growth tests ===
122 refblock_alloc.hookup \
123 refblock_alloc.write \
124 refblock_alloc.write_blocks \
125 refblock_alloc.write_table \
126 refblock_alloc.switch_table \
130 # This one takes a while, so let's test only one error code (ENOSPC should
131 # never be generated by qemu, so it's probably a good choice)
134 for once in on off; do
135 for vmstate in "" "-b"; do
137 cat > "$TEST_DIR/blkdebug.conf" <<EOF
148 echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
149 $QEMU_IO -c "write $vmstate 0 64M" "$BLKDBG_TEST_IMG" | _filter_qemu_io
151 _check_test_img 2>&1 | grep -v "refcount=1 reference=0"
160 echo === L1 growth tests ===
166 l1_grow.alloc_table \
167 l1_grow.write_table \
168 l1_grow.activate_table \
172 for errno in 5 28; do
174 for once in on off; do
176 cat > "$TEST_DIR/blkdebug.conf" <<EOF
187 echo "Event: $event; errno: $errno; imm: $imm; once: $once"
188 $QEMU_IO -c "write -b 0 64k" "$BLKDBG_TEST_IMG" | _filter_qemu_io
190 _check_test_img 2>&1 | grep -v "refcount=1 reference=0"