From nobody Tue Apr 15 06:10:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549041452706787.897677844513; Fri, 1 Feb 2019 09:17:32 -0800 (PST) Received: from localhost ([127.0.0.1]:58475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpcRS-0007c6-FY for importer@patchew.org; Fri, 01 Feb 2019 12:17:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpboB-0007s7-63 for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:36:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbo7-00008f-MJ for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:36:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44122) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpbnt-00082h-2h; Fri, 01 Feb 2019 11:36:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 585B72DE40D; Fri, 1 Feb 2019 16:35:42 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-95.ams2.redhat.com [10.36.117.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AF95608C8; Fri, 1 Feb 2019 16:35:40 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 1 Feb 2019 17:34:58 +0100 Message-Id: <20190201163518.31157-8-kwolf@redhat.com> In-Reply-To: <20190201163518.31157-1-kwolf@redhat.com> References: <20190201163518.31157-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 01 Feb 2019 16:35:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 07/27] iotests: Make 234 stable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Max Reitz This test waits for a MIGRATION event with status=3Dcompleted on the source VM before querying the migration status on both source and destination. However, just because the source says migration has completed does not mean the destination thinks the same. Therefore, in some cases, the destination VM may still report "active" instead of "completed" when asked for its migration status. Fix this by enabling migration events on both VMs and waiting until both source and destination emit a status=3Dcompleted MIGRATION event. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- tests/qemu-iotests/234 | 56 ++++++++++++++++++++------------------ tests/qemu-iotests/234.out | 10 +++++-- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234 index a8185b4360..c4c26bc21e 100755 --- a/tests/qemu-iotests/234 +++ b/tests/qemu-iotests/234 @@ -26,6 +26,22 @@ import os iotests.verify_image_format(supported_fmts=3D['qcow2']) iotests.verify_platform(['linux']) =20 +def enable_migration_events(vm, name): + iotests.log('Enabling migration QMP events on %s...' % name) + iotests.log(vm.qmp('migrate-set-capabilities', capabilities=3D[ + { + 'capability': 'events', + 'state': True + } + ])) + +def wait_migration(vm): + while True: + event =3D vm.event_wait('MIGRATION') + iotests.log(event, filters=3D[iotests.filter_qmp_event]) + if event['data']['status'] =3D=3D 'completed': + break + with iotests.FilePath('img') as img_path, \ iotests.FilePath('backing') as backing_path, \ iotests.FilePath('mig_fifo_a') as fifo_a, \ @@ -46,6 +62,8 @@ with iotests.FilePath('img') as img_path, \ .add_blockdev('%s,file=3Ddrive0-backing-file,node-name=3Ddrive0-b= acking' % (iotests.imgfmt)) .launch()) =20 + enable_migration_events(vm_a, 'A') + iotests.log('Launching destination VM...') (vm_b.add_blockdev('file,filename=3D%s,node-name=3Ddrive0-file' % (img= _path)) .add_blockdev('%s,file=3Ddrive0-file,node-name=3Ddrive0' % (iotes= ts.imgfmt)) @@ -54,6 +72,8 @@ with iotests.FilePath('img') as img_path, \ .add_incoming("exec: cat '%s'" % (fifo_a)) .launch()) =20 + enable_migration_events(vm_b, 'B') + # Add a child node that was created after the parent node. The reverse= case # is covered by the -blockdev options above. iotests.log(vm_a.qmp('blockdev-snapshot', node=3D'drive0-backing', @@ -61,22 +81,13 @@ with iotests.FilePath('img') as img_path, \ iotests.log(vm_b.qmp('blockdev-snapshot', node=3D'drive0-backing', overlay=3D'drive0')) =20 - iotests.log('Enabling migration QMP events on A...') - iotests.log(vm_a.qmp('migrate-set-capabilities', capabilities=3D[ - { - 'capability': 'events', - 'state': True - } - ])) - iotests.log('Starting migration to B...') iotests.log(vm_a.qmp('migrate', uri=3D'exec:cat >%s' % (fifo_a))) with iotests.Timeout(3, 'Migration does not complete'): - while True: - event =3D vm_a.event_wait('MIGRATION') - iotests.log(event, filters=3D[iotests.filter_qmp_event]) - if event['data']['status'] =3D=3D 'completed': - break + # Wait for the source first (which includes setup=3Dsetup) + wait_migration(vm_a) + # Wait for the destination second (which does not) + wait_migration(vm_b) =20 iotests.log(vm_a.qmp('query-migrate')['return']['status']) iotests.log(vm_b.qmp('query-migrate')['return']['status']) @@ -94,25 +105,18 @@ with iotests.FilePath('img') as img_path, \ .add_incoming("exec: cat '%s'" % (fifo_b)) .launch()) =20 + enable_migration_events(vm_a, 'A') + iotests.log(vm_a.qmp('blockdev-snapshot', node=3D'drive0-backing', overlay=3D'drive0')) =20 - iotests.log('Enabling migration QMP events on B...') - iotests.log(vm_b.qmp('migrate-set-capabilities', capabilities=3D[ - { - 'capability': 'events', - 'state': True - } - ])) - iotests.log('Starting migration back to A...') iotests.log(vm_b.qmp('migrate', uri=3D'exec:cat >%s' % (fifo_b))) with iotests.Timeout(3, 'Migration does not complete'): - while True: - event =3D vm_b.event_wait('MIGRATION') - iotests.log(event, filters=3D[iotests.filter_qmp_event]) - if event['data']['status'] =3D=3D 'completed': - break + # Wait for the source first (which includes setup=3Dsetup) + wait_migration(vm_b) + # Wait for the destination second (which does not) + wait_migration(vm_a) =20 iotests.log(vm_a.qmp('query-migrate')['return']['status']) iotests.log(vm_b.qmp('query-migrate')['return']['status']) diff --git a/tests/qemu-iotests/234.out b/tests/qemu-iotests/234.out index b9ed910b1a..692976d1c6 100644 --- a/tests/qemu-iotests/234.out +++ b/tests/qemu-iotests/234.out @@ -1,14 +1,18 @@ Launching source VM... +Enabling migration QMP events on A... +{"return": {}} Launching destination VM... +Enabling migration QMP events on B... {"return": {}} {"return": {}} -Enabling migration QMP events on A... {"return": {}} Starting migration to B... {"return": {}} {"data": {"status": "setup"}, "event": "MIGRATION", "timestamp": {"microse= conds": "USECS", "seconds": "SECS"}} {"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} {"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"mic= roseconds": "USECS", "seconds": "SECS"}} +{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"mic= roseconds": "USECS", "seconds": "SECS"}} completed completed {"return": {"running": false, "singlestep": false, "status": "postmigrate"= }} @@ -16,14 +20,16 @@ completed Add a second parent to drive0-file... {"return": {}} Restart A with -incoming and second parent... +Enabling migration QMP events on A... {"return": {}} -Enabling migration QMP events on B... {"return": {}} Starting migration back to A... {"return": {}} {"data": {"status": "setup"}, "event": "MIGRATION", "timestamp": {"microse= conds": "USECS", "seconds": "SECS"}} {"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} {"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"mic= roseconds": "USECS", "seconds": "SECS"}} +{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} +{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"mic= roseconds": "USECS", "seconds": "SECS"}} completed completed {"return": {"running": true, "singlestep": false, "status": "running"}} --=20 2.20.1