@@ -176,7 +176,7 @@ void vga_hw_invalidate(void)
active_console->hw_invalidate(active_console->hw);
}
-void vga_hw_screen_dump(const char *filename)
+static void vga_hw_screen_dump_helper(const char *filename, bool async)
{
TextConsole *previous_active_console;
bool cswitch;
@@ -189,8 +189,13 @@ void vga_hw_screen_dump(const char *filename)
if (cswitch) {
console_select(0);
}
- if (consoles[0] && consoles[0]->hw_screen_dump) {
+ if (async && consoles[0] && consoles[0]->hw_screen_dump_async) {
+ consoles[0]->hw_screen_dump_async(consoles[0]->hw, filename, cswitch);
+ } else if (consoles[0] && consoles[0]->hw_screen_dump) {
consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch);
+ if (async) {
+ monitor_protocol_screen_dump_complete_event(filename);
+ }
} else {
error_report("screen dump not implemented");
}
@@ -200,6 +205,16 @@ void vga_hw_screen_dump(const char *filename)
}
}
+void vga_hw_screen_dump(const char *filename)
+{
+ vga_hw_screen_dump_helper(filename, false);
+}
+
+void vga_hw_screen_dump_async(const char *filename)
+{
+ vga_hw_screen_dump_helper(filename, true);
+}
+
void vga_hw_text_update(console_ch_t *chardata)
{
if (active_console && active_console->hw_text_update)
@@ -901,6 +901,11 @@ static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
return 0;
}
+void qmp_screendump_async(const char *filename, Error **errp)
+{
+ vga_hw_screen_dump_async(filename);
+}
+
static void do_logfile(Monitor *mon, const QDict *qdict)
{
cpu_set_log_filename(qdict_get_str(qdict, "filename"));
@@ -1633,3 +1633,23 @@
{ 'command': 'qom-list-types',
'data': { '*implements': 'str', '*abstract': 'bool' },
'returns': [ 'ObjectTypeInfo' ] }
+
+##
+## @screendump-async:
+#
+# This command will perform a screen dump of the first console to the givem
+# filename. The additional parameters are unused at this time.
+#
+# @filename name of output file to write screen dump to
+#
+# Since: 1.1
+#
+# Notes: This command is experimental and may change syntax in future releases.
+#
+# This command is the same as the qmp/hmp screendump command, except that on
+# successful completion of the scren dump the SCREEN_DUMP_COMPLETE event is
+# emitted.
+#
+##
+{ 'command': 'screendump-async',
+ 'data': { 'filename': 'str' } }
@@ -170,6 +170,32 @@ Example:
EQMP
{
+ .name = "screendump-async",
+ .args_type = "filename:F",
+ .params = "filename",
+ .help = "save screen into PPM image 'filename'",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = qmp_marshal_input_screendump_async,
+ },
+
+SQMP
+screendump-async
+----------------
+
+Save screen into PPM image. Fires a SCREEN_DUMP_COMPLETE event on completion.
+
+Arguments:
+
+- "filename": file path (json-string)
+
+Example:
+
+-> { "execute": "screendump-async", "arguments": { "filename": "/tmp/image" } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "stop",
.args_type = "",
.mhandler.cmd_new = qmp_marshal_input_stop,
Uses a new console.h function, vga_hw_screen_dump_async. vga_hw_screen_dump_async falls back to hw_vga_screen_dump if there is no hw_vga_screen_dump_async callback provided to graphic_console_init. This is the only case right now, but the up side is that the interface is already implemented. The QEVENT_SCREEN_DUMP event is used to notify of completion. Signed-off-by: Alon Levy <alevy@redhat.com> --- console.c | 19 +++++++++++++++++-- monitor.c | 5 +++++ qapi-schema.json | 20 ++++++++++++++++++++ qmp-commands.hx | 26 ++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 2 deletions(-)