]> Git Repo - qemu.git/blame - tests/qemu-iotests/071
iotests: ignore import warnings from pylint
[qemu.git] / tests / qemu-iotests / 071
CommitLineData
11a82d14 1#!/usr/bin/env bash
30bd6a4d
HR
2#
3# Test case for the QMP blkdebug and blkverify interfaces
4#
5# Copyright (C) 2013 Red Hat, Inc.
6#
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.
11#
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.
16#
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/>.
19#
20
21# creator
22[email protected]
23
24seq="$(basename $0)"
25echo "QA output created by $seq"
26
30bd6a4d
HR
27status=1 # failure is the default!
28
29_cleanup()
30{
31 _cleanup_test_img
32}
33trap "_cleanup; exit \$status" 0 1 2 3 15
34
35# get standard environment, filters and checks
36. ./common.rc
37. ./common.filter
38
1b7650ef 39_supported_fmt qcow2
1f7bf7d0 40_supported_proto file
21b43d00 41_require_drivers blkdebug blkverify
3be2024a
HR
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
30bd6a4d 45
8cedcffd 46do_run_qemu()
30bd6a4d
HR
47{
48 echo Testing: "$@" | _filter_imgfmt
49 $QEMU -nographic -qmp stdio -serial none "$@"
50 echo
51}
52
8cedcffd 53run_qemu()
30bd6a4d 54{
4dd7b8d3 55 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp | _filter_qemu_io
30bd6a4d
HR
56}
57
58IMG_SIZE=64M
59
60echo
61echo "=== Testing blkverify through filename ==="
62echo
63
10b61256 64TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\
30bd6a4d
HR
65 _filter_imgfmt
66_make_test_img $IMG_SIZE
8f9e835f 67$QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
30bd6a4d
HR
68 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
69
70$QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
71
8f9e835f 72$QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
30bd6a4d
HR
73 -c 'read -P 42 0 512' | _filter_qemu_io
74
75echo
76echo "=== Testing blkverify through file blockref ==="
77echo
78
10b61256 79TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\
30bd6a4d
HR
80 _filter_imgfmt
81_make_test_img $IMG_SIZE
8f9e835f 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" \
30bd6a4d
HR
83 -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x38000 512' | _filter_qemu_io
84
85$QEMU_IO -c 'write -P 42 0 512' "$TEST_IMG" | _filter_qemu_io
86
8f9e835f 87$QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \
30bd6a4d
HR
88 -c 'read -P 42 0 512' | _filter_qemu_io
89
90echo
91echo "=== Testing blkdebug through filename ==="
92echo
93
94$QEMU_IO -c "open -o file.driver=blkdebug,file.inject-error.event=l2_load $TEST_IMG" \
95 -c 'read -P 42 0x38000 512'
96
97echo
98echo "=== Testing blkdebug through file blockref ==="
99echo
100
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'
103
104echo
105echo "=== Testing blkdebug on existing block device ==="
106echo
107
8e9e6530 108run_qemu <<EOF
30bd6a4d 109{ "execute": "qmp_capabilities" }
8e9e6530
HR
110{ "execute": "blockdev-add",
111 "arguments": {
0153d2f5
KW
112 "node-name": "drive0",
113 "driver": "file",
114 "filename": "$TEST_IMG"
8e9e6530
HR
115 }
116}
30bd6a4d
HR
117{ "execute": "blockdev-add",
118 "arguments": {
0153d2f5
KW
119 "driver": "$IMGFMT",
120 "node-name": "drive0-debug",
121 "file": {
122 "driver": "blkdebug",
123 "image": "drive0",
124 "inject-error": [{
125 "event": "l2_load"
126 }]
30bd6a4d
HR
127 }
128 }
129}
130{ "execute": "human-monitor-command",
131 "arguments": {
132 "command-line": 'qemu-io drive0-debug "read 0 512"'
133 }
134}
135{ "execute": "quit" }
136EOF
137
138echo
139echo "=== Testing blkverify on existing block device ==="
140echo
141
8e9e6530 142run_qemu <<EOF
30bd6a4d 143{ "execute": "qmp_capabilities" }
8e9e6530
HR
144{ "execute": "blockdev-add",
145 "arguments": {
0153d2f5
KW
146 "node-name": "drive0",
147 "driver": "$IMGFMT",
148 "file": {
149 "driver": "file",
150 "filename": "$TEST_IMG"
8e9e6530
HR
151 }
152 }
153}
30bd6a4d
HR
154{ "execute": "blockdev-add",
155 "arguments": {
0153d2f5
KW
156 "driver": "blkverify",
157 "node-name": "drive0-verify",
158 "test": "drive0",
159 "raw": {
160 "driver": "file",
161 "filename": "$TEST_IMG.base"
30bd6a4d
HR
162 }
163 }
164}
165{ "execute": "human-monitor-command",
166 "arguments": {
167 "command-line": 'qemu-io drive0-verify "read 0 512"'
168 }
169}
170{ "execute": "quit" }
171EOF
172
173echo
174echo "=== Testing blkverify on existing raw block device ==="
175echo
176
8e9e6530 177run_qemu <<EOF
30bd6a4d 178{ "execute": "qmp_capabilities" }
8e9e6530
HR
179{ "execute": "blockdev-add",
180 "arguments": {
0153d2f5
KW
181 "node-name": "drive0",
182 "driver": "file",
183 "filename": "$TEST_IMG.base"
8e9e6530
HR
184 }
185}
30bd6a4d
HR
186{ "execute": "blockdev-add",
187 "arguments": {
0153d2f5
KW
188 "driver": "blkverify",
189 "node-name": "drive0-verify",
190 "test": {
191 "driver": "$IMGFMT",
192 "file": {
193 "driver": "file",
194 "filename": "$TEST_IMG"
195 }
196 },
197 "raw": "drive0"
30bd6a4d
HR
198 }
199}
200{ "execute": "human-monitor-command",
201 "arguments": {
202 "command-line": 'qemu-io drive0-verify "read 0 512"'
203 }
204}
205{ "execute": "quit" }
206EOF
207
208echo
209echo "=== Testing blkdebug's set-state through QMP ==="
210echo
211
8e9e6530 212run_qemu <<EOF
30bd6a4d 213{ "execute": "qmp_capabilities" }
8e9e6530
HR
214{ "execute": "blockdev-add",
215 "arguments": {
0153d2f5
KW
216 "node-name": "drive0",
217 "driver": "file",
218 "filename": "$TEST_IMG"
8e9e6530
HR
219 }
220}
30bd6a4d
HR
221{ "execute": "blockdev-add",
222 "arguments": {
0153d2f5
KW
223 "driver": "$IMGFMT",
224 "node-name": "drive0-debug",
225 "file": {
226 "driver": "blkdebug",
227 "image": "drive0",
228 "inject-error": [{
229 "event": "read_aio",
230 "state": 42
231 }],
232 "set-state": [{
233 "event": "write_aio",
234 "new_state": 42
235 }]
30bd6a4d
HR
236 }
237 }
238}
239{ "execute": "human-monitor-command",
240 "arguments": {
241 "command-line": 'qemu-io drive0-debug "read 0 512"'
242 }
243}
244{ "execute": "human-monitor-command",
245 "arguments": {
246 "command-line": 'qemu-io drive0-debug "write 0 512"'
247 }
248}
249{ "execute": "human-monitor-command",
250 "arguments": {
251 "command-line": 'qemu-io drive0-debug "read 0 512"'
252 }
253}
254{ "execute": "quit" }
255EOF
256
257# success, all done
258echo "*** done"
259rm -f $seq.full
260status=0
This page took 0.367936 seconds and 4 git commands to generate.