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
44 echo Testing
: "$@" | _filter_imgfmt
45 $QEMU -nographic -qmp stdio
-serial none
"$@"
51 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
57 echo "=== Testing blkverify through filename ==="
60 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
62 _make_test_img
$IMG_SIZE
63 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
64 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
66 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
68 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
69 -c 'read -P 42 0 512' | _filter_qemu_io
72 echo "=== Testing blkverify through file blockref ==="
75 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
77 _make_test_img
$IMG_SIZE
78 $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" \
79 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
81 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
83 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
84 -c 'read -P 42 0 512' | _filter_qemu_io
87 echo "=== Testing blkdebug through filename ==="
90 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
91 -c 'read -P 42 0x38000 512'
94 echo "=== Testing blkdebug through file blockref ==="
97 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
98 -c 'read -P 42 0x38000 512'
101 echo "=== Testing blkdebug on existing block device ==="
105 { "execute": "qmp_capabilities" }
106 { "execute": "blockdev-add",
108 "node-name": "drive0",
110 "filename": "$TEST_IMG"
113 { "execute": "blockdev-add",
116 "node-name": "drive0-debug",
118 "driver": "blkdebug",
126 { "execute": "human-monitor-command",
128 "command-line": 'qemu-io drive0-debug "read 0 512"'
131 { "execute": "quit" }
135 echo "=== Testing blkverify on existing block device ==="
139 { "execute": "qmp_capabilities" }
140 { "execute": "blockdev-add",
142 "node-name": "drive0",
146 "filename": "$TEST_IMG"
150 { "execute": "blockdev-add",
152 "driver": "blkverify",
153 "node-name": "drive0-verify",
157 "filename": "$TEST_IMG.base"
161 { "execute": "human-monitor-command",
163 "command-line": 'qemu-io drive0-verify "read 0 512"'
166 { "execute": "quit" }
170 echo "=== Testing blkverify on existing raw block device ==="
174 { "execute": "qmp_capabilities" }
175 { "execute": "blockdev-add",
177 "node-name": "drive0",
179 "filename": "$TEST_IMG.base"
182 { "execute": "blockdev-add",
184 "driver": "blkverify",
185 "node-name": "drive0-verify",
190 "filename": "$TEST_IMG"
196 { "execute": "human-monitor-command",
198 "command-line": 'qemu-io drive0-verify "read 0 512"'
201 { "execute": "quit" }
205 echo "=== Testing blkdebug's set-state through QMP ==="
209 { "execute": "qmp_capabilities" }
210 { "execute": "blockdev-add",
212 "node-name": "drive0",
214 "filename": "$TEST_IMG"
217 { "execute": "blockdev-add",
220 "node-name": "drive0-debug",
222 "driver": "blkdebug",
229 "event": "write_aio",
235 { "execute": "human-monitor-command",
237 "command-line": 'qemu-io drive0-debug "read 0 512"'
240 { "execute": "human-monitor-command",
242 "command-line": 'qemu-io drive0-debug "write 0 512"'
245 { "execute": "human-monitor-command",
247 "command-line": 'qemu-io drive0-debug "read 0 512"'
250 { "execute": "quit" }