qapi: convert screendump
authorLuiz Capitulino <lcapitulino@redhat.com>
Thu, 24 May 2012 16:48:23 +0000 (13:48 -0300)
committerLuiz Capitulino <lcapitulino@redhat.com>
Wed, 5 Sep 2012 18:48:57 +0000 (15:48 -0300)
Next commits will update devices to propagate errors.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
console.c
console.h
hmp-commands.hx
hmp.c
hmp.h
monitor.c
qapi-schema.json
qmp-commands.hx

index 8228773ddcf50412a72ca8d0693544b83dc14c89..c1ed5e09e09393bd5edfcfacdf9918317f8b4a80 100644 (file)
--- a/console.c
+++ b/console.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "console.h"
 #include "qemu-timer.h"
+#include "qmp-commands.h"
 
 //#define DEBUG_CONSOLE
 #define DEFAULT_BACKSCROLL 512
@@ -176,7 +177,7 @@ void vga_hw_invalidate(void)
         active_console->hw_invalidate(active_console->hw);
 }
 
-void vga_hw_screen_dump(const char *filename)
+void qmp_screendump(const char *filename, Error **errp)
 {
     TextConsole *previous_active_console;
     bool cswitch;
@@ -190,9 +191,9 @@ void vga_hw_screen_dump(const char *filename)
         console_select(0);
     }
     if (consoles[0] && consoles[0]->hw_screen_dump) {
-        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch, NULL);
+        consoles[0]->hw_screen_dump(consoles[0]->hw, filename, cswitch, errp);
     } else {
-        error_report("screen dump not implemented");
+        error_setg(errp, "device doesn't support screendump\n");
     }
 
     if (cswitch) {
index fd68ecca75024cf69c241390e3410074ee6d34cf..f990684ef4d294ce94ff70ebaa6c06d83f580946 100644 (file)
--- a/console.h
+++ b/console.h
@@ -357,7 +357,6 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
 
 void vga_hw_update(void);
 void vga_hw_invalidate(void);
-void vga_hw_screen_dump(const char *filename);
 void vga_hw_text_update(console_ch_t *chardata);
 
 int is_graphic_console(void);
index 5cee1310cc0e36c619fadf6870bfca1f20424fcc..ed67e997fd67ab54065e8fd572b866396a45fbdc 100644 (file)
@@ -194,8 +194,7 @@ ETEXI
         .args_type  = "filename:F",
         .params     = "filename",
         .help       = "save screen into PPM image 'filename'",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_screen_dump,
+        .mhandler.cmd = hmp_screen_dump,
     },
 
 STEXI
diff --git a/hmp.c b/hmp.c
index ba99b2fb30d4bd5ff843d93c235e01c657410a9e..1bdab22778c9623bd833a092989dc6fdafb27061 100644 (file)
--- a/hmp.c
+++ b/hmp.c
@@ -1157,3 +1157,12 @@ void hmp_send_key(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
     qapi_free_QKeyCodeList(head);
 }
+
+void hmp_screen_dump(Monitor *mon, const QDict *qdict)
+{
+    const char *filename = qdict_get_str(qdict, "filename");
+    Error *err = NULL;
+
+    qmp_screendump(filename, &err);
+    hmp_handle_error(mon, &err);
+}
diff --git a/hmp.h b/hmp.h
index 8e7838ce5dffdef877cd89c366df65124a1f2d63..48b9c59f8af01bd3bd21888f12cf8f0edc0200e7 100644 (file)
--- a/hmp.h
+++ b/hmp.h
@@ -72,5 +72,6 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict);
 void hmp_getfd(Monitor *mon, const QDict *qdict);
 void hmp_closefd(Monitor *mon, const QDict *qdict);
 void hmp_send_key(Monitor *mon, const QDict *qdict);
+void hmp_screen_dump(Monitor *mon, const QDict *qdict);
 
 #endif
index d73bad8316456ea211925bd71996deefa4c2d287..e315b270ee2a40af73e6b9aad5e75c7adb6b46dc 100644 (file)
--- a/monitor.c
+++ b/monitor.c
@@ -1016,12 +1016,6 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
     return -1;
 }
 
-static int do_screen_dump(Monitor *mon, const QDict *qdict, QObject **ret_data)
-{
-    vga_hw_screen_dump(qdict_get_str(qdict, "filename"));
-    return 0;
-}
-
 static void do_logfile(Monitor *mon, const QDict *qdict)
 {
     cpu_set_log_filename(qdict_get_str(qdict, "filename"));
index 5421382991dacaed50d160d89d015353c2169ae5..df47fcee2f85fcccaca8cfa5b084c1d0d31b4483 100644 (file)
 ##
 { 'command': 'send-key',
   'data': { 'keys': ['QKeyCode'], '*hold-time': 'int' } }
+
+##
+# @screendump:
+#
+# Write a PPM of the VGA screen to a file.
+#
+# @filename: the path of a new PPM file to store the image
+#
+# Returns: Nothing on success
+#
+# Since: 0.14.0
+##
+{ 'command': 'screendump', 'data': {'filename': 'str'} }
index 470f08ed997dff342fba8f47ab1b6c7b7cb7ed44..6e21ddba61325b97b70961c39ccd37fb70364874 100644 (file)
@@ -146,10 +146,7 @@ EQMP
     {
         .name       = "screendump",
         .args_type  = "filename:F",
-        .params     = "filename",
-        .help       = "save screen into PPM image 'filename'",
-        .user_print = monitor_user_noop,
-        .mhandler.cmd_new = do_screen_dump,
+        .mhandler.cmd_new = qmp_marshal_input_screendump,
     },
 
 SQMP