tcg: Search includes in the parent source directory
[qemu/ar7.git] / tests / qemu-iotests / 212
blob8f3ccc7b15b3d8bf1eafb6f590ac1e315c8cba47
1 #!/usr/bin/env python
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/>.
23 import iotests
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, \
30 iotests.VM() as vm:
33 # Successful image creation (defaults)
35 iotests.log("=== Successful image creation (defaults) ===")
36 iotests.log("")
38 size = 128 * 1024 * 1024
40 vm.launch()
41 vm.blockdev_create({ 'driver': 'file',
42 'filename': disk_path,
43 'size': 0 })
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,
49 'file': 'imgfile',
50 'size': size })
51 vm.shutdown()
53 iotests.img_info_log(disk_path)
56 # Successful image creation (explicit defaults)
58 iotests.log("=== Successful image creation (explicit defaults) ===")
59 iotests.log("")
61 # Choose a different size to show that we got a new image
62 size = 64 * 1024 * 1024
64 vm.launch()
65 vm.blockdev_create({ 'driver': 'file',
66 'filename': disk_path,
67 'size': 0 })
68 vm.blockdev_create({ 'driver': imgfmt,
69 'file': {
70 'driver': 'file',
71 'filename': disk_path,
73 'size': size,
74 'cluster-size': 1048576 })
75 vm.shutdown()
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) ===")
83 iotests.log("")
85 # Choose a different size to show that we got a new image
86 size = 32 * 1024 * 1024
88 vm.launch()
89 vm.blockdev_create({ 'driver': 'file',
90 'filename': disk_path,
91 'size': 0 })
92 vm.blockdev_create({ 'driver': imgfmt,
93 'file': {
94 'driver': 'file',
95 'filename': disk_path,
97 'size': size,
98 'cluster-size': 65536 })
99 vm.shutdown()
101 iotests.img_info_log(disk_path)
104 # Invalid BlockdevRef
106 iotests.log("=== Invalid BlockdevRef ===")
107 iotests.log("")
109 vm.launch()
110 vm.blockdev_create({ 'driver': imgfmt,
111 'file': "this doesn't exist",
112 'size': size })
113 vm.shutdown()
116 # Zero size
118 iotests.log("=== Zero size ===")
119 iotests.log("")
121 vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
122 vm.launch()
123 vm.blockdev_create({ 'driver': imgfmt,
124 'file': 'node0',
125 'size': 0 })
126 vm.shutdown()
128 iotests.img_info_log(disk_path)
131 # Maximum size
133 iotests.log("=== Maximum size ===")
134 iotests.log("")
136 vm.launch()
137 vm.blockdev_create({ 'driver': imgfmt,
138 'file': 'node0',
139 'size': 4503599627369984})
140 vm.shutdown()
142 iotests.img_info_log(disk_path)
145 # Invalid sizes
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
153 # 2. 2^64 - 512
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
156 # exceed 63 bits)
157 # 5. 2^52 (512 bytes more than maximum image size)
159 iotests.log("=== Invalid sizes ===")
160 iotests.log("")
162 vm.launch()
163 for size in [ 1234, 18446744073709551104, 9223372036854775808,
164 9223372036854775296, 4503599627370497 ]:
165 vm.blockdev_create({ 'driver': imgfmt,
166 'file': 'node0',
167 'size': size })
168 vm.shutdown()
171 # Invalid cluster size
173 iotests.log("=== Invalid cluster size ===")
174 iotests.log("")
176 vm.launch()
177 for csize in [ 1234, 128, 4294967296, 9223372036854775808,
178 18446744073709551104, 0 ]:
179 vm.blockdev_create({ 'driver': imgfmt,
180 'file': 'node0',
181 'size': 67108864,
182 'cluster-size': csize })
183 vm.blockdev_create({ 'driver': imgfmt,
184 'file': 'node0',
185 'size': 281474976710656,
186 'cluster-size': 512 })
187 vm.shutdown()