iotests.py: Let wait_migration wait even more
[qemu/ar7.git] / tests / qemu-iotests / 210
blob4ca0fe26ef27964de0a643d9f0c9cd14fedc9b29
1 #!/usr/bin/env python
3 # Test luks 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=['luks'])
27 iotests.verify_protocol(supported=['file'])
29 with iotests.FilePath('t.luks') as disk_path, \
30 iotests.VM() as vm:
32 vm.add_object('secret,id=keysec0,data=foo')
35 # Successful image creation (defaults)
37 iotests.log("=== Successful image creation (defaults) ===")
38 iotests.log("")
40 size = 128 * 1024 * 1024
42 vm.launch()
43 vm.blockdev_create({ 'driver': 'file',
44 'filename': disk_path,
45 'size': 0 })
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,
51 'file': 'imgfile',
52 'key-secret': 'keysec0',
53 'size': size,
54 'iter-time': 10 })
55 vm.shutdown()
57 # TODO Proper support for images to be used with imgopts and/or protocols
58 iotests.img_info_log(
59 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
60 filter_path=disk_path,
61 extra_args=['--object', 'secret,id=keysec0,data=foo'],
62 imgopts=True)
65 # Successful image creation (with non-default options)
67 iotests.log("=== Successful image creation (with non-default options) ===")
68 iotests.log("")
70 size = 64 * 1024 * 1024
72 vm.launch()
73 vm.blockdev_create({ 'driver': 'file',
74 'filename': disk_path,
75 'size': 0 })
76 vm.blockdev_create({ 'driver': imgfmt,
77 'file': {
78 'driver': 'file',
79 'filename': disk_path,
81 'size': size,
82 'key-secret': 'keysec0',
83 'cipher-alg': 'twofish-128',
84 'cipher-mode': 'ctr',
85 'ivgen-alg': 'plain64',
86 'ivgen-hash-alg': 'md5',
87 'hash-alg': 'sha1',
88 'iter-time': 10 })
89 vm.shutdown()
91 # TODO Proper support for images to be used with imgopts and/or protocols
92 iotests.img_info_log(
93 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
94 filter_path=disk_path,
95 extra_args=['--object', 'secret,id=keysec0,data=foo'],
96 imgopts=True)
99 # Invalid BlockdevRef
101 iotests.log("=== Invalid BlockdevRef ===")
102 iotests.log("")
104 size = 64 * 1024 * 1024
106 vm.launch()
107 vm.blockdev_create({ 'driver': imgfmt,
108 'file': "this doesn't exist",
109 'size': size })
110 vm.shutdown()
113 # Zero size
115 iotests.log("=== Zero size ===")
116 iotests.log("")
118 vm.add_blockdev('driver=file,filename=%s,node-name=node0' % (disk_path))
119 vm.launch()
120 vm.blockdev_create({ 'driver': imgfmt,
121 'file': 'node0',
122 'key-secret': 'keysec0',
123 'size': 0,
124 'iter-time': 10 })
125 vm.shutdown()
127 # TODO Proper support for images to be used with imgopts and/or protocols
128 iotests.img_info_log(
129 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
130 filter_path=disk_path,
131 extra_args=['--object', 'secret,id=keysec0,data=foo'],
132 imgopts=True)
135 # Invalid sizes
138 # TODO Negative image sizes aren't handled correctly, but this is a problem
139 # with QAPI's implementation of the 'size' type and affects other commands as
140 # well. Once this is fixed, we may want to add a test case here.
142 # 1. 2^64 - 512
143 # 2. 2^63 = 8 EB (qemu-img enforces image sizes less than this)
144 # 3. 2^63 - 512 (generally valid, but with the crypto header the file will
145 # exceed 63 bits)
146 iotests.log("=== Invalid sizes ===")
147 iotests.log("")
149 vm.launch()
150 for size in [ 18446744073709551104, 9223372036854775808, 9223372036854775296 ]:
151 vm.blockdev_create({ 'driver': imgfmt,
152 'file': 'node0',
153 'key-secret': 'keysec0',
154 'size': size })
155 vm.shutdown()
158 # Resize image with invalid sizes
160 iotests.log("=== Resize image with invalid sizes ===")
161 iotests.log("")
163 vm.add_blockdev('driver=luks,file=node0,key-secret=keysec0,node-name=node1')
164 vm.launch()
165 vm.qmp_log('block_resize', node_name='node1', size=9223372036854775296)
166 vm.qmp_log('block_resize', node_name='node1', size=9223372036854775808)
167 vm.qmp_log('block_resize', node_name='node1', size=18446744073709551104)
168 vm.qmp_log('block_resize', node_name='node1', size=-9223372036854775808)
169 vm.shutdown()
171 # TODO Proper support for images to be used with imgopts and/or protocols
172 iotests.img_info_log(
173 'driver=luks,file.driver=file,file.filename=%s,key-secret=keysec0' % (disk_path),
174 filter_path=disk_path,
175 extra_args=['--object', 'secret,id=keysec0,data=foo'],
176 imgopts=True)