4 # Test parallels and file image creation
6 # Copyright (C) 2018 Red Hat, Inc.
8 # Creator/Owner: Kevin Wolf <kwolf@redhat.com>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 from iotests import imgfmt
27 iotests.script_initialize(
28 supported_fmts=['parallels'],
29 supported_protocols=['file'],
32 with iotests.FilePath('t.parallels') as disk_path, \
36 # Successful image creation (defaults)
38 iotests.log("=== Successful image creation (defaults) ===")
41 size = 128 * 1024 * 1024
44 vm.blockdev_create({ 'driver': 'file',
45 'filename': disk_path,
48 vm.qmp_log('blockdev-add', driver='file', filename=disk_path,
49 node_name='imgfile', filters=[iotests.filter_qmp_testfiles])
51 vm.blockdev_create({ 'driver': imgfmt,
56 iotests.img_info_log(disk_path)
59 # Successful image creation (explicit defaults)
61 iotests.log("=== Successful image creation (explicit defaults) ===")
64 # Choose a different size to show that we got a new image
65 size = 64 * 1024 * 1024
68 vm.blockdev_create({ 'driver': 'file',
69 'filename': disk_path,
71 vm.blockdev_create({ 'driver': imgfmt,
74 'filename': disk_path,
77 'cluster-size': 1048576 })
80 iotests.img_info_log(disk_path)
83 # Successful image creation (with non-default options)
85 iotests.log("=== Successful image creation (with non-default options) ===")
88 # Choose a different size to show that we got a new image
89 size = 32 * 1024 * 1024
92 vm.blockdev_create({ 'driver': 'file',
93 'filename': disk_path,
95 vm.blockdev_create({ 'driver': imgfmt,
98 'filename': disk_path,
101 'cluster-size': 65536 })
104 iotests.img_info_log(disk_path)
107 # Invalid BlockdevRef
109 iotests.log("=== Invalid BlockdevRef ===")
113 vm.blockdev_create({ 'driver': imgfmt,
114 'file': "this doesn't exist",
121 iotests.log("=== Zero size ===")
124 vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
126 vm.blockdev_create({ 'driver': imgfmt,
131 iotests.img_info_log(disk_path)
136 iotests.log("=== Maximum size ===")
140 vm.blockdev_create({ 'driver': imgfmt,
142 'size': 4503599627369984})
145 iotests.img_info_log(disk_path)
151 # TODO Negative image sizes aren't handled correctly, but this is a problem
152 # with QAPI's implementation of the 'size' type and affects other commands
153 # as well. Once this is fixed, we may want to add a test case here.
155 # 1. Misaligned image size
157 # 3. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
158 # 4. 2^63 - 512 (generally valid, but with the image header the file will
160 # 5. 2^52 (512 bytes more than maximum image size)
162 iotests.log("=== Invalid sizes ===")
166 for size in [ 1234, 18446744073709551104, 9223372036854775808,
167 9223372036854775296, 4503599627370497 ]:
168 vm.blockdev_create({ 'driver': imgfmt,
174 # Invalid cluster size
176 iotests.log("=== Invalid cluster size ===")
180 for csize in [ 1234, 128, 4294967296, 9223372036854775808,
181 18446744073709551104, 0 ]:
182 vm.blockdev_create({ 'driver': imgfmt,
185 'cluster-size': csize })
186 vm.blockdev_create({ 'driver': imgfmt,
188 'size': 281474976710656,
189 'cluster-size': 512 })