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/>.
22 owner
=kwolf@redhat.com
25 echo "QA output created by $seq"
28 status
=1 # failure is the default!
30 # get standard environment, filters and checks
34 _supported_fmt parallels
38 function do_run_qemu
()
41 $QEMU -nographic -qmp stdio
-serial none
"$@"
47 do_run_qemu
"$@" 2>&1 | _filter_testdir | _filter_qmp \
48 | _filter_qemu | _filter_imgfmt \
49 | _filter_actual_image_size
53 echo "=== Successful image creation (defaults) ==="
56 size
=$
((128 * 1024 * 1024))
59 { "execute": "qmp_capabilities" }
60 { "execute": "x-blockdev-create",
63 "filename": "$TEST_IMG",
67 { "execute": "blockdev-add",
70 "node-name": "imgfile",
71 "filename": "$TEST_IMG"
74 { "execute": "x-blockdev-create",
84 _img_info
--format-specific | _filter_img_info
--format-specific
87 echo "=== Successful image creation (explicit defaults) ==="
90 # Choose a different size to show that we got a new image
91 size
=$
((64 * 1024 * 1024))
94 { "execute": "qmp_capabilities" }
95 { "execute": "x-blockdev-create",
98 "filename": "$TEST_IMG",
102 { "execute": "x-blockdev-create",
107 "filename": "$TEST_IMG"
110 "cluster-size": 1048576
113 { "execute": "quit" }
116 _img_info
--format-specific | _filter_img_info
--format-specific
119 echo "=== Successful image creation (with non-default options) ==="
122 # Choose a different size to show that we got a new image
123 size
=$
((32 * 1024 * 1024))
126 { "execute": "qmp_capabilities" }
127 { "execute": "x-blockdev-create",
130 "filename": "$TEST_IMG",
134 { "execute": "x-blockdev-create",
139 "filename": "$TEST_IMG"
142 "cluster-size": 65536
145 { "execute": "quit" }
148 _img_info
--format-specific | _filter_img_info
--format-specific
151 echo "=== Invalid BlockdevRef ==="
155 { "execute": "qmp_capabilities" }
156 { "execute": "x-blockdev-create",
159 "file": "this doesn't exist",
163 { "execute": "quit" }
167 echo "=== Zero size ==="
170 run_qemu
-blockdev driver
=file,filename
="$TEST_IMG",node-name
=node0
<<EOF
171 { "execute": "qmp_capabilities" }
172 { "execute": "x-blockdev-create",
179 { "execute": "quit" }
182 _img_info | _filter_img_info
185 echo "=== Maximum size ==="
188 run_qemu
-blockdev driver
=file,filename
="$TEST_IMG",node-name
=node0
<<EOF
189 { "execute": "qmp_capabilities" }
190 { "execute": "x-blockdev-create",
194 "size": 4503599627369984
197 { "execute": "quit" }
200 _img_info | _filter_img_info
203 echo "=== Invalid sizes ==="
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
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
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",
226 { "execute": "x-blockdev-create",
230 "size": 18446744073709551104
233 { "execute": "x-blockdev-create",
237 "size": 9223372036854775808
240 { "execute": "x-blockdev-create",
244 "size": 9223372036854775296
247 { "execute": "x-blockdev-create",
251 "size": 4503599627370497
254 { "execute": "quit" }
258 echo "=== Invalid cluster size ==="
261 run_qemu
-blockdev driver
=file,filename
="$TEST_IMG",node-name
=node0
<<EOF
262 { "execute": "qmp_capabilities" }
263 { "execute": "x-blockdev-create",
271 { "execute": "x-blockdev-create",
279 { "execute": "x-blockdev-create",
284 "cluster-size": 4294967296
287 { "execute": "x-blockdev-create",
292 "cluster-size": 9223372036854775808
295 { "execute": "x-blockdev-create",
300 "cluster-size": 18446744073709551104
303 { "execute": "x-blockdev-create",
311 { "execute": "x-blockdev-create",
315 "size": 281474976710656,
319 { "execute": "quit" }