3 # Test parallels and file image creation
5 # Copyright (C) 2018 Red Hat, Inc.
7 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
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.script_initialize(
27 supported_fmts=['parallels'],
28 supported_protocols=['file'],
31 with iotests.FilePath('t.parallels') as disk_path, \
35 # Successful image creation (defaults)
37 iotests.log("=== Successful image creation (defaults) ===")
40 size = 128 * 1024 * 1024
43 vm.blockdev_create({ 'driver': 'file',
44 'filename': disk_path,
47 vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
48 node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
50 vm.blockdev_create({ 'driver': imgfmt,
55 iotests.img_info_log(disk_path)
58 # Successful image creation (explicit defaults)
60 iotests.log("=== Successful image creation (explicit defaults) ===")
63 # Choose a different size to show that we got a new image
64 size = 64 * 1024 * 1024
67 vm.blockdev_create({ 'driver': 'file',
68 'filename': disk_path,
70 vm.blockdev_create({ 'driver': imgfmt,
73 'filename': disk_path,
76 'cluster-size': 1048576 })
79 iotests.img_info_log(disk_path)
82 # Successful image creation (with non-default options)
84 iotests.log("=== Successful image creation (with non-default options) ===")
87 # Choose a different size to show that we got a new image
88 size = 32 * 1024 * 1024
91 vm.blockdev_create({ 'driver': 'file',
92 'filename': disk_path,
94 vm.blockdev_create({ 'driver': imgfmt,
97 'filename': disk_path,
100 'cluster-size': 65536 })
103 iotests.img_info_log(disk_path)
106 # Invalid BlockdevRef
108 iotests.log("=== Invalid BlockdevRef ===")
112 vm.blockdev_create({ 'driver': imgfmt,
113 'file': "this doesn't exist",
120 iotests.log("=== Zero size ===")
123 vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
125 vm.blockdev_create({ 'driver': imgfmt,
130 iotests.img_info_log(disk_path)
135 iotests.log("=== Maximum size ===")
139 vm.blockdev_create({ 'driver': imgfmt,
141 'size': 4503599627369984})
144 iotests.img_info_log(disk_path)
150 # TODO Negative image sizes aren't handled correctly, but this is a problem
151 # with QAPI's implementation of the 'size' type and affects other commands
152 # as well. Once this is fixed, we may want to add a test case here.
154 # 1. Misaligned image size
156 # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
157 # 4. 2^63 - 512 (generally valid, but with the image header the file will
159 # 5. 2^52 (512 bytes more than maximum image size)
161 iotests.log("=== Invalid sizes ===")
165 for size in [ 1234, 18446744073709551104, 9223372036854775808,
166 9223372036854775296, 4503599627370497 ]:
167 vm.blockdev_create({ 'driver': imgfmt,
173 # Invalid cluster size
175 iotests.log("=== Invalid cluster size ===")
179 for csize in [ 1234, 128, 4294967296, 9223372036854775808,
180 18446744073709551104, 0 ]:
181 vm.blockdev_create({ 'driver': imgfmt,
184 'cluster-size': csize })
185 vm.blockdev_create({ 'driver': imgfmt,
187 'size': 281474976710656,
188 'cluster-size': 512 })