3 # Test VPC and file image creation
5 # Copyright (C) 2019 Red Hat, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 from iotests import imgfmt
25 # Successful image creation (defaults)
26 def implicit_defaults(vm, file_path):
27 iotests.log("=== Successful image creation (defaults) ===")
30 # 8 heads, 964 cyls/head, 17 secs/cyl
32 size = 8 * 964 * 17 * 512
34 vm.blockdev_create({ 'driver': imgfmt,
35 'file': 'protocol-node',
39 # Successful image creation (explicit defaults)
40 def explicit_defaults(vm, file_path):
41 iotests.log("=== Successful image creation (explicit defaults) ===")
44 # 16 heads, 964 cyls/head, 17 secs/cyl
46 size = 16 * 964 * 17 * 512
48 vm.blockdev_create({ 'driver': imgfmt,
49 'file': 'protocol-node',
51 'subformat': 'dynamic',
52 'force-size': False })
55 # Successful image creation (non-default options)
56 def non_defaults(vm, file_path):
57 iotests.log("=== Successful image creation (non-default options) ===")
60 # Not representable in CHS (fine with force-size=True)
63 vm.blockdev_create({ 'driver': imgfmt,
64 'file': 'protocol-node',
70 # Size not representable in CHS with force-size=False
71 def non_chs_size_without_force(vm, file_path):
72 iotests.log("=== Size not representable in CHS ===")
75 # Not representable in CHS (will not work with force-size=False)
78 vm.blockdev_create({ 'driver': imgfmt,
79 'file': 'protocol-node',
81 'force-size': False })
85 def zero_size(vm, file_path):
86 iotests.log("=== Zero size===")
89 vm.blockdev_create({ 'driver': imgfmt,
90 'file': 'protocol-node',
95 def maximum_chs_size(vm, file_path):
96 iotests.log("=== Maximum CHS size===")
99 vm.blockdev_create({ 'driver': imgfmt,
100 'file': 'protocol-node',
101 'size': 16 * 65535 * 255 * 512 })
104 # Actual maximum size
105 def maximum_size(vm, file_path):
106 iotests.log("=== Actual maximum size===")
109 vm.blockdev_create({ 'driver': imgfmt,
110 'file': 'protocol-node',
111 'size': 0xff000000 * 512,
112 'force-size': True })
116 for test_func in [implicit_defaults, explicit_defaults, non_defaults,
117 non_chs_size_without_force, zero_size, maximum_chs_size,
120 with iotests.FilePath('t.vpc') as file_path, \
125 iotests.log('--- Creating empty file ---')
126 vm.blockdev_create({ 'driver': 'file',
127 'filename': file_path,
130 vm.qmp_log('blockdev-add', driver='file', filename=file_path,
131 node_name='protocol-node',
132 filters=[iotests.filter_qmp_testfiles])
135 print_info = test_func(vm, file_path)
139 iotests.img_info_log(file_path)
142 iotests.script_main(main,
143 supported_fmts=['vpc'],
144 supported_protocols=['file'])