From nobody Fri Oct 23 21:32:27 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=1792676708; cv=none; d=zohomail.com; s=zohoarc; b=VxB47Op7DXmaA84DOuZQna2t8cJuLZ66E8P7GI/SjVrwJ1izh8BYqSuDIMFLnKMMsoOogBpdJF010DNbQ1hKgAZTW/pMPHuCodaEmkxvaO8JyPEMAFztBTVsji107p70uv5pHyyzWJmdeJMdE9zWNhnS4x2iepm+7UAH7ZSenPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792676708; h=Content-Type: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=6ja1WQ32PBzrBRoDzSTkVXS5hdj5jskCGw304i/anU4=; b=PX7JH/dpNlFW4wODqBj2c0X3jZxnIycymNZHweahHh3tgPAGHxEldcCyHmcEigE1IEi36J55j8RArvwDpA79aYTgKzD8tfc664Io/4bHJz6mhLPKgy2Vi71Zn4tI/X14mMQb7pxJL75DCTdA5G/HtLEQGeDcSN13ebUdm2yDmFw= 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 1792676708663559.9311792590813; Thu, 22 Oct 2026 06:45:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJt5W-0005SA-1B; Thu, 22 Oct 2026 09:44:10 -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 1xJt5T-0005RY-Gc for qemu-devel@nongnu.org; Thu, 22 Oct 2026 09:44:07 -0400 Received: from nx233.node01.secure-mailgate.com ([89.22.108.233]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJt5R-0004YW-B7 for qemu-devel@nongnu.org; Thu, 22 Oct 2026 09:44:07 -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 1xJt5M-008gLc-QY; Thu, 22 Oct 2026 15:44:02 +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 06C9A2808AE; Thu, 22 Oct 2026 15:44:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792676640; bh=6ja1WQ32PBzrBRoDzSTkVXS5hdj5jskCGw304i/anU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u9iJfAcIXSV3f+SX/3Da9b6lgQdClq1DG+PYddzOycy/mtyfLErbL0e5JWspONm4a DeeXt/HZrVE+4aYF1KXYWvNu8+rLbcoOJWiuy32y5LjDr/FqSiWgZxzHXyNXvRVduc GC9Vlk+Ht5XsMoiL7Nfq5RM5RqFWvrX2I8w91C4w= 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 v2 1/2] ui/dbus: send a Scanout before the first Update of a new surface Date: Thu, 22 Oct 2026 15:43:32 +0200 Message-ID: <20261022134335.12241-2-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261022134335.12241-1-christian@quante.one> References: <20261022134335.12241-1-christian@quante.one> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179267664051.1250690.8197730579438019933@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.00627735341472) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuWs1zXd1Ec5oxGqjhYw8bjRdeqUVtxDfpTk HBd/69NvrSu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4anFFRVwuHEEuCw/NAbcayAS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6K5mANmx2g/2xIniaWLUPf0al0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+sTkIyyXTS8VYEqgliTsM5joQI1u/kR19C5IhkvqbTy GsfR/qM1xcrzZXCdLvDNYUL7Nx2KMWdgPAi++APAaUY2cFCBi+CnLjlTLZenhrEW9bnSYHqLeOHt 2MdG2gILvLgi94PWRqqg5f2zj0Czwt/24XdQQ9W+OVoe9sHR20A4zMJATnq4izMHC9hVf+BNvOPT Esk3n0wm6EnWJyExE0ewASJFC/49WOPBr5nlEUI4xN5+JHTQUPjco6i83mpro7FPxa76uBJogGrx ftb074ShQCbCj9LKtsZtyrbbjZsnezM+5ly4EqnfEs3lsfc1QHHyucDjZQKHTfIF/c7b2Fbyfday zbIhmWzRD5lR5XTkXmwMnk6kZqPMr7Lqqe7ZNGbH3jkGLXsNuD1Se4l+eKHp92PNDpgLsd6Ddd/s 7VM53kXwgq+dJEq2XrEAl/8Xgp6KgYnDwVj9AJ0/uoGeEasaz6X+WraWTQaj9RGIOyWlXz053gVz HEBMLWovRbw1Va6bEN8AS4X48yy5NsQGHgkOWjkyv6wdxnNATvt2iCm/wvUf9oDBqtClgM5jH/om 1Q6vnKrWgldgJy7s2QKVxGAzg95Rxl42mCUt901ywiJbhL6P7W8ZBEJJJOn/KfKpUV8al0h743VO pKNY+4Mjijih1TdBphqYc7PW6V3n6hA0Kwo2w5US6doM8xAVRHdGR3XxnWX8toxo5WwaR4zGdOgD 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.233; envelope-from=christian@quante.one; helo=nx233.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: 1792676711481158500 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 624d0fb71d..26ed84d700 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 or ScanoutMap of ds has been sent */ + bool ds_scanout_pending; =20 bool ds_mapped; bool can_share_map; @@ -480,6 +482,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl) } =20 ddl->ds_share =3D SHARE_KIND_MAPPED; + ddl->ds_scanout_pending =3D false; =20 return true; } @@ -591,6 +594,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl) } =20 ddl->ds_share =3D SHARE_KIND_MAPPED; + ddl->ds_scanout_pending =3D false; =20 return true; } @@ -844,6 +848,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 +877,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 +914,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:27 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=1792676686; cv=none; d=zohomail.com; s=zohoarc; b=Yw6+6QuSKy8R4hg3/WNNkGzbbsFblhqHFUc2CCTmQXZD0Mk+di7YoyIurWSGIt7vV9djLmq6fNVCN/n2dBOzMjwL/4Bq6tJxbKScSJjbs/Du4EYZZqR03KOmD/XiP3AhEDVeyglJWnZtheYMX8m286jJKSegle/dOb4AJTk5xCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1792676686; h=Content-Type: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=HAbgcJRIMWvejf+d2eVBi5QNqNG0X6ouyN5oW5RmWCI=; b=PzGleu7N0X/ucFKZTi3W+bdNkLfWCTG2XWh5GFRWBApjyOqzim3vL2t1H+8Dt4new5lXnJqllVI7/tV+dIiaFgdDNoWK3Ib25Tg8IAcPytYu35L1ijDJysswK3NJOynapUXPE4d3JW4/9Wq+YOa3bb2fYCuaQAy6BPpui4L6wIg= 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 1792676686362374.5594964017944; Thu, 22 Oct 2026 06:44:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xJt5W-0005S6-0m; Thu, 22 Oct 2026 09:44:10 -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 1xJt5U-0005Ri-1z for qemu-devel@nongnu.org; Thu, 22 Oct 2026 09:44:08 -0400 Received: from nx34.node02.secure-mailgate.com ([192.162.87.34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xJt5R-0004YZ-5y for qemu-devel@nongnu.org; Thu, 22 Oct 2026 09:44:07 -0400 Received: from web279.dogado.net ([31.47.255.59]) by node02.secure-mailgate.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1xJt5N-0022qp-JD; Thu, 22 Oct 2026 15:44:02 +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 B09CE281C96; Thu, 22 Oct 2026 15:44:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quante.one; s=cloudpit; t=1792676641; bh=HAbgcJRIMWvejf+d2eVBi5QNqNG0X6ouyN5oW5RmWCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WmsYM1/z1I2Yp5i+F1XWHKeOqMpahWYaYihK+iCpONBQkEtiOo+tRFuPcvIdEUMfR XkoYSvikrq7Kuv5cDV8brKuNamNSmU8CE9CCH6ihs5ixQp8xtz1Mxq+jHLdAevKtVi 3DiOdYUPQpMa4aFZlKGaduuLdqvYUgvyf+ziJZqw= 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 v2 2/2] tests/qtest/dbus-display-test: check the Scanout after a text resize Date: Thu, 22 Oct 2026 15:43:33 +0200 Message-ID: <20261022134335.12241-3-christian@quante.one> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261022134335.12241-1-christian@quante.one> References: <20261022134335.12241-1-christian@quante.one> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-PPP-Message-ID: <179267664131.1250912.12079473830258782967@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.000287407726432) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuXrliPY/UonToGsfsq8ugyJzoCuiKwS65ED pautRICfqSu2SmbhJN1U9FKs8X3+Nt1HOctZ5X+40a9IXddeG3M38JQYgcgjsac3uQcQdCX4ROfH zJ6mVE7ewsipSVIfs4ZjA9Ob/CZLcxS4VHLkkqapS5+h1uiHzk/Rfxfh461YLyu3RZI1CD15pCOE 1vk99RMgoMVb7lebWWPLzvZvEUCPdOtYechJ/ikE1WgRg4cS6A6B6pTstltS07kaQJ8I9sYal0h7 43VOpKNY+4MjijihZK0EMmf3P50Ajf/tIX00Fuu2beRqilmjgQ6jA3UwYgm3QTha208ypFqQwBFb xm4JX7semJdl8Weuy8+tlMSTQwhoy9D5QZ6a84vJal7pM1XhlAOd290vPXa7Loma0jth+x0iJ0NX 07iZIeUSWePdS+owFPr4kjXuZPwOU47Z9+u6ffrnBlJ/YqH1yn3Cst2xbkPGIRcDT6rLne4OdACl OctV6sNUpLlLzrnCw1TFot2DkCrUkXoFc9xPnGOHdNrvKzHXVbgGS7w2P8nPW3J1xwRaF5dGK1eM UkB0FGdiCjIUUBm1A0OeWEadRp7IkjpM+zcdijFnYDwIvvgDwGlGNltqz//gVodr2Bbrpa11KQ1X 60pfttRUJPEpY+dD8D1vIveD1kaqoOX9s49As8Lf9rIL5hu6PBBmQVXJOgy40oaNgxLGDo2IfSff yLpMY4GiERnEqbM7eXcjjx1NgqwoSQEiRQv+PVjjwa+Z5RFCOMQRxM2W6biFbzhekDa7/BtMWlcI SpJ6e8JC6wP/8HYDLw28epu/aG1pgqaCRoxNoPbHYZi/RQSVvjLZ9073r2ThsSxXvtcBnutXV2hR cyZeMt5qC3RC37WOfcNnA2gZY0tsDJ5OpGajzK+y6qnu2TRmCgWkeniwaIPiNK/dtWTwcPdjzQ6Y C7Heg3Xf7O1TOd4AR3bnyxZNhM1OcgqdW/wVtHH2Jl8eCsKWVs21EHNFpMmQSlj1IZHH2YTOuGo7 uSjxCAheiVMc/Zdx7yWxu+m0xKrS24UQEiEcX0sIf20P9Z24W5FAMBlV4QRE+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=192.162.87.34; envelope-from=christian@quante.one; helo=nx34.node02.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: 1792676692405158500 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