]> git.proxmox.com Git - mirror_qemu.git/blob - tests/qemu-iotests/087
qemu-nbd: add support for authorization of TLS clients
[mirror_qemu.git] / tests / qemu-iotests / 087
1 #!/bin/bash
2 #
3 # Test unsupported blockdev-add cases
4 #
5 # Copyright (C) 2014 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 owner=kwolf@redhat.com
23
24 seq=`basename $0`
25 echo "QA output created by $seq"
26
27 status=1 # failure is the default!
28
29 # get standard environment, filters and checks
30 . ./common.rc
31 . ./common.filter
32
33 _supported_fmt qcow2
34 _supported_proto file
35 _supported_os Linux
36
37 do_run_qemu()
38 {
39 echo Testing: "$@"
40 $QEMU -nographic -qmp stdio -serial none "$@"
41 echo
42 }
43
44 run_qemu()
45 {
46 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
47 | _filter_qemu | _filter_imgfmt \
48 | _filter_actual_image_size
49 }
50
51 size=128M
52
53 _make_test_img $size
54
55 echo
56 echo === Missing ID and node-name ===
57 echo
58
59 run_qemu <<EOF
60 { "execute": "qmp_capabilities" }
61 { "execute": "blockdev-add",
62 "arguments": {
63 "driver": "$IMGFMT",
64 "file": {
65 "driver": "file",
66 "filename": "$TEST_IMG"
67 }
68 }
69 }
70 { "execute": "quit" }
71 EOF
72
73 echo
74 echo === Duplicate ID ===
75 echo
76
77 run_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF
78 { "execute": "qmp_capabilities" }
79 { "execute": "blockdev-add",
80 "arguments": {
81 "driver": "$IMGFMT",
82 "node-name": "disk",
83 "file": {
84 "driver": "null-co"
85 }
86 }
87 }
88 { "execute": "blockdev-add",
89 "arguments": {
90 "driver": "$IMGFMT",
91 "node-name": "test-node",
92 "file": {
93 "driver": "null-co"
94 }
95 }
96 }
97 { "execute": "quit" }
98 EOF
99
100 echo
101 echo === aio=native without O_DIRECT ===
102 echo
103
104 # Skip this test if AIO is not enabled in this build
105 run_qemu_filter_aio()
106 {
107 run_qemu "$@" | \
108 sed -e 's/is not supported in this build/it requires cache.direct=on, which was not specified/'
109 }
110
111 run_qemu_filter_aio <<EOF
112 { "execute": "qmp_capabilities" }
113 { "execute": "blockdev-add",
114 "arguments": {
115 "driver": "$IMGFMT",
116 "node-name": "disk",
117 "file": {
118 "driver": "file",
119 "filename": "$TEST_IMG",
120 "aio": "native"
121 }
122 }
123 }
124 { "execute": "quit" }
125 EOF
126
127 echo
128 echo === Encrypted image QCow ===
129 echo
130
131 _make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
132 run_qemu <<EOF
133 { "execute": "qmp_capabilities" }
134 { "execute": "object-add",
135 "arguments": {
136 "qom-type": "secret",
137 "id": "sec0",
138 "props": {
139 "data": "123456"
140 }
141 }
142 }
143 { "execute": "blockdev-add",
144 "arguments": {
145 "driver": "$IMGFMT",
146 "node-name": "disk",
147 "file": {
148 "driver": "file",
149 "filename": "$TEST_IMG"
150 },
151 "encrypt": {
152 "format": "aes",
153 "key-secret": "sec0"
154 }
155 }
156 }
157 { "execute": "quit" }
158 EOF
159
160 echo
161 echo === Encrypted image LUKS ===
162 echo
163
164 _make_test_img --object secret,id=sec0,data=123456 -o encrypt.format=luks,encrypt.key-secret=sec0 $size
165 run_qemu <<EOF
166 { "execute": "qmp_capabilities" }
167 { "execute": "object-add",
168 "arguments": {
169 "qom-type": "secret",
170 "id": "sec0",
171 "props": {
172 "data": "123456"
173 }
174 }
175 }
176 { "execute": "blockdev-add",
177 "arguments": {
178 "driver": "$IMGFMT",
179 "node-name": "disk",
180 "file": {
181 "driver": "file",
182 "filename": "$TEST_IMG"
183 },
184 "encrypt": {
185 "format": "luks",
186 "key-secret": "sec0"
187 }
188 }
189 }
190 { "execute": "quit" }
191 EOF
192
193 echo
194 echo === Missing driver ===
195 echo
196
197 _make_test_img --object secret,id=sec0,data=123456 -o encryption=on,encrypt.key-secret=sec0 $size
198 run_qemu -S <<EOF
199 { "execute": "qmp_capabilities" }
200 { "execute": "blockdev-add",
201 "arguments": {
202 "node-name": "disk"
203 }
204 }
205 { "execute": "quit" }
206 EOF
207
208 # success, all done
209 echo "*** done"
210 rm -f $seq.full
211 status=0