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