qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] QMP test code - qmp.py
@ 2010-04-07  0:40 Costas Drogos
  2010-04-07 13:36 ` [Qemu-devel] " Luiz Capitulino
  0 siblings, 1 reply; 4+ messages in thread
From: Costas Drogos @ 2010-04-07  0:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino

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):

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-07 14:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-07  0:40 [Qemu-devel] [PATCH 1/1] QMP test code - qmp.py Costas Drogos
2010-04-07 13:36 ` [Qemu-devel] " Luiz Capitulino
2010-04-07 13:51   ` Avi Kivity
2010-04-07 14:38     ` Costas Drogos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).