From patchwork Thu Feb 4 14:24:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 44497 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 9DDBFB7D09 for ; Fri, 5 Feb 2010 01:31:08 +1100 (EST) Received: from localhost ([127.0.0.1]:40401 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd2jC-00053S-QP for incoming@patchwork.ozlabs.org; Thu, 04 Feb 2010 09:30:42 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nd2dk-0001Ca-Ut for qemu-devel@nongnu.org; Thu, 04 Feb 2010 09:25:05 -0500 Received: from [199.232.76.173] (port=54673 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nd2dj-0001Ab-3S for qemu-devel@nongnu.org; Thu, 04 Feb 2010 09:25:03 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nd2df-0008Gm-29 for qemu-devel@nongnu.org; Thu, 04 Feb 2010 09:25:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62671) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nd2de-0008GZ-0c for qemu-devel@nongnu.org; Thu, 04 Feb 2010 09:24:58 -0500 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o14EOuLo009671 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 4 Feb 2010 09:24:56 -0500 Received: from localhost (vpn-9-202.rdu.redhat.com [10.11.9.202]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o14EOtBF004839; Thu, 4 Feb 2010 09:24:56 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2010 12:24:42 -0200 Message-Id: <1265293484-30677-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1265293484-30677-1-git-send-email-lcapitulino@redhat.com> References: <1265293484-30677-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com, armbru@redhat.com Subject: [Qemu-devel] [PATCH 2/4] QMP: Introduce the qmp_capabilities command 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 command will be used to enable QMP capabilities advertised by the capabilities array. Note that it will be mandatory to issue this command in order to make QMP functional (although this behavior is not being enforced yet). Also, as we don't have any capabilities yet, the new command doesn't accept any arguments. I will postpone the decision for a format for this until we get our first capability. Finally, this command is visible from the user Monitor too, in the meaning that you can execute it but it won't do anything. Making it only visible in QMP is beyond this series' goal, as it requires changes in unrelated places. Signed-off-by: Luiz Capitulino --- monitor.c | 11 +++++++++++ qemu-monitor.hx | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index 47b0050..7dac2f7 100644 --- a/monitor.c +++ b/monitor.c @@ -122,6 +122,7 @@ typedef struct MonitorControl { QObject *id; int print_enabled; JSONMessageParser parser; + int command_mode; } MonitorControl; struct Monitor { @@ -409,6 +410,15 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) QDECREF(qmp); } +static void do_qmp_capabilities(Monitor *mon, const QDict *params, + QObject **ret_data) +{ + /* Will setup QMP capabilities in the future */ + if (monitor_ctrl_mode(mon)) { + mon->mc->command_mode = 1; + } +} + static int compare_cmd(const char *name, const char *list) { const char *p, *pstart; @@ -4382,6 +4392,7 @@ static void monitor_control_event(void *opaque, int event) QObject *data; Monitor *mon = opaque; + mon->mc->command_mode = 0; json_message_parser_init(&mon->mc->parser, handle_qmp_command); data = get_qmp_gretting(); diff --git a/qemu-monitor.hx b/qemu-monitor.hx index e5bff8e..8edbf23 100644 --- a/qemu-monitor.hx +++ b/qemu-monitor.hx @@ -1066,6 +1066,20 @@ STEXI Set the encrypted device @var{device} password to @var{password} ETEXI + { + .name = "qmp_capabilities", + .args_type = "", + .params = "", + .help = "enable QMP capabilities", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_qmp_capabilities, + }, + +STEXI +@item qmp_capabilities +Enable the specified QMP capabilities +ETEXI + STEXI @end table ETEXI