From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org, anthony@codemonkey.ws, kraxel@redhat.com,
lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v3 3/3] add qmp screendump-async
Date: Mon, 5 Mar 2012 17:56:29 +0200 [thread overview]
Message-ID: <1330962989-20077-4-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1330962989-20077-1-git-send-email-alevy@redhat.com>
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 | 51 +++++++++++++++++++++++++++++++++++++++++++++++++--
monitor.c | 5 +++++
qapi-schema.json | 20 ++++++++++++++++++++
qmp-commands.hx | 26 ++++++++++++++++++++++++++
4 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/console.c b/console.c
index 1e97c4a..301ac3d 100644
--- a/console.c
+++ b/console.c
@@ -176,8 +176,38 @@ void vga_hw_invalidate(void)
active_console->hw_invalidate(active_console->hw);
}
-void vga_hw_screen_dump(const char *filename)
+typedef struct VGAHwScreenDumpAsyncCbData {
+ char *filename;
+} VGAHwScreenDumpAsyncCbData;
+
+static VGAHwScreenDumpAsyncCbData *
+vga_hw_screen_dump_async_data_new(const char *filename)
+{
+ VGAHwScreenDumpAsyncCbData *data = g_malloc0(
+ sizeof(VGAHwScreenDumpAsyncCbData));
+
+ data->filename = g_strdup(filename);
+ return data;
+}
+
+static void vga_hw_screen_dump_async_data_free(
+ VGAHwScreenDumpAsyncCbData *data)
{
+ g_free(data->filename);
+ g_free(data);
+}
+
+static void vga_hw_screen_dump_async_cb(void *opaque)
+{
+ VGAHwScreenDumpAsyncCbData *data = opaque;
+
+ monitor_protocol_screen_dump_complete_event(data->filename);
+ vga_hw_screen_dump_async_data_free(data);
+}
+
+static void vga_hw_screen_dump_helper(const char *filename, bool async)
+{
+ VGAHwScreenDumpAsyncCbData *data;
TextConsole *previous_active_console;
bool cswitch;
@@ -189,8 +219,15 @@ 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) {
+ data = vga_hw_screen_dump_async_data_new(filename);
+ consoles[0]->hw_screen_dump_async(consoles[0]->hw, filename, cswitch,
+ vga_hw_screen_dump_async_cb, data);
+ } 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 +237,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,
--
1.7.9.1
next prev parent reply other threads:[~2012-03-05 15:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-05 14:16 [Qemu-devel] [PATCH v2 1/2] console: add hw_screen_dump_async Alon Levy
2012-03-05 14:16 ` [Qemu-devel] [PATCH v2 2/2] add qmp screendump-async Alon Levy
2012-03-05 14:33 ` [Qemu-devel] [PATCH v2 1/2] console: add hw_screen_dump_async Anthony Liguori
2012-03-05 15:17 ` Alon Levy
2012-03-05 15:56 ` [Qemu-devel] [PATCH v3 0/3] screendump async command Alon Levy
2012-03-05 15:56 ` [Qemu-devel] [PATCH v3 1/3] monitor, console: add QEVENT_SCREEN_DUMP_COMPLETE Alon Levy
2012-03-05 15:56 ` [Qemu-devel] [PATCH v3 2/3] console: add hw_screen_dump_async Alon Levy
2012-03-05 15:56 ` Alon Levy [this message]
2012-03-05 17:17 ` [Qemu-devel] [PATCH v3 0/3] screendump async command Anthony Liguori
2012-03-05 17:20 ` [Qemu-devel] [PATCH v2 1/2] console: add hw_screen_dump_async Avi Kivity
2012-03-05 17:27 ` Anthony Liguori
2012-03-05 17:29 ` Avi Kivity
2012-03-05 17:56 ` Luiz Capitulino
2012-03-05 18:16 ` Anthony Liguori
2012-03-05 18:22 ` Avi Kivity
2012-03-05 19:32 ` Anthony Liguori
2012-03-05 17:31 ` Luiz Capitulino
2012-03-05 18:09 ` Alon Levy
2012-03-05 18:17 ` Avi Kivity
2012-03-05 18:58 ` Alon Levy
2012-03-05 19:45 ` Luiz Capitulino
2012-03-06 7:36 ` Gerd Hoffmann
2012-03-06 7:43 ` Alon Levy
2012-03-06 7:56 ` Alon Levy
2012-03-06 8:10 ` Gerd Hoffmann
2012-03-06 9:35 ` Alon Levy
2012-03-06 12:24 ` Luiz Capitulino
2012-03-06 13:16 ` Alon Levy
2012-03-06 13:51 ` Anthony Liguori
2012-03-06 13:53 ` Luiz Capitulino
2012-03-06 14:23 ` Alon Levy
2012-03-06 15:07 ` Anthony Liguori
2012-03-06 15:56 ` Alon Levy
2012-03-06 16:02 ` Alon Levy
2012-03-06 16:16 ` Anthony Liguori
2012-03-06 16:26 ` Alon Levy
2012-03-06 16:47 ` Anthony Liguori
2012-03-07 6:57 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330962989-20077-4-git-send-email-alevy@redhat.com \
--to=alevy@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=kraxel@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).