Skip to contentSkip to conversation

KVM test: qmp_basic: Go through available monitors to find a qmp one

PATCH In review Lucas Meneghel Rodrigues 2 participants 2 messages Jan 11, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM test: qmp_basic: Go through available monitors to find a qmp one

It is more convenient to look at all available monitors that the VM has and return the first qmp monitor than relying that the qmp monitor will be allways be the primary one. In case we can't find one, just error the test with a more descriptive message

Also, clarify the exception thrown when the monitor is not responsive after the test.

---
 client/tests/kvm/tests/qmp_basic.py |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
client/tests/kvm/tests/qmp_basic.py +17 -8
index 952da99..94ba9ee 100644
@@ -1,4 +1,4 @@
-import kvm_test_utils
+import kvm_test_utils, kvm_monitor
 from autotest_lib.client.common_lib import error
 
 def run_qmp_basic(test, params, env):
@@ -384,13 +384,22 @@ def run_qmp_basic(test, params, env):
     vm = env.get_vm(params["main_vm"])
     vm.verify_alive()
 
+    # Look for the first qmp monitor available, otherwise, fail the test
+    qmp_monitor = None
+    for m in vm.monitors:
+        if isinstance(m, kvm_monitor.QMPMonitor):
+            qmp_monitor = m
+
+    if qmp_monitor is None:
+        raise error.TestError('Could not find a QMP monitor, aborting test')
+
     # Run all suites
-    greeting_suite(vm.monitor)
-    input_object_suite(vm.monitor)
-    argument_checker_suite(vm.monitor)
-    unknown_commands_suite(vm.monitor)
-    json_parsing_errors_suite(vm.monitor)
+    greeting_suite(qmp_monitor)
+    input_object_suite(qmp_monitor)
+    argument_checker_suite(qmp_monitor)
+    unknown_commands_suite(qmp_monitor)
+    json_parsing_errors_suite(qmp_monitor)
 
     # check if QMP is still alive
-    if not vm.monitor.is_responsive():
-        raise error.TestFail('QEMU is not alive after QMP testing')
+    if not qmp_monitor.is_responsive():
+        raise error.TestFail('QMP monitor is not responsive after testing')
Signature · 1 line
1.7.3.4
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · On Tue, 11 Jan 2011 14:55:47 -0200 Lucas Meneghel Rodrigues <[email protected]>…

It is more convenient to look at all available monitors that the VM has and return the first qmp monitor than relying that the qmp monitor will be allways be the primary one. In case we can't find one, just error the test with a more descriptive message

Also, clarify the exception thrown when the monitor is not responsive after the test.

Makes sense:

Quoted 44 lines
---
 client/tests/kvm/tests/qmp_basic.py |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)
client/tests/kvm/tests/qmp_basic.py +17 -8
index 952da99..94ba9ee 100644
@@ -1,4 +1,4 @@
-import kvm_test_utils
+import kvm_test_utils, kvm_monitor
 from autotest_lib.client.common_lib import error
 
 def run_qmp_basic(test, params, env):
@@ -384,13 +384,22 @@ def run_qmp_basic(test, params, env):
     vm = env.get_vm(params["main_vm"])
     vm.verify_alive()
 
+    # Look for the first qmp monitor available, otherwise, fail the test
+    qmp_monitor = None
+    for m in vm.monitors:
+        if isinstance(m, kvm_monitor.QMPMonitor):
+            qmp_monitor = m
+
+    if qmp_monitor is None:
+        raise error.TestError('Could not find a QMP monitor, aborting test')
+
     # Run all suites
-    greeting_suite(vm.monitor)
-    input_object_suite(vm.monitor)
-    argument_checker_suite(vm.monitor)
-    unknown_commands_suite(vm.monitor)
-    json_parsing_errors_suite(vm.monitor)
+    greeting_suite(qmp_monitor)
+    input_object_suite(qmp_monitor)
+    argument_checker_suite(qmp_monitor)
+    unknown_commands_suite(qmp_monitor)
+    json_parsing_errors_suite(qmp_monitor)
 
     # check if QMP is still alive
-    if not vm.monitor.is_responsive():
-        raise error.TestFail('QEMU is not alive after QMP testing')
+    if not qmp_monitor.is_responsive():
+        raise error.TestFail('QMP monitor is not responsive after testing')