target/ppc: introduce GEN_VSX_HELPER_R2 macro to fpu_helper.c
[qemu/ar7.git] / tests / qemu-iotests / 207
blobec8c1d06f00ca19f34a3dedf0842371027798c2b
1 #!/usr/bin/env python
3 # Test ssh 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 import subprocess
25 import re
27 iotests.verify_image_format(supported_fmts=['raw'])
28 iotests.verify_protocol(supported=['ssh'])
30 def filter_hash(qmsg):
31 def _filter(key, value):
32 if key == 'hash' and re.match('[0-9a-f]+', value):
33 return 'HASH'
34 return value
35 return iotests.filter_qmp(qmsg, _filter)
37 def blockdev_create(vm, options):
38 result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
39 filters=[iotests.filter_qmp_testfiles, filter_hash])
41 if 'return' in result:
42 assert result['return'] == {}
43 vm.run_job('job0')
44 iotests.log("")
46 with iotests.FilePath('t.img') as disk_path, \
47 iotests.VM() as vm:
49 remote_path = iotests.remote_filename(disk_path)
52 # Successful image creation (defaults)
54 iotests.log("=== Successful image creation (defaults) ===")
55 iotests.log("")
57 vm.launch()
58 blockdev_create(vm, { 'driver': 'ssh',
59 'location': {
60 'path': disk_path,
61 'server': {
62 'host': '127.0.0.1',
63 'port': '22'
66 'size': 4194304 })
67 vm.shutdown()
69 iotests.img_info_log(remote_path)
70 iotests.log("")
71 iotests.img_info_log(disk_path)
74 # Test host-key-check options
76 iotests.log("=== Test host-key-check options ===")
77 iotests.log("")
79 vm.launch()
80 blockdev_create(vm, { 'driver': 'ssh',
81 'location': {
82 'path': disk_path,
83 'server': {
84 'host': '127.0.0.1',
85 'port': '22'
87 'host-key-check': {
88 'mode': 'none'
91 'size': 8388608 })
92 vm.shutdown()
94 iotests.img_info_log(remote_path)
96 vm.launch()
97 blockdev_create(vm, { 'driver': 'ssh',
98 'location': {
99 'path': disk_path,
100 'server': {
101 'host': '127.0.0.1',
102 'port': '22'
104 'host-key-check': {
105 'mode': 'known_hosts'
108 'size': 4194304 })
109 vm.shutdown()
111 iotests.img_info_log(remote_path)
113 keys = subprocess.check_output(
114 'ssh-keyscan 127.0.0.1 2>/dev/null | grep -v "\\^#" | ' +
115 'cut -d" " -f3',
116 shell=True).rstrip().decode('ascii').split('\n')
118 # Mappings of base64 representations to digests
119 md5_keys = {}
120 sha1_keys = {}
122 for key in keys:
123 md5_keys[key] = subprocess.check_output(
124 'echo %s | base64 -d | md5sum -b | cut -d" " -f1' % key,
125 shell=True).rstrip().decode('ascii')
127 sha1_keys[key] = subprocess.check_output(
128 'echo %s | base64 -d | sha1sum -b | cut -d" " -f1' % key,
129 shell=True).rstrip().decode('ascii')
131 vm.launch()
133 # Find correct key first
134 matching_key = None
135 for key in keys:
136 result = vm.qmp('blockdev-add',
137 driver='ssh', node_name='node0', path=disk_path,
138 server={
139 'host': '127.0.0.1',
140 'port': '22',
141 }, host_key_check={
142 'mode': 'hash',
143 'type': 'md5',
144 'hash': md5_keys[key],
147 if 'error' not in result:
148 vm.qmp('blockdev-del', node_name='node0')
149 matching_key = key
150 break
152 if matching_key is None:
153 vm.shutdown()
154 iotests.notrun('Did not find a key that fits 127.0.0.1')
156 blockdev_create(vm, { 'driver': 'ssh',
157 'location': {
158 'path': disk_path,
159 'server': {
160 'host': '127.0.0.1',
161 'port': '22'
163 'host-key-check': {
164 'mode': 'hash',
165 'type': 'md5',
166 'hash': 'wrong',
169 'size': 2097152 })
170 blockdev_create(vm, { 'driver': 'ssh',
171 'location': {
172 'path': disk_path,
173 'server': {
174 'host': '127.0.0.1',
175 'port': '22'
177 'host-key-check': {
178 'mode': 'hash',
179 'type': 'md5',
180 'hash': md5_keys[matching_key],
183 'size': 8388608 })
184 vm.shutdown()
186 iotests.img_info_log(remote_path)
188 vm.launch()
189 blockdev_create(vm, { 'driver': 'ssh',
190 'location': {
191 'path': disk_path,
192 'server': {
193 'host': '127.0.0.1',
194 'port': '22'
196 'host-key-check': {
197 'mode': 'hash',
198 'type': 'sha1',
199 'hash': 'wrong',
202 'size': 2097152 })
203 blockdev_create(vm, { 'driver': 'ssh',
204 'location': {
205 'path': disk_path,
206 'server': {
207 'host': '127.0.0.1',
208 'port': '22'
210 'host-key-check': {
211 'mode': 'hash',
212 'type': 'sha1',
213 'hash': sha1_keys[matching_key],
216 'size': 4194304 })
217 vm.shutdown()
219 iotests.img_info_log(remote_path)
222 # Invalid path and user
224 iotests.log("=== Invalid path and user ===")
225 iotests.log("")
227 vm.launch()
228 blockdev_create(vm, { 'driver': 'ssh',
229 'location': {
230 'path': '/this/is/not/an/existing/path',
231 'server': {
232 'host': '127.0.0.1',
233 'port': '22'
235 'host-key-check': {
236 'mode': 'none'
239 'size': 4194304 })
240 blockdev_create(vm, { 'driver': 'ssh',
241 'location': {
242 'path': disk_path,
243 'user': 'invalid user',
244 'server': {
245 'host': '127.0.0.1',
246 'port': '22'
248 'host-key-check': {
249 'mode': 'none'
252 'size': 4194304 })
253 vm.shutdown()