If the value returned from a monitor method call
is a string, treat it as human monitor output.
Otherwise treat it as QMP output.

Signed-off-by: Michael Goldish <[email protected]>
---
 client/tests/kvm/kvm_test_utils.py |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py 
b/client/tests/kvm/kvm_test_utils.py
index 760a462..fcfbed0 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -123,19 +123,31 @@ def migrate(vm, env=None, mig_timeout=3600, 
mig_protocol="tcp",
     """
     def mig_finished():
         o = vm.monitor.info("migrate")
-        return "status: active" not in o
+        if isinstance(o, str):
+            return "status: active" not in o
+        else:
+            return o.get("status") != "active"
 
     def mig_succeeded():
         o = vm.monitor.info("migrate")
-        return "status: completed" in o
+        if isinstance(o, str):
+            return "status: completed" in o
+        else:
+            return o.get("status") == "completed"
 
     def mig_failed():
         o = vm.monitor.info("migrate")
-        return "status: failed" in o
+        if isinstance(o, str):
+            return "status: failed" in o
+        else:
+            return o.get("status") == "failed"
 
     def mig_cancelled():
         o = vm.monitor.info("migrate")
-        return "Migration status: cancelled" in o
+        if isinstance(o, str):
+            return "Migration status: cancelled" in o
+        else:
+            return o.get("status") == "cancelled"
 
     def wait_for_migration():
         if not kvm_utils.wait_for(mig_finished, mig_timeout, 2, 2,
-- 
1.7.0.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to