]> git.proxmox.com Git - mirror_qemu.git/blame - tests/qemu-iotests/087
iotests: define group in each iotest
[mirror_qemu.git] / tests / qemu-iotests / 087
CommitLineData
11a82d14 1#!/usr/bin/env bash
9dd003a9 2# group: rw quick
c75203c8
KW
3#
4# Test unsupported blockdev-add cases
5#
6# Copyright (C) 2014 Red Hat, Inc.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21
22# creator
23owner=kwolf@redhat.com
24
25seq=`basename $0`
26echo "QA output created by $seq"
27
c75203c8
KW
28status=1 # failure is the default!
29
801ddbda
HR
30_cleanup()
31{
32 _cleanup_test_img
33}
34trap "_cleanup; exit \$status" 0 1 2 3 15
35
c75203c8
KW
36# get standard environment, filters and checks
37. ./common.rc
38. ./common.filter
39
40_supported_fmt qcow2
41_supported_proto file
42_supported_os Linux
d2a839ed 43_require_working_luks
c75203c8 44
8cedcffd 45do_run_qemu()
c75203c8
KW
46{
47 echo Testing: "$@"
48 $QEMU -nographic -qmp stdio -serial none "$@"
49 echo
50}
51
8cedcffd 52run_qemu()
c75203c8 53{
e6ff69bf
DB
54 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
55 | _filter_qemu | _filter_imgfmt \
44673a0b 56 | _filter_actual_image_size
c75203c8
KW
57}
58
59size=128M
60
61_make_test_img $size
62
63echo
be4b67bc 64echo === Missing ID and node-name ===
c75203c8
KW
65echo
66
67run_qemu <<EOF
68{ "execute": "qmp_capabilities" }
69{ "execute": "blockdev-add",
70 "arguments": {
0153d2f5
KW
71 "driver": "$IMGFMT",
72 "file": {
73 "driver": "file",
74 "filename": "$TEST_IMG"
c75203c8
KW
75 }
76 }
77 }
78{ "execute": "quit" }
79EOF
80
f2d953ec
KW
81echo
82echo === Duplicate ID ===
83echo
84
5feb08ed 85run_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF
f2d953ec
KW
86{ "execute": "qmp_capabilities" }
87{ "execute": "blockdev-add",
88 "arguments": {
0153d2f5
KW
89 "driver": "$IMGFMT",
90 "node-name": "disk",
91 "file": {
d5b8336a 92 "driver": "null-co"
90d9d301
KW
93 }
94 }
95 }
96{ "execute": "blockdev-add",
97 "arguments": {
0153d2f5
KW
98 "driver": "$IMGFMT",
99 "node-name": "test-node",
100 "file": {
d5b8336a 101 "driver": "null-co"
90d9d301
KW
102 }
103 }
104 }
f2d953ec
KW
105{ "execute": "quit" }
106EOF
107
c75203c8
KW
108echo
109echo === aio=native without O_DIRECT ===
110echo
111
c0012e9a 112# Skip this test if AIO is not enabled in this build
8cedcffd 113run_qemu_filter_aio()
c0012e9a
HR
114{
115 run_qemu "$@" | \
116 sed -e 's/is not supported in this build/it requires cache.direct=on, which was not specified/'
117}
118
119run_qemu_filter_aio <<EOF
c75203c8
KW
120{ "execute": "qmp_capabilities" }
121{ "execute": "blockdev-add",
122 "arguments": {
0153d2f5
KW
123 "driver": "$IMGFMT",
124 "node-name": "disk",
125 "file": {
126 "driver": "file",
127 "filename": "$TEST_IMG",
128 "aio": "native"
c75203c8
KW
129 }
130 }
131 }
132{ "execute": "quit" }
133EOF
134
135echo
426d52d8 136echo === Encrypted image QCow ===
c75203c8
KW
137echo
138
b25b387f
DB
139_make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
140run_qemu <<EOF
c3adb58f 141{ "execute": "qmp_capabilities" }
b25b387f 142{ "execute": "object-add",
c3adb58f 143 "arguments": {
b25b387f
DB
144 "qom-type": "secret",
145 "id": "sec0",
146 "props": {
147 "data": "123456"
c3adb58f 148 }
c3adb58f 149 }
b25b387f 150}
c75203c8
KW
151{ "execute": "blockdev-add",
152 "arguments": {
0153d2f5
KW
153 "driver": "$IMGFMT",
154 "node-name": "disk",
155 "file": {
156 "driver": "file",
157 "filename": "$TEST_IMG"
b25b387f
DB
158 },
159 "encrypt": {
160 "format": "aes",
161 "key-secret": "sec0"
c75203c8
KW
162 }
163 }
164 }
165{ "execute": "quit" }
166EOF
167
426d52d8
DB
168echo
169echo === Encrypted image LUKS ===
170echo
171
172_make_test_img --object secret,id=sec0,data=123456 -o encrypt.format=luks,encrypt.key-secret=sec0 $size
173run_qemu <<EOF
174{ "execute": "qmp_capabilities" }
175{ "execute": "object-add",
176 "arguments": {
177 "qom-type": "secret",
178 "id": "sec0",
179 "props": {
180 "data": "123456"
181 }
182 }
183}
184{ "execute": "blockdev-add",
185 "arguments": {
186 "driver": "$IMGFMT",
187 "node-name": "disk",
188 "file": {
189 "driver": "file",
190 "filename": "$TEST_IMG"
191 },
192 "encrypt": {
193 "format": "luks",
194 "key-secret": "sec0"
195 }
196 }
197 }
198{ "execute": "quit" }
199EOF
200
fe509ee2
FZ
201echo
202echo === Missing driver ===
203echo
204
b25b387f 205_make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
fe509ee2
FZ
206run_qemu -S <<EOF
207{ "execute": "qmp_capabilities" }
208{ "execute": "blockdev-add",
209 "arguments": {
0153d2f5 210 "node-name": "disk"
fe509ee2
FZ
211 }
212 }
213{ "execute": "quit" }
214EOF
215
c75203c8
KW
216# success, all done
217echo "*** done"
218rm -f $seq.full
219status=0