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"
28 status
=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
36 # get standard environment, filters and checks
44 function do_run_qemu
()
46 echo Testing
: "$@" | _filter_imgfmt
47 $QEMU -nographic -qmp stdio
-serial none
"$@"
53 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
59 echo "=== Testing blkverify through filename ==="
62 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
64 _make_test_img
$IMG_SIZE
65 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
66 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
68 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
70 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
71 -c 'read -P 42 0 512' | _filter_qemu_io
74 echo "=== Testing blkverify through file blockref ==="
77 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
79 _make_test_img
$IMG_SIZE
80 $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" \
81 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
83 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
85 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
86 -c 'read -P 42 0 512' | _filter_qemu_io
89 echo "=== Testing blkdebug through filename ==="
92 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
93 -c 'read -P 42 0x38000 512'
96 echo "=== Testing blkdebug through file blockref ==="
99 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
100 -c 'read -P 42 0x38000 512'
103 echo "=== Testing blkdebug on existing block device ==="
107 { "execute": "qmp_capabilities" }
108 { "execute": "blockdev-add",
110 "node-name": "drive0",
112 "filename": "$TEST_IMG"
115 { "execute": "blockdev-add",
118 "node-name": "drive0-debug",
120 "driver": "blkdebug",
128 { "execute": "human-monitor-command",
130 "command-line": 'qemu-io drive0-debug "read 0 512"'
133 { "execute": "quit" }
137 echo "=== Testing blkverify on existing block device ==="
141 { "execute": "qmp_capabilities" }
142 { "execute": "blockdev-add",
144 "node-name": "drive0",
148 "filename": "$TEST_IMG"
152 { "execute": "blockdev-add",
154 "driver": "blkverify",
155 "node-name": "drive0-verify",
159 "filename": "$TEST_IMG.base"
163 { "execute": "human-monitor-command",
165 "command-line": 'qemu-io drive0-verify "read 0 512"'
168 { "execute": "quit" }
172 echo "=== Testing blkverify on existing raw block device ==="
176 { "execute": "qmp_capabilities" }
177 { "execute": "blockdev-add",
179 "node-name": "drive0",
181 "filename": "$TEST_IMG.base"
184 { "execute": "blockdev-add",
186 "driver": "blkverify",
187 "node-name": "drive0-verify",
192 "filename": "$TEST_IMG"
198 { "execute": "human-monitor-command",
200 "command-line": 'qemu-io drive0-verify "read 0 512"'
203 { "execute": "quit" }
207 echo "=== Testing blkdebug's set-state through QMP ==="
211 { "execute": "qmp_capabilities" }
212 { "execute": "blockdev-add",
214 "node-name": "drive0",
216 "filename": "$TEST_IMG"
219 { "execute": "blockdev-add",
222 "node-name": "drive0-debug",
224 "driver": "blkdebug",
231 "event": "write_aio",
237 { "execute": "human-monitor-command",
239 "command-line": 'qemu-io drive0-debug "read 0 512"'
242 { "execute": "human-monitor-command",
244 "command-line": 'qemu-io drive0-debug "write 0 512"'
247 { "execute": "human-monitor-command",
249 "command-line": 'qemu-io drive0-debug "read 0 512"'
252 { "execute": "quit" }