vhost: Allow adjoining regions
[qemu/ar7.git] / tests / qemu-iotests / 212
blobe5a1ba77cec68d8295398a1a144a95e534547a25
1 #!/bin/bash
3 # Test parallels and file image creation
5 # Copyright (C) 2018 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/>.
21 # creator
22 owner=kwolf@redhat.com
24 seq=`basename $0`
25 echo "QA output created by $seq"
27 here=`pwd`
28 status=1 # failure is the default!
30 # get standard environment, filters and checks
31 . ./common.rc
32 . ./common.filter
34 _supported_fmt parallels
35 _supported_proto file
36 _supported_os Linux
38 function do_run_qemu()
40 echo Testing: "$@"
41 $QEMU -nographic -qmp stdio -serial none "$@"
42 echo
45 function run_qemu()
47 do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp \
48 | _filter_qemu | _filter_imgfmt \
49 | _filter_actual_image_size
52 echo
53 echo "=== Successful image creation (defaults) ==="
54 echo
56 size=$((128 * 1024 * 1024))
58 run_qemu <<EOF
59 { "execute": "qmp_capabilities" }
60 { "execute": "x-blockdev-create",
61 "arguments": {
62 "driver": "file",
63 "filename": "$TEST_IMG",
64 "size": 0
67 { "execute": "blockdev-add",
68 "arguments": {
69 "driver": "file",
70 "node-name": "imgfile",
71 "filename": "$TEST_IMG"
74 { "execute": "x-blockdev-create",
75 "arguments": {
76 "driver": "$IMGFMT",
77 "file": "imgfile",
78 "size": $size
81 { "execute": "quit" }
82 EOF
84 _img_info --format-specific | _filter_img_info --format-specific
86 echo
87 echo "=== Successful image creation (explicit defaults) ==="
88 echo
90 # Choose a different size to show that we got a new image
91 size=$((64 * 1024 * 1024))
93 run_qemu <<EOF
94 { "execute": "qmp_capabilities" }
95 { "execute": "x-blockdev-create",
96 "arguments": {
97 "driver": "file",
98 "filename": "$TEST_IMG",
99 "size": 0
102 { "execute": "x-blockdev-create",
103 "arguments": {
104 "driver": "$IMGFMT",
105 "file": {
106 "driver": "file",
107 "filename": "$TEST_IMG"
109 "size": $size,
110 "cluster-size": 1048576
113 { "execute": "quit" }
116 _img_info --format-specific | _filter_img_info --format-specific
118 echo
119 echo "=== Successful image creation (with non-default options) ==="
120 echo
122 # Choose a different size to show that we got a new image
123 size=$((32 * 1024 * 1024))
125 run_qemu <<EOF
126 { "execute": "qmp_capabilities" }
127 { "execute": "x-blockdev-create",
128 "arguments": {
129 "driver": "file",
130 "filename": "$TEST_IMG",
131 "size": 0
134 { "execute": "x-blockdev-create",
135 "arguments": {
136 "driver": "$IMGFMT",
137 "file": {
138 "driver": "file",
139 "filename": "$TEST_IMG"
141 "size": $size,
142 "cluster-size": 65536
145 { "execute": "quit" }
148 _img_info --format-specific | _filter_img_info --format-specific
150 echo
151 echo "=== Invalid BlockdevRef ==="
152 echo
154 run_qemu <<EOF
155 { "execute": "qmp_capabilities" }
156 { "execute": "x-blockdev-create",
157 "arguments": {
158 "driver": "$IMGFMT",
159 "file": "this doesn't exist",
160 "size": $size
163 { "execute": "quit" }
166 echo
167 echo "=== Zero size ==="
168 echo
170 run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
171 { "execute": "qmp_capabilities" }
172 { "execute": "x-blockdev-create",
173 "arguments": {
174 "driver": "$IMGFMT",
175 "file": "node0",
176 "size": 0
179 { "execute": "quit" }
182 _img_info | _filter_img_info
184 echo
185 echo "=== Maximum size ==="
186 echo
188 run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
189 { "execute": "qmp_capabilities" }
190 { "execute": "x-blockdev-create",
191 "arguments": {
192 "driver": "$IMGFMT",
193 "file": "node0",
194 "size": 4503599627369984
197 { "execute": "quit" }
200 _img_info | _filter_img_info
202 echo
203 echo "=== Invalid sizes ==="
204 echo
206 # TODO Negative image sizes aren't handled correctly, but this is a problem
207 # with QAPI's implementation of the 'size' type and affects other commands as
208 # well. Once this is fixed, we may want to add a test case here.
210 # 1. Misaligned image size
211 # 2. 2^64 - 512
212 # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
213 # 4. 2^63 - 512 (generally valid, but with the image header the file will
214 # exceed 63 bits)
215 # 5. 2^52 (512 bytes more than maximum image size)
217 run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
218 { "execute": "qmp_capabilities" }
219 { "execute": "x-blockdev-create",
220 "arguments": {
221 "driver": "$IMGFMT",
222 "file": "node0",
223 "size": 1234
226 { "execute": "x-blockdev-create",
227 "arguments": {
228 "driver": "$IMGFMT",
229 "file": "node0",
230 "size": 18446744073709551104
233 { "execute": "x-blockdev-create",
234 "arguments": {
235 "driver": "$IMGFMT",
236 "file": "node0",
237 "size": 9223372036854775808
240 { "execute": "x-blockdev-create",
241 "arguments": {
242 "driver": "$IMGFMT",
243 "file": "node0",
244 "size": 9223372036854775296
247 { "execute": "x-blockdev-create",
248 "arguments": {
249 "driver": "$IMGFMT",
250 "file": "node0",
251 "size": 4503599627370497
254 { "execute": "quit" }
257 echo
258 echo "=== Invalid cluster size ==="
259 echo
261 run_qemu -blockdev driver=file,filename="$TEST_IMG",node-name=node0 <<EOF
262 { "execute": "qmp_capabilities" }
263 { "execute": "x-blockdev-create",
264 "arguments": {
265 "driver": "$IMGFMT",
266 "file": "node0",
267 "size": 67108864,
268 "cluster-size": 1234
271 { "execute": "x-blockdev-create",
272 "arguments": {
273 "driver": "$IMGFMT",
274 "file": "node0",
275 "size": 67108864,
276 "cluster-size": 128
279 { "execute": "x-blockdev-create",
280 "arguments": {
281 "driver": "$IMGFMT",
282 "file": "node0",
283 "size": 67108864,
284 "cluster-size": 4294967296
287 { "execute": "x-blockdev-create",
288 "arguments": {
289 "driver": "$IMGFMT",
290 "file": "node0",
291 "size": 67108864,
292 "cluster-size": 9223372036854775808
295 { "execute": "x-blockdev-create",
296 "arguments": {
297 "driver": "$IMGFMT",
298 "file": "node0",
299 "size": 67108864,
300 "cluster-size": 18446744073709551104
303 { "execute": "x-blockdev-create",
304 "arguments": {
305 "driver": "$IMGFMT",
306 "file": "node0",
307 "size": 67108864,
308 "cluster-size": 0
311 { "execute": "x-blockdev-create",
312 "arguments": {
313 "driver": "$IMGFMT",
314 "file": "node0",
315 "size": 281474976710656,
316 "cluster-size": 512
319 { "execute": "quit" }
323 # success, all done
324 echo "*** done"
325 rm -f $seq.full
326 status=0