From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzVQd-0000uu-FR for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:36:23 -0400 Received: from [140.186.70.92] (port=58856 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzVQc-0000tj-6o for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzVQa-0007Di-Me for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:36:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43941) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzVQa-0007Da-DF for qemu-devel@nongnu.org; Wed, 07 Apr 2010 09:36:20 -0400 Date: Wed, 7 Apr 2010 10:36:10 -0300 From: Luiz Capitulino Message-ID: <20100407103610.4080b945@redhat.com> In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [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: Costas Drogos Cc: qemu-devel@nongnu.org On Wed, 7 Apr 2010 03:40:32 +0300 Costas Drogos wrote: > 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. I already have a new version of that script in the master branch of: git://repo.or.cz/qemu/qmp-unstable.git It fixes current problems and has other improvements, I didn't submit it yet because I didn't test it much. So, I will add a fix for the json problem and would appreciate any testing. > 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 This won't do what we want for 2.7 and newer, so a better if would be: if sys.version_info < (2, 6): import simplejson as json else: import json