[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 16/23] monitor: Allow to exclude commands from QM
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] [PATCH v4 16/23] monitor: Allow to exclude commands from QMP |
Date: |
Wed, 16 Jun 2010 00:38:40 +0200 |
From: Jan Kiszka <address@hidden>
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 <address@hidden>
---
monitor.c | 18 +++++++++++++++---
monitor.h | 1 +
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index 2d3d70d..9c0a91c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -343,6 +343,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;
@@ -625,6 +630,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);
@@ -722,13 +732,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));
@@ -4376,7 +4387,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_input;
}
diff --git a/monitor.h b/monitor.h
index e3f0119..ec1fe42 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 {
--
1.6.0.2
- Re: [Qemu-devel] [PATCH v4 13/23] monitor: Allow to specify HMP-specifc command arguments, (continued)
- [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Jan Kiszka, 2010/06/15
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Markus Armbruster, 2010/06/23
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Jan Kiszka, 2010/06/23
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Markus Armbruster, 2010/06/23
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Luiz Capitulino, 2010/06/28
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Jan Kiszka, 2010/06/28
- Re: [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists, Luiz Capitulino, 2010/06/28
- [Qemu-devel] [PATCH] monitor: Allow to exclude commands from QMP, Jan Kiszka, 2010/06/28
[Qemu-devel] [PATCH v4 15/23] monitor: Establish cmd flags and convert the async tag, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 16/23] monitor: Allow to exclude commands from QMP,
Jan Kiszka <=
[Qemu-devel] [PATCH v4 14/23] monitor: return length of printed string via monitor_[v]printf, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 17/23] Add base64 encoder/decoder, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 21/23] QMP: Teach basic capability negotiation to python example, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 12/23] monitor: Add completion for qdev paths, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 19/23] QMP: Add QBuffer, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 18/23] QMP: Reserve namespace for complex object classes, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 22/23] QMP: Fix python helper /wrt long return strings, Jan Kiszka, 2010/06/15
[Qemu-devel] [PATCH v4 23/23] QMP: Add support for buffer class to qmp python helper, Jan Kiszka, 2010/06/15