From patchwork Thu Jul 1 19:21:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 57589 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 2F3A5B6F44 for ; Fri, 2 Jul 2010 05:54:10 +1000 (EST) Received: from localhost ([127.0.0.1]:37562 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUPpm-0006Xy-Vn for incoming@patchwork.ozlabs.org; Thu, 01 Jul 2010 15:54:07 -0400 Received: from [140.186.70.92] (port=37923 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUPLr-0006ue-LT for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:23:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUPLb-0007SP-CX for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:23:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13216) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUPLb-0007SH-47 for qemu-devel@nongnu.org; Thu, 01 Jul 2010 15:22:55 -0400 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 o61JMs3d022319 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 1 Jul 2010 15:22:54 -0400 Received: from localhost (vpn-10-238.rdu.redhat.com [10.11.10.238]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o61JMrZE020415; Thu, 1 Jul 2010 15:22:53 -0400 From: Luiz Capitulino To: aliguori@us.ibm.com Date: Thu, 1 Jul 2010 16:21:51 -0300 Message-Id: <1278012111-26227-24-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> References: <1278012111-26227-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jan Kiszka , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 23/23] monitor: Allow to exclude commands from QMP 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 From: Jan Kiszka Ported commands that are marked 'user_only' will not be considered for QMP monitor sessions. This allows to implement new commands that do not (yet) provide a sufficiently stable interface for QMP use. Signed-off-by: Jan Kiszka Signed-off-by: Luiz Capitulino --- monitor.c | 18 +++++++++++++++--- monitor.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index 00a627a..f319fee 100644 --- a/monitor.c +++ b/monitor.c @@ -333,6 +333,11 @@ static inline bool monitor_handler_is_async(const mon_cmd_t *cmd) return cmd->flags & MONITOR_CMD_ASYNC; } +static inline bool monitor_cmd_user_only(const mon_cmd_t *cmd) +{ + return (cmd->flags & MONITOR_CMD_USER_ONLY); +} + static inline int monitor_has_error(const Monitor *mon) { return mon->error != NULL; @@ -615,6 +620,11 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) goto help; } + if (monitor_ctrl_mode(mon) && monitor_cmd_user_only(cmd)) { + qerror_report(QERR_COMMAND_NOT_FOUND, item); + return -1; + } + if (monitor_handler_is_async(cmd)) { if (monitor_ctrl_mode(mon)) { qmp_async_info_handler(mon, cmd); @@ -712,13 +722,14 @@ static void do_info_commands(Monitor *mon, QObject **ret_data) cmd_list = qlist_new(); for (cmd = mon_cmds; cmd->name != NULL; cmd++) { - if (monitor_handler_ported(cmd) && !compare_cmd(cmd->name, "info")) { + if (monitor_handler_ported(cmd) && !monitor_cmd_user_only(cmd) && + !compare_cmd(cmd->name, "info")) { qlist_append_obj(cmd_list, get_cmd_dict(cmd->name)); } } for (cmd = info_cmds; cmd->name != NULL; cmd++) { - if (monitor_handler_ported(cmd)) { + if (monitor_handler_ported(cmd) && !monitor_cmd_user_only(cmd)) { char buf[128]; snprintf(buf, sizeof(buf), "query-%s", cmd->name); qlist_append_obj(cmd_list, get_cmd_dict(buf)); @@ -4271,7 +4282,8 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) qobject_from_jsonf("{ 'item': %s }", info_item)); } else { cmd = monitor_find_command(cmd_name); - if (!cmd || !monitor_handler_ported(cmd)) { + if (!cmd || !monitor_handler_ported(cmd) + || monitor_cmd_user_only(cmd)) { qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); goto err_out; } diff --git a/monitor.h b/monitor.h index 9582b9c..38b22a4 100644 --- a/monitor.h +++ b/monitor.h @@ -17,6 +17,7 @@ extern Monitor *default_mon; /* flags for monitor commands */ #define MONITOR_CMD_ASYNC 0x0001 +#define MONITOR_CMD_USER_ONLY 0x0002 /* QMP events */ typedef enum MonitorEvent {