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
45 echo Testing
: "$@" | _filter_imgfmt
46 $QEMU -nographic -qmp stdio
-serial none
"$@"
52 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
58 echo "=== Testing blkverify through filename ==="
61 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
63 _make_test_img
$IMG_SIZE
64 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
65 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
67 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
69 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
70 -c 'read -P 42 0 512' | _filter_qemu_io
73 echo "=== Testing blkverify through file blockref ==="
76 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
78 _make_test_img
$IMG_SIZE
79 $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" \
80 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
82 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
84 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
85 -c 'read -P 42 0 512' | _filter_qemu_io
88 echo "=== Testing blkdebug through filename ==="
91 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
92 -c 'read -P 42 0x38000 512'
95 echo "=== Testing blkdebug through file blockref ==="
98 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
99 -c 'read -P 42 0x38000 512'
102 echo "=== Testing blkdebug on existing block device ==="
106 { "execute": "qmp_capabilities" }
107 { "execute": "blockdev-add",
109 "node-name": "drive0",
111 "filename": "$TEST_IMG"
114 { "execute": "blockdev-add",
117 "node-name": "drive0-debug",
119 "driver": "blkdebug",
127 { "execute": "human-monitor-command",
129 "command-line": 'qemu-io drive0-debug "read 0 512"'
132 { "execute": "quit" }
136 echo "=== Testing blkverify on existing block device ==="
140 { "execute": "qmp_capabilities" }
141 { "execute": "blockdev-add",
143 "node-name": "drive0",
147 "filename": "$TEST_IMG"
151 { "execute": "blockdev-add",
153 "driver": "blkverify",
154 "node-name": "drive0-verify",
158 "filename": "$TEST_IMG.base"
162 { "execute": "human-monitor-command",
164 "command-line": 'qemu-io drive0-verify "read 0 512"'
167 { "execute": "quit" }
171 echo "=== Testing blkverify on existing raw block device ==="
175 { "execute": "qmp_capabilities" }
176 { "execute": "blockdev-add",
178 "node-name": "drive0",
180 "filename": "$TEST_IMG.base"
183 { "execute": "blockdev-add",
185 "driver": "blkverify",
186 "node-name": "drive0-verify",
191 "filename": "$TEST_IMG"
197 { "execute": "human-monitor-command",
199 "command-line": 'qemu-io drive0-verify "read 0 512"'
202 { "execute": "quit" }
206 echo "=== Testing blkdebug's set-state through QMP ==="
210 { "execute": "qmp_capabilities" }
211 { "execute": "blockdev-add",
213 "node-name": "drive0",
215 "filename": "$TEST_IMG"
218 { "execute": "blockdev-add",
221 "node-name": "drive0-debug",
223 "driver": "blkdebug",
230 "event": "write_aio",
236 { "execute": "human-monitor-command",
238 "command-line": 'qemu-io drive0-debug "read 0 512"'
241 { "execute": "human-monitor-command",
243 "command-line": 'qemu-io drive0-debug "write 0 512"'
246 { "execute": "human-monitor-command",
248 "command-line": 'qemu-io drive0-debug "read 0 512"'
251 { "execute": "quit" }