blob: df2884ba5148740dc043b54ef94e283f4ec717e1 [file] [log] [blame]
Kevin Wolf52280ea2010-06-14 11:17:54 +02001#!/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
22owner=kwolf@redhat.com
23
24seq=`basename $0`
25echo "QA output created by $seq"
26
27here=`pwd`
28tmp=/tmp/$$
29status=1 # failure is the default!
30
31_cleanup()
32{
33 _cleanup_test_img
Jeff Codyfef9c192013-09-25 08:12:22 -040034 rm "$TEST_DIR/blkdebug.conf"
Kevin Wolf52280ea2010-06-14 11:17:54 +020035}
36trap "_cleanup; exit \$status" 0 1 2 3 15
37
38# get standard environment, filters and checks
39. ./common.rc
40. ./common.filter
41. ./common.pattern
42
43# Currently only qcow2 supports rebasing
44_supported_fmt qcow2
Peter Lieven1f7bf7d2014-02-03 10:26:14 +010045_supported_proto file
Kevin Wolf52280ea2010-06-14 11:17:54 +020046_supported_os Linux
Fam Zhengf210a832013-12-04 09:07:00 +080047_default_cache_mode "writethrough"
48_supported_cache_modes "writethrough" "none"
Kevin Wolf52280ea2010-06-14 11:17:54 +020049
50echo "Errors while writing 128 kB"
51echo
52
53CLUSTER_SIZE=1024
54
55BLKDBG_TEST_IMG="blkdebug:$TEST_DIR/blkdebug.conf:$TEST_IMG"
56
57for event in \
58 l1_update \
59 \
60 l2_load \
61 l2_update \
62 l2_alloc.write \
63 \
64 write_aio \
65 \
66 refblock_load \
67 refblock_update_part \
68 refblock_alloc \
69 \
70 cluster_alloc \
71
72do
73
74for errno in 5 28; do
75for imm in off; do
76for once in on off; do
77for vmstate in "" "-b"; do
78
Jeff Codyfef9c192013-09-25 08:12:22 -040079cat > "$TEST_DIR/blkdebug.conf" <<EOF
Kevin Wolf52280ea2010-06-14 11:17:54 +020080[inject-error]
81event = "$event"
82errno = "$errno"
83immediately = "$imm"
84once ="$once"
85EOF
86
87_make_test_img 1G
88
89echo
90echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
Kevin Wolf92ab69b2011-04-29 15:32:55 +020091
92# We want to catch a simple L2 update, not the allocation of the first L2 table
93if [ "$event" == "l2_update" ]; then
Jeff Codyfef9c192013-09-25 08:12:22 -040094 $QEMU_IO -c "write $vmstate 0 512" "$TEST_IMG" > /dev/null 2>&1
Kevin Wolf92ab69b2011-04-29 15:32:55 +020095fi
96
Jeff Codyfef9c192013-09-25 08:12:22 -040097$QEMU_IO -c "write $vmstate 0 128k " "$BLKDBG_TEST_IMG" | _filter_qemu_io
Kevin Wolf52280ea2010-06-14 11:17:54 +020098
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
101if [ "$event" == "l2_load" ]; then
Jeff Codyfef9c192013-09-25 08:12:22 -0400102 $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
Kevin Wolf52280ea2010-06-14 11:17:54 +0200104fi
105
Federico Simoncellic6bb9ad2013-01-28 06:59:46 -0500106_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
Kevin Wolf52280ea2010-06-14 11:17:54 +0200107
108done
109done
110done
111done
112done
113
114
115echo
116echo === Refcout table growth tests ===
117echo
118CLUSTER_SIZE=512
119
120
121for event in \
122 refblock_alloc.hookup \
123 refblock_alloc.write \
124 refblock_alloc.write_blocks \
125 refblock_alloc.write_table \
126 refblock_alloc.switch_table \
127
128do
129
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)
132for errno in 28; do
133for imm in off; do
134for once in on off; do
135for vmstate in "" "-b"; do
136
Jeff Codyfef9c192013-09-25 08:12:22 -0400137cat > "$TEST_DIR/blkdebug.conf" <<EOF
Kevin Wolf52280ea2010-06-14 11:17:54 +0200138[inject-error]
139event = "$event"
140errno = "$errno"
141immediately = "$imm"
142once = "$once"
143EOF
144
145_make_test_img 1G
146
147echo
148echo "Event: $event; errno: $errno; imm: $imm; once: $once; write $vmstate"
Jeff Codyfef9c192013-09-25 08:12:22 -0400149$QEMU_IO -c "write $vmstate 0 64M" "$BLKDBG_TEST_IMG" | _filter_qemu_io
Kevin Wolf52280ea2010-06-14 11:17:54 +0200150
Federico Simoncellic6bb9ad2013-01-28 06:59:46 -0500151_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
Kevin Wolf52280ea2010-06-14 11:17:54 +0200152
153done
154done
155done
156done
157done
158
159echo
160echo === L1 growth tests ===
161echo
162CLUSTER_SIZE=1024
163
164
165for event in \
166 l1_grow.alloc_table \
167 l1_grow.write_table \
168 l1_grow.activate_table \
169
170do
171
172for errno in 5 28; do
173for imm in off; do
174for once in on off; do
175
Jeff Codyfef9c192013-09-25 08:12:22 -0400176cat > "$TEST_DIR/blkdebug.conf" <<EOF
Kevin Wolf52280ea2010-06-14 11:17:54 +0200177[inject-error]
178event = "$event"
179errno = "$errno"
180immediately = "$imm"
181once = "$once"
182EOF
183
184_make_test_img 1G
185
186echo
187echo "Event: $event; errno: $errno; imm: $imm; once: $once"
Jeff Codyfef9c192013-09-25 08:12:22 -0400188$QEMU_IO -c "write -b 0 64k" "$BLKDBG_TEST_IMG" | _filter_qemu_io
Kevin Wolf52280ea2010-06-14 11:17:54 +0200189
Federico Simoncellic6bb9ad2013-01-28 06:59:46 -0500190_check_test_img 2>&1 | grep -v "refcount=1 reference=0"
Kevin Wolf52280ea2010-06-14 11:17:54 +0200191
192done
193done
194done
195done
196
197# success, all done
198echo "*** done"
199rm -f $seq.full
200status=0