KVM test: kvm_monitor.py: add QMP interface
An initial QMP client implementation.
Should be fully functional and supports asynchronous events.
However, most tests must be modified to support it, because it returns output
in a different format from the human monitor (the human monitor returns strings
and the QMP one returns dicts or lists).
To enable QMP, set main_monitor to a monitor whose monitor_type is "qmp".
For example (a single QMP monitor):
monitors = monitor1
monitor_type_monitor1 = qmp
main_monitor = monitor1
Another example (multiple monitors, both human and QMP):
monitors = MyMonitor SomeOtherMonitor YetAnotherMonitor # defines 3 monitors
monitor_type = human # default for all monitors
monitor_type_SomeOtherMonitor = qmp # applies only to SomeOtherMonitor
monitor_type_YetAnotherMonitor = qmp # applies only to YetAnotherMonitor
main_monitor = SomeOtherMonitor # the main monitor is a QMP one, so
# the test will use QMP
Note:
Monitor methods now raise exceptions such as MonitorLockError and QMPCmdError.
If this turns out to be a bad idea, it shouldn't be hard to revert to the old
convention of returning a (status, output) tuple.
Changes from v1:
- Upon connection make sure the QMP greeting is received (otherwise raise an
exception)
- Upon connection make sure the json module is available
- Rename the events attribute to _events to indicate private use
- Use _lock instead of lock
- Use _socket instead of socket
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@4640 592f7852-d20e-0410-864c-8624ca9c26a4
2 files changed