@@ -4594,6 +4594,26 @@ static void monitor_command_cb(Monitor *mon, const char *cmdline, void *opaque)
monitor_resume(mon);
}
+int qemu_suspend_monitor(const char *fmt, ...)
+{
+ int ret;
+
+ if (cur_mon) {
+ ret = monitor_suspend(cur_mon);
+ } else {
+ ret = -ENOTTY;
+ }
+
+ if (ret < 0 && fmt) {
+ va_list ap;
+ va_start(ap, fmt);
+ monitor_vprintf(cur_mon, fmt, ap);
+ va_end(ap);
+ }
+
+ return ret;
+}
+
int monitor_suspend(Monitor *mon)
{
if (!mon->rs)
@@ -4602,6 +4622,13 @@ int monitor_suspend(Monitor *mon)
return 0;
}
+void qemu_resume_monitor(void)
+{
+ if (cur_mon) {
+ monitor_resume(cur_mon);
+ }
+}
+
void monitor_resume(Monitor *mon)
{
if (!mon->rs)
@@ -43,7 +43,9 @@ int monitor_cur_is_qmp(void);
void monitor_protocol_event(MonitorEvent event, QObject *data);
void monitor_init(CharDriverState *chr, int flags);
+int qemu_suspend_monitor(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
int monitor_suspend(Monitor *mon);
+void qemu_resume_monitor(void);
void monitor_resume(Monitor *mon);
int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
Sync command needs these two APIs to suspend/resume monitor. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> --- monitor.c | 27 +++++++++++++++++++++++++++ monitor.h | 2 ++ 2 files changed, 29 insertions(+), 0 deletions(-)