block: implement bdrv_snapshot_goto for blkreplay
[qemu/ar7.git] / tests / qemu-iotests / 266
blob5b35cd67e46c9d3daca4545d5aee3be4c78cc690
1 #!/usr/bin/env python
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/>.
21 import iotests
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'] == {}
31 vm.run_job('job0')
34 # Successful image creation (defaults)
35 def implicit_defaults(vm, file_path):
36 iotests.log("=== Successful image creation (defaults) ===")
37 iotests.log("")
39 # 8 heads, 964 cyls/head, 17 secs/cyl
40 # (Close to 64 MB)
41 size = 8 * 964 * 17 * 512
43 blockdev_create(vm, { 'driver': imgfmt,
44 'file': 'protocol-node',
45 'size': size })
48 # Successful image creation (explicit defaults)
49 def explicit_defaults(vm, file_path):
50 iotests.log("=== Successful image creation (explicit defaults) ===")
51 iotests.log("")
53 # 16 heads, 964 cyls/head, 17 secs/cyl
54 # (Close to 128 MB)
55 size = 16 * 964 * 17 * 512
57 blockdev_create(vm, { 'driver': imgfmt,
58 'file': 'protocol-node',
59 'size': size,
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) ===")
67 iotests.log("")
69 # Not representable in CHS (fine with force-size=True)
70 size = 1048576
72 blockdev_create(vm, { 'driver': imgfmt,
73 'file': 'protocol-node',
74 'size': size,
75 'subformat': 'fixed',
76 'force-size': True })
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 ===")
82 iotests.log("")
84 # Not representable in CHS (will not work with force-size=False)
85 size = 1048576
87 blockdev_create(vm, { 'driver': imgfmt,
88 'file': 'protocol-node',
89 'size': size,
90 'force-size': False })
93 # Zero size
94 def zero_size(vm, file_path):
95 iotests.log("=== Zero size===")
96 iotests.log("")
98 blockdev_create(vm, { 'driver': imgfmt,
99 'file': 'protocol-node',
100 'size': 0 })
103 # Maximum CHS size
104 def maximum_chs_size(vm, file_path):
105 iotests.log("=== Maximum CHS size===")
106 iotests.log("")
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===")
116 iotests.log("")
118 blockdev_create(vm, { 'driver': imgfmt,
119 'file': 'protocol-node',
120 'size': 0xff000000 * 512,
121 'force-size': True })
124 def main():
125 for test_func in [implicit_defaults, explicit_defaults, non_defaults,
126 non_chs_size_without_force, zero_size, maximum_chs_size,
127 maximum_size]:
129 with iotests.FilePath('t.vpc') as file_path, \
130 iotests.VM() as vm:
132 vm.launch()
134 iotests.log('--- Creating empty file ---')
135 blockdev_create(vm, { 'driver': 'file',
136 'filename': file_path,
137 'size': 0 })
139 vm.qmp_log('blockdev-add', driver='file', filename=file_path,
140 node_name='protocol-node',
141 filters=[iotests.filter_qmp_testfiles])
142 iotests.log('')
144 print_info = test_func(vm, file_path)
145 iotests.log('')
147 vm.shutdown()
148 iotests.img_info_log(file_path)
151 iotests.script_main(main,
152 supported_fmts=['vpc'],
153 supported_protocols=['file'])