From patchwork Mon Mar 5 15:56:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 144704 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4D558B6FA3 for ; Tue, 6 Mar 2012 02:57:29 +1100 (EST) Received: from localhost ([::1]:47022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4aHp-0006NA-T2 for incoming@patchwork.ozlabs.org; Mon, 05 Mar 2012 10:57:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4aHW-00068y-Hd for qemu-devel@nongnu.org; Mon, 05 Mar 2012 10:57:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S4aHK-0001jM-9i for qemu-devel@nongnu.org; Mon, 05 Mar 2012 10:56:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S4aHK-0001gL-1f for qemu-devel@nongnu.org; Mon, 05 Mar 2012 10:56:50 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q25FubDD029796 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Mar 2012 10:56:37 -0500 Received: from garlic.tlv.redhat.com (spice-ovirt.tlv.redhat.com [10.35.4.71]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q25FuTKQ029598; Mon, 5 Mar 2012 10:56:35 -0500 From: Alon Levy To: qemu-devel@nongnu.org, anthony@codemonkey.ws, kraxel@redhat.com, lcapitulino@redhat.com Date: Mon, 5 Mar 2012 17:56:29 +0200 Message-Id: <1330962989-20077-4-git-send-email-alevy@redhat.com> In-Reply-To: <1330962989-20077-1-git-send-email-alevy@redhat.com> References: <4F54CEA2.10808@codemonkey.ws> <1330962989-20077-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 3/3] add qmp screendump-async X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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,