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 def blockdev_create(vm
, options
):
26 result
= vm
.qmp_log('blockdev-create', job_id
='job0', options
=options
,
27 filters
=[iotests
.filter_qmp_testfiles
])
29 if 'return' in result
:
30 assert result
['return'] == {}
34 # Successful image creation (defaults)
35 def implicit_defaults(vm
, file_path
):
36 iotests
.log("=== Successful image creation (defaults) ===")
39 # 8 heads, 964 cyls/head, 17 secs/cyl
41 size
= 8 * 964 * 17 * 512
43 blockdev_create(vm
, { 'driver': imgfmt
,
44 'file': 'protocol-node',
48 # Successful image creation (explicit defaults)
49 def explicit_defaults(vm
, file_path
):
50 iotests
.log("=== Successful image creation (explicit defaults) ===")
53 # 16 heads, 964 cyls/head, 17 secs/cyl
55 size
= 16 * 964 * 17 * 512
57 blockdev_create(vm
, { 'driver': imgfmt
,
58 'file': 'protocol-node',
60 'subformat': 'dynamic',
61 'force-size': False })
64 # Successful image creation (non-default options)
65 def non_defaults(vm
, file_path
):
66 iotests
.log("=== Successful image creation (non-default options) ===")
69 # Not representable in CHS (fine with force-size=True)
72 blockdev_create(vm
, { 'driver': imgfmt
,
73 'file': 'protocol-node',
79 # Size not representable in CHS with force-size=False
80 def non_chs_size_without_force(vm
, file_path
):
81 iotests
.log("=== Size not representable in CHS ===")
84 # Not representable in CHS (will not work with force-size=False)
87 blockdev_create(vm
, { 'driver': imgfmt
,
88 'file': 'protocol-node',
90 'force-size': False })
94 def zero_size(vm
, file_path
):
95 iotests
.log("=== Zero size===")
98 blockdev_create(vm
, { 'driver': imgfmt
,
99 'file': 'protocol-node',
104 def maximum_chs_size(vm
, file_path
):
105 iotests
.log("=== Maximum CHS size===")
108 blockdev_create(vm
, { 'driver': imgfmt
,
109 'file': 'protocol-node',
110 'size': 16 * 65535 * 255 * 512 })
113 # Actual maximum size
114 def maximum_size(vm
, file_path
):
115 iotests
.log("=== Actual maximum size===")
118 blockdev_create(vm
, { 'driver': imgfmt
,
119 'file': 'protocol-node',
120 'size': 0xff000000 * 512,
121 'force-size': True })
125 for test_func
in [implicit_defaults
, explicit_defaults
, non_defaults
,
126 non_chs_size_without_force
, zero_size
, maximum_chs_size
,
129 with iotests
.FilePath('t.vpc') as file_path
, \
134 iotests
.log('--- Creating empty file ---')
135 blockdev_create(vm
, { 'driver': 'file',
136 'filename': file_path
,
139 vm
.qmp_log('blockdev-add', driver
='file', filename
=file_path
,
140 node_name
='protocol-node',
141 filters
=[iotests
.filter_qmp_testfiles
])
144 print_info
= test_func(vm
, file_path
)
148 iotests
.img_info_log(file_path
)
151 iotests
.script_main(main
,
152 supported_fmts
=['vpc'],
153 supported_protocols
=['file'])