From patchwork Sun Mar 18 18:29:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 147419 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 36540B6FA1 for ; Mon, 19 Mar 2012 06:02:43 +1100 (EST) Received: from localhost ([::1]:57093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9Kro-0007ji-MK for incoming@patchwork.ozlabs.org; Sun, 18 Mar 2012 14:30:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9Kr8-0006Sm-2z for qemu-devel@nongnu.org; Sun, 18 Mar 2012 14:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S9Kr5-00032R-94 for qemu-devel@nongnu.org; Sun, 18 Mar 2012 14:29:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S9Kr5-00032C-1U for qemu-devel@nongnu.org; Sun, 18 Mar 2012 14:29:23 -0400 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 q2IITLkw006862 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 18 Mar 2012 14:29:21 -0400 Received: from garlic.redhat.com (reserved-200-252.tlv.redhat.com [10.35.200.252] (may be forged)) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q2IITEpD031064; Sun, 18 Mar 2012 14:29:20 -0400 From: Alon Levy To: qemu-devel@nongnu.org, Luiz Capitulino Date: Sun, 18 Mar 2012 19:29:12 +0100 Message-Id: <1332095353-19120-5-git-send-email-alevy@redhat.com> In-Reply-To: <1332095353-19120-1-git-send-email-alevy@redhat.com> References: <1331765714-26209-1-git-send-email-alevy@redhat.com> <1332095353-19120-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 4/5] qapi: convert screendump 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 The documenting comment contains the long list of possible errors from qemu_fopen_err, this could probably be put somewhere else in the file once more of the api uses those common error classes. Signed-off-by: Alon Levy --- hmp-commands.hx | 3 +-- hmp.c | 8 ++++++++ hmp.h | 1 + monitor.c | 6 ------ qapi-schema.json | 24 ++++++++++++++++++++++++ qmp-commands.hx | 5 +---- qmp.c | 5 +++++ 7 files changed, 40 insertions(+), 12 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 6980214..d26421a 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -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_screendump, }, STEXI diff --git a/hmp.c b/hmp.c index 290c43d..42dc79a 100644 --- a/hmp.c +++ b/hmp.c @@ -860,3 +860,11 @@ void hmp_block_job_cancel(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, &error); } + +void hmp_screendump(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + + qmp_screendump(qdict_get_str(qdict, "filename"), &err); + hmp_handle_error(mon, &err); +} diff --git a/hmp.h b/hmp.h index 5409464..25d123f 100644 --- a/hmp.h +++ b/hmp.h @@ -59,5 +59,6 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict); void hmp_block_stream(Monitor *mon, const QDict *qdict); void hmp_block_job_set_speed(Monitor *mon, const QDict *qdict); void hmp_block_job_cancel(Monitor *mon, const QDict *qdict); +void hmp_screendump(Monitor *mon, const QDict *qdict); #endif diff --git a/monitor.c b/monitor.c index 2156fcf..34d7617 100644 --- a/monitor.c +++ b/monitor.c @@ -893,12 +893,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"), NULL); - return 0; -} - 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 04fa84f..b9baba9 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1663,3 +1663,27 @@ { 'command': 'qom-list-types', 'data': { '*implements': 'str', '*abstract': 'bool' }, 'returns': [ 'ObjectTypeInfo' ] } + +## +# @screendump: +# +# Write a PPM of the VGA screen to a file. +# +# @filename: the name of a new PPM file to create to store the image +# +# Returns: Nothing on success +# If @cpu is not a valid VCPU, InvalidParameterValue +# If @filename cannot be opened, OpenFileFailed or one of the more +# specific errors: +# EINTR - Interruped during operation +# EACCES - Cannot access file +# OpenFileEMFILE - Maximum open file descriptors reached +# ENOSPC - No space on device +# EPERM - No permission +# READ_ONLY - File system is read only +# ENOTDIR - Path to file contains a non directory element +# +## +# Since: 1.1 +## +{ 'command': 'screendump', 'data': {'filename': 'str'} } diff --git a/qmp-commands.hx b/qmp-commands.hx index dfe8a5b..5fe57fd 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -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 diff --git a/qmp.c b/qmp.c index a182b51..086cec8 100644 --- a/qmp.c +++ b/qmp.c @@ -415,3 +415,8 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements, return ret; } + +void qmp_screendump(const char *filename, Error **errp) +{ + vga_hw_screen_dump(filename, errp); +}