From patchwork Tue Mar 15 04:47:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kshitij Suri X-Patchwork-Id: 12781027 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 748F2C433F5 for ; Tue, 15 Mar 2022 04:48:49 +0000 (UTC) Received: from localhost ([::1]:37126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTz72-0004RY-Cx for qemu-devel@archiver.kernel.org; Tue, 15 Mar 2022 00:48:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTz6B-0002n2-RQ for qemu-devel@nongnu.org; Tue, 15 Mar 2022 00:47:55 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:26326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTz69-0000Jd-8H for qemu-devel@nongnu.org; Tue, 15 Mar 2022 00:47:55 -0400 Received: from pps.filterd (m0127837.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22EIZjPM003588; Mon, 14 Mar 2022 21:47:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=9vARoc5tEfrCv0LNPooRMlevnMa0GTxPsLKqJcDA3Hc=; b=ML+YfcpefPKwrTllbnNF74lLYEL9PGJdrWHfY2cpLdbGvNTs7S0FUlQc9FVpvKaOX+5b YmzJuYBbv0hcCRygQ6W7JSgLmAqoEPNK6L18fE7V0HD834evZW314aPK9iit9yZmo7GL YDk/TOxVg7PgBPxFbFMwejTsjLONyT5ctjNKg9ZeEIOUZCi58piQk092aZS5AtOuWVGK RyBb9DQFa1+CHVABwjEUFUlhOaYHb7TmfBfPOmSt0KVFVKePFmb0s+Wt8EkDW/0kSIIO VMOSiGtJt4mBxbihNIGInekGq3L7m//JExks5vauCpxKNdREkFgB58ONA94GxUCtPLNO kA== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3et63h1p4f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 21:47:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PykMzuTBS5Jz+EvXn3vZ3TpmEY9yPGB4exbTBmKI2cX/bzwBEG5mJWypQRJQujNicwnGesOlkAZyIO+n1TzKXY+s7nhHdoGidNR9HsvM218UtRbclie5GjLIU/eUOR3ayF8P3keq8n+eeCxcJa+FwxYDcpGXTS2/vs6n4CAW9btnvD9NaqlV91PPvGM+GHbSqjccrR3XM7wOLsWkfApgct5P4zdrhGap4kPw/V2FfQEHmdKtFvoTzzcpQ1QtyjL4NkFs2Hcm0hi/bbXJF1kgkkQHCwfBC65LQI5RD4nLwoPMXxzlyaLMNCl9SY8uN7TE2kTHaSWcjz684sSVIgKkyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9vARoc5tEfrCv0LNPooRMlevnMa0GTxPsLKqJcDA3Hc=; b=GzjrAlXDAAHt5t/k6ZJbqPTO4Vl5JclEH63wtYb/H5CFpLqX28u6Ai9hTDUMxX12f1dHZ9ExF3l48eF64j8IQsn3qBiAXD1tLwrC0yO26HKQg4sVagHd4WeBgtYwz3zApc9UXuk2ru7LSKCbZLk4vx9sfFCRZntemfMExfGXxvxrzwiedb41VMIUyuSSxVu2xzSne+Lp/fae93pkEuHw6FczCoYYXDTnltx3uXQ8/mdsoq6UsEijVnHpfkG3PnKoAua+XiD2IuktQhoOLvfI4fxbFsFFKPjJFEWVenn7DhTeU3TUFdgjeRWFigBlNNtDqA3OHcySzQTYNvhEfARTKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BN7PR02MB4033.namprd02.prod.outlook.com (2603:10b6:406:f9::16) by DM5PR02MB3210.namprd02.prod.outlook.com (2603:10b6:4:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.26; Tue, 15 Mar 2022 04:47:46 +0000 Received: from BN7PR02MB4033.namprd02.prod.outlook.com ([fe80::5d3d:384c:d914:b12d]) by BN7PR02MB4033.namprd02.prod.outlook.com ([fe80::5d3d:384c:d914:b12d%6]) with mapi id 15.20.5061.029; Tue, 15 Mar 2022 04:47:46 +0000 From: Kshitij Suri To: qemu-devel@nongnu.org Subject: [PATCH v2 1/2] Replacing CONFIG_VNC_PNG with CONFIG_PNG Date: Tue, 15 Mar 2022 04:47:39 +0000 Message-Id: <20220315044740.155268-1-kshitij.suri@nutanix.com> X-Mailer: git-send-email 2.22.3 X-ClientProxiedBy: SJ0PR03CA0002.namprd03.prod.outlook.com (2603:10b6:a03:33a::7) To BN7PR02MB4033.namprd02.prod.outlook.com (2603:10b6:406:f9::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e612fd1a-51df-46a2-085b-08da063ef2d8 X-MS-TrafficTypeDiagnostic: DM5PR02MB3210:EE_ X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cw0znQRKXaHFchufJ0yklkI31ZltspetIX52qofkKUeSe8QhXHUQR5CSTf7h5OTGbjWTPNeWJJNGvIO2SzpihFFA4ZSfol3nRvs1xXbiyS450knR5tcx3Pmq4zNntsKDkdTLvDDAU7vjA/IH9/Nelm7x79aSeNV3pzpp6rojD5vYrIz3H055rGFIM0qwUGI/uKAawXrTPtwBNv4JtdN2B7ALJwes5cPUQykUK396i8dT4VQ8beBk1rlieHj+1sBgEzHyux44VozI5y707xqyz76UVu9xfZrW0dnpBZvH//vT976Ehl+/jEnanJ13wu+jtqSkGsL4Ux2UNN8szK/jxdAGkBm3vBRe47935776mWXbp1Oovav/X6oo0dvt0BcEUgpg7lmde3QJI3XT8iCU2KyZozKLowRPc1ieVJLEGy/EP8dT7IiswFIbY1kgtutk5Jz1qIVuO2SaIgfqTPj0oJ59QxxrP+OphKeik3TcF8U+V8jW5eqHV/fLv1EGYIWvGjI2thpg5ij2HlhVRhRMXxadvyQjpps5eIeklHzqmAZ0Eaj9Kpa23utRvGVqO+LEjXFSq27yOTk8ElcTqRlnxJ0SrEWCeAtk+38ZNQhRf+P6yF0h0zEFVEQIUF1mKhQnjZ2jybvVzLgMEK4KDxAIAHfafX+VcvFKqlf6hNNtLCwMmGIOyx7xSYF5a5ZHUfmq0qtGgJcQnqmYrH5zdoXo+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR02MB4033.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(38350700002)(38100700002)(83380400001)(8676002)(316002)(26005)(186003)(4326008)(6916009)(1076003)(6512007)(2616005)(86362001)(107886003)(6486002)(6666004)(44832011)(5660300002)(2906002)(66946007)(6506007)(66476007)(66556008)(52116002)(508600001)(36756003)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TtF0ngDmy0mHllKQd6o60xHh7MW8kv8q7kNQnEtyMG9wbcrGul2N7U0wtxPhFhn57FPgwQOUOep3awkUybV6kFMPharSYNpqf2/EiuYjXwpBeZ4ggR1l3ZT5ATPIgnMQkL12jhwcCVGoamoJ+pLhZxrOaILnr5lGXqiwP+9AQUDhuc/Me0EH8abeGhUOD6lv52zeqYJTjBAhFGhdkuWWZBq0GcZh5CFRwQqSjW2vdNmuI7ZPNUqJXhF2xz7W8zOSWRr4Rhw7fTwiDwg3DKQQ8vQjN7WxnS/VkccgWSEF/VbkqeMTCsOgLjaHxyubxFvH8qlkhc2mdpRCuX3bTdL+MPrGaKjR3u+lsTjW49yux13XR4SjizVfQcHGev5h3xF5ANVXktdOIzDwRU8yjaFebgcUVTgW9mvQyRvyDA0hH6wXEOOB3nF5N2kH1SRpxaaDj0eHGjMvHYrU+NSwEPgGWvXcHamTk/XWbHs6FrNFsKX+SHFPQfH0SAcr/Ztf1/CuuQMP87Qwax8NujyNlYgPqDQynjNNdlWAQyhurinVLgBin97toe5kcv483dTBEcKkfIJyp8YBOksGVk163M7iCFf6T9o5KLUBMKJF+o7n4rTGpuHxgkeXHUEgw5M7X2TIYIE/m9IKId0oeHJ9EFFvDEaMlatQKhDoOoqgB5X6v/TBu2+k2whr9bXuZeYtzdw8wGYMKZYfZHCy0nP0Wnue+aI1xHXcT4NVb5aQWC+QMWxneCM54tUxgvy1qm3ww+kKc6xWEsBGGnzmehU95P1n38brA2VZVbcMlA/AHUCGoH2X56kfluK6Om06jOWQz1J5CwXFAOq5bi9OERqShMwqSNEO6/nnXpI1p67MzW+FMZDh89tMmgyNWQoNe4qWNXG0WoC+BP/pWy7euKCr4nOnUzhPF8Gdj2JeZIgaoukXS9jcM7z8HWtOQ6V/Fu2XEI5JWVdaNpxx3cbn2LbSP2+TX0yP8uqs140kV3TswzQF2gVQXm5kceGYtZqbXJF+tDhBNB0n8hOsLWPgDOtg0Q5q1dYgv2h3IX48Hue93ZYYi3Hku1nSjtjtuMp9pR/zP8KWeTxglyAR5PjWk0uxgpQHrvqqAafBeZ3KSUNXsIM6utyLPnkiFzdZHEUTnZ4e1uXdpKFwjDvbkmJUCVPMRBqxlPHEZ2skSfqvhFgEqjM3YT1KX7JrGgatupmMyxgM/bQSzdfCtA3zC/1sug2DxefKgCtO+a7fKTYtxw71jWTM43e8xH56aMo9DNVQpQ5VnTFvwWQXWds/uV3RtYBOc4A11tjbtiohlZdJGNPyOvgHlXescd2XcomiLncMxJz8k5JKN5aIlbMjON+0y2HRb1JsolOFfUqEZBM0D8ej9t0kf/F5YQjnAzZUuYXmT57dl0tu61lXYNeMqMqeALLahRjx7cTmePXPCIVnS+YVeY8CuVg6mYgsyldSeDAhth+6TXY4haH66j2djCJ31UjUpacc3Q== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: e612fd1a-51df-46a2-085b-08da063ef2d8 X-MS-Exchange-CrossTenant-AuthSource: BN7PR02MB4033.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2022 04:47:45.9735 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vW4Kbr8TKnC08HhNSwwHplDtvLm3IgipSnO+8CErq6PmUnBhx7HPgHXr5bf5lmMiluJNBjzEbMjAjhjJkYKCg+l4CqhqssS+JJ3jxO+3Gvc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB3210 X-Proofpoint-ORIG-GUID: HMcDS5js5HF86bDDbKvQE1gDnj7jFl5L X-Proofpoint-GUID: HMcDS5js5HF86bDDbKvQE1gDnj7jFl5L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-14_14,2022-03-14_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=kshitij.suri@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: soham.ghosh@nutanix.com, thuth@redhat.com, berrange@redhat.com, prerna.saxena@nutanix.com, dgilbert@redhat.com, armbru@redhat.com, Kshitij Suri , philippe.mathieu.daude@gmail.com, kraxel@redhat.com, prachatos.mitra@nutanix.com, eblake@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Libpng is only detected if VNC is enabled currently. This patch adds a generalised png option in the meson build which is aimed to replace use of CONFIG_VNC_PNG with CONFIG_PNG. Signed-off-by: Kshitij Suri --- meson.build | 9 ++++----- meson_options.txt | 4 ++-- ui/vnc-enc-tight.c | 18 +++++++++--------- ui/vnc.c | 4 ++-- ui/vnc.h | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/meson.build b/meson.build index 8df40bfac4..3b67f83a2c 100644 --- a/meson.build +++ b/meson.build @@ -1112,14 +1112,13 @@ if gtkx11.found() x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(), kwargs: static_kwargs) endif +png = dependency('libpng', required: get_option('png'), + method: 'pkg-config', kwargs: static_kwargs) vnc = not_found -png = not_found jpeg = not_found sasl = not_found if get_option('vnc').allowed() and have_system vnc = declare_dependency() # dummy dependency - png = dependency('libpng', required: get_option('vnc_png'), - method: 'pkg-config', kwargs: static_kwargs) jpeg = dependency('libjpeg', required: get_option('vnc_jpeg'), method: 'pkg-config', kwargs: static_kwargs) sasl = cc.find_library('sasl2', has_headers: ['sasl/sasl.h'], @@ -1537,9 +1536,9 @@ config_host_data.set('CONFIG_TPM', have_tpm) config_host_data.set('CONFIG_USB_LIBUSB', libusb.found()) config_host_data.set('CONFIG_VDE', vde.found()) config_host_data.set('CONFIG_VHOST_USER_BLK_SERVER', have_vhost_user_blk_server) +config_host_data.set('CONFIG_PNG', png.found()) config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) -config_host_data.set('CONFIG_VNC_PNG', png.found()) config_host_data.set('CONFIG_VNC_SASL', sasl.found()) config_host_data.set('CONFIG_VIRTFS', have_virtfs) config_host_data.set('CONFIG_VTE', vte.found()) @@ -3579,11 +3578,11 @@ summary_info += {'curses support': curses} summary_info += {'virgl support': virgl} summary_info += {'curl support': curl} summary_info += {'Multipath support': mpathpersist} +summary_info += {'PNG support': png} summary_info += {'VNC support': vnc} if vnc.found() summary_info += {'VNC SASL support': sasl} summary_info += {'VNC JPEG support': jpeg} - summary_info += {'VNC PNG support': png} endif if targetos not in ['darwin', 'haiku', 'windows'] summary_info += {'OSS support': oss} diff --git a/meson_options.txt b/meson_options.txt index 52b11cead4..d85734f8e6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -177,12 +177,12 @@ option('vde', type : 'feature', value : 'auto', description: 'vde network backend support') option('virglrenderer', type : 'feature', value : 'auto', description: 'virgl rendering support') +option('png', type : 'feature', value : 'auto', + description: 'PNG support with libpng') option('vnc', type : 'feature', value : 'auto', description: 'VNC server') option('vnc_jpeg', type : 'feature', value : 'auto', description: 'JPEG lossy compression for VNC server') -option('vnc_png', type : 'feature', value : 'auto', - description: 'PNG compression for VNC server') option('vnc_sasl', type : 'feature', value : 'auto', description: 'SASL authentication for VNC server') option('vte', type : 'feature', value : 'auto', diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index cebd35841a..a23ad712eb 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -32,7 +32,7 @@ INT32 definitions between jmorecfg.h (included by jpeglib.h) and Win32 basetsd.h (included by windows.h). */ -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG /* The following define is needed by pngconf.h. Otherwise it won't compile, because setjmp.h was already included by qemu-common.h. */ #define PNG_SKIP_SETJMP_CHECK @@ -95,7 +95,7 @@ static const struct { }; #endif -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG static const struct { int png_zlib_level, png_filters; } tight_png_conf[] = { @@ -919,7 +919,7 @@ static int send_full_color_rect(VncState *vs, int x, int y, int w, int h) int stream = 0; ssize_t bytes; -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG if (tight_can_send_png_rect(vs, w, h)) { return send_png_rect(vs, x, y, w, h, NULL); } @@ -966,7 +966,7 @@ static int send_mono_rect(VncState *vs, int x, int y, int stream = 1; int level = tight_conf[vs->tight->compression].mono_zlib_level; -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG if (tight_can_send_png_rect(vs, w, h)) { int ret; int bpp = vs->client_pf.bytes_per_pixel * 8; @@ -1020,7 +1020,7 @@ static int send_mono_rect(VncState *vs, int x, int y, struct palette_cb_priv { VncState *vs; uint8_t *header; -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG png_colorp png_palette; #endif }; @@ -1082,7 +1082,7 @@ static int send_palette_rect(VncState *vs, int x, int y, int colors; ssize_t bytes; -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG if (tight_can_send_png_rect(vs, w, h)) { return send_png_rect(vs, x, y, w, h, palette); } @@ -1233,7 +1233,7 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality) /* * PNG compression stuff. */ -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG static void write_png_palette(int idx, uint32_t pix, void *opaque) { struct palette_cb_priv *priv = opaque; @@ -1379,7 +1379,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h, buffer_reset(&vs->tight->png); return 1; } -#endif /* CONFIG_VNC_PNG */ +#endif /* CONFIG_PNG */ static void vnc_tight_start(VncState *vs) { @@ -1706,7 +1706,7 @@ void vnc_tight_clear(VncState *vs) #ifdef CONFIG_VNC_JPEG buffer_free(&vs->tight->jpeg); #endif -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG buffer_free(&vs->tight->png); #endif } diff --git a/ui/vnc.c b/ui/vnc.c index 3ccd33dedc..a588ddff1c 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2165,7 +2165,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features |= VNC_FEATURE_TIGHT_MASK; vs->vnc_encoding = enc; break; -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG case VNC_ENCODING_TIGHT_PNG: vs->features |= VNC_FEATURE_TIGHT_PNG_MASK; vs->vnc_encoding = enc; @@ -3248,7 +3248,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc, #ifdef CONFIG_VNC_JPEG buffer_init(&vs->tight->jpeg, "vnc-tight-jpeg/%p", sioc); #endif -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG buffer_init(&vs->tight->png, "vnc-tight-png/%p", sioc); #endif buffer_init(&vs->zlib.zlib, "vnc-zlib/%p", sioc); diff --git a/ui/vnc.h b/ui/vnc.h index a7149831f9..a60fb13115 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -201,7 +201,7 @@ typedef struct VncTight { #ifdef CONFIG_VNC_JPEG Buffer jpeg; #endif -#ifdef CONFIG_VNC_PNG +#ifdef CONFIG_PNG Buffer png; #endif int levels[4]; From patchwork Tue Mar 15 04:47:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kshitij Suri X-Patchwork-Id: 12781026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BF2AC433EF for ; Tue, 15 Mar 2022 04:48:48 +0000 (UTC) Received: from localhost ([::1]:37038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTz71-0004OM-JI for qemu-devel@archiver.kernel.org; Tue, 15 Mar 2022 00:48:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTz6C-0002nA-Fc for qemu-devel@nongnu.org; Tue, 15 Mar 2022 00:47:56 -0400 Received: from mx0a-002c1b01.pphosted.com ([148.163.151.68]:65490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTz69-0000Jl-Th for qemu-devel@nongnu.org; Tue, 15 Mar 2022 00:47:55 -0400 Received: from pps.filterd (m0127838.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 22EIxiIa021114; Mon, 14 Mar 2022 21:47:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=P8iTfvTgCnoh84Yc0jdtVexAVrs565Hgi8uawx7c5ac=; b=R95/QLImaW8Hllvxd0VFQWaoVaxt+4MJGYx0V1ibbM0B5TMLO3J8j+QvpnieOlwwwZtP 55TIwe+SNUXzZDfkgu9PovNeDH4EiilF1wf3sIHWq1wtQ6LgEfhYCvkS53/haujeXBqt ybxF2mM9vidz2UBPF9zognd6BL8qX8rxLVNpAJTWJ3oUSms6a4uMqVLVAkbGCQLRniR6 Fp9MA4OcbaRKU98R+EuAJNigQyCSO2IX2iC0ZCWj5gyRI9nKQUOv+nAFQN4Wzq3HjCsA 4zwFmzP1UXCkxF6DKdQr/PtKT2mND+YVcfN8Ew6f7oMKQDxmtKjZj6idhcwhBzE382X0 tw== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3et64m1nnj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 14 Mar 2022 21:47:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSdcR+npyKsDQdbP9C4wvql48OYcXkJJlsMx2o/bvSaUa5UblP+fS4Lkv57aaQ8t9dLDFe66v6NK0Kgkie4TsEmQ76s9oTm8fVMrCDjMT7VSDaYjUuwb3kN0eFYmk4C5gEyBnYb+DazqzhdvwfUWbPMV+Q5XAEurDs3V6cbjhdg3TmdaoxQaVAzO6DsrOk3sNxwModvmoCT1TuXsGBrpmgp3qlaeLnMDlJxHbBdAOPXHs0GKHGoiQHrA7hXRd8gh/RbadWMAGjoVm2UMTVzwEGYQW7GrBn+wbqXphwXqn86+GInyaIbTtgRBAKZTgSRsHW82SEoW2/sAfuHwrkh69Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P8iTfvTgCnoh84Yc0jdtVexAVrs565Hgi8uawx7c5ac=; b=gU7C1I9W+SOk91clKRnqBIo+Q7Gu4Ud5SFxSg8WlnCPewSb3Pte7SjavpoWrXYCnsEeRLx2D1JrRhCv56Q0GJg6CvEdlfIHYuK8YaQLeChhIkmiK3c+3NOWMoQ8Illt/f4cfktwhxo3Yvb7pJtgXuyZPmOil+K89I7K58n03Wf3AggXYZTHMX22S1TO9aB27VBEFsjqKtjRMUCXZX3du29Vw+zexg1+OGo+kc266DKSjVHNDgDVRpCshXkJQClrCjDIb0TT7acKT/PGPWQSyvO3+9eKfe0buNYQxB7gEwOYomZ4ZY1aWpf4JN+MjkVPuybfB00RC6RnekHXBDyZT3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none Received: from BN7PR02MB4033.namprd02.prod.outlook.com (2603:10b6:406:f9::16) by DM5PR02MB3210.namprd02.prod.outlook.com (2603:10b6:4:62::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.26; Tue, 15 Mar 2022 04:47:49 +0000 Received: from BN7PR02MB4033.namprd02.prod.outlook.com ([fe80::5d3d:384c:d914:b12d]) by BN7PR02MB4033.namprd02.prod.outlook.com ([fe80::5d3d:384c:d914:b12d%6]) with mapi id 15.20.5061.029; Tue, 15 Mar 2022 04:47:49 +0000 From: Kshitij Suri To: qemu-devel@nongnu.org Subject: [PATCH v2 2/2] Added parameter to take screenshot with screendump as Date: Tue, 15 Mar 2022 04:47:40 +0000 Message-Id: <20220315044740.155268-2-kshitij.suri@nutanix.com> X-Mailer: git-send-email 2.22.3 In-Reply-To: <20220315044740.155268-1-kshitij.suri@nutanix.com> References: <20220315044740.155268-1-kshitij.suri@nutanix.com> X-ClientProxiedBy: SJ0PR03CA0002.namprd03.prod.outlook.com (2603:10b6:a03:33a::7) To BN7PR02MB4033.namprd02.prod.outlook.com (2603:10b6:406:f9::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a8d16d7f-53a2-4b36-1ef1-08da063ef501 X-MS-TrafficTypeDiagnostic: DM5PR02MB3210:EE_ X-Microsoft-Antispam-PRVS: x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hsDjlgDVDtJ4NKxiBKf0uebY7qqKFfUuIkWVJw36l12wL+yo1rQyMksVrROlG/9pq/2lPb/ntWKK6nyHND0vFLhi0LhgHvV+rcRPrPi426vGVgM78v2nz9PhOTvBytSnph+TID4Yad+LNj9DpLZR7lxHDybO3DSIvTPjjHhpuA3b3U3G3gdzQ3m7mSMb4cMVF3GkIrN/+M/BekEA080rwbWwQ7Pu6tlhTgG7qT50PcYtjuzH4JA4SUjiuUX069obdq0rxClmC0iZ16Wt0w9ukKEA5KNjSDUW1SPTBIzgXcq5ULSPJSc3psBvv6LcwtGdFTdk8q/xfBlbZ8lFy3+7R5Ttmd2tUJkrsfoIGD94iPbVD0TwizEtWn0TtbF8K0k5NVz5KFHRCi98hK5cezrAbRTHuUm4Hy+mV2sNBX08C+fxQ62HM6Er9XvdvZppZslAAqmjhiin4kHCmXaXIQtXhPQlHnwxsETUMhcgaxdugUufAF4cRd8fsvGnNQbnVgfqy0X4Im7QmdZWXTVUOkl31he8F1zVhqveQfGE/KDO092BoSTZfGG/MqPcv7THuu3kV9BZbTxnN6k9B8VHpm3FPle7zguVPFCOSJm3Y9v+P3FjMcj/hFXfNsBoWpfoiG4L7zB6NPsIsMNKo3DZ04w16JvVDbVBwiOc6IYpApc7oRbBT270oInfI35VSWg16KitvEprixV1hLWnt+QmN2g9tZdMvsfeniKx9T//ExmeomckKfB3lZTbwSfBBcxchX8CavdGeklplwI1OFIYPZLaUofoWNpp3G7cor3iOl+gxSo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN7PR02MB4033.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(38350700002)(38100700002)(83380400001)(8676002)(316002)(26005)(186003)(4326008)(6916009)(1076003)(6512007)(2616005)(86362001)(107886003)(6486002)(966005)(6666004)(44832011)(5660300002)(2906002)(66574015)(66946007)(6506007)(66476007)(66556008)(52116002)(508600001)(36756003)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mlbGo0z0Qjp7CA+y5pWI8nbjqh3cRQmL4/ncJtXKduuKBoWt44bhOfB1fVBHNXhivKLRKjck3xZQ4nZoStlYSOYfJWaoU89nz9343QxpCMvBaEZWBGs449EJBSCMBBb89TXhFYu3UBN87cPf/BqCMSWZnfeF+GknSvOs1HnqOAgEs13QqEil39jteOn1er2OXy6aY2A4zpHwXUOp1p55KlmTsFc1qMPdw0ZC75zKuMO40uZmDIOpo064v/L+3Ggo9W3peB72/K9O5FFOEMpOLbhTibLKbft+dFXFOmLBJz5es46fW+HS4xmyLYO+SdXK3Lfqqv29QPSa+mFYd7l3MUGZpDRiv9znVXaD91CvXyhqm/5Oq8ajjEi/gU4L032itXchLZA0dkqFUBPiPM3z0JFJ4csqIMYLtrHbHLIt5g5XcdzlWV88oJAlA91SyFX7b+qaYLdpZWx/kLo+D+MsjbDLw1W1x3xLkZ6TmLsURDraQ8JKwi024gDwAWLtf+BVL7lMQzzAgzeKvpTGAruEenrldOjSuW4m//E3TC4xjlwDKm8US73qrz1QbMMhE4tZgc1gZGsc6cdqWLTPdXQiZG+QBCWNdzGLmgUpBqLQtr5ZrVFxX7wG5fKbxpbRzAL0He/XnYBPxHRySs6LHhf2TG6uV1U6kari0XOcX8tlvPELkflSYPjqGGVA+QGMFoKExc5IEVj5qGUBvfT4h7tTcqcCGSOWWenkxRmrIXB9xxCofh59XRvwwD9A100nHdw6s54a0P1bPsmpk8Xzf1aglj4B9d9cyiJRAvZh2fV0RZN/spBqr1MnEQw008W3CLE+cAP5PE/gGGnZ1eYjvI8pzNOOWN1nULStXpKkmZwqb0TF1YNUFyJALgnyHr9Ip1nYq3Ct2MFZ00OhpPr0UCX3j3kDYphd9T3Q+Few3bMUg/wuY10tIh34m97/W2vnBpUbz6VcxeaRsGIIipPrA1Pj104xSKO5iKKKO8A7veXdVGIoEYtlRFYYOPJzkHQA0h5aM5oXjoFnXIEyYbENJGYS+jWxwdLcTaMzdSKxgYnv5mf1oSpew01nVD36u8kw8H9DV+5/DBF52rwspH+31Zg/+w2fidbi+jRVK2q/LGlpVgU7UmuHQHeWW44IZHR5g+ZkVCQhRFCV55B+d2Gi+v5bQHVOp4kuzA/KN3tmP0gQd+9TgwnDp2jOHXZnRkjtc3v4g8WtvjlkJSmx7NgzZOCEZMc27RNH9qvoj50d0jlvnS3/KHFDoL7+aEYrF3qyeeAyUSgGddwjQYC8Ktp1ZXY+CK6fJE+IeSIs1asy4OQYHyeW1v3bjnhL12uhXm9PLuR9+AcagrDlnq1spbr1NNLr6O1r72G83WzVW/NoykzKT0GFoS7KKNR/9fPNRmgX6yustU4bqAj40vk6ICu8G/3wCxb7yX814qMKk4Ntl3Bv+aivaN3Wx+avh01Fy8ezua43nZaadzJvL9UVj9lGiRcCIw== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8d16d7f-53a2-4b36-1ef1-08da063ef501 X-MS-Exchange-CrossTenant-AuthSource: BN7PR02MB4033.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Mar 2022 04:47:49.6139 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2yyGc9z/FCEstjekUox4fGxHF8uy3TsVgmBv7bjRLmg12ITQfo/urXAmQLTou5FXDNhPHcaUmfeOGtUibHrdIj6bRL9xa4dewrbMy5hcPSY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB3210 X-Proofpoint-ORIG-GUID: 0kv5lSB-BdMLvtUaXgFD2s3oFwKYkQ5a X-Proofpoint-GUID: 0kv5lSB-BdMLvtUaXgFD2s3oFwKYkQ5a X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.850,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-14_14,2022-03-14_02,2022-02-23_01 X-Proofpoint-Spam-Reason: safe Received-SPF: pass client-ip=148.163.151.68; envelope-from=kshitij.suri@nutanix.com; helo=mx0a-002c1b01.pphosted.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: soham.ghosh@nutanix.com, thuth@redhat.com, berrange@redhat.com, prerna.saxena@nutanix.com, dgilbert@redhat.com, armbru@redhat.com, "kshitij.suri" , philippe.mathieu.daude@gmail.com, kraxel@redhat.com, prachatos.mitra@nutanix.com, eblake@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "kshitij.suri" Currently screendump only supports PPM format, which is un-compressed and not standard. Added a "format" parameter to qemu monitor screendump capabilites to support PNG image capture using libpng. The param was added in QAPI schema of screendump present in ui.json along with png_save() function which converts pixman_image to PNG. HMP command equivalent was also modified to support the feature. Example usage: { "execute": "screendump", "arguments": { "filename": "/tmp/image", "format":"png" } } Resolves: https://gitlab.com/qemu-project/qemu/-/issues/718 Signed-off-by: Kshitij Suri diff to v1: - Removed repeated alpha conversion operation. - Modified logic to mirror png conversion in vnc-enc-tight.c file. - Added a new CONFIG_PNG parameter for libpng support. - Changed input format to enum instead of string. - Improved error handling. hmp-commands.hx | 11 ++--- monitor/hmp-cmds.c | 19 ++++++++- qapi/ui.json | 24 +++++++++-- ui/console.c | 102 +++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 144 insertions(+), 12 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 70a9136ac2..5eda4eeb24 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -244,17 +244,18 @@ ERST { .name = "screendump", - .args_type = "filename:F,device:s?,head:i?", - .params = "filename [device [head]]", - .help = "save screen from head 'head' of display device 'device' " - "into PPM image 'filename'", + .args_type = "filename:F,device:s?,head:i?,format:f?", + .params = "filename [device [head]] [format]", + .help = "save screen from head 'head' of display device 'device'" + "in specified format 'format' as image 'filename'." + "Currently only 'png' and 'ppm' formats are supported.", .cmd = hmp_screendump, .coroutine = true, }, SRST ``screendump`` *filename* - Save screen into PPM image *filename*. + Save screen as an image *filename*, with default format of PPM. ERST { diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8c384dc1b2..9a640146eb 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1677,9 +1677,26 @@ hmp_screendump(Monitor *mon, const QDict *qdict) const char *filename = qdict_get_str(qdict, "filename"); const char *id = qdict_get_try_str(qdict, "device"); int64_t head = qdict_get_try_int(qdict, "head", 0); + const char *input_format = qdict_get_str(qdict, "format"); Error *err = NULL; + ImageFormat format; - qmp_screendump(filename, id != NULL, id, id != NULL, head, &err); + int val = qapi_enum_parse(&ImageFormat_lookup, input_format, -1, &err); + if (val < 0) { + goto end; + } + + switch (val) { + case IMAGE_FORMAT_PNG: + format = IMAGE_FORMAT_PNG; + break; + default: + format = IMAGE_FORMAT_PPM; + } + + qmp_screendump(filename, id != NULL, id, id != NULL, head, + input_format != NULL, format, &err); +end: hmp_handle_error(mon, err); } diff --git a/qapi/ui.json b/qapi/ui.json index 9354f4c467..a6d994ba2c 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -73,12 +73,27 @@ ## { 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'} } +## +# @ImageFormat: +# +# Supported image format types. +# +# @png: PNG format +# +# @ppm: PPM format +# +# Since: 7.0 +# +## +{ 'enum': 'ImageFormat', + 'data': ['ppm', 'png'] } + ## # @screendump: # -# Write a PPM of the VGA screen to a file. +# Write a screenshot of the VGA screen to a file. # -# @filename: the path of a new PPM file to store the image +# @filename: the path of a new file to store the image # # @device: ID of the display device that should be dumped. If this parameter # is missing, the primary display will be used. (Since 2.12) @@ -87,6 +102,8 @@ # parameter is missing, head #0 will be used. Also note that the head # can only be specified in conjunction with the device ID. (Since 2.12) # +# @format: image format for screendump is specified. (default: ppm) (Since 7.0) +# # Returns: Nothing on success # # Since: 0.14 @@ -99,7 +116,8 @@ # ## { 'command': 'screendump', - 'data': {'filename': 'str', '*device': 'str', '*head': 'int'}, + 'data': {'filename': 'str', '*device': 'str', '*head': 'int', + '*format': 'ImageFormat'}, 'coroutine': true } ## diff --git a/ui/console.c b/ui/console.c index 40eebb6d2c..aab561e1ac 100644 --- a/ui/console.c +++ b/ui/console.c @@ -37,6 +37,9 @@ #include "exec/memory.h" #include "io/channel-file.h" #include "qom/object.h" +#ifdef CONFIG_PNG +#include +#endif #define DEFAULT_BACKSCROLL 512 #define CONSOLE_CURSOR_PERIOD 500 @@ -289,6 +292,89 @@ void graphic_hw_invalidate(QemuConsole *con) } } +#ifdef CONFIG_PNG +/** + * png_save: Take a screenshot as PNG + * + * Saves screendump as a PNG file + * + * Returns true for success or false for error. + * + * @fd: File descriptor for PNG file. + * @image: Image data in pixman format. + * @errp: Pointer to an error. + */ +static bool png_save(int fd, pixman_image_t *image, Error **errp) +{ + int width = pixman_image_get_width(image); + int height = pixman_image_get_height(image); + g_autofree png_struct *png_ptr = NULL; + g_autofree png_info *info_ptr = NULL; + g_autoptr(pixman_image_t) linebuf = + qemu_pixman_linebuf_create(PIXMAN_a8r8g8b8, width); + uint8_t *buf = (uint8_t *)pixman_image_get_data(linebuf); + FILE *f = fdopen(fd, "wb"); + int y; + if (!f) { + error_setg_errno(errp, errno, + "Failed to create file from file descriptor"); + return false; + } + + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, + NULL, NULL); + if (!png_ptr) { + error_setg(errp, "PNG creation failed. Unable to write struct"); + fclose(f); + return false; + } + + info_ptr = png_create_info_struct(png_ptr); + + if (!info_ptr) { + error_setg(errp, "PNG creation failed. Unable to write info"); + fclose(f); + png_destroy_write_struct(&png_ptr, &info_ptr); + return false; + } + + png_init_io(png_ptr, f); + + png_set_IHDR(png_ptr, info_ptr, width, height, 8, + PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + + png_write_info(png_ptr, info_ptr); + + for (y = 0; y < height; ++y) { + qemu_pixman_linebuf_fill(linebuf, image, width, 0, y); + png_write_row(png_ptr, buf); + } + qemu_pixman_image_unref(linebuf); + + png_write_end(png_ptr, NULL); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + if (fclose(f) != 0) { + error_setg_errno(errp, errno, + "PNG creation failed. Unable to close file"); + return false; + } + + return true; +} + +#else /* no png support */ + +static bool png_save(int fd, pixman_image_t *image, Error **errp) +{ + error_setg(errp, "Enable PNG support with libpng for screendump"); + return false; +} + +#endif /* CONFIG_PNG */ + static bool ppm_save(int fd, pixman_image_t *image, Error **errp) { int width = pixman_image_get_width(image); @@ -327,7 +413,8 @@ static void graphic_hw_update_bh(void *con) /* Safety: coroutine-only, concurrent-coroutine safe, main thread only */ void coroutine_fn qmp_screendump(const char *filename, bool has_device, const char *device, - bool has_head, int64_t head, Error **errp) + bool has_head, int64_t head, bool has_format, + ImageFormat format, Error **errp) { g_autoptr(pixman_image_t) image = NULL; QemuConsole *con; @@ -383,8 +470,17 @@ qmp_screendump(const char *filename, bool has_device, const char *device, * yields and releases the BQL. It could produce corrupted dump, but * it should be otherwise safe. */ - if (!ppm_save(fd, image, errp)) { - qemu_unlink(filename); + + if (has_format && format == IMAGE_FORMAT_PNG) { + /* PNG format specified for screendump */ + if (!png_save(fd, image, errp)) { + qemu_unlink(filename); + } + } else { + /* PPM format specified/default for screendump */ + if (!ppm_save(fd, image, errp)) { + qemu_unlink(filename); + } } }