Hello there, a very small patch to address two small issues:
1) The json state in python2.5 and python2.6. json module is included by default on python2.6, whereas you have to import simplejson in python2.5. I have this problem on Debian testing, so feel free to test if this is applicable in your distribution. 2) For qmp commands to work (e.g. query-kvm) we have to give first the command 'qmp_capabilities' because monitor is in 'Capabilities Negotiation mode' on startup. The patch takes care of issuing that command immediately after connecting. The patch is more of a hack to ease qmp testing and development. Costas Drogos -- diff --git a/QMP/qmp.py b/QMP/qmp.py index d9da603..f8581c4 100644 --- a/QMP/qmp.py +++ b/QMP/qmp.py @@ -8,7 +8,15 @@ # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. -import socket, json +import socket + +from sys import version +ver = version[:3] + +if ver == '2.6': + import json +else: + import simplejson as json class QMPError(Exception): pass @@ -24,6 +32,9 @@ class QEMUMonitorProtocol: raise QMPConnectError if not data.has_key('QMP'): raise QMPConnectError + # initialize the qmp interface + cmd = {'execute':'qmp_capabilities' } + self.sock.send(str(cmd)) return data['QMP']['capabilities'] def close(self):