From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzJKE-0000bL-LD for qemu-devel@nongnu.org; Tue, 06 Apr 2010 20:40:58 -0400 Received: from [140.186.70.92] (port=53727 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzJKC-0000bD-TK for qemu-devel@nongnu.org; Tue, 06 Apr 2010 20:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzJK9-0000ib-CC for qemu-devel@nongnu.org; Tue, 06 Apr 2010 20:40:56 -0400 Received: from fg-out-1718.google.com ([72.14.220.152]:9791) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzJK9-0000iJ-66 for qemu-devel@nongnu.org; Tue, 06 Apr 2010 20:40:53 -0400 Received: by fg-out-1718.google.com with SMTP id l26so1079257fgb.10 for ; Tue, 06 Apr 2010 17:40:52 -0700 (PDT) MIME-Version: 1.0 From: Costas Drogos Date: Wed, 7 Apr 2010 03:40:32 +0300 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] [PATCH 1/1] QMP test code - qmp.py List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: lcapitulino@redhat.com 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):