diff mbox

[RFC,01/15] monitor: introduce qemu_suspend_monitor()/qemu_resume_monitor()

Message ID 4F1788AF.10107@cn.fujitsu.com
State New
Headers show

Commit Message

Wen Congyang Jan. 19, 2012, 3:06 a.m. UTC
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(-)
diff mbox

Patch

diff --git a/monitor.c b/monitor.c
index 56f3778..ce2bc13 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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)
diff --git a/monitor.h b/monitor.h
index 274cd39..cc94bab 100644
--- a/monitor.h
+++ b/monitor.h
@@ -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,