From nobody Fri Oct 23 21:32:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792647429; cv=none; d=zohomail.com; s=zohoarc; b=V+lgJ5bIxH4A1/b51ypbGDUi0ghZU/wRlve+Pd2QJdZ9AlvEssaFgN5XltFH4u59kXmMG7D5qE1mxI5z0O6ASzm48+6tGmFuGZhDjwqBDZVsKxl7E16vgqWXjSWgNCDJTZ9cuI4e62c5CH/heLk5Zi8P2Rmr9ZoTRZnZFz0SYXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792647429; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pJXIbSCSCY1cQvosN7UGD1dqe/P7vXOxD27sVtH2nMQ=; b=FJFy2JqdCAYnPIiCpdwt83DHjiLCjSnrr/OrGZFMB2J7eHNwE9euzq8ez1trAY/2BcO/ZbOLrvlHbNdZW1yjAi2hnKBoPyWde2erwb/ZrpI4r+OmIUo322txIzrs8g9rUHK/9u2t85dQ28U6ianopYMC6IGAZrjv4Pv+8vA7US4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179264742923085.701468296538; Wed, 21 Oct 2026 22:37:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJlTQ-00040L-Pc; Thu, 22 Oct 2026 01:36:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJlTM-0003zc-T8 for qemu-devel@nongnu.org; Thu, 22 Oct 2026 01:36:16 -0400 Received: from nx230.node01.secure-mailgate.com ([89.22.108.230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJlTK-0005mb-8u for qemu-devel@nongnu.org; Thu, 22 Oct 2026 01:36:16 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xJlTC-007ALj-TJ; Thu, 22 Oct 2026 07:36:08 +0200 Received: from Zeuss.fritz.box (p57b2f06c.dip0.t-ipconnect.de [87.178.240.108]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id D0DDB2823DF; Thu, 22 Oct 2026 07:36:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792647366; bh=pJXIbSCSCY1cQvosN7UGD1dqe/P7vXOxD27sVtH2nMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zAgdrfpvwPLs4fdqTw6ZVvThv+DgmjH3zTyX7MlmO+K+PIuB09PrswGAxhRigSx/t fqu+d0yZtDjGf+8OhxlQKY/N55PqBWcP3JoF2N3xDK+Ep/vLzZqOdi58jHcBoL/JAF qaoimAbCjMmWTT2MqCiIisZPOD+Z9aktjkXHvAhU= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Cc: qemu-devel@nongnu.org Subject: [PATCH 1/2] ui/dbus: send a Scanout before the first Update of a new surface Date: Thu, 22 Oct 2026 07:35:32 +0200 Message-ID: <20261022053535.38791-2-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261022053535.38791-1-christian@quante.one> References: <20261022053535.38791-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179264736641.2629149.8862951297327352690@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: Combined (0.01) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuU0SH3+V0M92M6TPX6XoZfPUyRPtK4rQ3m4 cnxjBe65HCu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4YTEWDxl06PHqgMTgL9HpwYS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgnsj5xBssn0tIIHA3aH QzCq60l8YRpcxCjc2gcMa3Btw+OTpzU5Yy8oe2B0dJEHaEkiihVil/4PKs38NtnG3PEGvDsoH6Px tvFZEJq1ao2KN5EH/A/z83UAaQnqiAWuQHxGFdQa/R6nd5VFHne4SM1RwKLZ/phrV9Me8fSKrw4f A+4kDqBeCn8nwBijhCUNJGyCvsB/S6lahvN4tMy6dkx+prdNNcr2SN8Roi9WwIkFNxqXSHvjdU6k o1j7gyOKOKFtV1w91ummwAJgSfp95IB5KumLerNJaitFnP2ausrj+xM74OqDymuB/totiLbH5Lhy EYUeNDqrX3Sju+Zod+VznaUXiPoTcHWs9ZbziSvcjAfILneBruSXVJFMTtbeU7O5tXIuaHlw6sj8 kI/kwqmxDmhcGtkR8y9z81B5Ndl6ntj2X71nPVUIlgpagBYLgrI+1t0jgRpAgh7HGohm5hY9yspj qXTq7JACOyfgEMD59X5gezmDaQSeK6PbrzEZPBeLBDMrD7q/cJogwbqzsuokJcC8qx+Rmq5bU2ck JaKp5ix9QX0oe/06fQ8//V2TSnQfjKdzTmoKYEjQFpxaoYG3IMDGHYM62P/O4OV8g7wZZhzxetL+ zsw5uITiww0HzQO5A4HOIDb6HJquMBeQaPknUrEcH960Yb6MpiL+285bIYk5bXpb/yeR3Q3u2oYl JoJDLxC5XEDzNnn+IWGxqYpiBiFMXZsNOH+1R01VtZLf6H6YFrhxVw5i30CZMe0+JKqWmKu/Exva /4bO4tpXcmDOLBLnx328rZUKBRO/9xuL1l/1awwGVhCMt0tTKiHWpRk= X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.230; envelope-from=christian@quante.one; helo=nx230.node01.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792647432547158501 Content-Type: text/plain; charset="utf-8" Without OpenGL and without shared memory, the D-Bus listener sends a Scanout only for an update that covers the whole surface, and dbus_gfx_switch() only records the new surface. So when a device draws a new surface in parts, the client gets Updates for a size that no Scanout has given it. VGA text mode is such a device: vga_draw_text() sends one update per row of characters, so a text mode that changes its size does not send a Scanout. According to ui/dbus-display1.xml, Update is only called after a Scanout call, and Scanout is the call that resizes the display. The client can learn the new size only from the Width and Height properties of the Console. They come on a different connection, and the generated skeleton sends PropertiesChanged from an idle callback, after the redraw. A client that sets up a new buffer when this signal comes loses the rows that came before it. VGA text mode does not send them again: it redraws only the characters that change, and all of them only after changes such as a new font or palette, or with blinking enabled. The Windows NT 4.0 setup shows this. With blinking off, it changes the character height from 16 to 12 lines (720x400 to 720x396), and in a D-Bus client large parts of its blue background stayed black. With shared memory, dbus_scanout_map() already sends ScanoutMap with the new size at the first update after a surface switch. Do the same without shared memory: the first update after a switch sends a Scanout of the whole surface. Signed-off-by: Christian Quante Reviewed-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 624d0fb71d..d25132fe7e 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -71,6 +71,8 @@ struct _DBusDisplayListener { DisplayChangeListener dcl; DisplaySurface *ds; enum share_kind ds_share; + /* true until a Scanout of ds has been sent */ + bool ds_scanout_pending; =20 bool ds_mapped; bool can_share_map; @@ -844,6 +846,7 @@ static void ddl_scanout(DBusDisplayListener *ddl) ddl->proxy, surface_width(ddl->ds), surface_height(ddl->ds), surface_stride(ddl->ds), surface_format(ddl->ds), v_data, G_DBUS_CALL_FLAGS_NONE, DBUS_DEFAULT_TIMEOUT, NULL, NULL, NULL); + ddl->ds_scanout_pending =3D false; } =20 static void dbus_gfx_update(DisplayChangeListener *dcl, @@ -872,7 +875,9 @@ static void dbus_gfx_update(DisplayChangeListener *dcl, return; } =20 - if (x =3D=3D 0 && y =3D=3D 0 && w =3D=3D surface_width(ddl->ds) && h = =3D=3D surface_height(ddl->ds)) { + if (ddl->ds_scanout_pending || + (x =3D=3D 0 && y =3D=3D 0 && + w =3D=3D surface_width(ddl->ds) && h =3D=3D surface_height(ddl->d= s))) { return ddl_scanout(ddl); } =20 @@ -907,6 +912,7 @@ static void dbus_gfx_switch(DisplayChangeListener *dcl, =20 ddl->ds =3D new_surface; ddl->ds_share =3D SHARE_KIND_NONE; + ddl->ds_scanout_pending =3D true; } =20 static void dbus_mouse_set(DisplayChangeListener *dcl, --=20 2.53.0 From nobody Fri Oct 23 21:32:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1792647421; cv=none; d=zohomail.com; s=zohoarc; b=T6/08kCjIfDVIbIU+29yIweuZV32wUSecp/jn33iQugpPGYQSsFWVviB0O09U9CYuAVjYQhSNPp0Fju33BUgrdJcQDUicZcQB6xzJgv6Ch3Vx8YzRtgt7nemGxmtcWQJ1kbp5zDpF0+w5fpnX6f8hEnNWQaxpQmHRhP2O2aNGEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792647421; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EVrPbEAah38iZqoB58nHU6MwbmsXaRR64lme3poI/gE=; b=S7mgJlrGn8WgmJkgWDxYitJJa1AMuRq+FB2kIGoPTGpgfCaUzLtkSPsQjyoxpEwsw1b/tipzfF6jfQew3665Z2z5s/h/tq1eh7Wm/jLZwdtA2fce4BtqAkkoQbpavuv0xSMIKwRYMiLKQCxRW1+JkEMF5+O1dIPHHSepvi1uChA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1792647420951491.14070623011287; Wed, 21 Oct 2026 22:37:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJlTO-0003zj-NE; Thu, 22 Oct 2026 01:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJlTL-0003zO-JI for qemu-devel@nongnu.org; Thu, 22 Oct 2026 01:36:15 -0400 Received: from nx71.node01.secure-mailgate.com ([89.22.108.71]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJlTJ-0005mc-9Q for qemu-devel@nongnu.org; Thu, 22 Oct 2026 01:36:15 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node01.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xJlTD-007AUi-IO; Thu, 22 Oct 2026 07:36:08 +0200 Received: from Zeuss.fritz.box (p57b2f06c.dip0.t-ipconnect.de [87.178.240.108]) (Authenticated sender: christian@quante.one) by web279.dogado.net (Postfix) with ESMTPSA id A223E2828B3; Thu, 22 Oct 2026 07:36:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792647367; bh=EVrPbEAah38iZqoB58nHU6MwbmsXaRR64lme3poI/gE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajdaGI2yPzj1nkFlQ0STPfUG1rS5NXRIugvK5PyNPcBTL4BZgpGIXf5wywXX5YhBx jfm1y3I7Lob8Jr4vskkYdvs/FcoLyQqYqgBouNBH6q/bdRfQ1+o/yGC5BF7lP9D3O+ JJq2J74NFCEAXg0IYNI1oJ6kUqEBVGWoWdT8ud18= X-SecureMailgate-Identity: christian@quante.one;web279.dogado.net From: Christian Quante To: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Cc: qemu-devel@nongnu.org, Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PATCH 2/2] tests/qtest/dbus-display-test: check the Scanout after a text resize Date: Thu, 22 Oct 2026 07:35:33 +0200 Message-ID: <20261022053535.38791-3-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261022053535.38791-1-christian@quante.one> References: <20261022053535.38791-1-christian@quante.one> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179264736724.2629162.11243145881298831820@web279.dogado.net> X-PPP-Vhost: quante.one X-Originating-IP: 31.47.255.59 X-SecureMailgate-Domain: web279.dogado.net X-SecureMailgate-Username: 31.47.255.59 Authentication-Results: secure-mailgate.com; auth=pass smtp.auth=31.47.255.59@web279.dogado.net X-SecureMailgate-Outgoing-Class: ham X-SecureMailgate-Outgoing-Evidence: SB/global_tokens (0.000445194986704) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuUJcHV58VcNIoPIuBPaI5Y4gq7DyCGgmBLq BBs3aVSF1yu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4ZRuLwj7mBmNZbmHJFiqKcTS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+u6ffrnBlJ/YqH1yn3Cst2xbkPGIRcDT6rLne4OdACl OctV6sNUpLlLzrnCw1TFot2DkCrUkXoFc9xPnGOHdNrvKzHXVbgGS7w2P8nPW3J1xwRaF5dGK1eM UkB0FGdiCjIUUBm1A0OeWEadRp7IkjpM+zcdijFnYDwIvvgDwGlGNltqz//gVodr2Bbrpa11KQ1X 60pfttRUJPEpY+dD8D1vIveD1kaqoOX9s49As8Lf9rIL5hu6PBBmQVXJOgy40oaNgxLGDo2IfSff yLpMY4GiERnEqbM7eXcjjx1NgqwoSQEiRQv+PVjjwa+Z5RFCOMSo3Wzle3zs24yfrwncN9jnrJpR 1fkgawBqrJAecnrgmLJqDY7csGvvr6J8v3quL4fHYZi/RQSVvjLZ9073r2ThsSxXvtcBnutXV2hR cyZeMt5qC3RC37WOfcNnA2gZY0tsDJ5OpGajzK+y6qnu2TRmCgWkeniwaIPiNK/dtWTwcPdjzQ6Y C7Heg3Xf7O1TOd4AR3bnyxZNhM1OcgqdW/wVtHH2Jl8eCsKWVs21EHNFpH7GdMvY3KpSNLa1ogaG 6NVRQObPKiFrimp7C3MFrWz3xKrS24UQEiEcX0sIf20P9Z24W5FAMBlV4QRE+Zyl9in1H/aAwarQ pYDOYx/6JtUO0Mqlhs6pmFPCFjhhN7CA6xKgoHAnJs1I5c9E1S43mq3kM3Qwxv7D9C3QH5nA6BrC GpdIe+N1TqSjWPuDI4o4oSgbUYstBS2wVr+z782L/itpmtBVV8AcwDEGcp3bMIDG5wlpy6uLmsAa TUOwBUuWxQ== X-Report-Abuse-To: spam@node04.secure-mailgate.com X-Complaints-To: abuse@node01.secure-mailgate.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=89.22.108.71; envelope-from=christian@quante.one; helo=nx71.node01.secure-mailgate.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @quante.one) X-ZM-MESSAGEID: 1792647426272158500 Content-Type: text/plain; charset="utf-8" Set up an 80x25 VGA text mode, change the character height from 16 to 12 lines as the Windows NT 4.0 setup does, and check that the first message the listener gets after the change is a Scanout of the new size (720x396), not an Update. The registration of the listener moves from test_dbus_display_console() to test_dbus_console_register(), so that both tests can use it, and the listener now also handles Update. The test waits until no message has come for some time, so the cursor is put outside the screen: vga_draw_text() redraws the character under the cursor at every refresh, also when the cursor is off. Signed-off-by: Christian Quante Reviewed-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/dbus-display-test.c | 162 +++++++++++++++++++++++++++++--- 1 file changed, 148 insertions(+), 14 deletions(-) diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-tes= t.c index 7838ce7323..eb81b9ca05 100644 --- a/tests/qtest/dbus-display-test.c +++ b/tests/qtest/dbus-display-test.c @@ -94,8 +94,26 @@ typedef struct TestDBusConsoleRegister { GDBusConnection *listener_conn; GDBusObjectManagerServer *server; bool with_map; + /* Scanout and Update calls received, and the first one after @watch */ + guint messages; + bool watch; + const char *first; + guint first_width; + guint first_height; } TestDBusConsoleRegister; =20 +static void test_dbus_console_seen(TestDBusConsoleRegister *test, + const char *method, + guint width, guint height) +{ + test->messages++; + if (test->watch && !test->first) { + test->first =3D method; + test->first_width =3D width; + test->first_height =3D height; + } +} + static gboolean listener_handle_scanout( QemuDBusDisplay1Listener *object, GDBusMethodInvocation *invocation, @@ -106,6 +124,7 @@ static gboolean listener_handle_scanout( GVariant *arg_data, TestDBusConsoleRegister *test) { + test_dbus_console_seen(test, "Scanout", arg_width, arg_height); qemu_dbus_display1_listener_complete_scanout(object, invocation); =20 if (!test->with_map) { @@ -115,6 +134,24 @@ static gboolean listener_handle_scanout( return DBUS_METHOD_INVOCATION_HANDLED; } =20 +static gboolean listener_handle_update( + QemuDBusDisplay1Listener *object, + GDBusMethodInvocation *invocation, + gint arg_x, + gint arg_y, + gint arg_width, + gint arg_height, + guint arg_stride, + guint arg_pixman_format, + GVariant *arg_data, + TestDBusConsoleRegister *test) +{ + test_dbus_console_seen(test, "Update", arg_width, arg_height); + qemu_dbus_display1_listener_complete_update(object, invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + #ifndef WIN32 static gboolean listener_handle_scanout_map( QemuDBusDisplay1ListenerUnixMap *object, @@ -164,6 +201,7 @@ test_dbus_console_setup_listener(TestDBusConsoleRegiste= r *test, bool with_map) qemu_dbus_display1_listener_skeleton_new()); g_object_connect(iface, "signal::handle-scanout", listener_handle_scanout, te= st, + "signal::handle-update", listener_handle_update, test, NULL); g_dbus_object_skeleton_add_interface(listener, G_DBUS_INTERFACE_SKELETON(iface)); @@ -227,15 +265,12 @@ test_dbus_p2p_server_setup_thread(gpointer data) } =20 static void -test_dbus_display_console(const void* data) +test_dbus_console_register(QTestState *qts, GDBusConnection *conn, + TestDBusConsoleRegister *test) { g_autoptr(GError) err =3D NULL; - g_autoptr(GDBusConnection) conn =3D NULL; g_autoptr(QemuDBusDisplay1ConsoleProxy) console =3D NULL; - g_autoptr(GMainLoop) loop =3D NULL; - QTestState *qts =3D NULL; int pair[2]; - TestDBusConsoleRegister test =3D { 0, .with_map =3D GPOINTER_TO_INT(da= ta) }; #ifdef WIN32 WSAPROTOCOL_INFOW info; g_autoptr(GVariant) listener =3D NULL; @@ -244,8 +279,6 @@ test_dbus_display_console(const void* data) int idx; #endif =20 - test_setup(&qts, &conn); - g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), =3D=3D= , 0); #ifndef WIN32 fd_list =3D g_unix_fd_list_new(); @@ -262,9 +295,9 @@ test_dbus_display_console(const void* data) &err)); g_assert_no_error(err); =20 - test.loop =3D loop =3D g_main_loop_new(NULL, FALSE); - test.thread =3D g_thread_new(NULL, test_dbus_p2p_server_setup_thread, - GINT_TO_POINTER(pair[0])); + test->loop =3D g_main_loop_new(NULL, FALSE); + test->thread =3D g_thread_new(NULL, test_dbus_p2p_server_setup_thread, + GINT_TO_POINTER(pair[0])); =20 #ifdef WIN32 if (WSADuplicateSocketW(_get_osfhandle(pair[1]), @@ -295,12 +328,111 @@ test_dbus_display_console(const void* data) #endif NULL, test_dbus_console_registered, - &test); + test); + + g_main_loop_run(test->loop); +} + +static void +test_dbus_console_cleanup(TestDBusConsoleRegister *test) +{ + g_clear_object(&test->server); + g_clear_object(&test->listener_conn); + g_clear_pointer(&test->loop, g_main_loop_unref); +} + +static void +test_dbus_display_console(const void *data) +{ + g_autoptr(GDBusConnection) conn =3D NULL; + QTestState *qts =3D NULL; + TestDBusConsoleRegister test =3D { 0, .with_map =3D GPOINTER_TO_INT(da= ta) }; =20 - g_main_loop_run(loop); + test_setup(&qts, &conn); + test_dbus_console_register(qts, conn, &test); + + test_dbus_console_cleanup(&test); + g_clear_object(&conn); + qtest_quit(qts); +} + +/* Handle whatever reaches the listener during the next @ms milliseconds. = */ +static void +test_dbus_console_turn(guint ms) +{ + gint64 end =3D g_get_monotonic_time() + ms * G_TIME_SPAN_MILLISECOND; + + while (g_get_monotonic_time() < end) { + while (g_main_context_iteration(NULL, FALSE)) { + } + g_usleep(G_TIME_SPAN_MILLISECOND); + } +} + +/* Wait until the picture is still: no Scanout or Update for 200 ms. */ +static void +test_dbus_console_settle(TestDBusConsoleRegister *test) +{ + guint seen; + int i; + + for (i =3D 0; i < 25; i++) { + seen =3D test->messages; + test_dbus_console_turn(200); + if (test->messages =3D=3D seen) { + return; + } + } + g_assert_not_reached(); +} + +static void +vga_crtc_write(QTestState *qts, uint8_t index, uint8_t value) +{ + qtest_outb(qts, 0x3d4, index); + qtest_outb(qts, 0x3d5, value); +} + +static void +test_dbus_display_text_resize(void) +{ + g_autoptr(GDBusConnection) conn =3D NULL; + QTestState *qts =3D NULL; + TestDBusConsoleRegister test =3D { 0 }; + gint64 end; + + test_setup(&qts, &conn); + test_dbus_console_register(qts, conn, &test); + + /* VGA text mode, 80x25 cells of 9x16 pixels: 720x400 */ + qtest_outb(qts, 0x3c2, 0x67); /* CRTC at 0x3d4 */ + vga_crtc_write(qts, 0x01, 0x4f); /* 80 columns */ + vga_crtc_write(qts, 0x07, 0x02); /* bit 8 of the vertical display e= nd */ + vga_crtc_write(qts, 0x09, 0x0f); /* 16 scan lines per cell */ + vga_crtc_write(qts, 0x0e, 0x3f); /* cursor outside the screen */ + vga_crtc_write(qts, 0x0f, 0xff); + vga_crtc_write(qts, 0x12, 0x8f); /* 400 scan lines */ + vga_crtc_write(qts, 0x13, 0x28); /* 80 characters per row */ + qtest_inb(qts, 0x3da); /* attribute controller to index */ + qtest_outb(qts, 0x3c0, 0x20); /* display on */ + test_dbus_console_settle(&test); + + /* + * Cells of 9x12 pixels, as the Windows NT 4.0 setup sets: 720x396. + * VGA redraws a text mode one row of cells at a time, and the client + * has to know the new size before the first row arrives. + */ + test.watch =3D true; + vga_crtc_write(qts, 0x09, 0x0b); + end =3D g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; + while (!test.first && g_get_monotonic_time() < end) { + test_dbus_console_turn(10); + } + g_assert_cmpstr(test.first, =3D=3D, "Scanout"); + g_assert_cmpuint(test.first_width, =3D=3D, 720); + g_assert_cmpuint(test.first_height, =3D=3D, 396); =20 - g_clear_object(&test.server); - g_clear_object(&test.listener_conn); + test_dbus_console_cleanup(&test); g_clear_object(&conn); qtest_quit(qts); } @@ -462,6 +594,8 @@ main(int argc, char **argv) qtest_add_func("/dbus-display/vm", test_dbus_display_vm); qtest_add_data_func("/dbus-display/console", GINT_TO_POINTER(false), t= est_dbus_display_console); qtest_add_data_func("/dbus-display/console/map", GINT_TO_POINTER(true)= , test_dbus_display_console); + qtest_add_func("/dbus-display/console/text-resize", + test_dbus_display_text_resize); qtest_add_func("/dbus-display/keyboard", test_dbus_display_keyboard); if (qtest_has_machine("q35") && qtest_has_device("bochs-display")) { qtest_add_func("/dbus-display/hotplug", test_dbus_display_hotplug); --=20 2.53.0