qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Costas Drogos <costas.drogos@gmail.com>
To: qemu-devel@nongnu.org
Cc: lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH 1/1] QMP test code - qmp.py
Date: Wed, 7 Apr 2010 03:40:32 +0300	[thread overview]
Message-ID: <w2g555ed20a1004061740rc79f0640y64b52334c63bb9d1@mail.gmail.com> (raw)

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

             reply	other threads:[~2010-04-07  0:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07  0:40 Costas Drogos [this message]
2010-04-07 13:36 ` [Qemu-devel] Re: [PATCH 1/1] QMP test code - qmp.py Luiz Capitulino
2010-04-07 13:51   ` Avi Kivity
2010-04-07 14:38     ` Costas Drogos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=w2g555ed20a1004061740rc79f0640y64b52334c63bb9d1@mail.gmail.com \
    --to=costas.drogos@gmail.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).