Patchwork [v2,2/2] add qmp screendump-async

login
register
mail settings
Submitter Alon Levy
Date March 5, 2012, 2:16 p.m.
Message ID <1330956981-5001-2-git-send-email-alevy@redhat.com>
Download mbox | patch
Permalink /patch/144684/
State New
Headers show

Comments

Alon Levy - March 5, 2012, 2:16 p.m.
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(-)

Patch

diff --git a/console.c b/console.c
index 9a49e93..5102573 100644
--- a/console.c
+++ b/console.c
@@ -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)
diff --git a/monitor.c b/monitor.c
index a8c84c0..1c3bd2a 100644
--- a/monitor.c
+++ b/monitor.c
@@ -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"));
diff --git a/qapi-schema.json b/qapi-schema.json
index dd9e0e5..60dae67 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -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' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 0c9bfac..94ee1ae 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -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,