1*7c477526SPhilippe Mathieu-Daudé#!/usr/bin/env python3 27a9dda0dSStefan Hajnoczi# 37a9dda0dSStefan Hajnoczi# Copyright (C) 2017 Red Hat, Inc. 47a9dda0dSStefan Hajnoczi# 57a9dda0dSStefan Hajnoczi# This program is free software; you can redistribute it and/or modify 67a9dda0dSStefan Hajnoczi# it under the terms of the GNU General Public License as published by 77a9dda0dSStefan Hajnoczi# the Free Software Foundation; either version 2 of the License, or 87a9dda0dSStefan Hajnoczi# (at your option) any later version. 97a9dda0dSStefan Hajnoczi# 107a9dda0dSStefan Hajnoczi# This program is distributed in the hope that it will be useful, 117a9dda0dSStefan Hajnoczi# but WITHOUT ANY WARRANTY; without even the implied warranty of 127a9dda0dSStefan Hajnoczi# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 137a9dda0dSStefan Hajnoczi# GNU General Public License for more details. 147a9dda0dSStefan Hajnoczi# 157a9dda0dSStefan Hajnoczi# You should have received a copy of the GNU General Public License 167a9dda0dSStefan Hajnoczi# along with this program. If not, see <http://www.gnu.org/licenses/>. 177a9dda0dSStefan Hajnoczi# 187a9dda0dSStefan Hajnoczi# Creator/Owner: Stefan Hajnoczi <stefanha@redhat.com> 197a9dda0dSStefan Hajnoczi# 207a9dda0dSStefan Hajnoczi# Check that QMP 'migrate' with multiple drives on a single IOThread completes 217a9dda0dSStefan Hajnoczi# successfully. This particular command triggered a hang in the source QEMU 227a9dda0dSStefan Hajnoczi# process due to recursive AioContext locking in bdrv_invalidate_all() and 237a9dda0dSStefan Hajnoczi# BDRV_POLL_WHILE(). 247a9dda0dSStefan Hajnoczi 257a9dda0dSStefan Hajnocziimport iotests 267a9dda0dSStefan Hajnoczi 277a9dda0dSStefan Hajnocziiotests.verify_image_format(supported_fmts=['qcow2']) 287a9dda0dSStefan Hajnocziiotests.verify_platform(['linux']) 297a9dda0dSStefan Hajnoczi 307a9dda0dSStefan Hajnocziwith iotests.FilePath('disk0.img') as disk0_img_path, \ 317a9dda0dSStefan Hajnoczi iotests.FilePath('disk1.img') as disk1_img_path, \ 327a9dda0dSStefan Hajnoczi iotests.VM() as vm: 337a9dda0dSStefan Hajnoczi 347a9dda0dSStefan Hajnoczi img_size = '10M' 357a9dda0dSStefan Hajnoczi iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size) 367a9dda0dSStefan Hajnoczi iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size) 377a9dda0dSStefan Hajnoczi 387a9dda0dSStefan Hajnoczi iotests.log('Launching VM...') 397a9dda0dSStefan Hajnoczi (vm.add_object('iothread,id=iothread0') 407a9dda0dSStefan Hajnoczi .add_drive(disk0_img_path, 'node-name=drive0-node', interface='none') 417a9dda0dSStefan Hajnoczi .add_drive(disk1_img_path, 'node-name=drive1-node', interface='none') 427a9dda0dSStefan Hajnoczi .launch()) 437a9dda0dSStefan Hajnoczi 447a9dda0dSStefan Hajnoczi iotests.log('Setting IOThreads...') 457a9dda0dSStefan Hajnoczi iotests.log(vm.qmp('x-blockdev-set-iothread', 467a9dda0dSStefan Hajnoczi node_name='drive0-node', iothread='iothread0', 477a9dda0dSStefan Hajnoczi force=True)) 487a9dda0dSStefan Hajnoczi iotests.log(vm.qmp('x-blockdev-set-iothread', 497a9dda0dSStefan Hajnoczi node_name='drive1-node', iothread='iothread0', 507a9dda0dSStefan Hajnoczi force=True)) 517a9dda0dSStefan Hajnoczi 5221794244SStefan Hajnoczi iotests.log('Enabling migration QMP events...') 5321794244SStefan Hajnoczi iotests.log(vm.qmp('migrate-set-capabilities', capabilities=[ 5421794244SStefan Hajnoczi { 5521794244SStefan Hajnoczi 'capability': 'events', 5621794244SStefan Hajnoczi 'state': True 5721794244SStefan Hajnoczi } 5821794244SStefan Hajnoczi ])) 5921794244SStefan Hajnoczi 607a9dda0dSStefan Hajnoczi iotests.log('Starting migration...') 617a9dda0dSStefan Hajnoczi iotests.log(vm.qmp('migrate', uri='exec:cat >/dev/null')) 627a9dda0dSStefan Hajnoczi while True: 6321794244SStefan Hajnoczi event = vm.event_wait('MIGRATION') 6421794244SStefan Hajnoczi iotests.log(event, filters=[iotests.filter_qmp_event]) 6521794244SStefan Hajnoczi if event['data']['status'] == 'completed': 667a9dda0dSStefan Hajnoczi break 67