aboutsummaryrefslogtreecommitdiff
path: root/monitor.h
diff options
context:
space:
mode:
authorAdam Litke <agl@us.ibm.com>2010-01-25 12:18:44 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-26 17:08:03 -0600
commit940cc30d0d456781adcc48bf9f8c5582026d7983 (patch)
tree4f2203df37ce2de3c181363a2afb29d2ad5cd9cf /monitor.h
parente2a305fb13ff0f5cf6ff805555aaa90a5ed5954c (diff)
New API for asynchronous monitor commands
Qemu has a number of commands that can operate asynchronously (savevm, migrate, etc) and it will be getting more. For these commands, the user monitor needs to be suspended, but QMP monitors could continue to to accept other commands. This patch introduces a new command API that isolates the details of handling different monitor types from the actual command execution. A monitor command can use this API by implementing the mhandler.cmd_async handler (or info_async if appropriate). This function is responsible for submitting the command and does not return any data although it may raise errors. When the command completes, the QMPCompletion callback should be invoked with its opaque data and the command result. The process for submitting and completing an asynchronous command is different for QMP and user monitors. A user monitor must be suspended at submit time and resumed at completion time. The user_print() function must be passed to the QMPCompletion callback so the result can be displayed properly. QMP monitors are simpler. No submit time setup is required. When the command completes, monitor_protocol_emitter() writes the result in JSON format. This API can also be used to implement synchronous commands. In this case, the cmd_async handler should immediately call the QMPCompletion callback. It is my hope that this new interface will work for all commands, leading to a drastically simplified monitor.c once all commands are ported. Signed-off-by: Adam Litke <agl@us.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'monitor.h')
-rw-r--r--monitor.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/monitor.h b/monitor.h
index 2da30e8804..b0f9270a93 100644
--- a/monitor.h
+++ b/monitor.h
@@ -44,4 +44,6 @@ void monitor_printf(Monitor *mon, const char *fmt, ...)
void monitor_print_filename(Monitor *mon, const char *filename);
void monitor_flush(Monitor *mon);
+typedef void (MonitorCompletion)(void *opaque, QObject *ret_data);
+
#endif /* !MONITOR_H */