@@ -67,3 +67,46 @@ int GCC_FMT_ATTR(2, 3) monitor_fprintf(FILE *stream,
return 0;
}
+static void monitor_data_destroy(Monitor *mon)
+{
+ QDECREF(mon->outbuf);
+ qemu_mutex_destroy(&mon->out_lock);
+}
+
+char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
+ int64_t cpu_index, Error **errp)
+{
+ char *output = NULL;
+ Monitor *old_mon, hmp;
+
+ monitor_data_init(&hmp);
+ hmp.skip_flush = true;
+
+ old_mon = cur_mon;
+ cur_mon = &hmp;
+
+ if (has_cpu_index) {
+ int ret = monitor_set_cpu(cpu_index);
+ if (ret < 0) {
+ cur_mon = old_mon;
+ error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
+ "a CPU number");
+ goto out;
+ }
+ }
+
+ handle_user_command(&hmp, command_line);
+ cur_mon = old_mon;
+
+ qemu_mutex_lock(&hmp.out_lock);
+ if (qstring_get_length(hmp.outbuf) > 0) {
+ output = g_strdup(qstring_get_str(hmp.outbuf));
+ } else {
+ output = g_strdup("");
+ }
+ qemu_mutex_unlock(&hmp.out_lock);
+
+out:
+ monitor_data_destroy(&hmp);
+ return output;
+}
@@ -551,50 +551,6 @@ void monitor_data_init(Monitor *mon)
mon->cmd_table = mon_cmds;
}
-static void monitor_data_destroy(Monitor *mon)
-{
- QDECREF(mon->outbuf);
- qemu_mutex_destroy(&mon->out_lock);
-}
-
-char *qmp_human_monitor_command(const char *command_line, bool has_cpu_index,
- int64_t cpu_index, Error **errp)
-{
- char *output = NULL;
- Monitor *old_mon, hmp;
-
- monitor_data_init(&hmp);
- hmp.skip_flush = true;
-
- old_mon = cur_mon;
- cur_mon = &hmp;
-
- if (has_cpu_index) {
- int ret = monitor_set_cpu(cpu_index);
- if (ret < 0) {
- cur_mon = old_mon;
- error_set(errp, QERR_INVALID_PARAMETER_VALUE, "cpu-index",
- "a CPU number");
- goto out;
- }
- }
-
- handle_user_command(&hmp, command_line);
- cur_mon = old_mon;
-
- qemu_mutex_lock(&hmp.out_lock);
- if (qstring_get_length(hmp.outbuf) > 0) {
- output = g_strdup(qstring_get_str(hmp.outbuf));
- } else {
- output = g_strdup("");
- }
- qemu_mutex_unlock(&hmp.out_lock);
-
-out:
- monitor_data_destroy(&hmp);
- return output;
-}
-
int compare_cmd(const char *name, const char *list)
{
const char *p, *pstart;
Signed-off-by: Benoit Canet <benoit@irqsave.net> --- monitor-system.c | 43 +++++++++++++++++++++++++++++++++++++++++++ monitor.c | 44 -------------------------------------------- 2 files changed, 43 insertions(+), 44 deletions(-)