From mboxrd@z Thu Jan 1 00:00:00 1970 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 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> Subject: [Qemu-devel] [PATCH 2/8] QMP: Introduce 'query-qmp-mode' command List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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 = "", -- 1.6.6