From 2a597bba9b1e07adb6531628962682a0e53d29b1 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Mon, 24 Aug 2020 09:20:37 -0400 Subject: [PATCH 5/6] iotests.py: Let wait_migration() return on failure RH-Author: Max Reitz Message-id: <20200824092038.227913-3-mreitz@redhat.com> Patchwork-id: 98213 O-Subject: [RHEL-AV-8.3.0 qemu-kvm PATCH 2/3] iotests.py: Let wait_migration() return on failure Bugzilla: 1790492 RH-Acked-by: Stefano Garzarella RH-Acked-by: Dr. David Alan Gilbert RH-Acked-by: Stefan Hajnoczi Let wait_migration() return on failure (with the return value indicating whether the migration was completed or has failed), so we can use it for migrations that are expected to fail, too. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200820150725.68687-3-mreitz@redhat.com> Signed-off-by: Eric Blake (cherry picked from commit 4bf63c80357031be4eb8fff8a751f40e73ef1c10) Signed-off-by: Max Reitz Signed-off-by: Danilo C. L. de Paula --- tests/qemu-iotests/iotests.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 717b5b652c..e197c73ca5 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -729,16 +729,22 @@ class VM(qtest.QEMUQtestMachine): } ])) - def wait_migration(self, expect_runstate): + def wait_migration(self, expect_runstate: Optional[str]) -> bool: while True: event = self.event_wait('MIGRATION') log(event, filters=[filter_qmp_event]) - if event['data']['status'] == 'completed': + if event['data']['status'] in ('completed', 'failed'): break - # The event may occur in finish-migrate, so wait for the expected - # post-migration runstate - while self.qmp('query-status')['return']['status'] != expect_runstate: - pass + + if event['data']['status'] == 'completed': + # The event may occur in finish-migrate, so wait for the expected + # post-migration runstate + runstate = None + while runstate != expect_runstate: + runstate = self.qmp('query-status')['return']['status'] + return True + else: + return False def node_info(self, node_name): nodes = self.qmp('query-named-block-nodes') -- 2.27.0