From patchwork Tue Jul 6 22:19:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 58071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C0136B6ED0 for ; Wed, 7 Jul 2010 08:20:38 +1000 (EST) Received: from localhost ([127.0.0.1]:51718 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWGVH-0003ED-KT for incoming@patchwork.ozlabs.org; Tue, 06 Jul 2010 18:20:35 -0400 Received: from [140.186.70.92] (port=60294 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWGUD-0003Aw-CT for qemu-devel@nongnu.org; Tue, 06 Jul 2010 18:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWGUB-0006lA-Ho for qemu-devel@nongnu.org; Tue, 06 Jul 2010 18:19:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:61023) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWGUB-0006l2-B6 for qemu-devel@nongnu.org; Tue, 06 Jul 2010 18:19:27 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o66MJQQu004608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Jul 2010 18:19:26 -0400 Received: from localhost (vpn-226-161.phx2.redhat.com [10.3.226.161]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o66MJPbw003103; Tue, 6 Jul 2010 18:19:26 -0400 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 6 Jul 2010 19:19:17 -0300 Message-Id: <1278454757-5493-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1278454757-5493-1-git-send-email-lcapitulino@redhat.com> References: <1278454757-5493-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: armbru@redhat.com Subject: [Qemu-devel] [PATCH 2/2] QMP: Require 'use_unstable' arg for capabilities negotiation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This helps ensuring two things: 1. An initial warning on client writers playing with current QMP 2. Clients using unstable QMP will break when we declare QMP stable and drop that argument Signed-off-by: Luiz Capitulino --- QMP/README | 2 +- QMP/qmp-shell | 2 +- QMP/qmp.py | 3 +++ monitor.c | 7 ++++++- qemu-monitor.hx | 14 ++++++++++---- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/QMP/README b/QMP/README index 30a283b..14d36ee 100644 --- a/QMP/README +++ b/QMP/README @@ -65,7 +65,7 @@ Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. {"QMP": {"version": {"qemu": "0.12.50", "package": ""}, "capabilities": []}} -{ "execute": "qmp_capabilities" } +{ "execute": "qmp_capabilities", "arguments": { "use_unstable": true } } {"return": {}} { "execute": "query-version" } {"return": {"qemu": "0.12.50", "package": ""}} diff --git a/QMP/qmp-shell b/QMP/qmp-shell index a5b72d1..17033b1 100755 --- a/QMP/qmp-shell +++ b/QMP/qmp-shell @@ -42,7 +42,7 @@ def main(): qemu = qmp.QEMUMonitorProtocol(argv[1]) qemu.connect() - qemu.send("qmp_capabilities") + qemu.capabilities() print 'Connected!' diff --git a/QMP/qmp.py b/QMP/qmp.py index 4062f84..9d6f428 100644 --- a/QMP/qmp.py +++ b/QMP/qmp.py @@ -26,6 +26,9 @@ class QEMUMonitorProtocol: raise QMPConnectError return data['QMP']['capabilities'] + def capabilities(self): + self.send_raw('{ "execute": "qmp_capabilities", "arguments": { "use_unstable": true } }') + def close(self): self.sock.close() diff --git a/monitor.c b/monitor.c index 55633fd..19ddf1e 100644 --- a/monitor.c +++ b/monitor.c @@ -479,7 +479,12 @@ static int do_qmp_capabilities(Monitor *mon, const QDict *params, { /* Will setup QMP capabilities in the future */ if (monitor_ctrl_mode(mon)) { - mon->mc->command_mode = 1; + if (qdict_get_bool(params, "use_unstable")) { + mon->mc->command_mode = 1; + } else { + qerror_report(QERR_INVALID_PARAMETER, "use_unstable"); + return -1; + } } return 0; diff --git a/qemu-monitor.hx b/qemu-monitor.hx index 2d2a09e..a56e1f5 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -1557,7 +1557,7 @@ EQMP { .name = "qmp_capabilities", - .args_type = "", + .args_type = "use_unstable:b", .params = "", .help = "enable QMP capabilities", .user_print = monitor_user_noop, @@ -1575,14 +1575,20 @@ qmp_capabilities Enable QMP capabilities. -Arguments: None. +Arguments: + +- use_unstable: really enable unstable version of QMP (json-bool) Example: --> { "execute": "qmp_capabilities" } +-> { "execute": "qmp_capabilities", "arguments": { "use_unstable": true } } <- { "return": {} } -Note: This command must be issued before issuing any other command. +Notes: + +(1) This command must be issued before issuing any other command. + +(2) Setting "use_unstable" to true is the only way to get anything working. EQMP