[Spice-devel] [spice v1 3/8] tests: migrate: simplify wait_active()

Victor Toso victortoso at redhat.com
Mon Oct 7 12:19:30 UTC 2019


From: Victor Toso <me at victortoso.com>

We are only interested in the running state of qmp (or VCPUS) here
which is what we check. Moving this check to the try branch allows
removing some extra checks.

Signed-off-by: Victor Toso <victortoso at redhat.com>
---
 tests/migrate.py | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/tests/migrate.py b/tests/migrate.py
index f471ddfc..375e59a0 100755
--- a/tests/migrate.py
+++ b/tests/migrate.py
@@ -117,20 +117,16 @@ def start_client(client, spice_port):
     return Popen(client_cmd.split(), executable=client)
 
 def wait_active(q, active):
-    events = ["RESUME"] if active else ["STOP"]
     while True:
         try:
             ret = q.cmd("query-status")
+            if ret["return"]["running"] == active:
+                break
         except:
             # ValueError
             time.sleep(0.1)
             continue
-        if ret and ret.has_key("return"):
-            if ret["return"]["running"] == active:
-                break
-        for e in q.get_events():
-            if e["event"] in events:
-                break
+
         time.sleep(0.5)
 
 def wait_for_event(q, event):
-- 
2.21.0



More information about the Spice-devel mailing list