3 # Test case for the QMP blkdebug and blkverify interfaces
5 # Copyright (C) 2013 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/>.
22 owner
=mreitz@redhat.com
25 echo "QA output created by $seq"
27 status
=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
35 # get standard environment, filters and checks
41 _require_drivers blkdebug blkverify
42 # blkdebug can only inject errors on bs->file, not on the data_file,
43 # so thie test does not work with external data files
44 _unsupported_imgopts data_file
48 echo Testing
: "$@" | _filter_imgfmt
49 $QEMU -nographic -qmp stdio
-serial none
"$@"
55 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
61 echo "=== Testing blkverify through filename ==="
64 TEST_IMG
="$TEST_IMG.base" IMGFMT
="raw" _make_test_img
--no-opts $IMG_SIZE |\
66 _make_test_img
$IMG_SIZE
67 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
68 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
70 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
72 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
73 -c 'read -P 42 0 512' | _filter_qemu_io
76 echo "=== Testing blkverify through file blockref ==="
79 TEST_IMG
="$TEST_IMG.base" IMGFMT
="raw" _make_test_img
--no-opts $IMG_SIZE |\
81 _make_test_img
$IMG_SIZE
82 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base,file.test.driver=$IMGFMT,file.test.file.filename=$TEST_IMG" \
83 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
85 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
87 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
88 -c 'read -P 42 0 512' | _filter_qemu_io
91 echo "=== Testing blkdebug through filename ==="
94 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
95 -c 'read -P 42 0x38000 512'
98 echo "=== Testing blkdebug through file blockref ==="
101 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
102 -c 'read -P 42 0x38000 512'
105 echo "=== Testing blkdebug on existing block device ==="
109 { "execute": "qmp_capabilities" }
110 { "execute": "blockdev-add",
112 "node-name": "drive0",
114 "filename": "$TEST_IMG"
117 { "execute": "blockdev-add",
120 "node-name": "drive0-debug",
122 "driver": "blkdebug",
130 { "execute": "human-monitor-command",
132 "command-line": 'qemu-io drive0-debug "read 0 512"'
135 { "execute": "quit" }
139 echo "=== Testing blkverify on existing block device ==="
143 { "execute": "qmp_capabilities" }
144 { "execute": "blockdev-add",
146 "node-name": "drive0",
150 "filename": "$TEST_IMG"
154 { "execute": "blockdev-add",
156 "driver": "blkverify",
157 "node-name": "drive0-verify",
161 "filename": "$TEST_IMG.base"
165 { "execute": "human-monitor-command",
167 "command-line": 'qemu-io drive0-verify "read 0 512"'
170 { "execute": "quit" }
174 echo "=== Testing blkverify on existing raw block device ==="
178 { "execute": "qmp_capabilities" }
179 { "execute": "blockdev-add",
181 "node-name": "drive0",
183 "filename": "$TEST_IMG.base"
186 { "execute": "blockdev-add",
188 "driver": "blkverify",
189 "node-name": "drive0-verify",
194 "filename": "$TEST_IMG"
200 { "execute": "human-monitor-command",
202 "command-line": 'qemu-io drive0-verify "read 0 512"'
205 { "execute": "quit" }
209 echo "=== Testing blkdebug's set-state through QMP ==="
213 { "execute": "qmp_capabilities" }
214 { "execute": "blockdev-add",
216 "node-name": "drive0",
218 "filename": "$TEST_IMG"
221 { "execute": "blockdev-add",
224 "node-name": "drive0-debug",
226 "driver": "blkdebug",
233 "event": "write_aio",
239 { "execute": "human-monitor-command",
241 "command-line": 'qemu-io drive0-debug "read 0 512"'
244 { "execute": "human-monitor-command",
246 "command-line": 'qemu-io drive0-debug "write 0 512"'
249 { "execute": "human-monitor-command",
251 "command-line": 'qemu-io drive0-debug "read 0 512"'
254 { "execute": "quit" }