Merge remote-tracking branch 'qemu-project/master'
[qemu/ar7.git] / tests / qemu-iotests / 203
blob1ba878522b0e627c7cdcdf0c3ceeceddd6b567fd
1 #!/usr/bin/env python3
2 # group: rw auto migration quick
4 # Copyright (C) 2017 Red Hat, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 # Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com>
21 # Check that QMP 'migrate' with multiple drives on a single IOThread completes
22 # successfully.  This particular command triggered a hang in the source QEMU
23 # process due to recursive AioContext locking in bdrv_invalidate_all() and
24 # BDRV_POLL_WHILE().  Protect against regressions even though the AioContext
25 # lock no longer exists.
27 import iotests
29 iotests.script_initialize(supported_fmts=['qcow2'],
30                           supported_platforms=['linux'])
32 with iotests.FilePath('disk0.img') as disk0_img_path, \
33      iotests.FilePath('disk1.img') as disk1_img_path, \
34      iotests.VM() as vm:
36     img_size = '10M'
37     iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
38     iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
40     iotests.log('Launching VM...')
41     (vm.add_object('iothread,id=iothread0')
42        .add_drive(disk0_img_path, 'node-name=drive0-node', interface='none')
43        .add_drive(disk1_img_path, 'node-name=drive1-node', interface='none')
44        .launch())
46     iotests.log('Setting IOThreads...')
47     iotests.log(vm.qmp('x-blockdev-set-iothread',
48                        node_name='drive0-node', iothread='iothread0',
49                        force=True))
50     iotests.log(vm.qmp('x-blockdev-set-iothread',
51                        node_name='drive1-node', iothread='iothread0',
52                        force=True))
54     iotests.log('Enabling migration QMP events...')
55     iotests.log(vm.qmp('migrate-set-capabilities', capabilities=[
56         {
57             'capability': 'events',
58             'state': True
59         }
60     ]))
62     iotests.log('Starting migration...')
63     iotests.log(vm.qmp('migrate', uri='exec:cat >/dev/null'))
64     while True:
65         event = vm.event_wait('MIGRATION')
66         iotests.log(event, filters=[iotests.filter_qmp_event])
67         if event['data']['status'] == 'completed':
68             break