[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/20] QMP: Allow 'query-' commands
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 12/20] QMP: Allow 'query-' commands |
Date: |
Thu, 26 Nov 2009 22:59:02 -0200 |
The 'info' command makes sense for the user protocol, but for QMP
it doesn't, as its return data is not well defined. That is, it
can return anything.
To fix this Avi proposes having 'query-' commands when in protocol
mode. For example, 'info balloon' would become 'query-balloon'.
The right way of supporting this would probably be to move all
info handlers to qemu-monitor.hx, add a flags field to mon_cmd_t
to identify them and then modify do_info() to do its search based
on that flag.
Unfortunately, this would require a big change in the Monitor.
To make things simpler for now, this commit takes a different
approach: a check for commands starting with "query-" is added to
toplevel QMP code, if it's true we setup things so that do_info()
is called with the appropriate arguments.
This is a hack, but is a temporary one and guarantees that query-
commands will work from the first day.
Also note that 'info' is not allowed in protocol mode.
Signed-off-by: Luiz Capitulino <address@hidden>
---
monitor.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index c172343..0d4380d 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3813,9 +3813,9 @@ static void handle_qmp_command(JSONMessageParser *parser,
QList *tokens)
int err;
QObject *obj;
QDict *input, *args;
- const char *cmd_name;
const mon_cmd_t *cmd;
Monitor *mon = cur_mon;
+ const char *cmd_name, *info_item;
args = NULL;
qemu_errors_to_mon(mon);
@@ -3846,10 +3846,24 @@ static void handle_qmp_command(JSONMessageParser
*parser, QList *tokens)
}
cmd_name = qstring_get_str(qobject_to_qstring(obj));
- cmd = monitor_find_command(cmd_name);
- if (!cmd) {
+
+ /*
+ * XXX: We need this special case until we get info handlers
+ * converted into 'query-' commands
+ */
+ if (compare_cmd(cmd_name, "info")) {
qemu_error_new(QERR_COMMAND_NOT_FOUND, cmd_name);
goto err_input;
+ } else if (strstart(cmd_name, "query-", &info_item)) {
+ cmd = monitor_find_command("info");
+ qdict_put_obj(input, "arguments",
+ qobject_from_jsonf("{ 'item': %s }", info_item));
+ } else {
+ cmd = monitor_find_command(cmd_name);
+ if (!cmd) {
+ qemu_error_new(QERR_COMMAND_NOT_FOUND, cmd_name);
+ goto err_input;
+ }
}
obj = qdict_get(input, "arguments");
--
1.6.6.rc0.50.gaf06e
- [Qemu-devel] [PATCH 02/20] monitor: Command-line flag to enable control mode, (continued)
- [Qemu-devel] [PATCH 02/20] monitor: Command-line flag to enable control mode, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 03/20] monitor: Introduce monitor_call_handler(), Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 04/20] monitor: Introduce monitor_find_command(), Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 05/20] monitor: Rename monitor_handle_command(), Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 06/20] monitor: Introduce 'info commands', Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 07/20] QError: Add errors needed by QMP, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 08/20] QMP: Initial support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 09/20] QMP: Output support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 10/20] QMP: do_info() checks, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 11/20] QMP: Input support, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 12/20] QMP: Allow 'query-' commands,
Luiz Capitulino <=
- [Qemu-devel] [PATCH 13/20] QMP: Asynchronous events infrastructure, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 14/20] QMP: Introduce basic asynchronous events, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 15/20] QMP: Disable monitor print functions, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 16/20] QMP: Introduce README file, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 17/20] QMP: Introduce specification, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 18/20] QMP: Introduce qmp-events.txt, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 19/20] QMP: Introduce qmp-shell, Luiz Capitulino, 2009/11/26
- [Qemu-devel] [PATCH 20/20] QMP: Introduce vm-info, Luiz Capitulino, 2009/11/26