From patchwork Fri Sep 14 12:44:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryota OZAKI X-Patchwork-Id: 184069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 57C532C0093 for ; Sat, 15 Sep 2012 13:15:59 +1000 (EST) Received: from localhost ([::1]:46712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCirN-0006yP-4S for incoming@patchwork.ozlabs.org; Fri, 14 Sep 2012 23:15:57 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCVHI-0004PF-6N for qemu-devel@nongnu.org; Fri, 14 Sep 2012 08:45:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TCVHH-0007Im-3O for qemu-devel@nongnu.org; Fri, 14 Sep 2012 08:45:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47809) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TCVHG-0007If-ON for qemu-devel@nongnu.org; Fri, 14 Sep 2012 08:45:47 -0400 Received: by pbbrp12 with SMTP id rp12so5831902pbb.4 for ; Fri, 14 Sep 2012 05:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=wTTwT7D5MdueXVcjuNkrv3KNLFVQUdAemGfzkUu3VxM=; b=SbRV+dVfDAcgAi6xvbcgO7O7LDnV6nWa8NtrwJs1bfdk2DcK3bcw6kuxsgQeG/GCRG XZ1NOBdOVpeF22/dDDiBSOUI6/bi4bzPCNIS0G8ljIggbbY4V260BbNA//9hfjd4dk2k 8lA80jiOIn0sAIPBxp2PMLjiRgktMzdyMlq41l/qN+99ZUP9yhdQc2KqJ0np8yNR7dfM qvok4xd30RdGIFRqiBn1rJx44ZYJ65DQbbq1ld4SAtSHw6Pl3bpjLcMk/baJvzD5M7xy ei1CyV7PoU+cpDtBAlhICUhhmNTPpkI/NKjnuLpzC2xzmBeAecRjRiMhtDJ2XBDO4OSX AKjw== Received: by 10.68.189.99 with SMTP id gh3mr5081605pbc.31.1347626745608; Fri, 14 Sep 2012 05:45:45 -0700 (PDT) Received: from localhost.localdomain (w0109-49-133-81-122.uqwimax.jp. [49.133.81.122]) by mx.google.com with ESMTPS id uh7sm938250pbc.35.2012.09.14.05.45.43 (version=SSLv3 cipher=OTHER); Fri, 14 Sep 2012 05:45:45 -0700 (PDT) From: Ryota Ozaki To: qemu-devel@nongnu.org Date: Fri, 14 Sep 2012 21:44:20 +0900 Message-Id: <1347626662-3701-2-git-send-email-ozaki.ryota@gmail.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1347626662-3701-1-git-send-email-ozaki.ryota@gmail.com> References: <1347626662-3701-1-git-send-email-ozaki.ryota@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 X-Mailman-Approved-At: Fri, 14 Sep 2012 23:15:49 -0400 Subject: [Qemu-devel] [PATCH 1/3] Make negotiation optional in QEMUMonitorProtocol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is a preparation for qemu-ga-client which uses QEMUMonitorProtocol class. The class tries to negotiate capabilities on connect, however, qemu-ga doesn't suppose it and fails. This change makes the negotiation optional, though it's still performed by default for compatibility. Signed-off-by: Ryota Ozaki --- QMP/qmp.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/QMP/qmp.py b/QMP/qmp.py index 36ecc1d..5a573e1 100644 --- a/QMP/qmp.py +++ b/QMP/qmp.py @@ -49,7 +49,6 @@ class QEMUMonitorProtocol: return socket.socket(family, socket.SOCK_STREAM) def __negotiate_capabilities(self): - self.__sockfile = self.__sock.makefile() greeting = self.__json_read() if greeting is None or not greeting.has_key('QMP'): raise QMPConnectError @@ -73,7 +72,7 @@ class QEMUMonitorProtocol: error = socket.error - def connect(self): + def connect(self, negotiate=True): """ Connect to the QMP Monitor and perform capabilities negotiation. @@ -83,7 +82,9 @@ class QEMUMonitorProtocol: @raise QMPCapabilitiesError if fails to negotiate capabilities """ self.__sock.connect(self.__address) - return self.__negotiate_capabilities() + self.__sockfile = self.__sock.makefile() + if negotiate: + return self.__negotiate_capabilities() def accept(self): """