4 # Test VPC and file image creation
6 # Copyright (C) 2019 Red Hat, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 from iotests import imgfmt
26 # Successful image creation (defaults)
27 def implicit_defaults(vm, file_path):
28 iotests.log("=== Successful image creation (defaults) ===")
31 # 8 heads, 964 cyls/head, 17 secs/cyl
33 size = 8 * 964 * 17 * 512
35 vm.blockdev_create({ 'driver': imgfmt,
36 'file': 'protocol-node',
40 # Successful image creation (explicit defaults)
41 def explicit_defaults(vm, file_path):
42 iotests.log("=== Successful image creation (explicit defaults) ===")
45 # 16 heads, 964 cyls/head, 17 secs/cyl
47 size = 16 * 964 * 17 * 512
49 vm.blockdev_create({ 'driver': imgfmt,
50 'file': 'protocol-node',
52 'subformat': 'dynamic',
53 'force-size': False })
56 # Successful image creation (non-default options)
57 def non_defaults(vm, file_path):
58 iotests.log("=== Successful image creation (non-default options) ===")
61 # Not representable in CHS (fine with force-size=True)
64 vm.blockdev_create({ 'driver': imgfmt,
65 'file': 'protocol-node',
71 # Size not representable in CHS with force-size=False
72 def non_chs_size_without_force(vm, file_path):
73 iotests.log("=== Size not representable in CHS ===")
76 # Not representable in CHS (will not work with force-size=False)
79 vm.blockdev_create({ 'driver': imgfmt,
80 'file': 'protocol-node',
82 'force-size': False })
86 def zero_size(vm, file_path):
87 iotests.log("=== Zero size===")
90 vm.blockdev_create({ 'driver': imgfmt,
91 'file': 'protocol-node',
96 def maximum_chs_size(vm, file_path):
97 iotests.log("=== Maximum CHS size===")
100 vm.blockdev_create({ 'driver': imgfmt,
101 'file': 'protocol-node',
102 'size': 16 * 65535 * 255 * 512 })
105 # Actual maximum size
106 def maximum_size(vm, file_path):
107 iotests.log("=== Actual maximum size===")
110 vm.blockdev_create({ 'driver': imgfmt,
111 'file': 'protocol-node',
112 'size': 0xff000000 * 512,
113 'force-size': True })
117 for test_func in [implicit_defaults, explicit_defaults, non_defaults,
118 non_chs_size_without_force, zero_size, maximum_chs_size,
121 with iotests.FilePath('t.vpc') as file_path, \
126 iotests.log('--- Creating empty file ---')
127 vm.blockdev_create({ 'driver': 'file',
128 'filename': file_path,
131 vm.qmp_log('blockdev-add', driver='file', filename=file_path,
132 node_name='protocol-node',
133 filters=[iotests.filter_qmp_testfiles])
136 print_info = test_func(vm, file_path)
140 iotests.img_info_log(file_path, check=False)
143 iotests.script_main(main,
144 supported_fmts=['vpc'],
145 supported_protocols=['file'])