If necessary, add an helper that can be used to retrieve the associated monitor. This is useful for asynchronous commands that may have to update cur_mon for various reasons.
Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> --- include/monitor/monitor.h | 3 +++ monitor.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 0cb0538a31..2052a6b4e4 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -5,6 +5,7 @@ #include "block/block.h" #include "qapi/qapi-types-misc.h" #include "qemu/readline.h" +#include "qapi/qmp/dispatch.h" extern Monitor *cur_mon; @@ -46,4 +47,6 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); void monitor_fdset_dup_fd_remove(int dup_fd); int monitor_fdset_dup_fd_find(int dup_fd); +Monitor *qmp_return_get_monitor(QmpReturn *qret); + #endif /* MONITOR_H */ diff --git a/monitor.c b/monitor.c index 73a06d4156..f7826f5626 100644 --- a/monitor.c +++ b/monitor.c @@ -281,6 +281,12 @@ bool monitor_cur_is_qmp(void) return cur_mon && monitor_is_qmp(cur_mon); } +Monitor *qmp_return_get_monitor(QmpReturn *qret) +{ + return qret->session ? + container_of(qret->session, Monitor, qmp.session) : NULL; +} + void monitor_read_command(Monitor *mon, int show_prompt) { if (!mon->rs) -- 2.17.0.rc1.1.g4c4f2b46a3