3 # Test parallels and file image creation
5 # Copyright (C) 2018 Red Hat, Inc.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 from iotests import imgfmt
26 iotests.verify_image_format(supported_fmts=['parallels'])
27 iotests.verify_protocol(supported=['file'])
29 with iotests.FilePath('t.parallels') as disk_path, \
33 # Successful image creation (defaults)
35 iotests.log("=== Successful image creation (defaults) ===")
38 size = 128 * 1024 * 1024
41 vm.blockdev_create({ 'driver': 'file',
42 'filename': disk_path,
45 vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
46 node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
48 vm.blockdev_create({ 'driver': imgfmt,
53 iotests.img_info_log(disk_path)
56 # Successful image creation (explicit defaults)
58 iotests.log("=== Successful image creation (explicit defaults) ===")
61 # Choose a different size to show that we got a new image
62 size = 64 * 1024 * 1024
65 vm.blockdev_create({ 'driver': 'file',
66 'filename': disk_path,
68 vm.blockdev_create({ 'driver': imgfmt,
71 'filename': disk_path,
74 'cluster-size': 1048576 })
77 iotests.img_info_log(disk_path)
80 # Successful image creation (with non-default options)
82 iotests.log("=== Successful image creation (with non-default options) ===")
85 # Choose a different size to show that we got a new image
86 size = 32 * 1024 * 1024
89 vm.blockdev_create({ 'driver': 'file',
90 'filename': disk_path,
92 vm.blockdev_create({ 'driver': imgfmt,
95 'filename': disk_path,
98 'cluster-size': 65536 })
101 iotests.img_info_log(disk_path)
104 # Invalid BlockdevRef
106 iotests.log("=== Invalid BlockdevRef ===")
110 vm.blockdev_create({ 'driver': imgfmt,
111 'file': "this doesn't exist",
118 iotests.log("=== Zero size ===")
121 vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
123 vm.blockdev_create({ 'driver': imgfmt,
128 iotests.img_info_log(disk_path)
133 iotests.log("=== Maximum size ===")
137 vm.blockdev_create({ 'driver': imgfmt,
139 'size': 4503599627369984})
142 iotests.img_info_log(disk_path)
148 # TODO Negative image sizes aren't handled correctly, but this is a problem
149 # with QAPI's implementation of the 'size' type and affects other commands
150 # as well. Once this is fixed, we may want to add a test case here.
152 # 1. Misaligned image size
154 # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
155 # 4. 2^63 - 512 (generally valid, but with the image header the file will
157 # 5. 2^52 (512 bytes more than maximum image size)
159 iotests.log("=== Invalid sizes ===")
163 for size in [ 1234, 18446744073709551104, 9223372036854775808,
164 9223372036854775296, 4503599627370497 ]:
165 vm.blockdev_create({ 'driver': imgfmt,
171 # Invalid cluster size
173 iotests.log("=== Invalid cluster size ===")
177 for csize in [ 1234, 128, 4294967296, 9223372036854775808,
178 18446744073709551104, 0 ]:
179 vm.blockdev_create({ 'driver': imgfmt,
182 'cluster-size': csize })
183 vm.blockdev_create({ 'driver': imgfmt,
185 'size': 281474976710656,
186 'cluster-size': 512 })