From patchwork Thu Jan 28 13:42:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 43870 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 F24FEB7CFB for ; Fri, 29 Jan 2010 01:19:45 +1100 (EST) Received: from localhost ([127.0.0.1]:33826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaUj8-00022M-NM for incoming@patchwork.ozlabs.org; Thu, 28 Jan 2010 08:48:06 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NaUeY-0000Hk-Rm for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:22 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NaUeU-0000Da-68 for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:22 -0500 Received: from [199.232.76.173] (port=57163 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NaUeT-0000DN-Tz for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11040) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NaUeT-0003wE-Ev for qemu-devel@nongnu.org; Thu, 28 Jan 2010 08:43:17 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0SDhGaO022015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Jan 2010 08:43:16 -0500 Received: from localhost (vpn-10-249.rdu.redhat.com [10.11.10.249]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0SDhFRC014022 for ; Thu, 28 Jan 2010 08:43:16 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Thu, 28 Jan 2010 11:42:54 -0200 Message-Id: <1264686180-29845-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1264686180-29845-1-git-send-email-lcapitulino@redhat.com> References: <1264686180-29845-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 2/8] QMP: Introduce 'query-qmp-mode' 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 Only valid in QMP and allowed to run on both "handshake" and "operational" modes. Signed-off-by: Luiz Capitulino --- monitor.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/monitor.c b/monitor.c index baae9d0..3ced51d 100644 --- a/monitor.c +++ b/monitor.c @@ -672,6 +672,39 @@ static QObject *get_cmd_dict(const char *name) } /** + * do_info_qmp_mode(): Show current QMP mode + * + * Return a QDict with the following key: + * + * - "mode": either "handshake" or "operational" + * + * Example: + * + * { "mode": "handshake" } + */ +static void do_info_qmp_mode(Monitor *mon, QObject **ret_data) +{ + const char *mode; + + if (!monitor_ctrl_mode(mon)) { + return; + } + + switch (mon->mc->mode) { + case QMODE_HANDSHAKE: + mode = "handshake"; + break; + case QMODE_OPERATIONAL: + mode = "operational"; + break; + default: + abort(); + } + + *ret_data = qobject_from_jsonf("{ 'mode': %s }", mode); +} + +/** * do_info_commands(): List QMP available commands * * Each command is represented by a QDict, the returned QObject is a QList @@ -2727,6 +2760,15 @@ static const mon_cmd_t info_cmds[] = { .mhandler.info_new = do_info_migrate, }, { + .name = "qmp-mode", + .args_type = "", + .params = "", + .help = "show current mode", + .flags = HANDLER_HANDSHAKE, + .user_print = monitor_user_noop, + .mhandler.info_new = do_info_qmp_mode, + }, + { .name = "balloon", .args_type = "", .params = "",