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"
29 status
=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
37 # get standard environment, filters and checks
45 function do_run_qemu
()
47 echo Testing
: "$@" | _filter_imgfmt
48 $QEMU -nographic -qmp stdio
-serial none
"$@"
54 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
60 echo "=== Testing blkverify through filename ==="
63 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
65 _make_test_img
$IMG_SIZE
66 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
67 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
69 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
71 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
72 -c 'read -P 42 0 512' | _filter_qemu_io
75 echo "=== Testing blkverify through file blockref ==="
78 TEST_IMG
="$TEST_IMG.base" IMGOPTS
="" IMGFMT
="raw" _make_test_img
$IMG_SIZE |\
80 _make_test_img
$IMG_SIZE
81 $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" \
82 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
84 $QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
86 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
87 -c 'read -P 42 0 512' | _filter_qemu_io
90 echo "=== Testing blkdebug through filename ==="
93 $QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
94 -c 'read -P 42 0x38000 512'
97 echo "=== Testing blkdebug through file blockref ==="
100 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.inject-error.event=l2_load,file.image.filename=$TEST_IMG" \
101 -c 'read -P 42 0x38000 512'
104 echo "=== Testing blkdebug on existing block device ==="
108 { "execute": "qmp_capabilities" }
109 { "execute": "blockdev-add",
112 "node-name": "drive0",
114 "filename": "$TEST_IMG"
118 { "execute": "blockdev-add",
122 "id": "drive0-debug",
124 "driver": "blkdebug",
133 { "execute": "human-monitor-command",
135 "command-line": 'qemu-io drive0-debug "read 0 512"'
138 { "execute": "quit" }
142 echo "=== Testing blkverify on existing block device ==="
146 { "execute": "qmp_capabilities" }
147 { "execute": "blockdev-add",
150 "node-name": "drive0",
154 "filename": "$TEST_IMG"
159 { "execute": "blockdev-add",
162 "driver": "blkverify",
163 "id": "drive0-verify",
167 "filename": "$TEST_IMG.base"
172 { "execute": "human-monitor-command",
174 "command-line": 'qemu-io drive0-verify "read 0 512"'
177 { "execute": "quit" }
181 echo "=== Testing blkverify on existing raw block device ==="
185 { "execute": "qmp_capabilities" }
186 { "execute": "blockdev-add",
189 "node-name": "drive0",
191 "filename": "$TEST_IMG.base"
195 { "execute": "blockdev-add",
198 "driver": "blkverify",
199 "id": "drive0-verify",
204 "filename": "$TEST_IMG"
211 { "execute": "human-monitor-command",
213 "command-line": 'qemu-io drive0-verify "read 0 512"'
216 { "execute": "quit" }
220 echo "=== Testing blkdebug's set-state through QMP ==="
224 { "execute": "qmp_capabilities" }
225 { "execute": "blockdev-add",
228 "node-name": "drive0",
230 "filename": "$TEST_IMG"
234 { "execute": "blockdev-add",
238 "id": "drive0-debug",
240 "driver": "blkdebug",
247 "event": "write_aio",
254 { "execute": "human-monitor-command",
256 "command-line": 'qemu-io drive0-debug "read 0 512"'
259 { "execute": "human-monitor-command",
261 "command-line": 'qemu-io drive0-debug "write 0 512"'
264 { "execute": "human-monitor-command",
266 "command-line": 'qemu-io drive0-debug "read 0 512"'
269 { "execute": "quit" }