hw/arm/sbsa-ref: Remove unnecessary check for secure_sysmem == NULL
[qemu/ar7.git] / tests / qemu-iotests / 194
blobd746ab1e21864ec2d3d94b0911c232fda97c19bd
1 #!/usr/bin/env python
3 # Copyright (C) 2017 Red Hat, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com>
20 # Non-shared storage migration test using NBD server and drive-mirror
22 import iotests
24 iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw'])
25 iotests.verify_platform(['linux'])
27 with iotests.FilePath('source.img') as source_img_path, \
28 iotests.FilePath('dest.img') as dest_img_path, \
29 iotests.FilePath('migration.sock') as migration_sock_path, \
30 iotests.FilePath('nbd.sock') as nbd_sock_path, \
31 iotests.VM('source') as source_vm, \
32 iotests.VM('dest') as dest_vm:
34 img_size = '1G'
35 iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img_size)
36 iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_size)
38 iotests.log('Launching VMs...')
39 (source_vm.add_drive(source_img_path)
40 .launch())
41 (dest_vm.add_drive(dest_img_path)
42 .add_incoming('unix:{0}'.format(migration_sock_path))
43 .launch())
45 iotests.log('Launching NBD server on destination...')
46 iotests.log(dest_vm.qmp('nbd-server-start', addr={'type': 'unix', 'data': {'path': nbd_sock_path}}))
47 iotests.log(dest_vm.qmp('nbd-server-add', device='drive0', writable=True))
49 iotests.log('Starting `drive-mirror` on source...')
50 iotests.log(source_vm.qmp(
51 'drive-mirror',
52 device='drive0',
53 target='nbd+unix:///drive0?socket={0}'.format(nbd_sock_path),
54 sync='full',
55 format='raw', # always raw, the server handles the format
56 mode='existing',
57 job_id='mirror-job0'))
59 iotests.log('Waiting for `drive-mirror` to complete...')
60 iotests.log(source_vm.event_wait('BLOCK_JOB_READY'),
61 filters=[iotests.filter_qmp_event])
63 iotests.log('Starting migration...')
64 source_vm.qmp('migrate-set-capabilities',
65 capabilities=[{'capability': 'events', 'state': True}])
66 dest_vm.qmp('migrate-set-capabilities',
67 capabilities=[{'capability': 'events', 'state': True}])
68 iotests.log(source_vm.qmp('migrate', uri='unix:{0}'.format(migration_sock_path)))
70 while True:
71 event1 = source_vm.event_wait('MIGRATION')
72 iotests.log(event1, filters=[iotests.filter_qmp_event])
73 if event1['data']['status'] in ('completed', 'failed'):
74 iotests.log('Gracefully ending the `drive-mirror` job on source...')
75 iotests.log(source_vm.qmp('block-job-cancel', device='mirror-job0'))
76 break
78 while True:
79 event2 = source_vm.event_wait('BLOCK_JOB_COMPLETED')
80 iotests.log(event2, filters=[iotests.filter_qmp_event])
81 if event2['event'] == 'BLOCK_JOB_COMPLETED':
82 iotests.log('Stopping the NBD server on destination...')
83 iotests.log(dest_vm.qmp('nbd-server-stop'))
84 break