From nobody Fri Oct 24 22:00:19 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520234357199439.3185586995288; Sun, 4 Mar 2018 23:19:17 -0800 (PST) Received: from localhost ([::1]:47550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eskOw-0004ju-Gf for importer@patchew.org; Mon, 05 Mar 2018 02:19:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eskO2-0004MJ-4k for qemu-devel@nongnu.org; Mon, 05 Mar 2018 02:18:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eskNx-0008NV-6S for qemu-devel@nongnu.org; Mon, 05 Mar 2018 02:18:18 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:58112 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eskNx-0008NC-10 for qemu-devel@nongnu.org; Mon, 05 Mar 2018 02:18:13 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 525734023155 for ; Mon, 5 Mar 2018 07:18:08 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-103.ams2.redhat.com [10.36.116.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D4CC111DCE7; Mon, 5 Mar 2018 07:18:01 +0000 (UTC) From: Thomas Huth To: qemu-devel@nongnu.org, Gerd Hoffmann Date: Mon, 5 Mar 2018 08:18:00 +0100 Message-Id: <1520234280-19410-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 07:18:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 07:18:08 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'thuth@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] Allow to specify a display ID whith the screendump command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jiri Denemark , Markus Armbruster , "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" QEMU's screendump command can only take dumps from the primary display. When using multiple VGA cards, there is no way to get a dump from a secondary card yet. So let's add an 'id' parameter to the HMP and QMP commands to be able to specify alternative devices with the screendump command, too. Signed-off-by: Thomas Huth --- hmp-commands.hx | 6 +++--- hmp.c | 3 ++- qapi/ui.json | 4 +++- ui/console.c | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index d26eb41..045ffb0 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -253,9 +253,9 @@ ETEXI =20 { .name =3D "screendump", - .args_type =3D "filename:F", - .params =3D "filename", - .help =3D "save screen into PPM image 'filename'", + .args_type =3D "filename:F,id:s?", + .params =3D "filename [id]", + .help =3D "save screen from device 'id' into PPM image 'file= name'", .cmd =3D hmp_screendump, }, =20 diff --git a/hmp.c b/hmp.c index ae86bfb..e2f46f1 100644 --- a/hmp.c +++ b/hmp.c @@ -2132,9 +2132,10 @@ err_out: void hmp_screendump(Monitor *mon, const QDict *qdict) { const char *filename =3D qdict_get_str(qdict, "filename"); + const char *id =3D qdict_get_try_str(qdict, "id"); Error *err =3D NULL; =20 - qmp_screendump(filename, &err); + qmp_screendump(filename, id !=3D NULL, id, &err); hmp_handle_error(mon, &err); } =20 diff --git a/qapi/ui.json b/qapi/ui.json index 3e82f25..977212a 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -77,6 +77,8 @@ # # @filename: the path of a new PPM file to store the image # +# @id: ID of the display device that should be used (since 2.12) +# # Returns: Nothing on success # # Since: 0.14.0 @@ -88,7 +90,7 @@ # <- { "return": {} } # ## -{ 'command': 'screendump', 'data': {'filename': 'str'} } +{ 'command': 'screendump', 'data': {'filename': 'str', '*id': 'str'} } =20 ## # =3D=3D Spice diff --git a/ui/console.c b/ui/console.c index e22931a..a0db0c5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -344,10 +344,24 @@ write_err: goto out; } =20 -void qmp_screendump(const char *filename, Error **errp) +void qmp_screendump(const char *filename, bool has_id, const char *id, + Error **errp) { QemuConsole *con =3D qemu_console_lookup_by_index(0); DisplaySurface *surface; + DeviceState *dev; + + if (has_id) { + dev =3D qdev_find_recursive(sysbus_get_default(), id); + if (!dev) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, + "Device '%s' not found", id); + return; + } + con =3D qemu_console_lookup_by_device(dev, 0); + } else { + con =3D qemu_console_lookup_by_index(0); + } =20 if (con =3D=3D NULL) { error_setg(errp, "There is no QemuConsole I can screendump from."); --=20 1.8.3.1