summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--monitor.c29
-rw-r--r--qemu-monitor.hx3
2 files changed, 24 insertions, 8 deletions
diff --git a/monitor.c b/monitor.c
index d545124ea2..cc1b501cfe 100644
--- a/monitor.c
+++ b/monitor.c
@@ -76,6 +76,7 @@ typedef struct mon_cmd_t {
void (*user_print)(Monitor *mon, const QObject *data);
union {
void (*info)(Monitor *mon);
+ void (*info_new)(Monitor *mon, QObject **ret_data);
void (*cmd)(Monitor *mon, const QDict *qdict);
void (*cmd_new)(Monitor *mon, const QDict *params, QObject **ret_data);
} mhandler;
@@ -215,6 +216,8 @@ static int monitor_fprintf(FILE *stream, const char *fmt, ...)
return 0;
}
+static void monitor_user_noop(Monitor *mon, const QObject *data) { }
+
static inline int monitor_handler_ported(const mon_cmd_t *cmd)
{
return cmd->user_print != NULL;
@@ -289,22 +292,34 @@ static void do_commit(Monitor *mon, const QDict *qdict)
}
}
-static void do_info(Monitor *mon, const QDict *qdict)
+static void do_info(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
const mon_cmd_t *cmd;
const char *item = qdict_get_try_str(qdict, "item");
if (!item)
goto help;
- for(cmd = info_cmds; cmd->name != NULL; cmd++) {
+
+ for (cmd = info_cmds; cmd->name != NULL; cmd++) {
if (compare_cmd(item, cmd->name))
- goto found;
+ break;
}
- help:
- help_cmd(mon, "info");
+
+ if (cmd->name == NULL)
+ goto help;
+
+ if (monitor_handler_ported(cmd)) {
+ cmd->mhandler.info_new(mon, ret_data);
+ if (*ret_data)
+ cmd->user_print(mon, *ret_data);
+ } else {
+ cmd->mhandler.info(mon);
+ }
+
return;
- found:
- cmd->mhandler.info(mon);
+
+help:
+ help_cmd(mon, "info");
}
static void do_info_version(Monitor *mon)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index c689a074cb..c37b0cb435 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -40,7 +40,8 @@ ETEXI
.args_type = "item:s?",
.params = "[subcommand]",
.help = "show various information about the system state",
- .mhandler.cmd = do_info,
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = do_info,
},
STEXI