qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	Max Reitz <mreitz@redhat.com>
Subject: [PULL 13/14] iotests.py: Let wait_migration() return on failure
Date: Fri, 21 Aug 2020 09:08:25 -0500	[thread overview]
Message-ID: <20200821140826.194322-14-eblake@redhat.com> (raw)
In-Reply-To: <20200821140826.194322-1-eblake@redhat.com>

From: Max Reitz <mreitz@redhat.com>

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 <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200820150725.68687-3-mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 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 717b5b652c45..e197c73ca501 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.28.0



  parent reply	other threads:[~2020-08-21 14:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 14:08 [PULL 00/14] bitmaps patches for 2020-08-21 Eric Blake
2020-08-21 14:08 ` [PULL 01/14] iotests: add test for QCOW2 header dump Eric Blake
2020-08-21 14:08 ` [PULL 02/14] qcow2_format.py: make printable data an extension class member Eric Blake
2020-08-21 14:08 ` [PULL 03/14] qcow2_format.py: change Qcow2BitmapExt initialization method Eric Blake
2020-08-21 14:08 ` [PULL 04/14] qcow2_format.py: dump bitmap flags in human readable way Eric Blake
2020-08-21 14:08 ` [PULL 05/14] qcow2_format.py: Dump bitmap directory information Eric Blake
2020-08-21 14:08 ` [PULL 06/14] qcow2_format.py: pass cluster size to substructures Eric Blake
2020-08-21 14:08 ` [PULL 07/14] qcow2_format.py: Dump bitmap table serialized entries Eric Blake
2020-08-21 14:08 ` [PULL 08/14] qcow2.py: Introduce '-j' key to dump in JSON format Eric Blake
2020-08-21 14:08 ` [PULL 09/14] qcow2_format.py: collect fields " Eric Blake
2020-08-21 14:08 ` [PULL 10/14] qcow2_format.py: support dumping metadata " Eric Blake
2020-08-21 14:08 ` [PULL 11/14] iotests: dump QCOW2 header in JSON in #303 Eric Blake
2020-08-21 14:08 ` [PULL 12/14] migration: Add block-bitmap-mapping parameter Eric Blake
2020-08-21 14:08 ` Eric Blake [this message]
2020-08-21 14:08 ` [PULL 14/14] iotests: Test node/bitmap aliases during migration Eric Blake
2020-08-22 20:58 ` [PULL 00/14] bitmaps patches for 2020-08-21 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200821140826.194322-14-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).