From patchwork Sun May 23 10:59:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v3,13/17] monitor: Allow to exclude commands from QMP Date: Sun, 23 May 2010 00:59:26 -0000 From: Jan Kiszka X-Patchwork-Id: 53311 Message-Id: <5d0139dc62706a1efcbb6a63d5936484ad279916.1274612367.git.jan.kiszka@web.de> To: qemu-devel@nongnu.org, Anthony Liguori Cc: Juan Quintela , Jan Kiszka , Markus Armbruster , Luiz Capitulino , Blue Swirl , Avi Kivity 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 (e.g. device_show). Signed-off-by: Jan Kiszka --- monitor.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/monitor.c b/monitor.c index 6766e49..5768c6e 100644 --- a/monitor.c +++ b/monitor.c @@ -114,6 +114,7 @@ typedef struct mon_cmd_t { MonitorCompletion *cb, void *opaque); } mhandler; int async; + bool user_only; } mon_cmd_t; /* file descriptors passed via SCM_RIGHTS */ @@ -635,6 +636,11 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) goto help; } + if (monitor_ctrl_mode(mon) && cmd->user_only) { + 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); @@ -732,13 +738,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) && !cmd->user_only && + !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) && !cmd->user_only) { char buf[128]; snprintf(buf, sizeof(buf), "query-%s", cmd->name); qlist_append_obj(cmd_list, get_cmd_dict(buf)); @@ -4416,7 +4423,7 @@ 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) || cmd->user_only) { qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); goto err_input; }