From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168658; cv=none; d=zohomail.com; s=zohoarc; b=Jph4pV1WjjB9cIKs70Ds810y36cpekZUcs8wyl2BN7dqZp85Wfm9uQGARXsF+msJkOYxwePE7yVIS2YKPQyLk0MxSeaA0qk2OeDa6QmLWanrsoAwKSJuhG9lCE56zeDQI9dxwvVO5Av/v5iEXB754tmcz9PnBZriziAZjZa3oj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168658; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9dqc3xN1aXUIUrHWS9ggdBtgBTtuuRl396MsYkRuz4Q=; b=fxQ+OqoaFUdyPapvs3GlCGIWNjttDPfBs2ptAHZKPJKIpzpFMFLEYnvf0qNanpSWIK+lHrHDG67sI9DkDsz0Ane5FOtkO2LcBaCPyj91/Lmqs6UyF6hhcQbbt4AFxlLaPXp2gtDfjNYCp8cFVliJpQCyZdkFh9vt6DKPvtUOgS4= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168658163341.34564087790454; Thu, 11 Jun 2026 02:04:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKK-00005k-CH; Thu, 11 Jun 2026 05:03:52 -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 1wXbKI-00005W-T3 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:03:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKH-0004On-6i for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:03:50 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-342-y52BmiBuMTy9evHdRWebFA-1; Thu, 11 Jun 2026 05:03:45 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9501195606E; Thu, 11 Jun 2026 09:03:43 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 69F1436512; Thu, 11 Jun 2026 09:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9dqc3xN1aXUIUrHWS9ggdBtgBTtuuRl396MsYkRuz4Q=; b=SNMNt25gSm4cn78WJNM/qI0gUAi20tSUGCQPE929Tr/HQVbXF+kD3273EigEkPYb2OCihC /PmrH5RbopBc8P/R8tz2e0IllFP0fAwB6xefy7FEyC1/gJuQ2LsZYkvSVx0e+WdJXLVuDg dTSUrNsorWKfILiqPxfjYc2AxdghYso= X-MC-Unique: y52BmiBuMTy9evHdRWebFA-1 X-Mimecast-MFC-AGG-ID: y52BmiBuMTy9evHdRWebFA_1781168623 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:16 +0400 Subject: [PATCH v3 01/35] ui/gtk: fix bad widget realize on non-GFX VC MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-1-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=847; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=yZPCBoGjIn899rr3uGbGHNkKHH9rsNhzwmZ5Ol69PMI=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnci7ul/cfy0Xg8nzrxRtKUGcIs45uPXIJAg Rfe/QjzpZ2JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53AAKCRDa6OEJdZac 5cn4D/0ZVZWkxjM55OLT5VNlvkJfkUytixWIjtvMk5ArRGgtRn8HG3zu3Ik5Dl1onSZsuYYKejA Wp1m5Qq+Azg3UrDC0LfMuu+y178uuWwAnryGGuq45dx5IikgoeSAsr5rfoIK5/gozrjafyPhYnz otbFk6IkRJ8RC3h0uqeHP53qMeUrTxqWRcXTWA2hgODtNh82s8cwalqovij0mqrWlxDIURO04bX NJ/9BPXMFvrzCRhRM7LfZHcbzWFFSZ1wArU93szjJChpeRio75kc07vVuIjm8M4eyf77/vvBeaf d1AGOKCVY1PpvB2FueO3Ucfe7Nu8r6G6NboV3EJ0k6pP9626lC6RfxP1gi9e/eYtUCGcE/T+KeH 9x0GJQu24r7MzX6LZhS2Q0q6MbQLs0efCkO+j4uSYEXbo8C74QtGVODYzxgDRKG2pbOG+TlMMX5 yKkCGT+xxnXfKJHcmUFiOPKbIKz49NLocupDAqpOEUGiTkDBeE9xYDGQQYTp6EA5e85vGitiORI fD7RXGu+KvhVvuEkxKvGAs1aMftD6QxFQo3qWVIq2dVDWwyzKwKUsBBEbDwfNL15MTHDIcjOrF4 i7qJe29tcjKNcDH0JI4xwD70aDiF2vgaQ/KhacVezhNTRKizSPNoo/stcWenhbSaP8hw5fJ0wpL j81JB7MslGIUc7w== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168659882158500 The GTK VirtualConsole is a union, it may be .gfx or .vte depending on the type. Fixes: 565f85a9c2 ("ui/gtk: force realization of drawing area") Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 4f706c6bbb2..2ee826b56fb 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2585,7 +2585,9 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) if (!con) { break; } - gtk_widget_realize(s->vc[idx].gfx.drawing_area); + if (s->vc[idx].type =3D=3D GD_VC_GFX) { + gtk_widget_realize(s->vc[idx].gfx.drawing_area); + } } =20 if (opts->u.gtk.has_show_menubar && --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168672; cv=none; d=zohomail.com; s=zohoarc; b=DVQ3Qlk63uEA0HvVaeQe74PIr4yFwdu9kxsOcpgWflrM32qbflXgJi7HmTRf28Lk2QA30qGn6AQm22c3FOBgrttScEyPpQ+Z3AizAqja/XFkFSk/Mm0R8cKj4bHpFDAYaE54JnIBOaP9Bm1JuCflHk1nkYiCXc54OInRnM3vaPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168672; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dl3afpPZ5Vol+WdiE3UW2bUQGBhPNSG8m6dmBjmprSc=; b=au2cX6vcNERVy79fQlyD9eYcXB8fdEWYG1+6KdxEOrDwF7CjIo2HpR0tu/v0gIi/BYXt78fYDSLa1uzM6F4QQpj1SrejYwW3Z8DET7vERSIL0dbTHO2YRrz3X9Y0HBTcNHtacx9rz4EjwoDHu00Gwk2e8SgSZqSOz2dcolfHyAo= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168672353540.512259933149; Thu, 11 Jun 2026 02:04:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKR-00006i-86; Thu, 11 Jun 2026 05:03:59 -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 1wXbKP-00006B-BC for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:03:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKN-0004Te-UR for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:03:57 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-Py1wVDQLPaiciuuJ_df3-A-1; Thu, 11 Jun 2026 05:03:51 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 554351955E7D; Thu, 11 Jun 2026 09:03:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A68B7180029C; Thu, 11 Jun 2026 09:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168634; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dl3afpPZ5Vol+WdiE3UW2bUQGBhPNSG8m6dmBjmprSc=; b=dFANiiP/LLDgM3sR1U6ktXZvjWxBH+JHATJl+rUEhBb0ApNuEGPvNXBp6u0hVK+eiu1xWR GJqzNBVOn6C+dNekGay6ehhQDhORK2rZArSOZ4J3tzCEhiZrJPKY/iMRtp2jGcBzqlnd/D Ld9F0ibe9RI5fUKrpKFyVXYqOSD0k7o= X-MC-Unique: Py1wVDQLPaiciuuJ_df3-A-1 X-Mimecast-MFC-AGG-ID: Py1wVDQLPaiciuuJ_df3-A_1781168629 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:17 +0400 Subject: [PATCH v3 02/35] build-sys: build with -fno-omit-frame-pointer with ASAN MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-2-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=836; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=6MUlQar/gSPmID3QiOuS0gGUGfBPIRS3cXVDlzKv9Pc=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnncRQmnB13J0B0TKJjEVpdy9CFl3jiwhMzG/ 5ZsAJ/xahuJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53AAKCRDa6OEJdZac 5RtoD/9kcLstQMdLK1GEbX+78+4CKTMD5cHjnV/XgEaWNiXWJk7GBVT4eVDNT9IHf+aFpEIFW/e cJie/VX/tax3U2gmVE7LUTPa/OSa5EQ5cOhrTtJraw80btD+vsE3jTGrqKaz25a7H+F+a25/Kwg E91iG7K5o2E++zG3Xup07TOyZk7dG+4M7QGQo3Ie7sOMNw1GGCVSjSiQuUAZakHsu27OcsGU9K4 3bnPRxM7nvaApV/VKsr1mXww1Ok6N0duBh9SOWk6HOxpkxxo7BoIqwHYBvYb/T8MOkQg++Ra7MG N9rynQd/sFN7ZJS9J05r/bXvWC4QnvOK8DTtqxX5cldcq3LrMJZgezgyeBdKOLn6o/5NKPeq9l5 N/Y7aB8rf1bIdQx2VkDi8kYlS4V++pNv2nG3bvtXtPb/xRMLVGTQGBoHnyV78otFdiP42gGDp+2 ltJpyooCPoJA+sEgF8NjTESmeL4/O8xacI70ooIyC5tysa4bCeQCOD1aQ/wASG4F3xSttm/Rmtq 4qfH8zO2ingTrI9OEXLG+BljfZ/ShW7Vj/1ZOrVD8e7nlSfePT3EGMfwkC7+99xdBxhUHXMBwlj AtFgqrqg6VrJjELDlg1SzWKS/3oyCD9GxPq+h+Kk3LlvAwR+hoXJmwUm2Kp160qJPyZSl5d92sc N3V8e1IaufpuQug== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168673250158500 On fc44, LSan fails to suppress leak:qemu_irq_intercept_in, because the backtrace isn't deep enough. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- meson.build | 2 ++ 1 file changed, 2 insertions(+) diff --git a/meson.build b/meson.build index 19e123423b5..3711483b95e 100644 --- a/meson.build +++ b/meson.build @@ -545,6 +545,8 @@ if get_option('asan') if cc.has_argument('-fsanitize=3Daddress') qemu_cflags =3D ['-fsanitize=3Daddress'] + qemu_cflags qemu_ldflags =3D ['-fsanitize=3Daddress'] + qemu_ldflags + # Ensure complete stack traces for LSan suppressions to match correctl= y. + qemu_cflags +=3D ['-fno-omit-frame-pointer'] else error('Your compiler does not support -fsanitize=3Daddress') endif --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168658; cv=none; d=zohomail.com; s=zohoarc; b=cvVC5nLxe3rIvG8CO86l7v52hSVqdovCRVBTmnQgCtffwOtdd+Bq18sb/gyGkV+Zn7f2pPj9BnM3jv5CcDzWEuWEU3QQ9PDO1JdDutmkDPYDSAZhuRqdnTLNU9jy6e6mRwG34ZJLKWmZr1Ke8bs6z1x9o4Zz3sOESoc3sE22TuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168658; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Smidf6FMOj3LuQCqpb0c6LifDKbvfiyh56oQEfYvK00=; b=mRIXDILDG9fqTFeo6MxIUXhZj8HPmdmcnNqQTQSplhXP7SmDZx5NpySF28ZfmmaBBCjlJSVUtVqvf1r0Gnw+kl5dqE6yY2Qz0h4qJmFLdvIQ76DKp8f1J/ywBdnEslG7AuEVEG4Zh89JEmccYrbFykGC9PY63VFw/ygwPkwo/xI= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168658274229.58110848212698; Thu, 11 Jun 2026 02:04:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKV-000074-Si; Thu, 11 Jun 2026 05:04:03 -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 1wXbKU-00006r-Hv for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKS-0004WA-Q0 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:02 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-Zs8AfaNpP7-digZY3Tad2w-1; Thu, 11 Jun 2026 05:03:56 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3AB6019560A1; Thu, 11 Jun 2026 09:03:55 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 664DD19541B2; Thu, 11 Jun 2026 09:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168640; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Smidf6FMOj3LuQCqpb0c6LifDKbvfiyh56oQEfYvK00=; b=TYZNuqXP9lx8azGrv2Bq4vZ5TGlQiJQOHmgB3zAxAUCSXq4ubVgZDIvUBTfpfoPbCEHi/a jsBJk1eFvAKRYwSaXH3UXnwMx07+zhMAtZVQJM+q+FLxSXGM8fUZkEA9qYD1tEBzmWyqei UJs6HEdpmy2PLyxyH8v1kux/0u0tf10= X-MC-Unique: Zs8AfaNpP7-digZY3Tad2w-1 X-Mimecast-MFC-AGG-ID: Zs8AfaNpP7-digZY3Tad2w_1781168635 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:18 +0400 Subject: [PATCH v3 03/35] irq: add per-IRQ observer to fix qemu_irq_intercept_in leak MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-3-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4758; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=AgfY59Jw3FWwwFgiVCxaDztJQCKR319w+PzxgVpWWCs=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnndGPJZOIJsbGpAfn8IeXH89XuarbByT8S5m hwl8xDjIm6JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5YCOD/9Yt88JPH/wzCnpf1kwyN2iI51uAwkjqzYBIlBgDcJ1JvDUxokEExEVFQ1oJAyhSWVwvuV aJTaag/GKjjouwlAKVUF8yiMoo8sDF3wP0qY7Gkxo/8ttkkW5aPTKxg8qzsc/jCMl0JWkULjodw 2S/J2zCIjwnrUdclj8eB63xey2p1fMyv3v8v7wCMz08klNcVbaMs/tfyzEW5OUF2Wffqy8Yndxl SKEnCv1ROdnLJNASWbemeiJfoylCrphMIom1K8qwqQ4eEXpGc7XV4z/UInGoQ1o8iEM4TQBafHt T3olxQPYgMTFQjcKsrhQmAFZdybnh2rPyNsRuI5MXgZWrMHZlRclGl/dhX3xaHxvfDNI49oi2lh oysbBOKnkzJWyQ6iqbpnHQfEWvxDA3lCiyFp5bGZLHdW9QRy4ou8bxRRIZav1fLZJODq9fJv/ml pdibDwqiNw3B6+ociPn+0qwPB7l8eFSPrc20f3xKTZ//BoK+5IcNRrmk0muyVMGz2wlbi6xhmU0 pCmgGjDAXYtvIAMXqW+XdNXKnJyeYqIk3YKvmKpHl6WoIcsNwieimJmBICEUR2IniaLxp+9lusd j+PQ2+327ez7+tccBF9U7QArk2b3V3jeoAZaaruSTEIpS9HRJSWY1z7RwMkL8CTmAXM5UQEdt+w BLasrAXhP7c2++A== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168660895158500 qemu_irq_intercept_in() saves original IRQ handlers by allocating new QOM objects, which are never freed. On a PC machine, this leaks IRQ objects (one per IOAPIC pin) on every qtest run. Rather than tracking allocations to free later, avoid them: add an "observer" field to IRQState, called by qemu_set_irq() after the real handler. Interception sets the observer instead of rewriting handlers, so there's nothing to save and nothing to leak. Fix qemu_notirq() to route through qemu_set_irq() so inverted IRQs trigger observers too. Drop the LSan suppression. Reviewed-by: Fabiano Rosas Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/core/irq.h | 6 +++--- hw/core/irq.c | 12 ++++++------ system/qtest.c | 5 +---- scripts/lsan_suppressions.txt | 8 -------- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/include/hw/core/irq.h b/include/hw/core/irq.h index 291fdd67df4..299a4a9a8ce 100644 --- a/include/hw/core/irq.h +++ b/include/hw/core/irq.h @@ -14,6 +14,7 @@ struct IRQState { qemu_irq_handler handler; void *opaque; int n; + qemu_irq_handler observer; }; =20 void qemu_set_irq(qemu_irq irq, int level); @@ -96,9 +97,8 @@ void qemu_free_irq(qemu_irq irq); /* Returns a new IRQ with opposite polarity. */ qemu_irq qemu_irq_invert(qemu_irq irq); =20 -/* For internal use in qtest. Similar to qemu_irq_split, but operating - on an existing vector of qemu_irq. */ -void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, in= t n); +/* For internal use in qtest. */ +void qemu_irq_set_observer(qemu_irq *gpio_in, qemu_irq_handler handler, in= t n); =20 /** * qemu_irq_is_connected: Return true if IRQ line is wired up diff --git a/hw/core/irq.c b/hw/core/irq.c index 106805e2417..1b610e75e15 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -32,6 +32,9 @@ void qemu_set_irq(qemu_irq irq, int level) return; =20 irq->handler(irq->opaque, irq->n, level); + if (unlikely(irq->observer)) { + irq->observer(irq->opaque, irq->n, level); + } } =20 static void init_irq_fields(IRQState *irq, qemu_irq_handler handler, @@ -111,7 +114,7 @@ static void qemu_notirq(void *opaque, int line, int lev= el) { IRQState *irq =3D opaque; =20 - irq->handler(irq->opaque, irq->n, !level); + qemu_set_irq(irq, !level); } =20 qemu_irq qemu_irq_invert(qemu_irq irq) @@ -121,14 +124,11 @@ qemu_irq qemu_irq_invert(qemu_irq irq) return qemu_allocate_irq(qemu_notirq, irq, 0); } =20 -void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, in= t n) +void qemu_irq_set_observer(qemu_irq *gpio_in, qemu_irq_handler handler, in= t n) { int i; - qemu_irq *old_irqs =3D qemu_allocate_irqs(NULL, NULL, n); for (i =3D 0; i < n; i++) { - *old_irqs[i] =3D *gpio_in[i]; - gpio_in[i]->handler =3D handler; - gpio_in[i]->opaque =3D &old_irqs[i]; + gpio_in[i]->observer =3D handler; } } =20 diff --git a/system/qtest.c b/system/qtest.c index fd37bcbfaab..cf301239177 100644 --- a/system/qtest.c +++ b/system/qtest.c @@ -326,9 +326,6 @@ void qtest_sendf(CharFrontend *chr, const char *fmt, ..= .) =20 static void qtest_irq_handler(void *opaque, int n, int level) { - qemu_irq old_irq =3D *(qemu_irq *)opaque; - qemu_set_irq(old_irq, level); - if (irq_levels[n] !=3D level) { CharFrontend *chr =3D &qtest->qtest_chr; irq_levels[n] =3D level; @@ -421,7 +418,7 @@ static void qtest_process_command(CharFrontend *chr, gc= har **words) interception_succeeded =3D true; } } else { - qemu_irq_intercept_in(ngl->in, qtest_irq_handler, + qemu_irq_set_observer(ngl->in, qtest_irq_handler, ngl->num_in); interception_succeeded =3D true; } diff --git a/scripts/lsan_suppressions.txt b/scripts/lsan_suppressions.txt index f88bbab18b8..30256bc6d01 100644 --- a/scripts/lsan_suppressions.txt +++ b/scripts/lsan_suppressions.txt @@ -16,11 +16,3 @@ leak:/lib64/libxkbcommon.so.0 # https://github.com/GNOME/glib/blob/main/tools/glib.supp # This avoids false positive leak reports for the qga-ssh-test. leak:g_set_user_dirs - -# qemu_irq_intercept_in is only used by the qtest harness, and -# its API inherently involves a leak. -# While we could keep track of the old IRQ data structure -# in order to free it, it doesn't seem very important to fix -# since it is only used by the qtest test harness. -# Just ignore the leak, at least for the moment. -leak:qemu_irq_intercept_in --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168688; cv=none; d=zohomail.com; s=zohoarc; b=Btec+bKG9lJSXIgZRbjIQuPGRs3gUD/Rgxn53PQjV1WQ7jAEbOzFyGjTU5kWRCWCSIwPfXravRTL1bI+3+1qfWQQ1bODtylc8bOHc+whdEsmJwuxNOiUbQQXQDlPOFFrQOVCLnML298ugDcWQ/Rl1TPYJZTP1gk9TryctEtbrck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168688; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L+HZdqqrd0luKP2zM9aSu8MqpsVYDB3E/9BW4+J/ZDE=; b=iEI3/tvjaofGZJWTJoV+F5YV5ixiGOm4s75svK1TXUk+m1VpgnHRDLhJoq7gyDfCWFOwo+0ypVI5mtz4tgcIf4L2PjeXhbruGeoXe1kOQboAQ8mLgwsZxP3epkJ8NkXMZFt800k0IWVvBO4KtMMQw2HFJYTv4a979IA4bOyoSYA= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17811686887373.888719699774583; Thu, 11 Jun 2026 02:04:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKe-0000C8-93; Thu, 11 Jun 2026 05:04:12 -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 1wXbKd-0000Bg-14 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKY-0004bS-G3 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:10 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-8QUC_fXiMGS3BfIOu83P3g-1; Thu, 11 Jun 2026 05:04:02 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DCFBA1956064; Thu, 11 Jun 2026 09:04:00 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 81A861954B0D; Thu, 11 Jun 2026 09:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L+HZdqqrd0luKP2zM9aSu8MqpsVYDB3E/9BW4+J/ZDE=; b=gDk66Mu1t3Ndkjli2mFoiKhRBoCumO7m001ueNh3OV6NdmHgjvcSWKe7KbTEDzPElj+U3j wRKePFO64d0xvxVTTMKwaygKqjFzHBnm/VUmGBUCkpPs8JKS0uf+6TfPPbj0XRC9xRBrKs mTCrherWvH3qP4UwID/K2UIyv3Qvsgo= X-MC-Unique: 8QUC_fXiMGS3BfIOu83P3g-1 X-Mimecast-MFC-AGG-ID: 8QUC_fXiMGS3BfIOu83P3g_1781168641 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:19 +0400 Subject: [PATCH v3 04/35] scripts/lsan_suppressions: suppress fontconfig leaks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-4-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=898; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=wrh0d0W1JMMRcWG4uHoQU8DwdCsMZB8Ib76jiTAFaYU=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnddhP/U7iHrrxlMy6Umd4tz6l49LfJERww4 upMRbKPDHOJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5SuqD/oDn6OinbCwq+QW+dX7iRQjtwLXRIg28Ng4ZYuGBCkzNE39VgYKHHLP6TAoJJ8qFg0EBhw 1XWiBtwlLDjQuIFpE0XmnGGwUhkNfy9Z3DmiC3GZTwCmz89KWzwt1etIseWTWZ9f1yyIT5qZzDM SwNL5ucicTou7ZQQFm+mcNZrsaY5Odwk/glyMlqFqwrgEQ2ZvsFPGx9jUoOW5q0YwZ4WOqpK0GE dDi78rBrQaXldxLwvXQt3E4hKM9c+jtLSHSKCo/ugP7ywAMC8V4pI/3wLWJ9a/MotFP37cCrgQ9 WzNGrN4pLpUGrvTgdYBCsRu1k7btiex81HRq2Mw5pghGrLZyDDebjHrXmG1B3C2UKzsaEEVD8WO a9Mmm+lAwu4ESCIWksUdadieTXBcnt+IFZ+SUcyXkry7I+CR+6jUBToU9AUlBIDsO7svpAyqNBt /Lu51iYXxXvvvrhSjaAsaRZI1sqvvVo20kyzfn+OUp1cysqCKrPU294mbHb1i7yc9xfqW85WgbC LoMWgsjYO9SeQuYYwb3zPnI6v8L20F4bfMtnnv2Tt9/9rHOM8lDHZznwZ1Q0ISHedWnUiwgRNq7 G0vPMlvMQBBHH62s5qugDP9Q30vVsrhBPQT0CUhQqPzQI9scy+g7yuRjNSy1a9GXpDnfshD4rRz KUbbbwVe7GUDGGQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168689417158500 Those are annoying reports for gtk/sdl etc. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/lsan_suppressions.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/lsan_suppressions.txt b/scripts/lsan_suppressions.txt index 30256bc6d01..f3b827facff 100644 --- a/scripts/lsan_suppressions.txt +++ b/scripts/lsan_suppressions.txt @@ -10,6 +10,10 @@ leak:/lib64/libtcmalloc_minimal.so.4 # libxkbcommon also leaks in qemu-keymap leak:/lib64/libxkbcommon.so.0 =20 +# libfontconfig leaks are notorious, for ex +# https://gitlab.freedesktop.org/fontconfig/fontconfig/-/work_items/519 +leak:libfontconfig.so + # g_set_user_dirs() deliberately leaks the previous cached g_get_user_* # values. This is documented in upstream glib's valgrind-format # suppression file: --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168685; cv=none; d=zohomail.com; s=zohoarc; b=hOoc6dnJST1dgZ+0+P0E9/B+JBN22LlBZbdu3apjbXhgCw8zAWKzbhCqu728X2iSo7/j30+e6R+v9avzxLXDXO349Dm+ApMM9uFl51cZ54vd6vwfpm4mtnuLc8iIWc7XogeXykixNc65hvfNOCiOEsJqJKmMAL0+LPaSM2oyzsQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168685; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=x8KCcxB/87JZWf00pdVP2Q3ZKQiVGJ/SAu2efz9MEMM=; b=d+KWDwed+JotxLSRNgAF7+lCe48pEHTJbrPyD0aHGNWgGi0aHIPizfdNt8RgfRlg33l6Axp1pXiwq3J2aBbimzU2E/h6/bvkFBkDZTBcgrWXhg4hDuP8ht6DttfFbNFDdYmKPg/bstK67pmrC2dAcCFJGkWYherQd2zEeM4j4Aw= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168685630895.4277862663732; Thu, 11 Jun 2026 02:04:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKi-0000E5-PJ; Thu, 11 Jun 2026 05:04:16 -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 1wXbKg-0000Cj-VD for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKf-0004cl-AZ for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:14 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-zCFaqJ6DNVy4fEkBg22dCg-1; Thu, 11 Jun 2026 05:04:08 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E69A1955EA5; Thu, 11 Jun 2026 09:04:06 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D3FDA180057F; Thu, 11 Jun 2026 09:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8KCcxB/87JZWf00pdVP2Q3ZKQiVGJ/SAu2efz9MEMM=; b=Op0iZInGyVimr3iHzWu+JHApsPAUIzIpCevKK8O4qLJGTHW+34nEC/Rc7sZ557S/AnlnrT VKBXXq8TWyAsbVNtm2g7HcLnxgwgCG/QvsbAbXm/x7AAlX1EvyyVt+eHlcFsSKFyQRnmnw fopi+tJiwvIUmmXeA9ysRxJzNp0YXKU= X-MC-Unique: zCFaqJ6DNVy4fEkBg22dCg-1 X-Mimecast-MFC-AGG-ID: zCFaqJ6DNVy4fEkBg22dCg_1781168646 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:20 +0400 Subject: [PATCH v3 05/35] vfio/pci: close display console during unrealize, not finalize MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-5-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4013; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=K1oZPfnVuo07AbIZqxBLuVUWmmjqQNhuapL73uboTaM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnndsqDms/2WXDcdA+mf79HcIPQ81hKpFIgLD KOmFp84gh+JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5Y4bD/9ror9HzYrSC32OPiVm8eyyrb4gFGQ6ILiaMU4m9UXvt3ftSssr4lt4aUYRqr6wg5IOnA4 7z2aaoj3Jdnz3Ra9Lwoh2oKuTjEchFf6M+xgBp7LBDti121/Fj/JdsHnKeGZ+f2mCm0PGUGb+2n L7/an2jBeZ3SDgCywTCO4VzO5WU+lldxYNbNzL4wJrVGu2V7GWykNmMVap+vptXUlCVWRT7/lnH Ur0wwdLYigK20q9D9VjTN2juObQsw7wuh6jmpDaLi6IetMNDhDraTr2FMSmse45WS7+uc+5fhme owwKy9aVA7JgaqOWASiTQxX7fp8bg7uL7R9KtbSD6x/VukBmmVNUL+EnUFZs/vktMv7x0fs3LDK eSw3ygEjVUtriNuTpY4j/rzFDJMoJb6UV/TUCSj+tonI+ZlZYUqWL8SLF3WGvL6HI1q9na6TL1F uHARZ1Xg7x3rrov21aXGPTIMaBIxSUpGJA94Wy8U7tn6vYx7UYzpazRKxCusgQvuoc2vgkqsDdz YXj/cj/RMI1fdzAGYgxs1aSMYf4DgDYjVe+D22vXHFRTnEPYnecS6a2xVpodbOfegD7FopPZQ5Y 82RCOnTVAEOlRlNLkWjgPFsL63qu1e/yrJM6pYJcggekoceo5wLoC6FYURpealGBSw8OXMqINQo BuK1p7sl5MXwQ+A== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168688035158500 The QemuGraphicConsole holds a strong QOM link back to the device via its "device" property (OBJ_PROP_LINK_STRONG). When graphic_console_close() is only called from vfio_display_finalize() during object finalize, this creates a ref-cycle deadlock: the device can't reach refcount 0 because the console holds a strong ref, but the console's ref is only dropped by graphic_console_close() which runs inside finalize. Split the display teardown into two phases: - vfio_display_exit(): called during unrealize (vfio_exitfn), closes the graphic console to break the ref cycle, and removes display region subregions while the parent memory regions are still alive. - vfio_display_finalize(): remains in finalize (vfio_pci_put_device), frees display region memory, dmabuf, and edid resources. The region memory contains QOM child objects (MemoryRegions) that must stay alive until QOM finalization has processed them. Acked-by: C=C3=A9dric Le Goater Signed-off-by: Marc-Andr=C3=A9 Lureau --- MAINTAINERS | 1 + hw/vfio/pci.h | 1 + hw/vfio/display.c | 29 +++++++++++++++++------------ hw/vfio/pci.c | 1 + 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 748ec77beb4..8320b37fc32 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2347,6 +2347,7 @@ S: Supported F: hw/vfio/* F: util/vfio-helpers.c F: include/hw/vfio/ +F: docs/devel/vfio-mdpy.rst F: docs/devel/migration/vfio.rst F: qapi/vfio.json F: migration/vfio-stub.c diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index c3a1f53d350..cf567115870 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -270,6 +270,7 @@ bool vfio_populate_vga(VFIOPCIDevice *vdev, Error **err= p); =20 void vfio_display_reset(VFIOPCIDevice *vdev); bool vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); +void vfio_display_exit(VFIOPCIDevice *vdev); void vfio_display_finalize(VFIOPCIDevice *vdev); =20 extern const VMStateDescription vfio_display_vmstate; diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 8f91e83da88..cb83d98e9af 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -505,15 +505,6 @@ static bool vfio_display_region_init(VFIOPCIDevice *vd= ev, Error **errp) return true; } =20 -static void vfio_display_region_exit(VFIODisplay *dpy) -{ - if (!dpy->region.buffer.size) { - return; - } - - vfio_region_exit(&dpy->region.buffer); - vfio_region_finalize(&dpy->region.buffer); -} =20 /* ---------------------------------------------------------------------- = */ =20 @@ -547,17 +538,31 @@ bool vfio_display_probe(VFIOPCIDevice *vdev, Error **= errp) return false; } =20 -void vfio_display_finalize(VFIOPCIDevice *vdev) +void vfio_display_exit(VFIOPCIDevice *vdev) { if (!vdev->dpy) { return; } =20 - qemu_graphic_console_close(vdev->dpy->con); vfio_display_dmabuf_exit(vdev->dpy); - vfio_display_region_exit(vdev->dpy); + qemu_graphic_console_close(vdev->dpy->con); + if (vdev->dpy->region.buffer.size) { + vfio_region_exit(&vdev->dpy->region.buffer); + } +} + +void vfio_display_finalize(VFIOPCIDevice *vdev) +{ + if (!vdev->dpy) { + return; + } + + if (vdev->dpy->region.buffer.size) { + vfio_region_finalize(&vdev->dpy->region.buffer); + } vfio_display_edid_exit(vdev->dpy); g_free(vdev->dpy); + vdev->dpy =3D NULL; } =20 static bool migrate_needed(void *opaque) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 9c06b25e637..78beacd24e1 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3624,6 +3624,7 @@ static void vfio_exitfn(PCIDevice *pdev) VFIOPCIDevice *vdev =3D VFIO_PCI_DEVICE(pdev); VFIODevice *vbasedev =3D &vdev->vbasedev; =20 + vfio_display_exit(vdev); vfio_unregister_req_notifier(vdev); vfio_unregister_err_notifier(vdev); pci_device_set_intx_routing_notifier(pdev, NULL); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168748; cv=none; d=zohomail.com; s=zohoarc; b=S9i3Amm1YRcYCydiQ7IQNOU75U4xoehvb3aoWqOpi6sP0LnyflHPzG6GhAM6lFA1HMTIphHtRJvC8+g1XxWRtGqJX26oQr14k440+xlku4dYmIcQoV80XOS3wMjy3/kpUBScu5te58/CKz+Tlxf2NM8sfKmQX8yztzOL38sdAeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168748; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MxoHi3/BVRshoRkYAb1tWFuXo1nZHct01e2GbgnVJ9I=; b=IUrglOjPPwh3mMtuEcA+pvwaX44yHwR/oUAILA1ZuyUOLBf78AIbzCzLqmtX+mNpAhBi3E0PFamOuFvnSox9HIGLQb04IfuaPdQ2bXWP0frTgW3J8WL9aIPR7EhVgTzAfooW3TnTODUVxqPutEW2pS2D5AN5t8bVC/HkvJctgxo= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168748216794.5935724350496; Thu, 11 Jun 2026 02:05:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKn-0000NR-4N; Thu, 11 Jun 2026 05:04: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 1wXbKl-0000MU-FK for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKj-0004dL-Rv for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:19 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-_FLkLpaAMyufAS0mUEx8nQ-1; Thu, 11 Jun 2026 05:04:14 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4D99A1944F03; Thu, 11 Jun 2026 09:04:12 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE7B219541B2; Thu, 11 Jun 2026 09:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MxoHi3/BVRshoRkYAb1tWFuXo1nZHct01e2GbgnVJ9I=; b=HSFItGnkT5ppjuAq21klskp6xGtiBIaDV7v/0nWBlTG8sr1GNt5YC5lTqrOgP1TKF6eyQh W2bVr3HpdESMRGZjhGf7yKDzRVekyANU8xEliG75Q9BNpUmJKkN9//y3yndw/S554Rtrq7 9MrILYjHVQ/BsKLKcGWhp1rOGGAZyrY= X-MC-Unique: _FLkLpaAMyufAS0mUEx8nQ-1 X-Mimecast-MFC-AGG-ID: _FLkLpaAMyufAS0mUEx8nQ_1781168652 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:21 +0400 Subject: [PATCH v3 06/35] docs: start a vfio-pci document MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-6-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3094; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=b85O20VHUevR2QzmBXGUiER4+nMVtbaVVXPoZyWpLTM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnndaycbxzzZmUePQ70mErJKrN+ll9JDNOAmg /zOn7ru3H2JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5fMtEACzT5JyOmnRMcvrQZvjtV0kTj5ZoaNHyUJa6PvbdhxEUY99yiDvgPddIsjUqcYaIc0n+dt Z2BwJ6TuQDoiGH0Gg7bPnUeCc1/S94OxxZlxC2RjbKRRS6V6ZDKaMvvqYs13KV5TfjM6Tearb3O /IiICleyqCoDDPuhk2KA8UTeA3jg64Fy9bSRPDGVIP5QsGEFIDuH7v+jxLnJ6W3fqmvd72ujefY xblwsvCQ+Dv2AMnJXk2VJeUMr3SnzFYmPEq7bRSqmVyI9V64qjdQs26vG3VW0paPBQNKaX9Q0Qo 3PBNj/sqmBvffcSDoXDzVUQmvcmYEPU39xQ2B4zOtUHtZ8luPmqUvDm0IpOaj/SAXy4hZgrUz82 ZTm0u++xAYbQ23MM/JGM8iECoToPx0aGZsK84hSGFQn5MqRYxawu30S6HWXAOR3HsKKoJsrIXnO VdjsRsM511zu0jd8c7gvKVf33RZA0ZQInmb59ZdISz1vonlpGG0L2aFO3V8cBXAyCqNJRTRzWpd oz1PQkUN3m9+TVNxPqkHtqm3k1SA1YJ5vS54k3z4iFLJOuI05GywXJPu5zbbg1jcLoM72/zn0B6 r6na5bdz4VXL6TLJu88RZH94It8Jc4Nb2pFKYPZaEI2I/Mq26Nggx6K6gNoQp7Z2GwXSU7GO9hj 2J5/ozoWbVXJtcQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168749915158500 Add a section to help me remember how to test vfio display hotplug. Signed-off-by: Marc-Andr=C3=A9 Lureau --- docs/devel/index-internals.rst | 1 + docs/devel/vfio-mdpy.rst | 83 ++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 84 insertions(+) diff --git a/docs/devel/index-internals.rst b/docs/devel/index-internals.rst index 7a0678cbdd3..198f155247a 100644 --- a/docs/devel/index-internals.rst +++ b/docs/devel/index-internals.rst @@ -22,6 +22,7 @@ Details about QEMU's various subsystems including how to = add features to them. tracing uefi-vars vfio-iommufd + vfio-mdpy writing-monitor-commands virtio-backends crypto diff --git a/docs/devel/vfio-mdpy.rst b/docs/devel/vfio-mdpy.rst new file mode 100644 index 00000000000..14cddd11d81 --- /dev/null +++ b/docs/devel/vfio-mdpy.rst @@ -0,0 +1,83 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Testing VFIO display with mdev mdpy +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. contents:: Table of Contents + +The kernel provides a sample mediated device driver, ``mdpy`` +(``samples/vfio-mdev/mdpy.c``), that exposes a fake framebuffer through th= e VFIO +display region interface. It can be used to test VFIO display support, inc= luding +hotplug, without any real GPU hardware. + +The kernel modules +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ``mdpy`` driver depends on the ``mdev`` subsystem. Enable, build and l= oad +the modules. + +Verify that the driver registered successfully: + +.. code-block:: bash + + ls /sys/devices/virtual/mdpy/mdpy/mdev_supported_types/ + +Creating an mdev instance +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +Available types correspond to different resolutions (e.g. ``mdpy-vga`` +for 640x480, ``mdpy-xga`` for 1024x768, ``mdpy-hd`` for 1920x1080). + +Each mdev instance is identified by a UUID: + +.. code-block:: bash + + uuid=3D$(uuidgen) + echo "$uuid" > /sys/devices/virtual/mdpy/mdpy/mdev_supported_types/mdp= y-xga/create + +To remove the instance later: + +.. code-block:: bash + + echo 1 > /sys/bus/mdev/devices/$uuid/remove + +Make sure your user has the necessary permissions to access the vfio group. +(ex: chmod 666 /dev/vfio/16) + +Starting QEMU +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Boot-time attachment +-------------------- + +.. code-block:: bash + + qemu-system-x86_64 -machine q35 -m 1G \ + -device vfio-pci,sysfsdev=3D/sys/bus/mdev/devices/$uuid,display=3D= on \ + -display gtk,gl=3Don + +Hotplug via HMP +--------------- + +Start QEMU with a PCIe root port (required for PCIe hotplug) and a +monitor: + +.. code-block:: bash + + qemu-system-x86_64 -machine q35 -m 1G \ + -device pcie-root-port,id=3Drp0,slot=3D1 \ + -display gtk,gl=3Don \ + -monitor stdio + +Then at the ``(qemu)`` prompt: + +.. code-block:: none + + device_add vfio-pci,sysfsdev=3D/sys/bus/mdev/devices/,display=3D= on,bus=3Drp0,id=3Dmdpy0 + +To hot-unplug: + +.. code-block:: none + + device_del mdpy0 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168814; cv=none; d=zohomail.com; s=zohoarc; b=LteaHeQhhs0Cdcl6kvu0gVRwLZ0LhsAEkw0Ww3y0fTr+qGry8QlzdcCK/olsreoHBaLiO6DIhDNsXASexl/JTGe2IFBF5Dq0R8I9yOpgdYV7lfuo/n4tinY6tTl1XfvE1Ki9a3w19DyLA/YSCQ0N2HcBNfha3m0YYZO+dLXRLFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168814; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9Uq/YOD4Tyc0jQlm9DPacra4GuZK8eNHou9efZzgg2Y=; b=NhK6X+DSADEZpVJ7cS2TEAztW9KWmgqWzsVabEMLa/kf1iKZp4kVrEvBPGsYW4dos+zoE1E862lsOM9XnFpSRNyEpvgE4VGpcfu0WcauabIOz6Z7ZNLSsrbuJtrOxFDXIM1pJdevITIrq4/iF2fr6/BN4cZSedbDbU5feWBGBYw= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168814257242.6799417739901; Thu, 11 Jun 2026 02:06:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKs-0000OJ-Hx; Thu, 11 Jun 2026 05:04:26 -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 1wXbKr-0000O0-Hh for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKq-0004dn-7H for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:25 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-gutft811ObqBsC0Ib2jKYg-1; Thu, 11 Jun 2026 05:04:18 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7BB011800378; Thu, 11 Jun 2026 09:04:17 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3E21B180029C; Thu, 11 Jun 2026 09:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168663; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Uq/YOD4Tyc0jQlm9DPacra4GuZK8eNHou9efZzgg2Y=; b=D7KVuheOyHTWPG3L7vuvHpCSWl7nfMf0WernMa/QRuKZzdn0z1BLZerNESqjXUVAL4xUTr gojvQbSL1YuGiydPH4RndYwcwNkYGZ9k5Tn5aFG61XVrDQo7BVOZ83L4HjRF+vdGP5xTv3 uAAatYnz4PhgiebdZH00rgKYr42Kk40= X-MC-Unique: gutft811ObqBsC0Ib2jKYg-1 X-Mimecast-MFC-AGG-ID: gutft811ObqBsC0Ib2jKYg_1781168657 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:22 +0400 Subject: [PATCH v3 07/35] glib-compat: add fallback for g_clear_fd/g_autofd MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-7-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1464; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Oc6bYtbmoQuSGvRLMjbnGE3Qy+VIBvYlZ2fSX7bu/zw=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnndJS3U8ds+2xrkI61RwjnGLXrpSNf13PGyS M57Wl52yh6JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5UWnD/wM854nGLRh4wNJWnYDe2QKcyIg5vZLMVPQtAWXLsGTs+2hdf8jAZkXXzcY/kqxNciKXCU Ln3cq1FWxUWUNwVkneBx5UuFKmy8aRl/RbhMbT+imv4EFaR/FTkccrt1FGDivuhIMsbNrJLFGnF i9ruQM4jA/XD2sumz0LJlzBxskX0gDPS/aRy1sm8CMyeH1D5eWrA0DEkco7CGQxLROMNIjUQCbF e6PUav9nMG430kJpUjwvp2DogbkJV4jL/SaqTSE67rwueiebcULzlMSMq14TEitWUGIfuFD53Of 16h0bN0prRKQZ8EBWzl5tXsep414Yju26DSDkR9k4I68h5wcpPAj2P9SO/yahtm1V1V/NdineEO +EpkhDxtXxKaOvBOjsKa9IqaRY2oksF1c1aeVU/k69L8ZmWjvV8fl9NNaQbGJHgpA6UWzBTrntt 6or1PwtSa9NoghAAc0GnTFgI4oaCY1AinOySo7YiUfPZTvRgXb7KxDVgQLiiCPae4oTZcZqlHcc K/cLTt7BYriUyeJh6hQ6yid7LGaBGmXFA76VCPXxBEudf0MvpUJM4AtsDbnqQTYb/+s19jKjkC5 yDikjeV3fk9WfuF6TwAwrtKyiWgRny3tx3QV7VyWnAwyxkrBFGgkSMerBg4ygFkYNwl9gQEldzW 7wYKP/HaVxSTOJQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168816312158500 Those helpers were added in glib 2.76. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/glib-compat.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/glib-compat.h b/include/glib-compat.h index 2e32b90f051..32ee2afdcdf 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -30,6 +30,7 @@ #pragma GCC diagnostic ignored "-Wdeprecated-declarations" =20 #include +#include #if defined(G_OS_UNIX) #include #include @@ -129,6 +130,34 @@ qemu_g_test_slow(void) #define g_test_thorough() qemu_g_test_slow() #define g_test_quick() (!qemu_g_test_slow()) =20 +static inline gboolean g_clear_fd_qemu(int *fd_ptr, GError **error) +{ +#if GLIB_CHECK_VERSION(2, 76, 0) + return g_clear_fd(fd_ptr, error); +#else + int fd =3D *fd_ptr; + + *fd_ptr =3D -1; + + if (fd < 0) { + return TRUE; + } + + return g_close(fd, error); +#endif +} +#define g_clear_fd(fd, err) g_clear_fd_qemu(fd, err) + +#if !GLIB_CHECK_VERSION(2, 76, 0) +static inline void _g_clear_fd_ignore_error(int *fd_ptr) +{ + int errsv =3D errno; + g_clear_fd(fd_ptr, NULL); + errno =3D errsv; +} +#define g_autofd __attribute__((cleanup(_g_clear_fd_ignore_error))) +#endif + #pragma GCC diagnostic pop =20 #ifndef G_NORETURN --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168697; cv=none; d=zohomail.com; s=zohoarc; b=VS4gwtzBEIqIqmDO4iMlOJYPwMKazQmKnyw2sDIhph2TL/zyOmaiAp+4pZfDmv2k58NBY+JlCNI+6pzeuzQzVd5swZfy1B+xERId5h8L9WnbTGNC8JccZfzqj8fsBDHL2TEOMqT38CZDEnJFfJE2/OH8b+7S71i659lzU9ulEjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168697; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=w+Oi233XiBxp+rpO5j9u0aVn45NZSh3AuQTspxE9xl8=; b=e2TdT2wQHgHtKVk8TD16REx8OGrOZLnhpFP4P4PDwTywy+e8LZCh0e0ExqesnK6LsJFA4ypQhOdRpBi30sDB4amM8+oSMwrhgXhWkIHfJg3/dONIS2Gfp1hOYh68zoz56nDXAAk2AiMAuYFLONNGb6d/A8/8yh4+dTIi+l8GYNg= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168697850461.48087791897956; Thu, 11 Jun 2026 02:04:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbKv-0000Oq-NJ; Thu, 11 Jun 2026 05:04:29 -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 1wXbKv-0000Og-4g for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbKt-0004et-Rc for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:28 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-676-yLej1UJ3PoaWZJj4GC2CcQ-1; Thu, 11 Jun 2026 05:04:24 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EDA1B1956057; Thu, 11 Jun 2026 09:04:22 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7447630A8; Thu, 11 Jun 2026 09:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168667; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w+Oi233XiBxp+rpO5j9u0aVn45NZSh3AuQTspxE9xl8=; b=H0DbBmswJZ8ayURVzGAWGHY7dS7TU5kEGHlEYZn9l5dfCWtT5bI77DrSIob4FUVR9fYRI6 iXkdk5FUzKpJCGRe+AiCb3Pyf0A4CKFjydbVPTRfCxzfyW9O4h4/DKabh1tYky7Ks2Zodw qJIVG3Q8esIJ2BrECG1zX1qk6EyxESU= X-MC-Unique: yLej1UJ3PoaWZJj4GC2CcQ-1 X-Mimecast-MFC-AGG-ID: yLej1UJ3PoaWZJj4GC2CcQ_1781168663 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:23 +0400 Subject: [PATCH v3 08/35] util: make notifer_remove() safer MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-8-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=675; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=UOpL3VWQfoL9NOG90tt8t0YDaaO8SV+WZheSRGL3tSg=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnndAFE9tCuKT6G59Y0DAwNdFhEqkJ+zR2vWV y1eHjnWyiWJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53QAKCRDa6OEJdZac 5SkSD/9LhsAn+PDeC2F0MiFqztW7/COnzAdfMHx8LtjXlK6JZjmxIG57s+QgMTakcJGz+BzFwnp YR2yF8C/i+0l42/vbjuXb0a+MJWnMbr7Gz0OYwmRmcoJhJVHA5n39bj+tG/le8KzYgH1xeu3/RL o2FZsuV+qLUl3VpkQbtNeHojc9YqUg5hmBlR25dsSyAHu2VixZqo1iccL9DBuYaLQDwq32+hCU3 w0Shj1hV8A/L6Ouc3wpJLGkAN0+H5yAJaV1gIfDy7IFoeo0A3b/kUS1rNUzsoPTLV8aMORujtLS 0ItG7KCLbQ5b+VRgn9KDzaI6TfyXraIlGkC9qzIQQITQpIdhFeX1RMoJyZsfS8apOH7rw5+qCIP 0XfMw+dDTL8Ewe74p92Co8lfZBPynmK9lDw+Ok1LYq+JksWObWFJqyswydTZZlZaFhjzvmAW+nZ II1GQqvuUbj5xImuGwE4FArDTBgR93hP+YOIOH0eKhYvGQmyVlqaa6bvkiEboa/d1TiMauu4zsV 4b+s+ieCBuuBAiBGm0EtqGtWbVKeXSuWr91KNwjYO5IFAihTyHc8WmeHeeATCHcZYCRC/3KSgwU +visnRPPL77e9gxvd6xTKfshlCqm1iSpFH+vB1llz+CF8/z+gSGQb/maMFahcc/qQJFcChyDFF+ MMXwg43Oe3xksIw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168700079158500 Allow to call multiple time notifier_remove() safely. This shoudn't impact performance in any measurable way... Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/notify.c b/util/notify.c index c6e158ffb33..24420a7288e 100644 --- a/util/notify.c +++ b/util/notify.c @@ -28,7 +28,7 @@ void notifier_list_add(NotifierList *list, Notifier *noti= fier) =20 void notifier_remove(Notifier *notifier) { - QLIST_REMOVE(notifier, node); + QLIST_SAFE_REMOVE(notifier, node); } =20 void notifier_list_notify(NotifierList *list, void *data) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168701; cv=none; d=zohomail.com; s=zohoarc; b=FZv56//ThGTJebWN0h2f+BKth9vplPz1wzM3Cuv4iCYJU5SEblrwQVnRtZvhbtV24+uu7xjGNHSEh9LVFfD4JWuEj9osdQ1PaqYUn7FdFMF9SlR6Pxer4Zf5bx6KC9Pbbdk2E/LiLVN/qsAy7D9WlWLuInjhgGJdcFPBQIYlHow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168701; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3pcyNGo+qPF7A1W/+3xFE1YsJUVgw/+6amnmb5TgNlI=; b=Se/eNajufiDgKle704pF8lawdF6fAFIY2fO5KWvo9HqcRxDD7xpOKMTSX17ZyNhgMo7ZioVNu6K9X8H1CCuTYOVxVVcve4jQ1z6mnilEySSwHqG/RRSsMShPoKp8X5o1qM+zavnlp44ZzKbAFMEGoxrnt8TBAgniWeraic/VDeM= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168701844235.43185625748822; Thu, 11 Jun 2026 02:05:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbL4-0000fh-EE; Thu, 11 Jun 2026 05:04:38 -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 1wXbL2-0000TQ-8k for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbL0-0004fs-SK for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:36 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-CEsAmOJDMLGyO_lFg0ISxg-1; Thu, 11 Jun 2026 05:04:29 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8EE8619352EF; Thu, 11 Jun 2026 09:04:28 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3328219541B2; Thu, 11 Jun 2026 09:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3pcyNGo+qPF7A1W/+3xFE1YsJUVgw/+6amnmb5TgNlI=; b=R+lf4/zUh3HHeFRpjfGZr7OyQJYtbn2SOMPAYOE+NlugjF63+UnVVP9vruM+4MBAS6sxlg GXE+8QkIZS9x/2nUNZsMRTS7dHKSB2epg0EO575OVF4NxkyjgRdVqz3tRmLm97mPm1Qk+H KJXPcQork6AEKuOCQ5rbBLEKik5tfEE= X-MC-Unique: CEsAmOJDMLGyO_lFg0ISxg-1 X-Mimecast-MFC-AGG-ID: CEsAmOJDMLGyO_lFg0ISxg_1781168668 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:24 +0400 Subject: [PATCH v3 09/35] ui/dbus: remove mouse handler on dispose MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-9-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=775; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=oU6JmTe/phIh4luHU7JB2qhh1DBckGQ34XnugyV3zOQ=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnezvZUS4DVOBPYIPS/qFAqAM5dNIK5ZbENI +matzbYA0qJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53gAKCRDa6OEJdZac 5WqbD/9LKaBGPU+wJqz77ZU0Lu6/nVMupdunHVwShFJT7AlvVxDmstT84YHgLzkR+XwMh9u38MB 5gR0MsMnqrW+3o6CZ0w6Vua7LbuyBYqq9u+bNKlLrCASaO5Qkq/y+Gw83bblcw4lUwSNMUQeYK/ 3EIgOSL5iyeCJOhZJVKlTku1l1DJKTtoUBkuGuObQef7dscej9g0AYy36BpxDXi52qUmmHVWYOb GJVCAur+9LGip6JqBcAF92w3cveDndchfjUOGO07XidcLja0povMGPomYYEUGMTaNlwx5ogLedj g7NCkjZIo1/3aUct96O+68cQ7co5iWE/mwEAUSvj/syiL3GQBiiftIDZ5doZ85R3VthPX7CMe74 PcQnE/LQfdbzRVtSRkHmOjWCwHn5JG6usY9oYpGZ4WfoiIKmIpl6B/lYDbRgHDUnNV4kmZoGK1h aGBki6H7SMSUfceMMCGFnq93k2X7F0682l7nm0xvveiRDxwO3xcI81zgWT3HTw1r6b168F5ccSJ z1Du7ZXY1AAC1bIvcxUCu7Dr4jVbtMS11IkdrWKJJOmpbezc1kNNtyl+i7+m698p0AZuVp7CCZA 9ELJxBffNLg7zvdnWmgN95goCGNpmvsRgDjbj04S/BbraK+LXT8l/GTPM5mTEintxCpFX446yvM nbOmseR//RQoJ7Q== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168704081158500 Fixes: 142ca628a7 ("ui: add a D-Bus display backend") Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 21eceb24362..0813a08f85e 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -151,6 +151,7 @@ dbus_display_console_dispose(GObject *object) DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); =20 qemu_console_unregister_listener(&ddc->dcl); + qemu_remove_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); g_clear_object(&ddc->iface_touch); g_clear_object(&ddc->iface_mouse); g_clear_object(&ddc->iface_kbd); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168702; cv=none; d=zohomail.com; s=zohoarc; b=mZzj83XJ24MZF2vNiOheSY7Gy96U1uUBY3g1hpMdbg/Q2IkXh0bRM0aD3dQYCoSF634//qRWT1g/GElwvkb6NUGKdZysFceS868phHJu/5yV4jQcbmblOS2XIcbNs0LQ8/dXIuHgdpvsPmu51OFCY/yGp0vhbY1m2+07dirKRW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168702; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PNF4dBrQupDS+BQkGMmXzc/jIpRKvawBFwy1v2uFoyM=; b=hAu0tk2Rsvym2/SnVzAV2nqSLoPjrZszpRWbXbOFjTnQ5fn7QkFyPYcJzjsLrYlFRWeTnz2OP7uE7lzOVA1WmE3K9jdphNG3Oh9WXgPRBk1g1nsG/GoW93sBpn2h0IB0BlKhQp54LyFHGZQQDqt12SLYhe53Px9Tc/DWNE+M4NU= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168702134925.8032930491012; Thu, 11 Jun 2026 02:05:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLH-00017T-3y; Thu, 11 Jun 2026 05:04:51 -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 1wXbL7-0000tB-Pu for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbL6-0004h3-5q for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:41 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-583-EBl_9U2RMMmpxTwmyde7Ww-1; Thu, 11 Jun 2026 05:04:35 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EEC9C180ACD1; Thu, 11 Jun 2026 09:04:33 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AFBD730A8; Thu, 11 Jun 2026 09:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PNF4dBrQupDS+BQkGMmXzc/jIpRKvawBFwy1v2uFoyM=; b=PqjvLFffgu6jeopy2X+J522q57M/nVxh8B5YuUumlCpqRJTn+/2ithgAP56/bYKxhKv0Qo mOjF40pVVTsN6Qyjgy5mspA3/Mf40K0moHVfxrNjidkSRhfJ95ciKOGWOACJH9CTQnBH5C rC5zps7+JwId801hKfz+vL90kGS73I8= X-MC-Unique: EBl_9U2RMMmpxTwmyde7Ww-1 X-Mimecast-MFC-AGG-ID: EBl_9U2RMMmpxTwmyde7Ww_1781168674 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:25 +0400 Subject: [PATCH v3 10/35] ui/dbus: remove led handler MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-10-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1501; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=FpVxxG8nNRmQ0abvxiCSMpev/nXrAIip6WcnPZ/1grM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnne5ailz8B+fXcBUMbo0OoWi7sWguWSmaswN AC2a1+15LyJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53gAKCRDa6OEJdZac 5cgiEACeyoI/FWgSw+IkfSt/fs/PVOLM8BtnHP8mjzIHnH2GDM+dbIScEAnq07QeEaxk03fu9xt zGt0vxqXnkE8hA0KDJworA4rsJrjX/tR4EB4qGaueU9qWZ4me6lxUHGvxZf0iNEsqNIjcpyXUDk jzn44pWgNqEwHV3CRWPranYmr4Bwzyn8FzVAuQnGgK7BS1NDukjDK8mcTIYvHb3mG1EWZmoYmUZ juyruMEpQ/pcb/+SBHzzolAV2VqrS7Y7yNtcO0VyoVN75oD0TCCkMMDxPy5hF6YrDZyIgO9bieH eXQDHbPjEXuON559DrPS0ulE1IioLUbrnLcc6cHnzifTXCnKEcY/1k2I95PupM53HLPW5wkBnZT yXZQeCkk7a2yMhr5YmUmVJ0tqAdDmtpLaDlyM6Mk1TW39OJyXibENzF6v8CJlFzULOi65ntMV03 d+Gn1bwL/EeAVz2SzoVN+GhYq2wT1SeMcunQlkk9zyuBAx5DDOsIppwZIH6iA+q50O5n5MngNkj ZGfPRmNPIkScb0++brlu1alCNMkx4ZtpsNps9K0ayyD1VTCH7iXTHyF4bK+2FZyHkt5TynrZAme kui++xFp4g8KnndjSKPAuafOtpwjf/HD+gydD86QvS+GQQNFHEUEasHj5XpFS5z/Rkwou24ENv0 P7YUxqH/i9TARPQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168704082158500 Reported-by: Akihiko Odaki Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-console.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 0813a08f85e..742bf9639a4 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -53,6 +53,7 @@ struct _DBusDisplayConsole { guint last_x; guint last_y; Notifier mouse_mode_notifier; + QEMUPutLEDEntry *kbd_leds_updated; }; =20 G_DEFINE_TYPE(DBusDisplayConsole, @@ -152,6 +153,7 @@ dbus_display_console_dispose(GObject *object) =20 qemu_console_unregister_listener(&ddc->dcl); qemu_remove_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); + g_clear_pointer(&ddc->kbd_leds_updated, qemu_remove_led_event_handler); g_clear_object(&ddc->iface_touch); g_clear_object(&ddc->iface_mouse); g_clear_object(&ddc->iface_kbd); @@ -578,7 +580,8 @@ dbus_display_console_new(DBusDisplay *display, QemuCons= ole *con) =20 ddc->kbd =3D qkbd_state_init(con); ddc->iface_kbd =3D qemu_dbus_display1_keyboard_skeleton_new(); - qemu_add_led_event_handler(dbus_kbd_qemu_leds_updated, ddc); + ddc->kbd_leds_updated =3D qemu_add_led_event_handler( + dbus_kbd_qemu_leds_updated, ddc); g_object_connect(ddc->iface_kbd, "swapped-signal::handle-press", dbus_kbd_press, ddc, "swapped-signal::handle-release", dbus_kbd_release, ddc, --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168763; cv=none; d=zohomail.com; s=zohoarc; b=A4d4NZIT72oX+icRWWlVn8d+L/c6eUJRAigWDlGB5rqMh6PBYcBMDfSBq42jQSdlpMdszPqHszQJ3WktmtnpHvqWtpFUCVTutCMbHdpZPvH/dcQrBELGlEfhG/7SQsODo5qcMgWJi8p67AAsu2e0mwBuvTPsF4bfVLnx/AZ7XvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168763; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fy9FDnBBuQA6XOva2yHkr/+J1a7o999MtLZIJzCYeGU=; b=OzzuTGgWpDuVAky49AGDvRXEoIuJ12u33xhqE7Gh16kFYT+rRk83F8aPvgx/VuR7xKkzp5nc3zMrYPTfJkGHS+az2Slka1YB72bmJ/eSMxWQIULD8cg/tjLw1LWDv3A12bhq/Ezop3VEBVMBbh8R8S78qGhmYCM98AvXTb+fpv8= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168763346679.9189163195119; Thu, 11 Jun 2026 02:06:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLO-0001J2-Q8; Thu, 11 Jun 2026 05:04:58 -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 1wXbLA-0000uT-EI for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbL9-0004iN-28 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:44 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-hQ8UocCaMaSeGkCcty7E_Q-1; Thu, 11 Jun 2026 05:04:40 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 62B361956069; Thu, 11 Jun 2026 09:04:39 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2353018005B3; Thu, 11 Jun 2026 09:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fy9FDnBBuQA6XOva2yHkr/+J1a7o999MtLZIJzCYeGU=; b=f7Ksp86d/0F89pJzjulakN2WbVR82kp8z5LO0Kh0Gp9ce+hE8rhHGixSp13Gqbk6SGf/Mm LHwagOC6Te11tncLPx2t7MIstNLPpQKynwO/kZP7JE6R2ydsy7Siy0fIWre24Y3Yjh5nDp oEq+QfZ6JhUVd2+vmE6kW29PTSsNj0Y= X-MC-Unique: hQ8UocCaMaSeGkCcty7E_Q-1 X-Mimecast-MFC-AGG-ID: hQ8UocCaMaSeGkCcty7E_Q_1781168679 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:26 +0400 Subject: [PATCH v3 11/35] ui/qmp: keep a reference of console across yield MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-11-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1035; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=nFUMF9aw2NB5tNGhWCH8b3CLuYQw1GaCHR49bKZmaWs=; b=kA0DAAoB2ujhCXWWnOUByyZiAGoqed6ih/g6Pkh4EfgpXzqXsEuKI0qnkPA7us6Q0H+QrAtjc 4kCMwQAAQoAHRYhBIepvZM/h8YG0nb2Ldro4Ql1lpzlBQJqKnneAAoJENro4Ql1lpzlhT0P/A9d hfsTPofOWCDc54iytPg7lO6FmZksNt/VNLkvCxja6Z5IVlpmSBD98t4yy2vD9bqwUA+1ELlpcPo nzukPQmPeLMssnjbzmoQNtw7cH7hDAAxi2bpt2vsnqKu7hv51DIEZMmNSTCZlD9EcJkawV8agdW 9p0NeS7J2JijBMW6f3NZIjG6pYREeKeEzBGzQCl9WuFDPh0RkIU3y6zkLjZ6bXiAj9WDU6ArRII Mrw9J5lxu5M+Z9sP6zyB4KJchLLEy+Bq9tFFk77eILUEuJ4mGsbjcFW9hnPEGKJklIQkRB5/Inl RBDNDKB4wDW3ZTwTSxQejpZ+Uaqhf2SUI+NaxeTlAnHseTJNsnjJUT1EnIkQq0uAcQyY6Pc/6Kw JyK/jMUnuqn0b1+CHDUZg5ZIJMyRYnKJ9spjZor7h9BVmZxW9gnH3x2MTXZzQ5bRQQNezfOfJ/L FE6+xQQs2qcB3gEX9+rFxR7jWfI+ZDCDsdWsbSICbKs4kHqf1J4kfbE5mdLw+tTKpoYh5qhEoF5 Eo1iqbIph7vqIazanfPjKamfA50GSon3kMtfixiyi6I5mM2JfGSyHmfrDaY/NeTp8z79LK8AzDZ 3zErfpKq/VViM4RRcHQAut/ToCwd139LfKVyNANn6qNf+aQZN751Jz5Ou0lDy40iYUd07steRQ8 XcSCY X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168764214158500 While the coroutine is waiting, the console could be finalized. Keep a reference to prevent this. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/ui-qmp-cmds.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/ui-qmp-cmds.c b/ui/ui-qmp-cmds.c index 1173c82cf7f..753cc2bf522 100644 --- a/ui/ui-qmp-cmds.c +++ b/ui/ui-qmp-cmds.c @@ -348,6 +348,7 @@ qmp_screendump(const char *filename, const char *device, } } =20 + object_ref(con); qemu_console_co_wait_update(con); =20 /* @@ -358,9 +359,11 @@ qmp_screendump(const char *filename, const char *devic= e, surface =3D qemu_console_surface(con); if (!surface) { error_setg(errp, "no surface"); + object_unref(con); return; } image =3D pixman_image_ref(surface->image); + object_unref(con); =20 fd =3D qemu_create(filename, O_WRONLY | O_TRUNC | O_BINARY, 0666, errp= ); if (fd =3D=3D -1) { --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168741; cv=none; d=zohomail.com; s=zohoarc; b=iiQDrk/g3U/4AxKilluvbr9IWtoB9ljONN7jEpUXqV+fNM1IPK22XdAEdXBsC1/HCOlf5nfW2eT2pWDkK4eCBHK0QIvg1WpWWo2hnj954QUdiGJzLFkU354NscmDoUAXx6LG5RFg2wK38mKNHvjXGXDV41e5tP9MOvZ01K3OD2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168741; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NtnkDg33MYu/ghaopwN30hvH/Rt4UQH+q1oST+NTnl8=; b=liBVhio+v+qXzCTNo7zYN+QneBMApZkp7ZtO8MAEBVUkJu+M/AT77Jehar2wv7x52Q1vtkgOuJCWZO25Ags4lM2P3SO5ElTkZFQQqYLEOKsPLQQN9OLK+8KQEB3oyAmbuyAzfIGYjUCkkEV1PkFgjwBhCAuqcXAWBlEnqwF1B+E= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168741985860.9759527179382; Thu, 11 Jun 2026 02:05:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLQ-0001gS-HN; Thu, 11 Jun 2026 05:05:00 -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 1wXbLL-0001J4-5i for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLI-0004mt-Pq for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:54 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-ZSHnaKdBPim4vr927yXueA-1; Thu, 11 Jun 2026 05:04:46 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C806A18005B6; Thu, 11 Jun 2026 09:04:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6EE6A1954B0E; Thu, 11 Jun 2026 09:04:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NtnkDg33MYu/ghaopwN30hvH/Rt4UQH+q1oST+NTnl8=; b=SgQythqBwP8MmDhMU0bsHusagAEWe9fTWmMoxxLc5LNGSM0VOS5EWtMo2IRGBR5CIqDjjb kp413mYdDyrmaOP5RUmaewsSlvOLDOU0wFNbEOvv5O4Z0CL+owi0iM9+5JkLedL4mvvJqH OuJZ13VaejsGqk4LYVsgnWfJPMXAgi0= X-MC-Unique: ZSHnaKdBPim4vr927yXueA-1 X-Mimecast-MFC-AGG-ID: ZSHnaKdBPim4vr927yXueA_1781168685 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:27 +0400 Subject: [PATCH v3 12/35] ui: stop ui timer when closing MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-12-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=794; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=1hj0l337W3NJOgj2iQ5HiEquhGCiA0qJG1NmyVMnuVU=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnneJrWucxATzN3yF9uH49DNdOPb6BNfSKtYy t12Dz+GFBeJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53gAKCRDa6OEJdZac 5QDjD/459XSa8SSkem2tlgPK8UBNb02TRx8K5VQlG42C+4tkRnqATTRLKgn2a3/Rdy7Om+nU1ke BlIT6m6gzujaKYPZQ/7U48IzvuCwSdBkj3GZlPf/lWGiy2aIji9bYaTcCnSsgW8dFuuZ33EWGUS fXtNCTSYxGS4IzJQ5c+K1IFLAZft9zlFtgzvfJgrUB45RxhQSo358O/Gosxm8rkLv59NnWTsB+y kC6Hj2D+fv/s/eKTuRxtgZjcjA8HIB78YijN9NczdrxWu8z1xaJOROhgc55GlOEuMvxwKSC2RtY DX4as/Mqa5ktknE1jK/WtPhqBXANu19DY4de8ZxBE+W2uAqtqDjG1x8B27iiAqrahBZ+52frSFf IKrOiz56HPSLL4JpFJf5wcqvSuKiMANV8YCsd+YCbpY19vrXL9hMqKqCQhTAvyadcGHHvI9lm0+ BJk7ElAU0UnOj03BBxOOwgWp6RAVEFxjiHrVLMVtf01nE+l/TI2Q9tz2ZziO0WZqHYmXLhVBErl cN1VdJgm+iYMVQWSlM/4VDuAoiJrIocWH/ZBIeEXnZnsup9/oflAQoj4Ah/eOne5JmJ5e0BEJ+P 9hTZBCIXHS+hAOE2LSpuMdPWM8vw59qvEnzbStmQu+umBjl4sc7DMtfI1GwXw6krWF6YGN2tvbF C87x9ZlS4Pj83/Q== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168743823158500 hwops is reset, so if the UI timer is pending it will crash. Fixes: 9588d67e72 ("console: minimal hotplug suport") Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/console.c b/ui/console.c index a7c977d0c44..436444723a5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1136,6 +1136,7 @@ void qemu_graphic_console_close(QemuConsole *con) trace_console_gfx_close(con->index); object_property_set_link(OBJECT(con), "device", NULL, &error_abort); qemu_graphic_console_set_hwops(con, &unused_ops, NULL); + timer_del(con->ui_timer); =20 if (con->gl) { qemu_console_gl_scanout_disable(con); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168740; cv=none; d=zohomail.com; s=zohoarc; b=eXOYhAwiGrs1Z9xRPHh8t8kz4ueEhaJ8Rs3ItZHaxWOHi3UTE1aBlT29881+4UmYHektuDyxuLmfLtJ9Hm/2DIKVsMKkeCJo4Ge45KcX+Sd4Zhy4FuRVLvoTy5CnN/LNsvXjK79dKshOe6RCABNGu919tE5ZhkdK69B4nG3Lx7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168740; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=InEIGu5JTrAOABwltf0bG4+QBVo09YgqKmwUUPjE9PM=; b=B+sIlmX5guYK7RBdoT3ejRf/j8YKqTMsCGDTiBxDemvQ8wCFst6eheS69hEzPGRqkSz61q0Hl9sl3tg/O7tAsaA57E4UDKoiuVq1L9wIOdGYGbjc+neo6cfibH8QR+l2vm1qeUQEMvSfUyFe+B5tP2lwzAVA4Pl1JgwXeS/nW6g= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168740122782.7251512027335; Thu, 11 Jun 2026 02:05:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLS-00027j-RF; Thu, 11 Jun 2026 05:05:02 -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 1wXbLO-0001N4-D2 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLM-0004nQ-W6 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:04:58 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-ctAovMlnOROnmx1PbDnFVw-1; Thu, 11 Jun 2026 05:04:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A3CE51800591; Thu, 11 Jun 2026 09:04:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 95D4C1954B0D; Thu, 11 Jun 2026 09:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168696; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=InEIGu5JTrAOABwltf0bG4+QBVo09YgqKmwUUPjE9PM=; b=L1hLnZJ4Y24OZHi+2P7Yzf5KwcFfLrPBopd/J/7vsf5zRrmMiqfneXdg8N7D0WwuQ5ywzN rTDn8QN5WGWnmLujxbDP5yuySShncV1NC5/zTLCEKsJmJ+dtTB+HmZ1fB6dF3wEI2IHR35 91X2223kKXfQzngeEDdZicl0Fq3vVZ4= X-MC-Unique: ctAovMlnOROnmx1PbDnFVw-1 X-Mimecast-MFC-AGG-ID: ctAovMlnOROnmx1PbDnFVw_1781168689 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:28 +0400 Subject: [PATCH v3 13/35] ui/console: init gl_unblock_timer in qemu_console_init MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-13-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1375; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=75m6XwEI/jEsuPHQxTKVuXwY/0BtApgtkgSd0IkJ6dk=; b=kA0DAAoB2ujhCXWWnOUByyZiAGoqed6hHsLwGPjrZh6NjzsoCHfrT1tFWSt9mIA/FcURHYuY6 4kCMwQAAQoAHRYhBIepvZM/h8YG0nb2Ldro4Ql1lpzlBQJqKnneAAoJENro4Ql1lpzlEqgP/1Z6 DCNn1hS1hQr105u3KXotaO2IhvfoOifUi/coCho6u6wCSSNVIc++3cmDUhJN/coc13JbpOQIKMW 7gPRZV5T8U0a7T7YdOaQp6nuDSM7G2olD2kOSxTqeZntiXHsUJUlesIJv1i0cn/XcX4tA8SKeG4 hjdRQbYjnYkFloTrufJqkUdOd/FufbdbQWMxWQ3qH6IGmstvrHqWbiqEIxdLGnC9tpgYFZU2j+w rKT91p1y/y2/b/uk7jKKcfCdyrIg+E8Z1pOBolsPR7LROSl2aqeZvmhApEApqqIhxU2GpwjzX95 kKAHgkdPP1F27IyaGExFdiWrTGGnLOG+iBVz39SfX0qM93E+huZJy7GX2GOj/ZXghvyXlUTApYF v7EqQSpidZBXKBvSSKLpnPMiba3zxYNthY3qTOVq4MUOYF84XjSfMbGsM1weDFLF1Vn+VFNoFGN 85cST7ZDJW6SKD3GC+bFWoIkiZRpXaiw0MJp4CaR9vw9OvcQqeGh9G1xwjqfTkDRUJj0xt/sS8S qnbc63n7mKFhfrJgaYBJgHG6WTd6zV4UFpCPsZjKioPRvr/IPkxaZzpB+MygAX3GlVGcAFw/jlx 78XdC/sdeL/uvc81UKMX2NfACenDG4TeBDBrrpDBty6A2OI3BEwIk2cFXb4qsFy87edx8fT8iDm F5JU+ X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168741821158500 Move gl_unblock_timer allocation from graphic_console_init() to qemu_console_init(), similar to what was done in commit cfde05d15b ("ui/console: allocate ui_timer in QemuConsole"). This fixes leaking timers on console recycling. Fixes: a9b1e471e17 ("ui: add a gl-unblock warning timer") Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/console.c b/ui/console.c index 436444723a5..58f29e82c85 100644 --- a/ui/console.c +++ b/ui/console.c @@ -433,6 +433,8 @@ qemu_console_init(Object *obj) c->window_id =3D -1; c->ui_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, dpy_set_ui_info_timer, c); + c->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, + console_hw_gl_unblock_timer, c); qemu_console_register(c); } =20 @@ -1116,8 +1118,6 @@ QemuConsole *qemu_graphic_console_create(DeviceState = *dev, uint32_t head, =20 surface =3D qemu_create_placeholder_surface(width, height, noinit); qemu_console_set_surface(s, surface); - s->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, - console_hw_gl_unblock_timer, s); return s; } =20 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168837; cv=none; d=zohomail.com; s=zohoarc; b=YUyVYmTXr4uyKQbsXU9M9yHHFRdC5I86isojC02RU6UDlKum7cP5lE8nNIG8nvpYF+vBQziBpK7IOK4agkolRzOoEINYMae71tJju9SuvKYV+5XCY9QwzjLaGpmqK2cruBUb5Qx4392Ys64eGixje+aSwHAif+2X8yD5Z1kb5yQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168837; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XkqraKUc6uDUOWv6dsveBCmO1J/oGh5rlye3uFwFBek=; b=QnW2is2ARU1F9mMisIt4jwBtBxbAmrhoGmXN+UxbstbiDsVysXEGl5c1XRblALAa5dlAMUWFyRR31t0WyB8y3XrrhmtR0inVf+v2I5OqoXTuNQ2IZ0G8INJ28vAcl6s2eSqcTw6llJkoAYiAOGjz13BFMx3wfHzme9ElegzO2Ts= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178116883731138.59574196843198; Thu, 11 Jun 2026 02:07:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLU-0002HP-66; Thu, 11 Jun 2026 05:05:04 -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 1wXbLT-0002CW-9U for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLR-0004nw-Im for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:02 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-69KLTbCJMkicEASBIejhNw-1; Thu, 11 Jun 2026 05:04:56 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 098411800675; Thu, 11 Jun 2026 09:04:55 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C72CE3008B34; Thu, 11 Jun 2026 09:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XkqraKUc6uDUOWv6dsveBCmO1J/oGh5rlye3uFwFBek=; b=MW7l1PZdZqKiiKpNWBvMDrZ7xUV+MYK8B4znH9G3p5kGy5E4zJFEYz7pCy7YUU6OlSHOlo mTCgnVY00bZvzBlP8U9CRaH/Lm1PNOcN82jL+V+60uBvE+SyUkndXRsvwx/fuaJWw2VVLg qoH7AgTz85rrdvHryd7zpNgLkxyUQ38= X-MC-Unique: 69KLTbCJMkicEASBIejhNw-1 X-Mimecast-MFC-AGG-ID: 69KLTbCJMkicEASBIejhNw_1781168695 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:29 +0400 Subject: [PATCH v3 14/35] ui/spice: remove dead spice_displays MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-14-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=924; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=nHts4H7Pj0xNu20cVIrWwmkK5/oJi1JsNd5AGFPzVAM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnfzCLc49yQbGVY2qV3/eWcXa3ofPXle7rvr i57bn2Idu2JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5aFpEACILvVbUNHpQqe0O5gBg6+8bM47/k7mf+clhaW/vBLOBFzW9D4iJUt6DxxoXH9PUCSGn4o Djennc4SHbcQuNA4m0aZUG2bkGWw4zUEvQ+m7KhqRdw0uJp/Z/vykW2aJG8iqbFufgqW4sCPwH8 Zm4CZ7CZ3uPZCmgCymjFb9S5PyDUDzxjb4F0rO7J1VHZ5VD8nUVL0bFB76Gc1Yrjds/O50SC7g0 ew9iR+Z0qUPp7qBvTNEKMM6R7arBwgupq3n3+J70R5iMFk51bim2dpmXdDnNSK0e5vvwhoD0hfT qgHvYbg9jATYjCERb/Lwphv5RPcZH+aLdwogIMPsM3fmB50VfILaRxSmKXt6NolKN7sF1jdbDEo inkJN/Me8IaBKhqWFFSQKV2luLCMWajBRgz60pjCbx5JIIigOlxRFEE7X6HI35ttsZVMnExCVTD n/rdHdFMLkWYBLsmzUf7pHYCVaTX4jtqo+3QCyVNLUDy60Mbiq7CAu+iCl0bvO+1UH/lp2Lriu1 KMDw5Lj/7UaNDVbmUzsADce5YK9rbrrPjVKwbS5q/Xr9ruxUgNu7RSwgIlMKV/7dfrsH4COgfCO donXGUNdC5VHkExWVnwRfLTGxgR2A4laMXhvOosbyTU6axpT65OQ3CulgCaIhN2utnwqiPrpayR 8+7ZmTm/fCwOXZw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168838424158500 This is left-over from commit 9fa032866da ("spice: fix multihead support") Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/qemu-spice.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 111a09ceca3..59a68cd9833 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -33,13 +33,6 @@ bool qemu_spice_have_display_interface(QemuConsole *con); int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con); int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, const char *subject); - -#else /* CONFIG_SPICE */ - -#include "qemu/error-report.h" - -#define spice_displays 0 - #endif /* CONFIG_SPICE */ =20 static inline bool qemu_using_spice(Error **errp) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168722; cv=none; d=zohomail.com; s=zohoarc; b=T5Gmd6Zg6Jw+/vDinS+XK16g+gICsE9VlDaCl8RUQKmgNgja1pE1HQed1De0VVRzGgMmdPdwof0RE/5eO0gGtjLFCAcR8A0Ej1lPqS0s+916GHkCeyya1VMDqxEbhMQG2I79ZBXzxhvvmQgtp8LqOzDSaVXhngquujhq7tp+Q8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168722; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wtIuehbACikmtRzKeZdlKQjVgxJxCKBEgIXdRAX00X8=; b=cc/NlyOIbVxwKh+XsatfWIDmGVdveWBgb4vvHK2dI9M9+Eg94o+JCX1NFT022uEnPiOpNktpVjExo7b7y4tY7pDESZxkyJkuboycJIMEz9nPP11dBVKCX50zLIsbxt68Z7pvJKw5P8wbMJBSUT4YUvUgajOCTS5BoY8a8Xbel8Q= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17811687220341020.6193103847771; Thu, 11 Jun 2026 02:05:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLa-0002Sr-0d; Thu, 11 Jun 2026 05:05: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 1wXbLY-0002S3-6I for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLV-0004od-Q7 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:07 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-RcJESy1cMOmkz2_yGKugaQ-1; Thu, 11 Jun 2026 05:05:01 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8E2A41944AB0; Thu, 11 Jun 2026 09:05:00 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3A4521954B10; Thu, 11 Jun 2026 09:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168705; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtIuehbACikmtRzKeZdlKQjVgxJxCKBEgIXdRAX00X8=; b=aUHnZdW7l7ifOIqE8goVcgCZ18wEGBceDY4I2zEhwO9YRJjkuqyyrzjH6NuKRGnzFpzpO2 msNxfMkWX8rcyYU77Z8mzTczwWnXYfLVFnK6TpzfcTuglrAqMUY7MC0yf0zgjDlM9Xb4vr Kw+pimxAhctXnmBZ9BKEQ7XZZbx2YBM= X-MC-Unique: RcJESy1cMOmkz2_yGKugaQ-1 X-Mimecast-MFC-AGG-ID: RcJESy1cMOmkz2_yGKugaQ_1781168700 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:30 +0400 Subject: [PATCH v3 15/35] ui/spice: add cleanup on shutdown MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-15-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=11898; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Ye9+Vgip4vwm6KSxEBhJWhIpcEVibFM6TefqtVC4tZc=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnfeEQvYnpMGEXEZYs66aGUELJOCvuTryLjN L/gcIjW3aCJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5cTtEACatc+SM8skmUNdHvxeEcFjgw3yHl9M5qpIVN5tXJtiLc0gZFAxSNjrsx2g00sXpRmPGsQ dPsWqMZ8IL0oIWJGdzkQNkywzzMddT7Pk5rAvjQ6PP13PykdpB760DQ3XSomslMhVI23bh+NzBQ 0oUifK/tz/ra5Xq9AuGbp0hRlc3P7uB4RgVE3rXXUL6bcM93I7or5wUIzcbQgyEzO1ZUUFcHJ/l zum/6Lsc91ItmAWhKALRFEbA3yN8E+Bgaxj9dq246E1DShe7BGSikV94JpwXe488VzCLQbqAvwF rMbJS/zNR5r4te+7kPu9VLGr+MuCT8WxAcu03CjrFRnHMLK74uP/BoP3BphAuJCO2K7huxHZODV RPvkKfG08anolC0sJRn6Hx36zSi7Uiljp6DiKp9lAHekjZwd1nwrDMQ3SZZHlfMn8C60RUW9fGM mkIZlRHsyHGw3TKAgEFrPGn4K4QWMbtVmQqNefLAUoY9QJaKM1jkEn9HmW7OTzccvFU1Y4hG8Qy dRVtwJ1+VEpVDDyqXGx0uWXa/wJQY9eUR/tW5UNRQDH9JrOR14AJ+0kHj2GiH5JknkzMl/PS4q6 i0TaD6TXVaLk06H25Ib/MaYa0uSMxP1U/IQ/vUVcnVQR5/MXlxEV5W5V533XjUMG9GjoqpzQllf uoO4944s1B4HyFg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168724084158500 SPICE resources were never freed on shutdown. Add per-subsystem cleanup (display, input, core) and call it from qemu_cleanup(). Move spice-module.c into libui so the qemu_spice ops table links with the rest of the UI code. Add an LSan suppression for a known spice-server leak. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/qemu-spice-module.h | 1 + include/ui/qemu-spice.h | 2 ++ system/runstate.c | 4 ++++ ui/spice-core.c | 25 ++++++++++++++++++-- ui/spice-display.c | 52 ++++++++++++++++++++++++++++++++++++++= ++++ ui/spice-input.c | 52 ++++++++++++++++++++++++++++----------= ---- ui/spice-module.c | 5 ++++ scripts/lsan_suppressions.txt | 5 ++++ ui/meson.build | 4 ++-- 9 files changed, 129 insertions(+), 21 deletions(-) diff --git a/include/ui/qemu-spice-module.h b/include/ui/qemu-spice-module.h index 072efa0c834..bb0f8437c26 100644 --- a/include/ui/qemu-spice-module.h +++ b/include/ui/qemu-spice-module.h @@ -26,6 +26,7 @@ typedef struct SpiceInfo SpiceInfo; =20 struct QemuSpiceOps { void (*init)(void); + void (*cleanup)(void); void (*display_init)(void); int (*migrate_info)(const char *h, int p, int t, const char *s); int (*set_passwd)(const char *passwd, diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h index 59a68cd9833..2cdf10f0313 100644 --- a/include/ui/qemu-spice.h +++ b/include/ui/qemu-spice.h @@ -27,7 +27,9 @@ #include "qemu/config-file.h" =20 void qemu_spice_input_init(void); +void qemu_spice_input_cleanup(void); void qemu_spice_display_init(void); +void qemu_spice_display_cleanup(void); void qemu_spice_display_init_done(void); bool qemu_spice_have_display_interface(QemuConsole *con); int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con); diff --git a/system/runstate.c b/system/runstate.c index 0e1cb3b4e67..d35fa270bd6 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -62,6 +62,7 @@ #include "system/system.h" #include "system/tpm.h" #include "ui/console.h" +#include "ui/qemu-spice-module.h" =20 #include "trace.h" =20 @@ -1048,6 +1049,9 @@ void qemu_cleanup(int status) user_creatable_cleanup(); #ifdef CONFIG_VNC vnc_cleanup(); +#endif +#ifdef CONFIG_SPICE + qemu_spice.cleanup(); #endif /* TODO: unref root container, check all devices are ok */ } diff --git a/ui/spice-core.c b/ui/spice-core.c index ef1c00134fa..1d2315f0b63 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -651,12 +651,15 @@ static void vm_change_state_handler(void *opaque, boo= l running, } } =20 +static VMChangeStateEntry *vm_change_entry; + void qemu_spice_display_init_done(void) { if (runstate_is_running()) { qemu_spice_display_start(); } - qemu_add_vm_change_state_handler(vm_change_state_handler, NULL); + vm_change_entry =3D + qemu_add_vm_change_state_handler(vm_change_state_handler, NULL); } =20 static void qemu_spice_init(void) @@ -894,7 +897,8 @@ static int qemu_spice_add_interface(SpiceBaseInstance *= sin) spice_server =3D spice_server_new(); spice_server_set_sasl_appname(spice_server, "qemu"); spice_server_init(spice_server, &core_interface); - qemu_add_vm_change_state_handler(vm_change_state_handler, NULL); + vm_change_entry =3D + qemu_add_vm_change_state_handler(vm_change_state_handler, NULL= ); } =20 return spice_server_add_interface(spice_server, sin); @@ -1005,8 +1009,25 @@ int qemu_spice_display_is_running(SimpleSpiceDisplay= *ssd) return spice_display_is_running; } =20 +static void qemu_spice_cleanup(void) +{ + if (!spice_server) { + return; + } + + qemu_spice_display_cleanup(); + qemu_spice_input_cleanup(); + migration_remove_notifier(&migration_state); + g_clear_pointer(&spice_consoles, g_slist_free); + g_clear_pointer(&auth_passwd, g_free); + g_clear_pointer(&spice_server, spice_server_destroy); + g_clear_pointer(&vm_change_entry, qemu_del_vm_change_state_handler); + using_spice =3D 0; +} + static struct QemuSpiceOps real_spice_ops =3D { .init =3D qemu_spice_init, + .cleanup =3D qemu_spice_cleanup, .display_init =3D qemu_spice_display_init, .migrate_info =3D qemu_spice_migrate_info, .set_passwd =3D qemu_spice_set_passwd, diff --git a/ui/spice-display.c b/ui/spice-display.c index e3716127203..75c7df7bb5e 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -34,6 +34,8 @@ bool spice_opengl; bool spice_remote_client; int spice_max_refresh_rate; =20 +static GPtrArray *spice_displays; + int qemu_spice_rect_is_empty(const QXLRect* r) { return r->top =3D=3D r->bottom || r->left =3D=3D r->right; @@ -1421,6 +1423,54 @@ static void qemu_spice_display_init_one(QemuConsole = *con) qemu_console_set_display_gl_ctx(con, &ssd->dgc); } qemu_console_register_listener(con, &ssd->dcl, ops); + g_ptr_array_add(spice_displays, ssd); +} + +void qemu_spice_display_cleanup(void) +{ + if (!spice_displays) { + return; + } + + for (guint i =3D 0; i < spice_displays->len; i++) { + SimpleSpiceDisplay *ssd =3D g_ptr_array_index(spice_displays, i); + SimpleSpiceUpdate *update; + + qemu_console_unregister_listener(&ssd->dcl); +#ifdef HAVE_SPICE_GL + if (spice_opengl) { + qemu_console_set_display_gl_ctx(ssd->dcl.con, NULL); + } +#endif + + if (ssd->ds) { + qemu_spice_destroy_host_primary(ssd); + } + qemu_spice_del_memslot(ssd, MEMSLOT_GROUP_HOST, 0); + spice_server_remove_interface(&ssd->qxl.base); + + while ((update =3D QTAILQ_FIRST(&ssd->updates)) !=3D NULL) { + QTAILQ_REMOVE(&ssd->updates, update, next); + qemu_spice_destroy_update(ssd, update); + } + g_clear_pointer(&ssd->ptr_define, g_free); + g_clear_pointer(&ssd->ptr_move, g_free); + g_clear_pointer(&ssd->cursor, cursor_unref); + g_clear_pointer(&ssd->surface, pixman_image_unref); + g_clear_pointer(&ssd->mirror, pixman_image_unref); + g_clear_pointer(&ssd->buf, g_free); +#ifdef HAVE_SPICE_GL + g_clear_pointer(&ssd->gl_unblock_bh, qemu_bh_delete); + g_clear_pointer(&ssd->gl_unblock_timer, timer_free); + g_clear_pointer(&ssd->gls, qemu_gl_fini_shader); + egl_fb_destroy(&ssd->guest_fb); + egl_fb_destroy(&ssd->blit_fb); + egl_fb_destroy(&ssd->cursor_fb); +#endif + qemu_mutex_destroy(&ssd->lock); + g_free(ssd); + } + g_clear_pointer(&spice_displays, g_ptr_array_unref); } =20 void qemu_spice_display_init(void) @@ -1431,6 +1481,8 @@ void qemu_spice_display_init(void) const char *str; int i; =20 + spice_displays =3D g_ptr_array_new(); + str =3D qemu_opt_get(opts, "display"); if (str) { int head =3D qemu_opt_get_number(opts, "head", 0); diff --git a/ui/spice-input.c b/ui/spice-input.c index f0bb915fd77..c975c1e2516 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -239,23 +239,41 @@ static void mouse_mode_notifier(Notifier *notifier, v= oid *data) pointer->absolute =3D is_absolute; } =20 +static QemuSpiceKbd *spice_kbd; +static QemuSpicePointer *spice_pointer; +static QEMUPutLEDEntry *spice_led; + void qemu_spice_input_init(void) { - QemuSpiceKbd *kbd; - QemuSpicePointer *pointer; - - kbd =3D g_malloc0(sizeof(*kbd)); - kbd->sin.base.sif =3D &kbd_interface.base; - qemu_spice.add_interface(&kbd->sin.base); - qemu_add_led_event_handler(kbd_leds, kbd); - - pointer =3D g_malloc0(sizeof(*pointer)); - pointer->mouse.base.sif =3D &mouse_interface.base; - pointer->tablet.base.sif =3D &tablet_interface.base; - qemu_spice.add_interface(&pointer->mouse.base); - - pointer->absolute =3D false; - pointer->mouse_mode.notify =3D mouse_mode_notifier; - qemu_add_mouse_mode_change_notifier(&pointer->mouse_mode); - mouse_mode_notifier(&pointer->mouse_mode, NULL); + spice_kbd =3D g_new0(QemuSpiceKbd, 1); + spice_kbd->sin.base.sif =3D &kbd_interface.base; + qemu_spice.add_interface(&spice_kbd->sin.base); + spice_led =3D qemu_add_led_event_handler(kbd_leds, spice_kbd); + + spice_pointer =3D g_new0(QemuSpicePointer, 1); + spice_pointer->mouse.base.sif =3D &mouse_interface.base; + spice_pointer->tablet.base.sif =3D &tablet_interface.base; + qemu_spice.add_interface(&spice_pointer->mouse.base); + + spice_pointer->absolute =3D false; + spice_pointer->mouse_mode.notify =3D mouse_mode_notifier; + qemu_add_mouse_mode_change_notifier(&spice_pointer->mouse_mode); + mouse_mode_notifier(&spice_pointer->mouse_mode, NULL); +} + +void qemu_spice_input_cleanup(void) +{ + g_clear_pointer(&spice_led, qemu_remove_led_event_handler); + if (spice_pointer) { + qemu_remove_mouse_mode_change_notifier(&spice_pointer->mouse_mode); + if (spice_pointer->absolute) { + spice_server_remove_interface(&spice_pointer->tablet.base); + } + spice_server_remove_interface(&spice_pointer->mouse.base); + g_clear_pointer(&spice_pointer, g_free); + } + if (spice_kbd) { + spice_server_remove_interface(&spice_kbd->sin.base); + g_clear_pointer(&spice_kbd, g_free); + } } diff --git a/ui/spice-module.c b/ui/spice-module.c index 7651c85885f..1961060d128 100644 --- a/ui/spice-module.c +++ b/ui/spice-module.c @@ -62,6 +62,10 @@ static int qemu_spice_display_add_client_stub(int csock,= int skipauth, return -1; } =20 +static void qemu_spice_cleanup_stub(void) +{ +} + struct QemuSpiceOps qemu_spice =3D { .init =3D qemu_spice_init_stub, .display_init =3D qemu_spice_display_init_stub, @@ -69,6 +73,7 @@ struct QemuSpiceOps qemu_spice =3D { .set_passwd =3D qemu_spice_set_passwd_stub, .set_pw_expire =3D qemu_spice_set_pw_expire_stub, .display_add_client =3D qemu_spice_display_add_client_stub, + .cleanup =3D qemu_spice_cleanup_stub, }; =20 #ifdef CONFIG_SPICE diff --git a/scripts/lsan_suppressions.txt b/scripts/lsan_suppressions.txt index f3b827facff..2dd6581a650 100644 --- a/scripts/lsan_suppressions.txt +++ b/scripts/lsan_suppressions.txt @@ -20,3 +20,8 @@ leak:libfontconfig.so # https://github.com/GNOME/glib/blob/main/tools/glib.supp # This avoids false positive leak reports for the qga-ssh-test. leak:g_set_user_dirs + +# spice_server_add_interface allocates internal channel data that +# spice_server_destroy does not free +# https://gitlab.freedesktop.org/spice/spice/-/merge_requests/246 +leak:spice_server_add_interface diff --git a/ui/meson.build b/ui/meson.build index bb01f0728e2..ca903581abd 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -42,13 +42,14 @@ libui_sources =3D files( 'kbd-state.c', 'keymaps.c', 'qemu-pixman.c', + 'spice-module.c', 'vgafont.c', ) if pixman.found() libui_sources +=3D files('cp437.c', 'vt100.c') endif libui =3D static_library('qemuui', libui_sources + genh, - dependencies: [pixman], + dependencies: [pixman, spice_headers], build_by_default: false) ui =3D declare_dependency(objects: libui.extract_all_objects(recursive: fa= lse), dependencies: [pixman]) system_ss.add(png) @@ -65,7 +66,6 @@ system_ss.add(when: pixman, if_true: files('console-vc.c'= ), if_false: files('con if dbus_display system_ss.add(files('dbus-module.c')) endif -system_ss.add([spice_headers, files('spice-module.c')]) system_ss.add(when: spice_protocol, if_true: files('vdagent.c')) =20 if host_os =3D=3D 'linux' --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168821; cv=none; d=zohomail.com; s=zohoarc; b=KLBmAI1cHssBWxma0Ex1jxvwwaPetqmni1jSQo6gIaK6RIry/yW3CcL8XBQ4RdI15QQ5lQzbOuaDhRsgIUem4GF/hzjvYRji6sNeyZQyEO5mEQ1VRxou/uGUUiGpiJtGaAg9UGC5g3z1zipgMKv8T6ib/aPanNqCTZFolsPJk3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168821; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mBrMf6sgce6eqalfbiLawauqWyu0Pfl9VQff8GIECLs=; b=aNqnaS3/WxmTUF1DndA9PpVIrVlOHUDbvQ3AsQVgRAtGIW2xOtrvTpfIP04JV8KKuH05zoYLvhax1w70tPrR0BoIIl+WqS09HfZMekqfDZrCKSNs540npNkZxYVNFQG1CDn/t25ca2j0yvEAjyqzdX3tvbFo7JH7YFSrFXC4sPI= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168821634574.80747113003; Thu, 11 Jun 2026 02:07:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLb-0002bj-QQ; Thu, 11 Jun 2026 05:05:12 -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 1wXbLa-0002Vj-EL for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLY-0004p0-O9 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:10 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-We_ee5WyO863Vwp-monISQ-1; Thu, 11 Jun 2026 05:05:06 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 66CAD1800591; Thu, 11 Jun 2026 09:05:05 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 762253008B34; Thu, 11 Jun 2026 09:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168708; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mBrMf6sgce6eqalfbiLawauqWyu0Pfl9VQff8GIECLs=; b=KfP7k55DarGxijoMuXWOSQi34nzqSdVVCKbubdB1yU4TEPdJVH+dNnRNA/N/9gkuxDhqnP 9bZ1VgCyQCG4oIorcJe+BrmC2aRHkibWgf5WcYa1fXzEcwYIoGU5S9jm3cGDjcltSeG6rJ MXoJCfa5VGPEOLjXdatIlmDj/7nrGK4= X-MC-Unique: We_ee5WyO863Vwp-monISQ-1 X-Mimecast-MFC-AGG-ID: We_ee5WyO863Vwp-monISQ_1781168705 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:31 +0400 Subject: [PATCH v3 16/35] ui: add display cleanup infrastructure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-16-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3294; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=lwX43CcKsWPglzBRxIi4xAYVtk1qkhgPHDupwvecx6A=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnfUQzBhIHyAdF99G+/IXkXobrUr6LlEgHUw nJpoxSjv4GJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5WJOD/0YHO3hmtGgBJ2aUUwI3GDwq70yibHqNgShIgCz5sE7dPpxYktVGisWB6jjdKK6PONpktY 6Qrh74dlOrmsTHiUuhe5/xVvDttcDJwI3ha7n7Gc5MlIBpFKG7rAom/bxcsj+IBWCULqGxLPv7Q bZn6Pfdkn36m95jPLH1I+Xp+U9ui4nvuWCIEEovvKhZStQER6STvTLgjzuTU2x/iF3BI9uqlupY m2jHq2TxjMjhizhmVZsivuKW+pATNgm9DfMHJ+c8jiyBCJU1GCFN5FHiWjEUbaJ66Mm+IObCm3a aEHG/cdEIPEDINxeTWtYEO/U/5P39QFD+56d2LUDgLzc6VGhGW5gEgCubJXn7yzZba/5PeczJIW 1KyY+KHbzkGxKP2pTXFY2ybjD3AP5wC55uytc8aiUgef7sDXLtn70kPFeBUrtbcDze0GUDsSWXq 0EFndz5lmU6tB18ht8JMFwOcBoKB17lwmGXiPiiEZXTwvPX3yvYEPNDwORQjJox4vur6Iibi56I ToSIo5QIQOlHx2etsEP3kkw1cx6KvP8oqIMKGg92cIzzWF9pwQ0NNPQzhVl305sGOB1uzELkBhn +gwiGl1O0NtoH9G7GyfMHwcPGjAgx1SykY87kvnRfeJlcqUrvAG7uir4VNBNvIE9c/sjlLaeS8H ikZALUPOyTkyfbg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168822666158500 Add a cleanup callback to QemuDisplay and a qemu_display_cleanup() function that iterates all registered display types and calls their cleanup handler. Wire it into qemu_cleanup() in runstate.c, replacing the ad-hoc vnc_cleanup() call. This provides a structured alternative to atexit() handlers, giving deterministic teardown ordering and making resource leaks visible to sanitizers. The cleanup should happen before user_creatable_cleanup(), since some display have weak user-creatable references to cleanup before. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 2 ++ system/runstate.c | 8 +------- ui/console.c | 20 +++++++++++++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index a31c5a4995c..1c7f7e62c1a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -430,6 +430,7 @@ struct QemuDisplay { DisplayType type; void (*early_init)(DisplayOptions *opts); void (*init)(DisplayState *ds, DisplayOptions *opts); + void (*cleanup)(void); const char *vc; }; =20 @@ -438,6 +439,7 @@ bool qemu_display_find_default(DisplayOptions *opts); void qemu_display_early_init(DisplayOptions *opts); void qemu_display_init(DisplayState *ds, DisplayOptions *opts); const char *qemu_display_get_vc(DisplayOptions *opts); +void qemu_display_cleanup(void); void qemu_display_help(void); =20 /* vnc.c */ diff --git a/system/runstate.c b/system/runstate.c index d35fa270bd6..18e585be47f 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -62,7 +62,6 @@ #include "system/system.h" #include "system/tpm.h" #include "ui/console.h" -#include "ui/qemu-spice-module.h" =20 #include "trace.h" =20 @@ -1046,12 +1045,7 @@ void qemu_cleanup(int status) audio_cleanup(); monitor_cleanup(); qemu_chr_cleanup(); + qemu_display_cleanup(); user_creatable_cleanup(); -#ifdef CONFIG_VNC - vnc_cleanup(); -#endif -#ifdef CONFIG_SPICE - qemu_spice.cleanup(); -#endif /* TODO: unref root container, check all devices are ok */ } diff --git a/ui/console.c b/ui/console.c index 58f29e82c85..1fe3e3a3a6c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -42,6 +42,7 @@ #include "qemu/memfd.h" #include "ui/vt100.h" #include "vgafont.h" +#include "ui/qemu-spice.h" =20 #include "console-priv.h" =20 @@ -575,7 +576,7 @@ void qemu_console_set_display_gl_ctx(QemuConsole *con, = DisplayGLCtx *gl) { /* display has opengl support */ assert(con); - if (con->gl) { + if (gl && con->gl) { error_report("The console already has an OpenGL context."); exit(1); } @@ -1414,6 +1415,23 @@ void qemu_display_init(DisplayState *ds, DisplayOpti= ons *opts) dpys[opts->type]->init(ds, opts); } =20 +void qemu_display_cleanup(void) +{ + int i; + + for (i =3D 0; i < DISPLAY_TYPE__MAX; i++) { + if (dpys[i] && dpys[i]->cleanup) { + dpys[i]->cleanup(); + } + } +#ifdef CONFIG_VNC + vnc_cleanup(); +#endif +#ifdef CONFIG_SPICE + qemu_spice.cleanup(); +#endif +} + const char *qemu_display_get_vc(DisplayOptions *opts) { #ifdef CONFIG_PIXMAN --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168847; cv=none; d=zohomail.com; s=zohoarc; b=XPMnlfuq16HR3h2JP/kqZZDs1Lgg+ElEGXbXw8Dy7ZopEoTjm+zWQF+uGaip5zXYKkLfdx3VgOvIv1vuwxUeA136HCdAyuCru6qvZoUYyduhtezM7N5yK/I0PG+/xHXJsbUVYfoioPnGX7p8Z3KTAklMc/953+bFInIjOfSPHng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168847; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0slAZr5wYvHwbne6mZ/zPGy2Lj/fJ6NfvG10inQysxA=; b=MUyOOlGPeKbXCPT4GD5jy8ns6XUft2quJUCs3dKetMQACkgtj7yb9QjJmaHTHyDNhOlWudXrmLf9sKsgnOkQbb1P/oaoMg/yiSPr9I3sD3SVZSLuIfseA4X02CUPeT1xk2oua2N1KFVNsCx3pLq3Zyv4tWrDyc7gV6g1A6nPPzs= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168847162161.05279745147539; Thu, 11 Jun 2026 02:07:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLp-0002xe-SD; Thu, 11 Jun 2026 05:05:26 -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 1wXbLg-0002nD-5P for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLe-0004q0-Il for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:15 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-4OFE46a2OiemkWZbqu1srw-1; Thu, 11 Jun 2026 05:05:11 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 895001955E89; Thu, 11 Jun 2026 09:05:10 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 894361954B0E; Thu, 11 Jun 2026 09:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168713; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0slAZr5wYvHwbne6mZ/zPGy2Lj/fJ6NfvG10inQysxA=; b=K5CUgyd1yyQ7M6lQZ+V7IByM6j1lWsne7IJ//6Rz091Mige0S+GlFIjNjar29IyEeSLIYM jywkH7hfxJjm9Heoh/Tc7X77rkOOxugNYkbCl0+sgwvy2QgqfkHVAV2YJ5s6a9Ij91EwGv BVguvCxddgY/eOBWAF+jX1vCIjsPGO4= X-MC-Unique: 4OFE46a2OiemkWZbqu1srw-1 X-Mimecast-MFC-AGG-ID: 4OFE46a2OiemkWZbqu1srw_1781168710 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:32 +0400 Subject: [PATCH v3 17/35] ui/curses: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-17-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1612; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=CrS76SW/HLMQ3iT1E5F2L0lWK5WfDn5ZaHj1Iew5FR4=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnf9yoSDjrQ4SM0UOLWZ8LvR5gsDuonYelbf A2zcfDL/u6JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5bgKD/91LPETvwvTdWqbMIg0W2Sidt4Z1F3MzekuTuo1gerYwgrT5R9Cx8sn+XijOXnbkIDUi0l KNwuEDwXU6gmorFRo65j+qunp0sRi0q104vqAK0AmvQh9QgbYntMCW/ZNH5q8Ni6jghTBEp89FD BJ6eUGQ5q67rSiuB73jng2sFaTrTdPZ2rYZ75FaRc2R8liTcFVrf9hY4tZw09zslG+Z0K5sKzz6 aXGZTP6cCWjHsgbSxlc2GVp4EOr5hkxd/XH/GbIayLaYp1SScJkYHh8dX8CIQcbowlkOQLDjK1V ewZg8bG824dLy4MnGpKJRSt+xZBvZJpJl6jMw+IKDgV6EMf4eFhd8T6urCEHMeyS4VEW6B539Zr yYnhDXhiHmIq0asSzUGmKtPbW1vkpD26lr6+QqDo/2pYNf5M5tHLzY3UOcLFulXQqy6QnZP2CU4 5asMQx75zXQVXLWKh/luXt0g3HUu/FUAbePNpRF1vUmE2eY4mIZ+jeU8jbL+/4SM5aYRa+znjnN 5aFD/mE2/RsYlBvpy0Y6gJeNpgJpmZV9odkkM4JoGnaagrsW4CG1E1VkxaTIpm5XvGoIeLdnEml sA/RvsmolxH8ToVB90bLEuxND5zW3mc4bD3UFsGCdEkj3shORl1clbDCxgEV/cklnzJysXnGq7/ x8KoIT/ulZVMfMQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168848771158500 Replace the atexit() handler with a proper cleanup callback. The new curses_cleanup() unregisters the display listener, destroy & free the allocated resources. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/curses.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ui/curses.c b/ui/curses.c index 24d3713e57d..4db32b6168d 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -411,11 +411,19 @@ static void curses_refresh(DisplayChangeListener *dcl) } } =20 -static void curses_atexit(void) +static void curses_cleanup(void) { + if (!dcl) { + return; + } + endwin(); - g_free(vga_to_curses); - g_free(screen); + qemu_console_unregister_listener(dcl); + g_clear_pointer(&dcl, g_free); + g_clear_pointer(&screenpad, delwin); + g_clear_pointer(&vga_to_curses, g_free); + g_clear_pointer(&screen, g_free); + g_clear_pointer(&kbd_layout, kbd_layout_free); } =20 /* @@ -799,8 +807,6 @@ static void curses_display_init(DisplayState *ds, Displ= ayOptions *opts) vga_to_curses =3D g_new0(cchar_t, 256); curses_setup(); curses_keyboard_setup(); - atexit(curses_atexit); - curses_winch_init(); =20 dcl =3D g_new0(DisplayChangeListener, 1); @@ -812,6 +818,7 @@ static void curses_display_init(DisplayState *ds, Displ= ayOptions *opts) static QemuDisplay qemu_display_curses =3D { .type =3D DISPLAY_TYPE_CURSES, .init =3D curses_display_init, + .cleanup =3D curses_cleanup, }; =20 static void register_curses(void) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168891; cv=none; d=zohomail.com; s=zohoarc; b=Q0UOLaxFBaQG7GwObsn51Z8l9rJ72EbM4pmER5pVjdXAFcHggi7HW80TUl8oQJ0OdN3Htn98hrIuf0oJUVzNHpynUtQeac0/rOLS6wlJA+E4c+RBQNgqdi91j4kvZOQtwSrJtt8wK7xXddxkBAaviroqyqhANog4uBNm80OMJcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168891; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7WXhIg19XYA4431BKDjvjcmVSAPWCiVeU7ZNrGEjkog=; b=Wb/iHDznRHOAcYaNk/gXTQnV3yD8xgMqbHcrdKCJyyjoV/dSYtOjQtF9yG0zh8zarisMVCuF48wPCPDT0pqsfGRygHFPBBZ76bAt1+ZqbsBRG+RcrM9+kDHE0SUqqz87POJRUWm68u4jzv+btEX2d+7EzSHyIIbSQNR4xCPSmb4= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17811688918471005.7095788053912; Thu, 11 Jun 2026 02:08:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLu-0003A2-4P; Thu, 11 Jun 2026 05:05:30 -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 1wXbLo-0002zH-Pb for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLn-00052H-4q for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:24 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-RQoECx0KNWG5NrRiONUpOw-1; Thu, 11 Jun 2026 05:05:17 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B164C180AD60; Thu, 11 Jun 2026 09:05:15 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 61DA72ED4; Thu, 11 Jun 2026 09:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168722; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7WXhIg19XYA4431BKDjvjcmVSAPWCiVeU7ZNrGEjkog=; b=aFD1JaQxzR8jv3q0l+giof/btlldkVJm+BxX6TyamkyvrQ2An7ufFRzwUYlvjT8Aoq6sBu vpHic2vu0PYgqQrVswAq1pS3ZmNTDg6rq7Z3vBJSOkMarAZvOOyojWaoeula0tp3WCLHh4 Rz1CdRgfSv0naBf5mzM612l8o7UKoKA= X-MC-Unique: RQoECx0KNWG5NrRiONUpOw-1 X-Mimecast-MFC-AGG-ID: RQoECx0KNWG5NrRiONUpOw_1781168715 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:33 +0400 Subject: [PATCH v3 18/35] ui/sdl2: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-18-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1871; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=SWP3H5Ca5KhdDjJmOi5TL9GzYnm/xCZHZJpowaDC8dc=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnfTLI4HTPi5KG4BZAMG5qZTGeuRVscsqfzc OzL10av9TyJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5VLRD/4hN6ouA39CbUyewopq1AhY/MKBwwnNi6H5/2lGmA/LSLMTU/DqK02rVEt6ppvZXRvJO/+ YUyDLOTSBUDesZQgEaQvsPoBcPLvdnf5dUSaT4K3Lxy4WvROIGA3esLyj6zyTCDg4vL/IpV0x2h wgjMuWx5vzXIVKyq26YMtWYTh3cO1CHqkYzE5pJiTqsoWQCDyXtqAzV6ZdvNm68WEkFhgH9co5P jqNExMJgUKHEZvRamQDzkZTQDSiTh1WhpttP4f47dAsiw4kknagDnP75LVusvYTHo3iCJQEtngJ uukejRqj9//O5gXnQOuftGnD8+98NCyY95KG/n3nrEwS0f7lddd5x7D42Oxhhxf8DCYPqmt8GPK 018VsakdX3QH0mNMDLu6NyGGffs5Iq9xiDlhQh/7o+maWHjtqKWuSHhKo7CBgVZcN5nvLJcfVk1 FZvPTz3A2bnN/IevhLu3z7LX05/yGAX61fMsRSfna/JbGG/KuSenGmdGoMchnsiCeV7HvpqDE86 Ol9fN0J6cK80/uMfkyXU9iiwhUfOCrvhCtbPcMof01vsNu7pePPKt6KJoW5vffqeorVgSEIwZda ryuK45H0+afXx6K1/qH4YA+2j6sik2iVuBIYEND3nwrLO9mWPu9OMcl7npuz30qEJXxqpdBvBbM Ah1GsIMeY2iQAfg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168892768158500 Replace the atexit() handler with a proper cleanup callback. Extend sdl_cleanup() to unregister display listeners, free keyboard state, destroy windows, and clean up all cursor resources. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/sdl2.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 4fcdbd79d3c..6adcbdb5af9 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -788,9 +788,25 @@ static void sdl_mouse_define(DisplayChangeListener *dc= l, =20 static void sdl_cleanup(void) { - if (guest_sprite) { - SDL_FreeCursor(guest_sprite); + int i; + + if (!sdl2_console) { + return; } + + qemu_remove_mouse_mode_change_notifier(&mouse_mode_notifier); + + for (i =3D 0; i < sdl2_num_outputs; i++) { + qemu_console_unregister_listener(&sdl2_console[i].dcl); + qkbd_state_free(sdl2_console[i].kbd); + sdl2_window_destroy(&sdl2_console[i]); + } + g_clear_pointer(&sdl2_console, g_free); + sdl2_num_outputs =3D 0; + + g_clear_pointer(&guest_sprite, SDL_FreeCursor); + g_clear_pointer(&guest_sprite_surface, SDL_FreeSurface); + g_clear_pointer(&sdl_cursor_hidden, SDL_FreeCursor); SDL_QuitSubSystem(SDL_INIT_VIDEO); } =20 @@ -995,8 +1011,6 @@ static void sdl2_display_init(DisplayState *ds, Displa= yOptions *o) sdl_grab_start(&sdl2_console[0]); } =20 - atexit(sdl_cleanup); - /* SDL's event polling (in dpy_refresh) must happen on the main thread= . */ qemu_main =3D NULL; } @@ -1005,6 +1019,7 @@ static QemuDisplay qemu_display_sdl2 =3D { .type =3D DISPLAY_TYPE_SDL, .early_init =3D sdl2_display_early_init, .init =3D sdl2_display_init, + .cleanup =3D sdl_cleanup, }; =20 static void register_sdl1(void) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168953; cv=none; d=zohomail.com; s=zohoarc; b=RBZ9gd+5Ja7ve92s7QS01NADimNfSZWz54feqfJSIJeSBDFUWr/iJ2rQeE6B7/BLQbmn41VB+ikSkUb67hLt/3Oc4IqRYOwFvekFJ19H2uJktiCFrxlmqfMKyLjnNDDd/Q4/ZoHMFTEjvQbB0xNHDF6iBFbszvtyG2HmBivxIT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168953; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=h0vBgMB+JfoVtADoFb3UEwzuxSvcYgxQQ4fbzcKMdy0=; b=E/S++XmXhLUjZ+6oVsWYwHrAf6htrBXh4+uiszSpb54mZZX7KfCX4jfrrnwzr7KubxFJnXTDoXWCQUPhRyrFpJc4p6D94nMXl80qu6csEK/yW8GbbMUg2jdpag4VzTBOlJVE4QQPP1fpDe0ACQorGLxQ+no/2ym4fj8BG+xEyoU= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168953580770.6471675364478; Thu, 11 Jun 2026 02:09:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbLv-0003Gk-1A; Thu, 11 Jun 2026 05:05:31 -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 1wXbLq-00033C-2C for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLo-00052V-M6 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:25 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-EAHA_6XwPPGNdbQYVwJbiA-1; Thu, 11 Jun 2026 05:05:22 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 38A591955E99; Thu, 11 Jun 2026 09:05:21 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CE68319541B2; Thu, 11 Jun 2026 09:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168724; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h0vBgMB+JfoVtADoFb3UEwzuxSvcYgxQQ4fbzcKMdy0=; b=b4mes0oLgmMXvKEkiVsDOasQnS3KhdzCjhG8Jgx6ABClT8ll1lu3BFZ/zPQL6lF9dv3Wiv tF24bYGh3w+S/REM1HRkjvC5nCyBQ25JfQoBvHvRruCH9IfmbtBzhKBjranTIv2FOJF3E3 r4vvOQgDCBU77dBiSXZgLmILsJH0tWQ= X-MC-Unique: EAHA_6XwPPGNdbQYVwJbiA-1 X-Mimecast-MFC-AGG-ID: EAHA_6XwPPGNdbQYVwJbiA_1781168721 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:34 +0400 Subject: [PATCH v3 19/35] ui/spice-app: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-19-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1540; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=cpTjZniLMqEA6rNMksDOJAEvoDe9Yx6APfWnAl9Mp3Q=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnf22mO14PZ0Uv7xo1UpF5ZYXq4o6mcBF5C1 Dp8wMrQbZGJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip53wAKCRDa6OEJdZac 5ZOyD/4gUc0GILX6pM2lWI6y2hMKysbPqbSrmdN03YOQVEgJGhHxL7Z4UrSWXF8U3xeV5XIi9Op qsgEhDh+vl7qT9q8dN1HZNQXtHq1a22xDgxekJN8an7KtpgA1eAGDiIDx0uydzkXl8JkSBC/k8u 96PM5nLjkZNvZcsOWPyNE5KuNZlhwO8HAwDk3Pdq4XH3NUweGyicaC0vGpY3YtA9IcZ7W2grMm7 DoGvpb1MaNXRjID3pcfejwPAHy16SoXmMOXSqpGVHZK90bDa6UrfH17d23sYHWLhKZi2TuYax6O D1aiVcJpDHzsnzNQl9ziDnqpvTGzo2goHfqBQHcBAqiIlNQqL637SGjzu+ZqwNsSezMovmojJ2c 4IyVJv/5o/vZ3hx2K9ORW1RIm+IO8L6DBV82FCKcO8twUPNnzxgzAKSnFkq/0PAyT1Kmhne9/Lj RbiN4jfB/1X/Z8vpS7o6KNxT9FT1ViSrhgq1Zlnl6kUTioCi412W3lH18+vl7StqBwuDncrRlhT YM+/QALGlrxL8CbYQn1oh7No8PShTkSQLmcNh9VbXBz0mhEGJZFja1pvJp8rO777QHpQDnxz0wT 6CI7Wur9nuNHRss2wB0Jwg25H6Av4F1MHWFVR8mUEpAmeTK92S43k69yEydWIobwKfE/ymGDY8g YeMku/I/uoCh9fA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168955184158500 Replace the atexit() handler with the display cleanup callback, reusing the existing spice_app_atexit() function. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/spice-app.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/spice-app.c b/ui/spice-app.c index 0df7325e679..fe3df62bfa5 100644 --- a/ui/spice-app.c +++ b/ui/spice-app.c @@ -119,16 +119,17 @@ static const TypeInfo char_vc_type_info =3D { .class_size =3D sizeof(VCChardevClass), }; =20 -static void spice_app_atexit(void) +static void spice_app_cleanup(void) { if (sock_path) { unlink(sock_path); + g_clear_pointer(&sock_path, g_free); } if (tmp_dir) { rmdir(tmp_dir); + tmp_dir =3D NULL; } - g_free(sock_path); - g_free(app_dir); + g_clear_pointer(&app_dir, g_free); } =20 static void spice_app_display_early_init(DisplayOptions *opts) @@ -146,8 +147,6 @@ static void spice_app_display_early_init(DisplayOptions= *opts) exit(1); } =20 - atexit(spice_app_atexit); - if (qemu_name) { app_dir =3D g_build_filename(g_get_user_runtime_dir(), "qemu", qemu_name, NULL); @@ -218,6 +217,7 @@ static QemuDisplay qemu_display_spice_app =3D { .type =3D DISPLAY_TYPE_SPICE_APP, .early_init =3D spice_app_display_early_init, .init =3D spice_app_display_init, + .cleanup =3D spice_app_cleanup, .vc =3D "vc", }; =20 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168793; cv=none; d=zohomail.com; s=zohoarc; b=DkufasSREtyTq3OCNwjIswNAK59AORgNMCR+UDhrCSPUGT1dn5bpeNRVLhP78Y7bifNsA89q7rsAAJ/ougl6cqXoOb/wDCEAzDD48oAXMTuQD7MxtgmCsG7HFN9YrFJIcVTGK+bhLjrWaWapfxb99jcbhbtlYQAziPearPkq1dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168793; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ESuLLFwIW6j5JF43r6z1Rimzjac38Z2vjPfM1I49KGw=; b=HKpm+UDnA5zkt6hnnhpmpl1IxcpTKHHU9KUgUgEKpM2AcL7MHRfmUyKb7b5eYLtYv5sIvMtaZJF5EH3BcE8OTPl0jobD7Q3QqBnqvfDLgGvDj8eIbo1PualJ1JHVZ8sQM/zTOZ/kjXTplIChdgMKkQGYYMnGbbGTlpwwzgNrzps= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168793467515.9037789297303; Thu, 11 Jun 2026 02:06:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbM0-0003lA-H1; Thu, 11 Jun 2026 05:05:36 -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 1wXbLw-0003TO-Dn for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbLu-00053G-Gm for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:31 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-680-BHjLEu0ROO26geFFMSZf4w-1; Thu, 11 Jun 2026 05:05:28 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BA3EB1956064; Thu, 11 Jun 2026 09:05:26 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6D3EA1800351; Thu, 11 Jun 2026 09:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ESuLLFwIW6j5JF43r6z1Rimzjac38Z2vjPfM1I49KGw=; b=Zqq6AFvU+uLgQ50jqhoFfON1h1xnO0/xsALrK0cFrafJolxvXxebtagjkWyNTnzgDy6CRp PrRkqqbVmnIh6jW7DCAz3UC0kue1WzvjByH4Wl7p+s3KSuWFJWBSDasDeqTmSI+fAO1emK Hf583TwHL6Fl6pZoKwaHriPjlfY5zPE= X-MC-Unique: BHjLEu0ROO26geFFMSZf4w-1 X-Mimecast-MFC-AGG-ID: BHjLEu0ROO26geFFMSZf4w_1781168726 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:35 +0400 Subject: [PATCH v3 20/35] ui/egl: implement display and EGL cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-20-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3768; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=3wgnq3+LmSQWhX3LOCNiGJbGeShmFv6Mi0xyiipmBTo=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnng+J6gha3gyuxDZ8AfO8zV6NTGjyyvk+5EB lMLRiW95/OJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5fcBEACTzXLnNPwTvTm+5LFw5kMCEwv4aIm2/xiX2PxUmVNdWbtmktf2RFsatr6LrD0V3hy4xhw +vBg5b8NcUUcY4RkR8hqPlcu2dJQElsDWQpg1bBWDzMPJcbySKdbia+Zx8xqz9kTore0sgEVzis m6K60GXOBjLfLicN2pfC5oRd2TNSRHvQGRA6mcE+sekvgoYoQnaljHLZFXTnJFYrT77Vgp7PhFE wAFsDggk217W8F8nOxABTKMp2gRhB4+y6r74SXgxg7MBIyEY9oCyOu7CD5o+qeHL4HguU7xh+ZJ kK5OBIVC9L8xs763RTUwNH1HJe5tp4BmfY83jRWQ31H+BdOkDXAJIVhdXHx3Bcb4XJA4rt9m7mw LKpSvhCAh1TZPwtH/iHcEAwQSNOSvy+cndiBuFIQjq7jOSGS4ie6MtUmArvMfGZ1xswAAjrYXts vHA1p3JpVXdRygL42HfQ6J0lJuAb5n4hmgCs3mOk4iAOb9GBSSez4U6qipen+RkqbRhd2iVyKve M0OzMegh7ZYgPgZeMGh0Qov8LR3JrirEUuRWIirJuO9j1rUkxZNPGM/uVBjrxtskwydYgkX2HeT VsAnjy2xZRC1llXJt97S2L4ifv2DzddELbbBOcysuZ5jjNGyyPn7F881hdcuTbEwi4/h6fjikx9 FElcjrtOU4biJ1Q== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168794172158500 Add egl_cleanup() to tear down the EGL render node context, GBM device, and EGL display. Add egl_headless_cleanup() to unregister listeners, destroy framebuffers, and free per-console state tracked via a new GPtrArray. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/egl-helpers.h | 1 + ui/egl-headless.c | 31 +++++++++++++++++++++++++++++++ ui/egl-helpers.c | 19 +++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index acf993fcf52..dba788fead7 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -76,6 +76,7 @@ EGLContext qemu_egl_init_ctx(void); bool qemu_egl_has_dmabuf(void); =20 bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp); +void egl_cleanup(void); =20 const char *qemu_egl_get_error_string(void); =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 878bfebb40c..ba27efcf4c3 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -9,6 +9,7 @@ =20 typedef struct egl_dpy { DisplayChangeListener dcl; + DisplayGLCtx *ctx; DisplaySurface *ds; QemuGLShader *gls; egl_fb guest_fb; @@ -19,6 +20,8 @@ typedef struct egl_dpy { uint32_t pos_y; } egl_dpy; =20 +static GPtrArray *egl_dpys; + /* ------------------------------------------------------------------ */ =20 static void egl_refresh(DisplayChangeListener *dcl) @@ -220,6 +223,8 @@ static void egl_headless_init(DisplayState *ds, Display= Options *opts) egl_dpy *edpy; int idx; =20 + egl_dpys =3D g_ptr_array_new(); + for (idx =3D 0;; idx++) { DisplayGLCtx *ctx; =20 @@ -232,15 +237,41 @@ static void egl_headless_init(DisplayState *ds, Displ= ayOptions *opts) edpy->gls =3D qemu_gl_init_shader(); ctx =3D g_new0(DisplayGLCtx, 1); ctx->ops =3D &eglctx_ops; + edpy->ctx =3D ctx; qemu_console_set_display_gl_ctx(con, ctx); qemu_console_register_listener(con, &edpy->dcl, &egl_ops); + g_ptr_array_add(egl_dpys, edpy); + } +} + +static void egl_headless_cleanup(void) +{ + if (!egl_dpys) { + return; } + + for (guint i =3D 0; i < egl_dpys->len; i++) { + egl_dpy *edpy =3D g_ptr_array_index(egl_dpys, i); + + qemu_console_unregister_listener(&edpy->dcl); + qemu_console_set_display_gl_ctx(edpy->dcl.con, NULL); + egl_fb_destroy(&edpy->guest_fb); + egl_fb_destroy(&edpy->cursor_fb); + egl_fb_destroy(&edpy->blit_fb); + qemu_gl_fini_shader(edpy->gls); + g_free(edpy->ctx); + g_free(edpy); + } + g_clear_pointer(&egl_dpys, g_ptr_array_unref); + + egl_cleanup(); } =20 static QemuDisplay qemu_display_egl =3D { .type =3D DISPLAY_TYPE_EGL_HEADLESS, .early_init =3D early_egl_headless_init, .init =3D egl_headless_init, + .cleanup =3D egl_headless_cleanup, }; =20 static void register_egl(void) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index e3f2872cc14..a7bfb15fd88 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -733,3 +733,22 @@ bool egl_init(const char *rendernode, DisplayGLMode mo= de, Error **errp) display_opengl =3D 1; return true; } + +void egl_cleanup(void) +{ + if (qemu_egl_rn_ctx) { + eglDestroyContext(qemu_egl_display, qemu_egl_rn_ctx); + qemu_egl_rn_ctx =3D NULL; + } + +#ifdef CONFIG_GBM + g_clear_pointer(&qemu_egl_rn_gbm_dev, gbm_device_destroy); + g_clear_fd(&qemu_egl_rn_fd, NULL); +#endif + + if (qemu_egl_display) { + eglReleaseThread(); + eglTerminate(qemu_egl_display); + qemu_egl_display =3D NULL; + } +} --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168749; cv=none; d=zohomail.com; s=zohoarc; b=AHTLeMVabM8jD1DVZAj7T8USZgKNCwyzAEilUpU5mJpmZ30Xq17rK0kfsEJx/GingzNg/5rbYIiJ8HGyQVS1xPjGypSywCD/7tZWIbVQW5qkD5tzK0jNaSngRsJjlVzkX9KP3fp5RSWIqQD7zyVIeOf1h/nJFK8iu1YFnoM9C8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168749; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=M99d8mm/rcGWFplxSkYyDHW5C0as6dK08CNz+VrRrRA=; b=ggIak+M9KfFJd9AQX3adoUFtTHosrJ0DSdKGPvOn6dWVXWs6NapWe0CtvytuDb412sh3jC5sdw0Pwh5xNfpd9nrebYBWfx65Fl7VLlIF9SgiStx4M/+wBwRHu57btLuLzhS9Wd7pGkUu4y9IWmjQw0cEvrHnKDm9wD8vSaZ374U= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168749310601.2367993419138; Thu, 11 Jun 2026 02:05:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbM6-0004Xw-SQ; Thu, 11 Jun 2026 05:05:42 -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 1wXbM3-0004Hm-T1 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbM2-00056M-98 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:39 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-2NPQ23S9O6Wcb_rwAlf5TA-1; Thu, 11 Jun 2026 05:05:33 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D0CAE1805C07; Thu, 11 Jun 2026 09:05:31 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C3E8319541B2; Thu, 11 Jun 2026 09:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168737; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M99d8mm/rcGWFplxSkYyDHW5C0as6dK08CNz+VrRrRA=; b=T8xkisO+8BsxJfvEuFUTiKwnqOxJiMZIijPeaE9z6w8cNfhMZ9pNLZVtyeuTsOoyAXkIeh 1FZBH0uMg0VUqHPxCxPnHaF6IkFRsyiIel3k/RfICfMPNZoKzY9QvGaPehekbud6BQoOQZ 4soSAfykswOZcZYkJhlXxIsbTc5Fie4= X-MC-Unique: 2NPQ23S9O6Wcb_rwAlf5TA-1 X-Mimecast-MFC-AGG-ID: 2NPQ23S9O6Wcb_rwAlf5TA_1781168731 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:36 +0400 Subject: [PATCH v3 21/35] ui/cocoa: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-21-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1474; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=d2sDlDsgKSJ2TB76kf45Z764VuTYl2D5ias8y7XNs1o=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnngfInRmsGBHdnUkfYGRbSq6aI2MIQ6EAliV oLZElE3R3iJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5SWrEACjdEqMP6hdVOZZgA7nV+Sog40j1r0LJHlYDhJ6f0Ae7npXDOTOLZhe6kOUZKiBD++TC8t pFa4w8TOEkT+Nm+Fsl38tx6hd0ERiqCh1gGhcA2ZfXhs3XzLk2imctT5yV1hN1iH2xvxRvwCv6+ a9kiOwuG47F4znEyC8nrBVC33f09QMHwzMhCN1dTV2IbSFvmWVmfd6uc4E803oXyS0rKgzN2v/V xG2+O63e3guE2Rb5O7Rtus1p4eo20usMPDdKKFMKvj6/GU07AhN2sxWcVOpV7R3mq+Rur8WNvip pp5Ks97cA/PsjmAZ6ARQZpOF3Vtqdq8MtGkvNaG7Pt0Am2TQsuK1OrKyZDj8Y8arIfINPxdQgyn D6v4GTtZiTdEv4jWb1C1j/xTi92rvltZtG3NgyO0LFwfAhRVv+AY0VzkefIrwhKYJ92oAZtQLAK jZuSRWpgHbvF2iUGZd1J8MExdcYqDS38KOVtPYftxHtm3Z+qeDLuO0s8IAefRHFDFvhEnNNEv6V idIBtu2X+gjeYveW5kTou9Ms6bPXTqlvycYXUQX4FS6sRa/ejVHw7Oc9j4wbA4GfwQ+CPwW5OhM OK2lgUbOuA9tPxcAmfua8sHglYh0FriaYXuiq9ZPOVNbXSu04d6kiCho5jN+pMrSdIaTYDUfLgG XCDhGFKoSAZsBaw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168749886158500 Move cbowner release from QemuCocoaAppController -dealloc to cocoa_display_cleanup(), since cbowner is allocated in cocoa_display_init() and cleanup is the symmetric teardown path. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/cocoa.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index c5e639ab98d..bd0c5c6ed9e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1331,8 +1331,6 @@ - (void) dealloc COCOA_DEBUG("QemuCocoaAppController: dealloc\n"); =20 [cocoaView release]; - [cbowner release]; - cbowner =3D nil; =20 [super dealloc]; } @@ -2163,9 +2161,26 @@ static void cocoa_display_init(DisplayState *ds, Dis= playOptions *opts) qemu_main =3D cocoa_main; } =20 +static void cocoa_display_cleanup(void) +{ + if (!kbd) { + return; + } + + qemu_console_unregister_listener(&dcl); + g_clear_pointer(&kbd, qkbd_state_free); + qemu_remove_mouse_mode_change_notifier(&mouse_mode_change_notifier); + qemu_clipboard_peer_unregister(&cbpeer); + g_clear_pointer(&cbinfo, qemu_clipboard_info_unref); + qemu_event_destroy(&cbevent); + [cbowner release]; + cbowner =3D nil; +} + static QemuDisplay qemu_display_cocoa =3D { .type =3D DISPLAY_TYPE_COCOA, .init =3D cocoa_display_init, + .cleanup =3D cocoa_display_cleanup, }; =20 static void register_cocoa(void) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168903; cv=none; d=zohomail.com; s=zohoarc; b=IxdHeTZEgRmN7pLWVPQuwNZOchjLYHw0ARaJChGmIjy3PHYpnsoqaRnJ/ncTMM2BL5L7lkdHRGQ5ZdGx8xr/MO2X9KfKWH8sNvVsDmKg+kG/tSGIrHZHR0YvdLdsIwOtTd9coFZqv8uNQu1YEp6pb/ylYNRnneZ1ORhTWVga+4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168903; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H3G+Z9C/f5p90NyI5uU870dyyh7DrtQUmLbu++czPQg=; b=W/jn9DC0aag7iQivS6+8v2jfsZsUN3jJv/iFCIOjcVN1R+/SUDFI3XeaefMSplBa7B5JWe7gjetmLwRa9hdo/hhJ21BBLbyiKr9XK2QgmyTn1OSSdjipKVyphmJdArVieL+RJkwTg009wrxbOF/EyKAH6faNx/nl3L8QlSiTHg4= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168903832448.19468467068293; Thu, 11 Jun 2026 02:08:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMA-0004m0-4i; Thu, 11 Jun 2026 05:05:46 -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 1wXbM8-0004dD-7k for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbM6-00059E-MN for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:43 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-K06Eifz_OqKkGew1DdmYcA-1; Thu, 11 Jun 2026 05:05:38 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 331501955F20; Thu, 11 Jun 2026 09:05:37 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D7D7F27A; Thu, 11 Jun 2026 09:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H3G+Z9C/f5p90NyI5uU870dyyh7DrtQUmLbu++czPQg=; b=UJQh0z/J4Bz4AJk8Q9I6dPZ8temUSvKSqvcArlUxzsSwiZCoVxdwcqpkSJSa5n15Wiym0y EViuaeYd0gavoN9QN1GdLviwhgm3vMfatLE96fmQ5L+kf/0VR1hMWr3KvSkFbHGM/TOkbu OlRRs4WTiibOnRx+82S24rMJDmOk4wM= X-MC-Unique: K06Eifz_OqKkGew1DdmYcA-1 X-Mimecast-MFC-AGG-ID: K06Eifz_OqKkGew1DdmYcA_1781168737 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:37 +0400 Subject: [PATCH v3 22/35] ui/dbus: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-22-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1581; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=pi+9APeT868BBLg7deiC9tV8dSRWZVksHDtFnOyZ704=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnngKiWILcZt6HNnBcYT9NUiY1h+TkBq0avud jGvr5Lt/Y2JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5ad6D/4nhjThoDRlweuhBnmny4UsV0CExe39sAyGbmPxKXZFfEZHqIR5Aaq1M1Jt6N1H2u7Ga5K RVj2JjLKEmWrCxS6RhYXKgh4NyAQdEwro2BgWCG4hIsN4gUlyJjd7bG08wSbxBsyfsIlsji8XKZ 93L1B5yYZM5PtoSRxJHtIHSo7RJJYDhvFNEP4FvdiTTgR9Ds1j8AiWvDNzBPsufOCk+/xag5VPU vBSGsopnX4w3Ps2O87cMtd2gN2HQSeIgbgzwnjUYOA5/HOihc1bKDkbiufFz1rSa/Wvo+chSw91 LdNdJ3tT3ttwZapHLmcJmZy0j0X5QACEZc/5DmYhMNZs+uzkJhv9PdIeqjdcZW2NQlRcEqYJjza EMEr2LcU7OTHtcEhk2kOLRZkahCcZFaMzkx+L/r8a1n9h9FXCVyUJpBclUGixAX79dNVOhVpcUd UUsyRIF3VgaiRtGxEgLsuYB+A3afEfudCSslUz8sdWIcTBFKAeMqw1OSf4lpBV5hurVxazhJTdx UHQ20QydRwQFmmtANhoFePXtpL9Sj9CSBYh6FzpGuWMRJMYeLFBRS9eELBLK8kxcZ+XZrw7FdHa YR4CuCxOv1EzFwBVFPdl84p/m0gwTkOotpA/7Uf7qovNyToWIrDsficlIsBqNUxibcPLb/+dxwc XRwcQuJrMa05IGQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168904828158500 Add dbus_cleanup() to unparent the D-Bus display object, ensuring proper teardown before user_creatable_cleanup() runs. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-console.c | 3 +++ ui/dbus.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 742bf9639a4..63d21493101 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -152,6 +152,9 @@ dbus_display_console_dispose(GObject *object) DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); =20 qemu_console_unregister_listener(&ddc->dcl); + if (ddc->dcl.con) { + qemu_console_set_display_gl_ctx(ddc->dcl.con, NULL); + } qemu_remove_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); g_clear_pointer(&ddc->kbd_leds_updated, qemu_remove_led_event_handler); g_clear_object(&ddc->iface_touch); diff --git a/ui/dbus.c b/ui/dbus.c index e02a94df2f3..b23cb44c535 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -615,10 +615,23 @@ static const TypeInfo dbus_display_info =3D { } }; =20 +static void +dbus_cleanup(void) +{ + Object *o; + + o =3D object_resolve_path_component(object_get_objects_root(), + "dbus-display"); + if (o) { + object_unparent(o); + } +} + static QemuDisplay qemu_display_dbus =3D { .type =3D DISPLAY_TYPE_DBUS, .early_init =3D early_dbus_init, .init =3D dbus_init, + .cleanup =3D dbus_cleanup, .vc =3D "vc", }; =20 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168793; cv=none; d=zohomail.com; s=zohoarc; b=Sl4cg7eL59NXItMBIAtmRiipvzV18c24gQY7ldx3B/9IU+Gbgme8NCOjxtnhJeYQhI2E0/fVjtqLCxJ5MPNOIlr2HbTB7ldyzLwAuet8zPv5PKQ6G6aU53l0GG5rYpzqR6l5gg47gwUmGO2dAWAIp8j08K/3xha7FEOb4AAKke8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168793; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tKlxCGNKs0kk4ALX1vXp/DYEb4dpEwlOWrBgQleDG7c=; b=RaZ9tCRDQ6M29AdfC+KZdFV6Dh2la/A13kt9y7f1OqskndsNA9FkjjZtFGZqCq4OjtiABJMjy01QWPPzgYary3JQ4JJL3XyluB8YEdg1BcpiJ8ZjVE4HLN1A2XK0USpoMmUTRfeUNe3Il4bMS3n6xE61rGVi8DGVyKypC+ygy54= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168793467488.11627783673543; Thu, 11 Jun 2026 02:06:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMF-0005ES-Be; Thu, 11 Jun 2026 05:05:51 -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 1wXbMD-00058S-M5 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMC-0005Az-0m for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:49 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-161-ZrJZQHXBMQmVfPQTwyeVCQ-1; Thu, 11 Jun 2026 05:05:43 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 947C91802170; Thu, 11 Jun 2026 09:05:42 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4FFF43008B34; Thu, 11 Jun 2026 09:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tKlxCGNKs0kk4ALX1vXp/DYEb4dpEwlOWrBgQleDG7c=; b=S2zpsvDh38SO93grwAfvjiui/5394d95Jc6qeXGhD4TsxJW+O7UirKQJjMZ8RUBVsaUnem qTG6EJcfZK0LfIwLc95pDvxn49nLDWSR/smFrMaTUHipSYPf+anUQ8gM99QANE7VMWhURq 2rtqv9qDQBsAyEVsCuo+tmD33ggTps8= X-MC-Unique: ZrJZQHXBMQmVfPQTwyeVCQ-1 X-Mimecast-MFC-AGG-ID: ZrJZQHXBMQmVfPQTwyeVCQ_1781168742 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:38 +0400 Subject: [PATCH v3 23/35] ui/gtk: implement display cleanup MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-23-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3764; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=+DG8xB4KJmLQS3EpZUbBQpkZhWCN+8ypFWbdujyuWPI=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnngr+N9u4sRqPhZrsRj/RtBI24fTQRU7DDt5 mKytcqg8U2JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5Q6DD/0RV3QQIuVBtTFRFNc8h4YAAUP2NgMSzNm3nitsj4ITdJ29Cx77YuzD+NDniYAocY0bVef XhZgsyzXM6zkWBkWASafj+Ck35dvJ0Cp1K5REq6EFLHDCGLfM6PTAaDAw1I9A7lPIB1Hzk30hPU Z/S+RUEfiPYtN5rJZxXRaEX/dXHXTwQkuijU1A9ZIQhjYuxp74fy6TP8q+b1dRoET3MWA1husYL bBtA9dLgwpWMCI1QVVxx2SfSRqM6xVecorffAyZ75lMcP5UFh7ohcLpeUrKJV2A8zx1QRVke8hM /j84ETxqzDX4NyPDg0QZp/zfvwVpeoodkoKkeD1wPdnogo7b/dnkJp+Ad8HefEYkEJSVm2H8rlO FRtVQ9WT8GFPXRpMB0x4Sq9odmFmM17OkHNDkk8dHcCje7nIWBlFLFcAEddMe7bU3RCORIE8PJL fIBKiWKHlW3hyGLYAgOFLKjfd9x0ororJ/uSKe07GYjLv+ws9soSP2+CPCBcSs4EfUgHxZEhe8U nl49HWmuIcmnbsD4OhkCPx47IZRoasIcaw+p8P3j3zEBpq55uQTAyPTX5AjsllLkyO+JpCDUQT3 f1e5gCtveOuS2k8fslGrcPj7hgwugCe3xXybJwzBJ0L+WWRReJiAwXaWLV/brAg/xYxdIxa2BSR PKWKGIhOkj4tKMQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168794229158500 Add gtk_display_cleanup() to properly tear down GTK display state: remove console and mouse notifiers, unregister clipboard peer, destroy the main window and virtual consoles. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/gtk.h | 2 ++ ui/gtk-clipboard.c | 15 +++++++++++++++ ui/gtk.c | 20 +++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 3e6ce3cb48c..f4c8e6a9f00 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -140,6 +140,7 @@ struct GtkDisplayState { =20 GdkCursor *null_cursor; Notifier mouse_mode_notifier; + VMChangeStateEntry *vmse; gboolean free_scale; gboolean keep_aspect_ratio; =20 @@ -225,6 +226,7 @@ int gd_gl_area_make_current(DisplayGLCtx *dgc, =20 /* gtk-clipboard.c */ void gd_clipboard_init(GtkDisplayState *gd); +void gd_clipboard_cleanup(GtkDisplayState *gd); =20 void gd_update_scale(VirtualConsole *vc, int ww, int wh, int fbw, int fbh); =20 diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index ea9444be70f..476e6b8303c 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -235,3 +235,18 @@ void gd_clipboard_init(GtkDisplayState *gd) g_signal_connect(gd->gtkcb[QEMU_CLIPBOARD_SELECTION_SECONDARY], "owner-change", G_CALLBACK(gd_owner_change), gd); } + +void gd_clipboard_cleanup(GtkDisplayState *gd) +{ + if (!gd->cbpeer.name) { + return; + } + qemu_clipboard_peer_unregister(&gd->cbpeer); + g_signal_handlers_disconnect_by_data( + gd->gtkcb[QEMU_CLIPBOARD_SELECTION_CLIPBOARD], gd); + g_signal_handlers_disconnect_by_data( + gd->gtkcb[QEMU_CLIPBOARD_SELECTION_PRIMARY], gd); + g_signal_handlers_disconnect_by_data( + gd->gtkcb[QEMU_CLIPBOARD_SELECTION_SECONDARY], gd); + gd->cbpeer.name =3D NULL; +} diff --git a/ui/gtk.c b/ui/gtk.c index 2ee826b56fb..dfef1b10fe3 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2505,6 +2505,7 @@ static void gd_create_menus(GtkDisplayState *s, Displ= ayOptions *opts) } =20 =20 +static GtkDisplayState *gtk_display_state; static gboolean gtkinit; =20 static void gtk_display_init(DisplayState *ds, DisplayOptions *opts) @@ -2523,6 +2524,7 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) } assert(opts->type =3D=3D DISPLAY_TYPE_GTK); s =3D g_malloc0(sizeof(*s)); + gtk_display_state =3D s; s->opts =3D opts; =20 theme =3D gtk_icon_theme_get_default(); @@ -2560,7 +2562,7 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) =20 s->mouse_mode_notifier.notify =3D gd_mouse_mode_change; qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier); - qemu_add_vm_change_state_handler(gd_change_runstate, s); + s->vmse =3D qemu_add_vm_change_state_handler(gd_change_runstate, s); =20 gtk_window_set_icon_name(GTK_WINDOW(s->window), "qemu"); =20 @@ -2681,10 +2683,26 @@ static void early_gtk_display_init(DisplayOptions *= opts) #endif } =20 +static void gtk_display_cleanup(void) +{ + GtkDisplayState *s =3D gtk_display_state; + + if (!s) { + return; + } + qemu_del_vm_change_state_handler(s->vmse); + qemu_remove_mouse_mode_change_notifier(&s->mouse_mode_notifier); + gd_clipboard_cleanup(s); + g_clear_pointer(&s->window, gtk_widget_destroy); + g_clear_object(&s->null_cursor); + g_clear_pointer(>k_display_state, g_free); +} + static QemuDisplay qemu_display_gtk =3D { .type =3D DISPLAY_TYPE_GTK, .early_init =3D early_gtk_display_init, .init =3D gtk_display_init, + .cleanup =3D gtk_display_cleanup, .vc =3D "vc", }; =20 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168911; cv=none; d=zohomail.com; s=zohoarc; b=DuByHgLcjBezLhgPpHj2J0/Ez6eVYb2v6jHwuxLtrQAxCacqEImnmX82W3JlCEpG+UaErUzFGpT2yA9dwKnBbQ1iBQmgvn5M6/6SlVwICQWGe/s3jwzaYkkotjYKHtHw/8wyhAny6Isk8+rppVxkJV8iGuw+8L2tsO+GdxcNhe0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168911; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=idSfeOkupul6CAnH9YIHT/7fjHiKKtjSvSj+yBGEr9o=; b=gwhSlyIVOjlYJLP9KWU9k9C4slJSAMMsEaMdL5MXmoxIxO6Jgpa0b2M6U/TZudXzjYtMWpO1GGPmMUnTJfcuiJT4gnw7eUgIenOZGaDITPLsfbTmsl9ZKJXKO0+ToNSLFpbwifSsnDR+kvS0DWd/p92c30obikMfdb7hiJrlM0U= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168911798544.0022890355933; Thu, 11 Jun 2026 02:08:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbML-0005Z8-Q0; Thu, 11 Jun 2026 05:05:57 -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 1wXbMK-0005YF-Hz for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMJ-0005Di-5J for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:56 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-658-BKLwRNSGNqiU2uAjI7W4LA-1; Thu, 11 Jun 2026 05:05:49 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D3A881955E7F; Thu, 11 Jun 2026 09:05:47 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A221D3008B34; Thu, 11 Jun 2026 09:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=idSfeOkupul6CAnH9YIHT/7fjHiKKtjSvSj+yBGEr9o=; b=bv+lupLrR95E4/cY4+IsjqYNQiRPv8adXvZmO2PH6zybE2zNI8xehTmMmMvC3wa6/OiMQ3 EJ93wk/hyoPvqhdu7jW8AoP2nyoHbaaH9Qku696Z5FJXCUVEJybDRcHsiO/GFSDlU/1rNd FcJO7ujHGNDcqgqrGNIk1WG3rmpwB6M= X-MC-Unique: BKLwRNSGNqiU2uAjI7W4LA-1 X-Mimecast-MFC-AGG-ID: BKLwRNSGNqiU2uAjI7W4LA_1781168747 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:39 +0400 Subject: [PATCH v3 24/35] ui/console: add console event notifier infrastructure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-24-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=2919; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=y/0JwIQWr7VsppBD/1tHcBRBSRlt5rwMryokCqoziC0=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnngtuxqvD9tRaqTMbqqNVpMxtoVRhOW8/jnt HSJl03+MACJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5Xv5D/9c8UPVVEoOEHHq4d7OGRwdMl+2mAL73W4CYwzCedRtNRu5wnY6DJiZqdhLigErHwWOqXi VAo/zzd3tZjLwo7WOdmzZjLNx6l4UR0Fzq/yaDLxD9RMxtTyZN9o28sSuuA1p5R+QFNQesb30bj h9TqCeRBZ8lCJ+XhJDxyxSbKmLUE2sA1dQwTR6JiAKza3hY9vREy3NTlh0Su9TbSKdp9PoUvdRP hvDc7t4WgJMSWOtnj8+mSAfX6t0/pRMi053YiDaUy6kMxCmCPnxtHOOO/KNkL3ApqM7zoxRGd+1 HHgs2thCtM6bIFlxMtuoMxwpe51PV996ctbk7ARJLSuO32WYL7Wu2IsD+ocYSVclJxoSECoplOR by7EnQk8Cdvh87wlWxdFblTU2Xqe3fP060jolhH/sjfc9j85SuNVxW2W/iU5ncvnpHRZvuVer/7 xymMLYA0WvvGuD1FtQxxmB3ZOjCEMvYfLhrBS1dxjM5Dc15j1jod1a5PcwVR+9GKHGq5szrQUao Aj6EFcDYNYBdx/IKgHee4COASpCl93D1rWOdMKAFiggZCCzzaIb8RlIEGvcZ/kiCQd0hLaLZC6n DrzESWA/6uBqcp0hrXGImZFoRQm7oZn0b0OSsnf7pViLl0GihI4bAghUCzPx5VGgQNsMO9To0Qz BxRyWIhPjw8vVAg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168912867158500 Add a NotifierList to DisplayState so display backends can be notified when consoles are added or removed at runtime. No events are fired yet, that follows in the next commits. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 18 ++++++++++++++++++ ui/console.c | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 1c7f7e62c1a..44ebc578651 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -442,6 +442,24 @@ const char *qemu_display_get_vc(DisplayOptions *opts); void qemu_display_cleanup(void); void qemu_display_help(void); =20 +/* + * Console notifications: + * Handlers must be idempotent, it may notify multiple times. + */ +typedef enum { + QEMU_CONSOLE_ADDED, + QEMU_CONSOLE_REMOVED, +} QemuConsoleEventType; + +typedef struct QemuConsoleEvent { + QemuConsoleEventType type; + QemuConsole *con; +} QemuConsoleEvent; + +void qemu_console_add_notifier(Notifier *notifier); +void qemu_console_remove_notifier(Notifier *notifier); +void qemu_console_notify(QemuConsoleEventType type, QemuConsole *con); + /* vnc.c */ void vnc_display_add_client(const char *id, int csock, bool skipauth); int vnc_display_password(const char *id, const char *password, Error **err= p); diff --git a/ui/console.c b/ui/console.c index 1fe3e3a3a6c..76851bc129d 100644 --- a/ui/console.c +++ b/ui/console.c @@ -70,6 +70,7 @@ struct DisplayState { bool refreshing; =20 QLIST_HEAD(, DisplayChangeListener) listeners; + NotifierList console_notifiers; }; =20 static DisplayState *display_state; @@ -84,6 +85,16 @@ static bool console_compatible_with(QemuConsole *con, static QemuConsole *qemu_graphic_console_lookup_unused(void); static void dpy_set_ui_info_timer(void *opaque); =20 +void qemu_console_notify(QemuConsoleEventType type, QemuConsole *con) +{ + DisplayState *ds =3D get_alloc_displaystate(); + QemuConsoleEvent event =3D { + .type =3D type, + .con =3D con, + }; + notifier_list_notify(&ds->console_notifiers, &event); +} + static void gui_update(void *opaque) { uint64_t interval =3D GUI_REFRESH_INTERVAL_IDLE; @@ -1056,10 +1067,22 @@ static DisplayState *get_alloc_displaystate(void) { if (!display_state) { display_state =3D g_new0(DisplayState, 1); + notifier_list_init(&display_state->console_notifiers); } return display_state; } =20 +void qemu_console_add_notifier(Notifier *notifier) +{ + DisplayState *ds =3D get_alloc_displaystate(); + notifier_list_add(&ds->console_notifiers, notifier); +} + +void qemu_console_remove_notifier(Notifier *notifier) +{ + notifier_remove(notifier); +} + /* * Called by main(), after creating QemuConsoles * and before initializing ui (sdl/vnc/...). --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168772; cv=none; d=zohomail.com; s=zohoarc; b=UyA4cPTTioHj2Sx8hh9SRAPh5DejKZrwigQVAWNB+HlSi7HUXuQrtUsh0EagY8RE5DHWsLnDMmNuDEa1dzG/YLxQcX5hdhugtkMu9qEqC6EhGoGzj4RrEl/7ykJcDbyQbgzeW9HJtsi91/YCSKo4AuqXSZfxJJ52I++as7WXvhw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168772; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BS5+8uDbUO8tnie7RIoFtC9U2mSiMSeu6Pam5/wgM3Q=; b=EE88PChW4ysazQddai5ATIIVUIAfcqE+3SaE92GAQfggOyMbirtphxW8uLolvv9Mcgj5FefUWRhN3o/8WchLFhIplKZxFQcRW3X4aHiAuXsAQrDPRewbu4unwHxJ/uF5cK6NaKkm12hX8ddTRrDItd6Dbem0j8FDxCxIIsJelKA= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168772266854.1917318405095; Thu, 11 Jun 2026 02:06:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMO-0005fv-O0; Thu, 11 Jun 2026 05:06:00 -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 1wXbMN-0005Zy-Fs for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMM-0005Dx-6P for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:05:59 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-339-VCkePTLoMtOZIxYDBBbg2w-1; Thu, 11 Jun 2026 05:05:54 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 246751800D85; Thu, 11 Jun 2026 09:05:53 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C31791800351; Thu, 11 Jun 2026 09:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BS5+8uDbUO8tnie7RIoFtC9U2mSiMSeu6Pam5/wgM3Q=; b=OEQL3Mkg2jcG/s2HjeSEURNe3bY34DZOENYuxNzfs/06WGomzjwTo6bXQB9trB0KVAsYZr Y5QfLxBAWOCHKKYetQHWMOnkeZe6QAeXNm35jhFwe9o5S2Xox9aASgovlVbWS970VVMq8A VZPYqyZ5xPfWk9N3BGCYYIpxqiAcqPU= X-MC-Unique: VCkePTLoMtOZIxYDBBbg2w-1 X-Mimecast-MFC-AGG-ID: VCkePTLoMtOZIxYDBBbg2w_1781168753 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:40 +0400 Subject: [PATCH v3 25/35] ui/console: fire console ADDED/REMOVED notifications MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-25-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1311; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=6hGNnrGYNd3ibRqfbbVKqo9FqKz4axEEuiTBy0WRKJo=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnngldUquYYFNJZkRmYZyhhlkaTwDKAsJ4c2j 8o1qdRRQw+JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54AAKCRDa6OEJdZac 5fpBEACQ7ANklRxneAg8PG5ki1UpNtpuQ+SicZD+jVMJAjYSREdsXxTX4O+kF7bHpBZqRxLJcms cfJnFGX4wO68l8Ks576tFedn7gXmhl2LKBoIA5Af2ZxFN5/GlB8qoMCHQiy7yvnb/+W4yUnR0dQ lb53t7j2LEZuTIcwHR1loa8ZwdELvLm6tlJKgJpHCBf8IhixvO6qfWWI5eAtZPAIjhDAdFLlJZF 7PM/Z2VHr7LgZTCJy2AQdBJJz1rnai9OUlO+o0MGkaTT6DVrFN4C2CCXRc84EG118GrL9AqSHRf HugjiPxn7hnNhtpD/Pg0cVZOrDoDhrxQqlEcXySSei2Tcv3IchZ2gTQK9uGyr/J+qpFhUHm3YF3 CVXQP6Dya8FLDH9i2XWvlOmQOJFlvI03WfUNvERNxlKcxE3EW7GdeE5ZHv8l1l93z4QzQ/o8rP9 fxzg088uU3yBbnPvHT4iynvFtscajA/hqebmY0Kjpp1giIFiMuI+wD/NUK8BqkYHgkol5QK80QZ gzDd7R9PFFOG6a+6x2pjYwt7bErk2Pns+zcruv1h296SSh9zQUOrSJo4d6R/bcI5ZYVQMmOQmf0 wyLFoSsmzsKOW8Clvk6BBHZDhbCcP5qBMctulS2IVSz/22sqKTFK3zC9w681jTgDKIxgT0NvVlP eeghKV+G1AP9pGQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168774142158500 Fire CONSOLE_ADDED at the end of graphic_console_init() and CONSOLE_REMOVED at the start of graphic_console_close(), so display backends can react to console hotplug/unplug events. REMOVED fires before the device link is cleared and before the placeholder surface swap, so handlers can unregister their DCL while the console is still in a known state. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/console.c b/ui/console.c index 76851bc129d..975eaf15706 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1142,6 +1142,7 @@ QemuConsole *qemu_graphic_console_create(DeviceState = *dev, uint32_t head, =20 surface =3D qemu_create_placeholder_surface(width, height, noinit); qemu_console_set_surface(s, surface); + qemu_console_notify(QEMU_CONSOLE_ADDED, s); return s; } =20 @@ -1158,6 +1159,7 @@ void qemu_graphic_console_close(QemuConsole *con) int height =3D qemu_console_get_height(con, 480); =20 trace_console_gfx_close(con->index); + qemu_console_notify(QEMU_CONSOLE_REMOVED, con); object_property_set_link(OBJECT(con), "device", NULL, &error_abort); qemu_graphic_console_set_hwops(con, &unused_ops, NULL); timer_del(con->ui_timer); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168849; cv=none; d=zohomail.com; s=zohoarc; b=gd0WZxDisLwz6/OpN6/cj6gL4JIL+FF11AL4I063ejG/L8D4zxmO0m4nSNVQ3Dn/QLQfhBWSHFz6x4HVJTdty3OO+wepXh9NKCJhnmSFxlAScRVaSdyRZiNAz5JxLG2Pz/5iiE0GNV7QJDdBc5cFCLy/3QuiSZ+pWcPYZqxDGfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168849; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L1PMzPwuEXW67aOzPq+tpb4RknWUk4HcTWyNDmnQBKs=; b=XdMZbVCEVuqxptDd3d5x/nNdk9vyjWwcicr2ZX339cvqZ7b4yyU0QQtc1gBHyJq0NimXi7u1Jt6XXGi4m0/qmKEvP6xBH91Vl3rB/nhdPFf1RQd6x3mljDwu1a2ezxBv1i6aK/zrrJ9v+Pv4iHOthgRScg69XSkVXyZnRTQpQfY= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168849748280.11821467068; Thu, 11 Jun 2026 02:07:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMV-00066S-85; Thu, 11 Jun 2026 05:06:07 -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 1wXbMU-000651-1r for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMS-0005EH-Iu for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:05 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-468-qIE0g4ZjNIKZ0iZ40iE9ug-1; Thu, 11 Jun 2026 05:06:00 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE9C4180ACF5; Thu, 11 Jun 2026 09:05:58 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2619D30A8; Thu, 11 Jun 2026 09:05:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L1PMzPwuEXW67aOzPq+tpb4RknWUk4HcTWyNDmnQBKs=; b=Ww7O1SIHQrUWi5c44OVuHE7EeqqH3JYL0nPNikBqdua89iHkRMJv3F4aseelmQUIIk8klh 0Dx/PpSevg/upHlFauYV+T9269NNIdyCRZk6/1mW7rCDpWukJDsT8bUe9LBQ1p3S8+4ScV Z+m53eNUaRA/DyqNQYZtElMJ/itGM6o= X-MC-Unique: qIE0g4ZjNIKZ0iZ40iE9ug-1 X-Mimecast-MFC-AGG-ID: qIE0g4ZjNIKZ0iZ40iE9ug_1781168758 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:41 +0400 Subject: [PATCH v3 26/35] ui/console-vc: fire ADDED/REMOVED notifications MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-26-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1532; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=YapQn9Mbsz473V4fTJPToKR0zvzbCFqEf4qxDOs0Qtc=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnhFSngo1bDyM927u/cfdEFlUh+pgnYfa52f ki2ZS/wu62JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5Tj0D/91jX0kbby7vaccX21/fQ1W4kVrW0XWdZnGZ0EnDx3gqw+skWlWy9O0lvHKRDYS82PhqCp 4Ly9ijSrbeiXXezCpgJVtcpz+mYj33SJD74ilBefs4tGr3e16L1Ov8JgJde9AGH+wiJVjDmphtP 3+q+hM1zu9WM9tHkAV2BM9FCJMNbUeJ6+wZIzVmPvS1AjwoRmkscyCt+J4h2j5K9FwFBdaGO2Su MIg50ozXpD9sBzf2gK4pg3E5v4Er9qb3JBY91VWhhzJ2sD8GYi232sgf/1LPMm3u5dtE9zoLr5X qjZXrmGIJkYtd5Zfeo0Ek+1VbXLz4VUoxhv54H79viq699XuaGL7jNYUPnm2b6xNJYm4mn7EU7E s/1yUSDH2S//4gXeJcCtbIKyKJbFKrJUVFEFzAVG+PUwvlwv0Rl6w/bkqR7sWmH9IrmuAi8HhIq ndDHK4U4PHf7ZlGiw419+TxorbKlxtcuxy878dIQZvpEPZpr7WmaNVDbsF5pTge0SK2dXu21Yhs JLVn06Su9GkD5dO32fGQB+1GN/FIAFwB/NzAy9Nrnw5JgFl4+fvS3wgM73dFkuH6EG3e9ge0YOG iU9Klf/c9LCMm0ghJQ5MPCeEdNCcAP4aEAygfRmgsqZBZXsHxQUV8c5O+sQBGmJUEhX4Ktrj58/ vMCKfF1lwDmmFqg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168850522158500 Fire CONSOLE_ADDED when the chardev is opened. Fire CONSOLE_REMOVED in char_vc_finalize() before dropping the console reference, so the console is still in a valid state when listeners handle the event. Also fixes a console object leak by adding the missing object_unref(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-vc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui/console-vc.c b/ui/console-vc.c index 828e78c41ea..53d9e9d39b3 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -255,6 +255,7 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend *b= ackend, Error **errp) } =20 qemu_chr_be_event(chr, CHR_EVENT_OPENED); + qemu_console_notify(QEMU_CONSOLE_ADDED, QEMU_CONSOLE(s)); return true; } =20 @@ -327,12 +328,24 @@ static void char_vc_init(Object *obj) vc->encoding =3D CHARDEV_VC_ENCODING_UTF8; } =20 +static void char_vc_finalize(Object *obj) +{ + VCChardev *vc =3D VC_CHARDEV(obj); + QemuConsole *con =3D QEMU_CONSOLE(vc->console); + + if (con) { + qemu_console_notify(QEMU_CONSOLE_REMOVED, con); + object_unref(con); + } +} + static const TypeInfo char_vc_type_info =3D { .name =3D TYPE_CHARDEV_VC, .parent =3D TYPE_CHARDEV, .instance_size =3D sizeof(VCChardev), .instance_init =3D char_vc_init, .instance_post_init =3D object_apply_compat_props, + .instance_finalize =3D char_vc_finalize, .class_init =3D char_vc_class_init, }; =20 --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168810; cv=none; d=zohomail.com; s=zohoarc; b=HFnOIOvDfl8JsPASGQN/+KD1YcsbUwIYmZFnwPQTrkr7asrQYwoTSEvGWN7Mn5d+3ObiNf9AvByNz6z4O9UV5YWMn/HxhHJsbBYIw85NFGRftIQGKddZmEBoAt5IWTTXMoVJfPgtaQlIoHh1pGQSsOZinIH1bdUGdSJFNwHiUsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168810; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4OdAzLtMXCE0KbwWonpJ6vMVm6YZX4iARVIMehN4nRo=; b=YGxQ67OUaID1PHoCYiU+aH/KlplfXAyNQFtRZeE077PSxu15TNi9fLNNKPPeA61Wt3K+AQRhEtE5OHSh9g/7oAHbcyplY/oa+LUD/ks6SQRNE31PHpyqaUvTW1RAwY51G5cfJGzp19mJImSYMpeZaVTD/8u59u9IY+MK2iY4mdo= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168810622425.6128907699966; Thu, 11 Jun 2026 02:06:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMZ-00069t-Nj; Thu, 11 Jun 2026 05:06:11 -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 1wXbMY-000687-Jx for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMW-0005FI-SF for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:10 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-221-swdp4dLPMxqfDqMUPdU4Kg-1; Thu, 11 Jun 2026 05:06:05 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AB06E180AE15; Thu, 11 Jun 2026 09:06:03 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B78F41800347; Thu, 11 Jun 2026 09:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4OdAzLtMXCE0KbwWonpJ6vMVm6YZX4iARVIMehN4nRo=; b=SDNAXKcH7vyAdEvv2MHRoX757oMELi8fZ08JYbSeWIdvhntVdkIxkcj+g9J3LsMyATLIUA 8TWVpvs3UF3cxAKcOcbqcsHsA0rB3wAI7oZb946cuyhUhpw5XNB/qJezWIkyNCoRPYhHpN in2pfqr1HL7F+qwvDK+Wb0ka30anExs= X-MC-Unique: swdp4dLPMxqfDqMUPdU4Kg-1 X-Mimecast-MFC-AGG-ID: swdp4dLPMxqfDqMUPdU4Kg_1781168763 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:42 +0400 Subject: [PATCH v3 27/35] ui/gtk: convert VirtualConsole storage from fixed array to GPtrArray MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-27-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=7432; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=pYkHf4xuhYrughcwER53jaOYI+5mKVTp6HoXtiFTfzo=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnhk4rPbt5aHMiwTmhgQHbw399YLWRoTdbA/ iqzb0f8WhaJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5SfWD/0YxGaIiFa28GB//PGUd0EiYXFkSR6onOjbXMnnN9ooc71iLbNNU2YteWrwD0CjhzHXKKZ R3JPEc/oXL2c9F+WwdcaSIiZkfVBn0Sy4y+ZsoI5KjvTt7EU71szlLnrCYT2Nm+Mm5SR1PeQK+M 6aAE6cp+jT1+UIFW1+fXxejKJrz92+2rx/YXf99SHctS/VXsgVdtYOemeME5tDw4I5YZmNTXUWf qvdXWSUzf18IR/mKR4Kg2v1wXh0QVT/5p+S8OFLmeGL/BYOiHP2DULGE7lGxR5voCD8uz/yGUqx 9CyKAzDNYIK1mh8qYvt+YCX34+KwfvEDnbTiHyyGMcJwL0k8PPgC5dh+jtgL7puBU8Hn56rvOKB 0k5xBbgDah0YSGA5P8dOaSsLsNU/18NL87Lw/4NAqnzYJVvVwwb4O3wr3lLe/mVPioqa0fykBD6 znYWZTCFSvFrHMBnT2JR0SzKX0WG/dEt5U/k4fq18YoykN8m3CbF9fmx+YWdaIQU4zpbmtkh3Nl xppwzNbZ7WEpdBHERDCBWjJzsT+gJKfs8mBk5CfpjAonxNHCJrneAJGUYIbwhcO537JfC4tkD7S XHxvWbijlYTUj8aFf6lCJBq6Hv9G2UoRBMPm7JRioJL1dDFaAQYLyH1ex7SR+QnuU0wcq/xVZfc Zw9r0fKD5NeccFg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168812291158500 Replace the fixed-size vc[MAX_VCS] with GPtrArray. This is a preparatory refactoring for console hotplug support, which needs to add/remove VCs dynamically. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/gtk.h | 3 +- ui/gtk.c | 108 +++++++++++++++++++++++++++++++++++++++++++--------= ---- 2 files changed, 87 insertions(+), 24 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index f4c8e6a9f00..fb60cbfda5d 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -118,8 +118,7 @@ struct GtkDisplayState { GtkWidget *grab_item; GtkWidget *grab_on_hover_item; =20 - int nb_vcs; - VirtualConsole vc[MAX_VCS]; + GPtrArray *vcs; =20 GtkWidget *show_tabs_item; GtkWidget *untabify_item; diff --git a/ui/gtk.c b/ui/gtk.c index dfef1b10fe3..b4dcdcd9a44 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -150,8 +150,8 @@ static VirtualConsole *gd_vc_find_by_menu(GtkDisplaySta= te *s) VirtualConsole *vc; gint i; =20 - for (i =3D 0; i < s->nb_vcs; i++) { - vc =3D &s->vc[i]; + for (i =3D 0; i < s->vcs->len; i++) { + vc =3D g_ptr_array_index(s->vcs, i); if (gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM(vc->menu_item))) { return vc; @@ -165,8 +165,11 @@ static VirtualConsole *gd_vc_find_by_page(GtkDisplaySt= ate *s, gint page) VirtualConsole *vc; gint i, p; =20 - for (i =3D 0; i < s->nb_vcs; i++) { - vc =3D &s->vc[i]; + if (!s->vcs) { + return NULL; + } + for (i =3D 0; i < s->vcs->len; i++) { + vc =3D g_ptr_array_index(s->vcs, i); p =3D gtk_notebook_page_num(GTK_NOTEBOOK(s->notebook), vc->tab_ite= m); if (p =3D=3D page) { return vc; @@ -247,8 +250,8 @@ static void gd_update_caption(GtkDisplayState *s) gtk_window_set_title(GTK_WINDOW(s->window), title); g_free(title); =20 - for (i =3D 0; i < s->nb_vcs; i++) { - VirtualConsole *vc =3D &s->vc[i]; + for (i =3D 0; i < s->vcs->len; i++) { + VirtualConsole *vc =3D g_ptr_array_index(s->vcs, i); =20 if (!vc->window) { continue; @@ -357,7 +360,7 @@ static void gtk_release_modifiers(GtkDisplayState *s) { VirtualConsole *vc =3D gd_vc_find_current(s); =20 - if (vc->type !=3D GD_VC_GFX || + if (!vc || vc->type !=3D GD_VC_GFX || !qemu_console_is_graphic(vc->gfx.dcl.con)) { return; } @@ -702,8 +705,8 @@ static void gd_mouse_mode_change(Notifier *notify, void= *data) gd_ungrab_pointer(s); } } - for (i =3D 0; i < s->nb_vcs; i++) { - VirtualConsole *vc =3D &s->vc[i]; + for (i =3D 0; i < s->vcs->len; i++) { + VirtualConsole *vc =3D g_ptr_array_index(s->vcs, i); gd_update_cursor(vc); } } @@ -2114,9 +2117,10 @@ static void gd_vcs_init(GtkDisplayState *s, GSList *= group, int i; =20 for (i =3D 0; i < nb_vcs; i++) { - VirtualConsole *vc =3D &s->vc[s->nb_vcs]; - group =3D gd_vc_vte_init(s, vc, vcs[i], s->nb_vcs, group, view_men= u); - s->nb_vcs++; + VirtualConsole *vc =3D g_new0(VirtualConsole, 1); + g_ptr_array_add(s->vcs, vc); + group =3D gd_vc_vte_init(s, vc, vcs[i], s->vcs->len - 1, + group, view_menu); } } #endif /* CONFIG_VTE */ @@ -2441,13 +2445,14 @@ static GtkWidget *gd_create_menu_view(GtkDisplaySta= te *s, DisplayOptions *opts) =20 /* gfx */ for (vc =3D 0;; vc++) { + VirtualConsole *v; con =3D qemu_console_lookup_by_index(vc); if (!con) { break; } - group =3D gd_vc_gfx_init(s, &s->vc[vc], con, - vc, group, view_menu); - s->nb_vcs++; + v =3D g_new0(VirtualConsole, 1); + g_ptr_array_add(s->vcs, v); + group =3D gd_vc_gfx_init(s, v, con, vc, group, view_menu); } =20 #if defined(CONFIG_VTE) @@ -2505,6 +2510,64 @@ static void gd_create_menus(GtkDisplayState *s, Disp= layOptions *opts) } =20 =20 +static void gd_vc_free(void *p) +{ + VirtualConsole *vc =3D p; + + switch (vc->type) { + case GD_VC_GFX: + qemu_console_unregister_listener(&vc->gfx.dcl); +#if defined(CONFIG_OPENGL) + if (display_opengl) { + qemu_console_set_display_gl_ctx(vc->gfx.dcl.con, NULL); + } + if (vc->gfx.ectx) { + eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, + vc->gfx.esurface, vc->gfx.ectx); + } else if (gtk_use_gl_area) { + gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area)); + } + if (vc->gfx.gls) { + surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds); + qemu_gl_fini_shader(vc->gfx.gls); + } + egl_fb_destroy(&vc->gfx.guest_fb); + egl_fb_destroy(&vc->gfx.win_fb); + egl_fb_destroy(&vc->gfx.cursor_fb); + if (vc->gfx.esurface) { + eglDestroySurface(qemu_egl_display, vc->gfx.esurface); + } + if (vc->gfx.ectx) { + eglDestroyContext(qemu_egl_display, vc->gfx.ectx); + } +#endif + qkbd_state_free(vc->gfx.kbd); + if (vc->gfx.surface) { + cairo_surface_destroy(vc->gfx.surface); + } + if (vc->gfx.convert) { + pixman_image_unref(vc->gfx.convert); + } + break; + case GD_VC_VTE: +#ifdef CONFIG_VTE + fifo8_destroy(&vc->vte.out_fifo); +#endif + break; + } + + if (vc->window) { + gtk_widget_destroy(vc->window); + } else if (vc->tab_item) { + gtk_widget_destroy(vc->tab_item); + } + if (vc->menu_item) { + gtk_widget_destroy(vc->menu_item); + } + g_free(vc->label); + g_free(vc); +} + static GtkDisplayState *gtk_display_state; static gboolean gtkinit; =20 @@ -2525,6 +2588,7 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) assert(opts->type =3D=3D DISPLAY_TYPE_GTK); s =3D g_malloc0(sizeof(*s)); gtk_display_state =3D s; + s->vcs =3D g_ptr_array_new_with_free_func(gd_vc_free); s->opts =3D opts; =20 theme =3D gtk_icon_theme_get_default(); @@ -2582,13 +2646,10 @@ static void gtk_display_init(DisplayState *ds, Disp= layOptions *opts) =20 gtk_widget_show_all(s->window); =20 - for (idx =3D 0;; idx++) { - QemuConsole *con =3D qemu_console_lookup_by_index(idx); - if (!con) { - break; - } - if (s->vc[idx].type =3D=3D GD_VC_GFX) { - gtk_widget_realize(s->vc[idx].gfx.drawing_area); + for (idx =3D 0; idx < s->vcs->len; idx++) { + VirtualConsole *v =3D g_ptr_array_index(s->vcs, idx); + if (v->type =3D=3D GD_VC_GFX) { + gtk_widget_realize(v->gfx.drawing_area); } } =20 @@ -2693,6 +2754,9 @@ static void gtk_display_cleanup(void) qemu_del_vm_change_state_handler(s->vmse); qemu_remove_mouse_mode_change_notifier(&s->mouse_mode_notifier); gd_clipboard_cleanup(s); + g_signal_handlers_disconnect_by_func(s->notebook, + G_CALLBACK(gd_change_page), s); + g_clear_pointer(&s->vcs, g_ptr_array_unref); g_clear_pointer(&s->window, gtk_widget_destroy); g_clear_object(&s->null_cursor); g_clear_pointer(>k_display_state, g_free); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168800; cv=none; d=zohomail.com; s=zohoarc; b=V+KKGhgja4jPUYW2Q4ytlSZbUClhr/7/guGCtgvLwFdcRLTvVLjuiMKSuprgvV6HU2mKVlnpb3JflIeisZ7dn9EGvnWCXB3tf7f+ZXuLQmZzkveKsRC5iKTmNWglwdj87Z13nYfF3Y42McKMIzHAFPf63QA2L7atFmES373hysY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168800; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sg7KsGskAxUGYQuCz+J5GZpDMT7LUWwYGX21cOcPlLI=; b=UH1PSChYUVMx4l2o5ZSNZwzpKFsJi8j/VBYunyQltWwC1liBHhp9GI3aAlQ5mNDz3NU7kp2oTIPSkyKsQR+45Urx2izqyW7cPhes5Km/55YG11O3p+USa+EgnXKpHfPqUDN7OiUV5HOZaTIlKSXV0JyEGdhndMgMsz5O4nDF/rE= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168800853797.4484261469103; Thu, 11 Jun 2026 02:06:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMd-0006Br-Aa; Thu, 11 Jun 2026 05:06:15 -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 1wXbMb-0006BY-Nw for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMa-0005FY-5I for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:13 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-M5idEvZ4OMyGSIvSC8Z7bw-1; Thu, 11 Jun 2026 05:06:10 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 140921955DCA; Thu, 11 Jun 2026 09:06:09 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D611736917; Thu, 11 Jun 2026 09:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sg7KsGskAxUGYQuCz+J5GZpDMT7LUWwYGX21cOcPlLI=; b=cQS/cYnPGNAE4C8CxJY4GJBUzB9E1VyD8cTkVWbww3tlp29xTledW/da6t3riBs+sju+4Q gjiigG2U0gTuTo0Q9OR3oiuqTigC0PGdYlfDu4vEmhxnmfWVuN3mhF38cZbVFX6XR1XbUN /9s2d/vHrSwvNq6f0IjPeg6L1hn1hPI= X-MC-Unique: M5idEvZ4OMyGSIvSC8Z7bw-1 X-Mimecast-MFC-AGG-ID: M5idEvZ4OMyGSIvSC8Z7bw_1781168769 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:43 +0400 Subject: [PATCH v3 28/35] ui/gtk: move global display settings out of per-console init MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-28-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=3093; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=qAumGrHZBnM0t7kIhTqS+Wj/lvxsIp0KF4uHpXKaqGU=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnhTyWXQINAwbT02RNtuXTGCPgeAFf+faeL9 oWD+jtFSBmJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5YukD/90qVdIZwlVa+kDOjvvTWEHF6ouSLD5z7e0Pwas78hvLrD4GoYa4RsI0cIM7S6SWyXWoXV BYNTIRAs3WG7T+CRc/gVVhkfVCS0+hD4t717U3JuYQdF/vnG+TeVzHvcfrs3RcNCDcE15AK4TRK gveqQcfIUpKwmFxShD8u9/WLQYrG3E+Vn4CnkFHEq9PsjIlJ4G5HKb3FszxT791fjr2iaNYaXWB GVPIUHF0U4uZYtNRyrro8DXMrhlFDrTOYcE9in5BkXI1I2ZgPw0rBMoq63qA2tCr0+MWuom2ugg KQ16EsJB8uYNcLjJgnWcqOZTWaTh6f0nwTs9jivD3igaDLGbyn7Bx3XxehJlDxFa3kPsm7vjZaU 7uySBOYGLBHHEhQK7M4EHTPiVistW7hmiXtVivedBwGMGI2EJrFJ7rQ381PD3ji4yfq0O6TUhWM wE5I0k4e44ETEjjzSr1pcrLDOXqtNsDV9lSu5NMfmIqalkWMhSBMk6Ws2EoUxEfu0ubh/vYXoiv O6wtWsvkmZ98fB3BnOpzf09DczRAxaqdHkzs9AipSV0VtVkxkgQKll3xcJJCRfVWLT64NoytfoR pLcQ8+1R3UWq/ZpNWHKLkug243UIZPKcwJVnyGmnMjy5v/usNBiR7D4svj5MVt3scn1cwsspUne GjAKPDV3roOHZbw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168802284158500 Move zoom_to_fit, keep_aspect_ratio and touch_slots initialisation from gd_vc_gfx_init() to gd_create_menu_view(). These are global display settings that should be set once after all consoles are created, not repeated on every per-console init (where the last iteration's values silently win). Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index b4dcdcd9a44..929e4cf43f7 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2269,8 +2269,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, GSList *group, GtkWidget *view_menu) { const DisplayChangeListenerOps *ops =3D &dcl_ops; - bool zoom_to_fit =3D false; - int i; =20 vc->label =3D qemu_console_get_label(con); vc->s =3D s; @@ -2350,26 +2348,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vi= rtualConsole *vc, gd_connect_vc_gfx_signals(vc); group =3D gd_vc_menu_init(s, vc, idx, group, view_menu); =20 - if (qemu_console_ui_info_supported(vc->gfx.dcl.con)) { - zoom_to_fit =3D true; - } - if (s->opts->u.gtk.has_zoom_to_fit) { - zoom_to_fit =3D s->opts->u.gtk.zoom_to_fit; - } - if (zoom_to_fit) { - gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item)); - s->free_scale =3D true; - } - - s->keep_aspect_ratio =3D true; - if (s->opts->u.gtk.has_keep_aspect_ratio) - s->keep_aspect_ratio =3D s->opts->u.gtk.keep_aspect_ratio; - - for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; i++) { - struct touch_slot *slot =3D &touch_slots[i]; - slot->tracking_id =3D -1; - } - return group; } =20 @@ -2379,7 +2357,8 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState= *s, DisplayOptions *opts) GtkWidget *view_menu; GtkWidget *separator; QemuConsole *con; - int vc; + bool zoom_to_fit =3D false; + int vc, i; =20 view_menu =3D gtk_menu_new(); gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group); @@ -2453,6 +2432,27 @@ static GtkWidget *gd_create_menu_view(GtkDisplayStat= e *s, DisplayOptions *opts) v =3D g_new0(VirtualConsole, 1); g_ptr_array_add(s->vcs, v); group =3D gd_vc_gfx_init(s, v, con, vc, group, view_menu); + if (qemu_console_ui_info_supported(con)) { + zoom_to_fit =3D true; + } + } + + if (s->opts->u.gtk.has_zoom_to_fit) { + zoom_to_fit =3D s->opts->u.gtk.zoom_to_fit; + } + if (zoom_to_fit) { + gtk_menu_item_activate(GTK_MENU_ITEM(s->zoom_fit_item)); + s->free_scale =3D true; + } + + s->keep_aspect_ratio =3D true; + if (s->opts->u.gtk.has_keep_aspect_ratio) { + s->keep_aspect_ratio =3D s->opts->u.gtk.keep_aspect_ratio; + } + + for (i =3D 0; i < INPUT_EVENT_SLOTS_MAX; i++) { + struct touch_slot *slot =3D &touch_slots[i]; + slot->tracking_id =3D -1; } =20 #if defined(CONFIG_VTE) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168858; cv=none; d=zohomail.com; s=zohoarc; b=RDpAU7vbJJdPjkV1WONhthQAqG8OIBDKhtyQYBMz6fRyLq1m057+xoW7VpY4O8oLid2/ue5QB1lm6losiXyLV3hv1OX8Oru+vRiPNEbtjP4Iqz24lNgX831oDE2+g1ddMawu7QtePIZic4JSpAO5Oh6hCYYwdJzAP37fMh7prvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168858; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PXp6IDcQDWTnCpWDPYd10qxyz4SzrMGhedvswMrxwag=; b=jLmb/kveDJ1sxNLlwAn4WjuN9Ig3XhUB5Jgl1dB7blmfpJLcPU8nhXC0iiQ32qbMZo6pHwVkjrsdyx1G3wawimhMzvesxnigYbQmLxIdTZJLZH0Abjw00qL919rUT4VDySXjUtS4VNUWCYR2ae4qgujPJ/FOnDlrNK8oN1SSZ0U= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168858210952.7444951979113; Thu, 11 Jun 2026 02:07:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMp-0006Cx-Ho; Thu, 11 Jun 2026 05:06:27 -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 1wXbMk-0006CX-4G for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMi-0005MS-4k for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:21 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-9mZrpGpoPY62YSBKbxjy0w-1; Thu, 11 Jun 2026 05:06:16 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B416F195D02B; Thu, 11 Jun 2026 09:06:14 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5DAD731D2; Thu, 11 Jun 2026 09:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PXp6IDcQDWTnCpWDPYd10qxyz4SzrMGhedvswMrxwag=; b=RahwR32w/1dApZHhU29WdQuV+KfwyGQ4aVeEH/qppeWDW7NBsrrRYbmoI8wi4BhQGPDjbC QVzgYnZxRzIXVHE8h8lErIGrIArdw4ntv4w1EfnTYv05kJn0gtLFlKPvKyvNqmzACnO38D kOA4KF3oEf5bHtHVsSBYRWsx8oTxO/w= X-MC-Unique: 9mZrpGpoPY62YSBKbxjy0w-1 X-Mimecast-MFC-AGG-ID: 9mZrpGpoPY62YSBKbxjy0w_1781168774 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:44 +0400 Subject: [PATCH v3 29/35] ui/gtk: fix tab re-insertion order on window close MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-29-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=2010; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=xP4Iks1pyzqBMR8iuAQ0TMhb5HtWj5rEEvbuyLR4l2o=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnhKoe/4hRwzr6q0Ya9eLLtgN6CuZdQgnXlH Q/CIdneJ5+JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5aEUEAC3qBpph5jTp3elbqk84Z0zRvVXMgXTiYBInFChBzal91/mJlgiRezxDDlQSLcHR5OJt31 BRlizjEi2Z/JxjjpVaQJSb+cd4Qlx8FdxYCUEUrWR1Vnr4Nf/l1rzstmggnmwTK0vTpNgoZisRN CL3MDBmU9sKNpgqe79PBOMXmBH9EM/Fx5XJ1kqnCwRtfKuKR91y8XDoDu3Ear04CXH9E/amJSi+ SnZs9bt/X8fSQVYjf/q3sMdlNy8zytOXlMm82F4GqVPNNRoPd8I9JrAyamxRd4A+Lkmw8e4Keyj 0od9awKREDW8aDeNS+AzvSVMQoUbjU47ZuOqN98Uf7KjgcEY8op4leZbhQmgsciUoqz8wBx481c QNo5PI79YH5KjIYjc/WIpq6mGQFmnH1Ga+YcvtYrXFdGz2oUGialhcD2HO2MZTHXJUaMS9AgR3h oUyvuN2MA/XqDgHOnHoZtsRBwwZr3rpdO+URoL3uYHWexR5qqPSDNJCCI5AjcLWsdfyZw1InBCu c1zmGBU5+5fB3KhvlG8wwkFHWnwPaHKAFMM1Ig+yOFhBXCtZvsBSXKfiyN5HMzIFDCRHCrIinst udXVRcDcRAzvmjTFKKCO9o5krTDJ6MJNeZYUq8ZrsqSpNlp4NzFFA2vedZquFvEHOeQDQrYdowe IkRpmyOcq1dYCdg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168858581158500 Add gd_vc_notebook_pos() which computes the correct notebook position for a console by counting only non-detached (non-windowed) tabs before it. Use it in gd_tab_window_close() so a re-attached tab is inserted at its logical position rather than appended at the end. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/gtk.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 929e4cf43f7..741f7bfe373 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1464,16 +1464,37 @@ static void gd_menu_show_tabs(GtkMenuItem *item, vo= id *opaque) gd_update_windowsize(vc); } =20 +static int gd_vc_notebook_pos(GtkDisplayState *s, VirtualConsole *target) +{ + int pos =3D 0; + guint i; + + for (i =3D 0; i < s->vcs->len; i++) { + VirtualConsole *vc =3D g_ptr_array_index(s->vcs, i); + if (vc =3D=3D target) { + return pos; + } + if (!vc->window) { + pos++; + } + } + g_assert_not_reached(); +} + static gboolean gd_tab_window_close(GtkWidget *widget, GdkEvent *event, void *opaque) { VirtualConsole *vc =3D opaque; GtkDisplayState *s =3D vc->s; + int page; =20 gtk_widget_set_sensitive(vc->menu_item, true); - gd_widget_reparent(vc->window, s->notebook, vc->tab_item); - gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(s->notebook), - vc->tab_item, vc->label); + g_object_ref(vc->tab_item); + gtk_container_remove(GTK_CONTAINER(vc->window), vc->tab_item); + page =3D gd_vc_notebook_pos(s, vc); + gtk_notebook_insert_page(GTK_NOTEBOOK(s->notebook), + vc->tab_item, gtk_label_new(vc->label), page); + g_object_unref(vc->tab_item); gtk_widget_destroy(vc->window); vc->window =3D NULL; #if defined(CONFIG_OPENGL) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168954; cv=none; d=zohomail.com; s=zohoarc; b=ilABo4XJwaRmRWydvVW50i+rNUeC7J22CHD4kYlZQUmE+ubT9fRC1AG1tS2wf4K9ZOHRqiQYXS5aahQAr3vwf36joavmCOiDuqKMEz7smDe9BYRg3PuepCtNg/I2Zuj5VRRrBSjiUenvrxWoC/GahuWPGMWuLNzrGD3wJ2CQtfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168954; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+SnNvxCGbeXv5dknnCkzFKzyAsN7nrweo4XRyHTsaZI=; b=mmCnWgLN5fpO3f6IOVWLoEdGQ+nkxuU0uiIHWPDUmAXTtShQ/neqrtr7nKw6Mh8NZppXHDFkd3YcX5vMfT/ZeF10MS5r4N8ICg/YZKmvLLqda6G2qcyBdCxpaEsY5/M+6lltFNNURBdYRaf7smdwcUkM0kMvBVHEwmkpYUUangw= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168954885486.8442179743472; Thu, 11 Jun 2026 02:09:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbMv-0006OD-Tv; Thu, 11 Jun 2026 05:06:33 -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 1wXbMq-0006Dn-4Z for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMn-0005NR-CU for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:27 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-lbG3Zd_uN-eEUztC5eXYTQ-1; Thu, 11 Jun 2026 05:06:21 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C55218301A7; Thu, 11 Jun 2026 09:06:20 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DF5BB3008B35; Thu, 11 Jun 2026 09:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+SnNvxCGbeXv5dknnCkzFKzyAsN7nrweo4XRyHTsaZI=; b=MHHexhYuRyiHoeLyi71X05qm+D0/fZiLPUxnfFJ0T9fyLJ7xt2jPhpmQ+F63KBshywYJ2S 3tE0wwM8VAKrbQEOU9124jv/BxeO9r5HWyljKLKCofsR4yLFL5r2qL29l1nYmBlydtZ+QO mnoh+i+42LWISJ/TWxm/qTIzwoZ2uDI= X-MC-Unique: lbG3Zd_uN-eEUztC5eXYTQ-1 X-Mimecast-MFC-AGG-ID: lbG3Zd_uN-eEUztC5eXYTQ_1781168780 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:45 +0400 Subject: [PATCH v3 30/35] ui/gtk: centralize console menu and shortcut management MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-30-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=11639; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=V/Cmo+6kZDY14zreByoLg+HhPs6wZHDZvYC2cJIvlG0=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnhRJLotzvEysfS0jW2tYAdrSUAx4Z46IRJ0 mk8/wj2HgOJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5TNpEACmnPEDEEiuQ/mMoB6nnxs63p3GdGQ7yj9dkiG22tzqxV04ugBL/W9NfOzsdi9SKLJTCnG W7lSKzetiztsk1uGaPmktTNKzZBDJpZB9wu599GevFM6Q0D4xSV+52PtD+AxXmMjPNmG3uWAE0D NDZLP9RaRS8Ef1VzspkDfJSxvDGPsV7NB+m5tMulr7tgCb2Q98+5sywUCNxMkZxezDbcaUsObGB t5cuRl9TKqW3yi01VKJSblIldv7pQnrWdPKe6AvWhmE9AEtscl9FMOX4vroAEltaIhXCEVSoZ7D lfdGOqELJnoiX4/O5RuQ0E11j+/UCKGJjUhX1FYm04d2+nDbH8FDkK94czYwQuPxhqiEvX+j/c5 gaEQlKCZKoawt5TPp918qYyTT7hcG5LCpR8KlLfYD1GPFs4Ux4/rcEuPebMhh8jhNsCihudFpza oYgTpxA/J/nBBJmSeTwqtZuthyYStgfp3SAmuW6W6laLfksWqbRhtzs/17u0q5BtNQelOuAFi0t yFJuxGeF8fQL3066GoMlZQyRjG9fnjteNXxxwPH+/AhLJd6FQRTTwDSXY6aD27FFOvENy5XfuA3 6WXS4nmQIAHsosS9tPMeUXlB/SQlOdNs8tBnMZb9wyL2QJFNlV9zcNd6qKiumD+K1wOKk0BOFyY ty9kDTqhD4JLtPw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168955340158500 Replace the per-console gd_vc_menu_init() with gd_rebuild_vc_menu() that tears down and rebuilds all console radio menu items and Ctrl+Alt+N accelerators at once. This is called from initialization and whenever consoles are detached or reattached. Shortcuts now skip detached (windowed) consoles, so they always map to reachable tabs. Rename gd_vc_gfx_init() to add_gfx_console() and simplify the init function signatures now that menu creation is decoupled. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/gtk.h | 1 + ui/gtk.c | 127 ++++++++++++++++++++++++++++++++++++---------------= ---- 2 files changed, 85 insertions(+), 43 deletions(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index fb60cbfda5d..53d0e447a23 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -120,6 +120,7 @@ struct GtkDisplayState { =20 GPtrArray *vcs; =20 + GtkWidget *vc_menu_separator; GtkWidget *show_tabs_item; GtkWidget *untabify_item; GtkWidget *show_menubar_item; diff --git a/ui/gtk.c b/ui/gtk.c index 741f7bfe373..e7a9156f206 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -142,6 +142,7 @@ static void gd_grab_pointer(VirtualConsole *vc, const c= har *reason); static void gd_ungrab_pointer(GtkDisplayState *s); static void gd_grab_keyboard(VirtualConsole *vc, const char *reason); static void gd_ungrab_keyboard(GtkDisplayState *s); +static void gd_rebuild_vc_menu(GtkDisplayState *s); =20 /** Utility Functions **/ =20 @@ -1488,7 +1489,6 @@ static gboolean gd_tab_window_close(GtkWidget *widget= , GdkEvent *event, GtkDisplayState *s =3D vc->s; int page; =20 - gtk_widget_set_sensitive(vc->menu_item, true); g_object_ref(vc->tab_item); gtk_container_remove(GTK_CONTAINER(vc->window), vc->tab_item); page =3D gd_vc_notebook_pos(s, vc); @@ -1508,6 +1508,8 @@ static gboolean gd_tab_window_close(GtkWidget *widget= , GdkEvent *event, } #endif =20 + gd_rebuild_vc_menu(s); + if (vc =3D=3D gd_vc_find_by_menu(s)) { gtk_widget_grab_focus(vc->focus); } @@ -1539,7 +1541,6 @@ static void gd_menu_untabify(GtkMenuItem *item, void = *opaque) FALSE); } if (!vc->window) { - gtk_widget_set_sensitive(vc->menu_item, false); vc->window =3D gtk_window_new(GTK_WINDOW_TOPLEVEL); #if defined(CONFIG_OPENGL) if (vc->gfx.esurface) { @@ -1566,6 +1567,7 @@ static void gd_menu_untabify(GtkMenuItem *item, void = *opaque) gtk_accel_group_connect(ag, GDK_KEY_g, HOTKEY_MODIFIERS, 0, cb= ); } =20 + gd_rebuild_vc_menu(s); gd_update_geometry_hints(vc); gd_update_caption(s); } @@ -1906,22 +1908,73 @@ static gboolean gd_configure(GtkWidget *widget, =20 /** Virtual Console Callbacks **/ =20 -static GSList *gd_vc_menu_init(GtkDisplayState *s, VirtualConsole *vc, - int idx, GSList *group, GtkWidget *view_men= u) +static void gd_rebuild_vc_menu(GtkDisplayState *s) { - vc->menu_item =3D gtk_radio_menu_item_new_with_mnemonic(group, vc->lab= el); - gtk_accel_group_connect(s->accel_group, GDK_KEY_1 + idx, - HOTKEY_MODIFIERS, 0, - g_cclosure_new_swap(G_CALLBACK(gd_accel_switch_vc), vc, NULL)); - gtk_accel_label_set_accel( - GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(vc->menu_item))), - GDK_KEY_1 + idx, HOTKEY_MODIFIERS); + GSList *group =3D NULL; + VirtualConsole *vc; + GList *children; + gint insert_pos; + int shortcut_idx =3D 0; + guint i; + + for (i =3D 0; i < s->vcs->len; i++) { + vc =3D g_ptr_array_index(s->vcs, i); + if (vc->menu_item) { + gtk_widget_destroy(vc->menu_item); + vc->menu_item =3D NULL; + } + } + + for (i =3D 0; i < 9; i++) { + gtk_accel_group_disconnect_key(s->accel_group, + GDK_KEY_1 + i, HOTKEY_MODIFIERS); + } + + /* find insertion position (just before vc_menu_separator) */ + children =3D gtk_container_get_children(GTK_CONTAINER(s->view_menu)); + insert_pos =3D g_list_index(children, s->vc_menu_separator); + g_list_free(children); + + /* create new menu items for each console */ + for (i =3D 0; i < s->vcs->len; i++) { + vc =3D g_ptr_array_index(s->vcs, i); =20 - g_signal_connect(vc->menu_item, "activate", - G_CALLBACK(gd_menu_switch_vc), s); - gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), vc->menu_item); + vc->menu_item =3D gtk_radio_menu_item_new_with_mnemonic(group, + vc->label); + group =3D gtk_radio_menu_item_get_group( + GTK_RADIO_MENU_ITEM(vc->menu_item)); + + if (vc->window) { + gtk_widget_set_sensitive(vc->menu_item, false); + } else if (shortcut_idx < 9) { + guint key =3D GDK_KEY_1 + shortcut_idx; + gtk_accel_group_connect(s->accel_group, key, + HOTKEY_MODIFIERS, 0, + g_cclosure_new_swap(G_CALLBACK(gd_accel_switch_vc), + vc, NULL)); + gtk_accel_label_set_accel( + GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(vc->menu_ite= m))), + key, HOTKEY_MODIFIERS); + shortcut_idx++; + } =20 - return gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(vc->menu_item= )); + g_signal_connect(vc->menu_item, "activate", + G_CALLBACK(gd_menu_switch_vc), s); + gtk_menu_shell_insert(GTK_MENU_SHELL(s->view_menu), + vc->menu_item, insert_pos + i); + gtk_widget_show(vc->menu_item); + } + + /* sync active menu item with current notebook page */ + vc =3D gd_vc_find_current(s); + if (vc && vc->menu_item) { + g_signal_handlers_block_by_func(vc->menu_item, + gd_menu_switch_vc, s); + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(vc->menu_item), TRUE); + g_signal_handlers_unblock_by_func(vc->menu_item, + gd_menu_switch_vc, s); + } } =20 #if defined(CONFIG_VTE) @@ -2064,9 +2117,8 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar= *text, guint size, return TRUE; } =20 -static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, - Chardev *chr, int idx, - GSList *group, GtkWidget *view_menu) +static void gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc, + Chardev *chr, int idx) { char buffer[32]; GtkWidget *box; @@ -2082,7 +2134,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, Vir= tualConsole *vc, =20 snprintf(buffer, sizeof(buffer), "vc%d", idx); vc->label =3D g_strdup(vc->vte.chr->label ? : buffer); - group =3D gd_vc_menu_init(s, vc, idx, group, view_menu); =20 vc->vte.terminal =3D vte_terminal_new(); g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc); @@ -2128,20 +2179,16 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, V= irtualConsole *vc, gtk_label_new(vc->label)); =20 qemu_chr_be_event(vc->vte.chr, CHR_EVENT_OPENED); - - return group; } =20 -static void gd_vcs_init(GtkDisplayState *s, GSList *group, - GtkWidget *view_menu) +static void gd_vcs_init(GtkDisplayState *s) { int i; =20 for (i =3D 0; i < nb_vcs; i++) { VirtualConsole *vc =3D g_new0(VirtualConsole, 1); g_ptr_array_add(s->vcs, vc); - group =3D gd_vc_vte_init(s, vc, vcs[i], s->vcs->len - 1, - group, view_menu); + gd_vc_vte_init(s, vc, vcs[i], s->vcs->len - 1); } } #endif /* CONFIG_VTE */ @@ -2285,12 +2332,12 @@ static bool gd_scale_valid(double scale) return scale >=3D VC_SCALE_MIN && scale <=3D VC_SCALE_MAX; } =20 -static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc, - QemuConsole *con, int idx, - GSList *group, GtkWidget *view_menu) +static void add_gfx_console(GtkDisplayState *s, QemuConsole *con) { + VirtualConsole *vc =3D g_new0(VirtualConsole, 1); const DisplayChangeListenerOps *ops =3D &dcl_ops; =20 + g_ptr_array_add(s->vcs, vc); vc->label =3D qemu_console_get_label(con); vc->s =3D s; vc->gfx.preferred_scale =3D 1.0; @@ -2367,14 +2414,10 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, V= irtualConsole *vc, qemu_console_register_listener(con, &vc->gfx.dcl, ops); =20 gd_connect_vc_gfx_signals(vc); - group =3D gd_vc_menu_init(s, vc, idx, group, view_menu); - - return group; } =20 -static GtkWidget *gd_create_menu_view(GtkDisplayState *s, DisplayOptions *= opts) +static void gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts) { - GSList *group =3D NULL; GtkWidget *view_menu; GtkWidget *separator; QemuConsole *con; @@ -2382,6 +2425,7 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState= *s, DisplayOptions *opts) int vc, i; =20 view_menu =3D gtk_menu_new(); + s->view_menu =3D view_menu; gtk_menu_set_accel_group(GTK_MENU(view_menu), s->accel_group); =20 s->full_screen_item =3D gtk_menu_item_new_with_mnemonic(_("_Fullscreen= ")); @@ -2445,14 +2489,11 @@ static GtkWidget *gd_create_menu_view(GtkDisplaySta= te *s, DisplayOptions *opts) =20 /* gfx */ for (vc =3D 0;; vc++) { - VirtualConsole *v; con =3D qemu_console_lookup_by_index(vc); if (!con) { break; } - v =3D g_new0(VirtualConsole, 1); - g_ptr_array_add(s->vcs, v); - group =3D gd_vc_gfx_init(s, v, con, vc, group, view_menu); + add_gfx_console(s, con); if (qemu_console_ui_info_supported(con)) { zoom_to_fit =3D true; } @@ -2478,11 +2519,13 @@ static GtkWidget *gd_create_menu_view(GtkDisplaySta= te *s, DisplayOptions *opts) =20 #if defined(CONFIG_VTE) /* vte */ - gd_vcs_init(s, group, view_menu); + gd_vcs_init(s); #endif =20 - separator =3D gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), separator); + s->vc_menu_separator =3D gtk_separator_menu_item_new(); + gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->vc_menu_separator); + + gd_rebuild_vc_menu(s); =20 s->show_tabs_item =3D gtk_check_menu_item_new_with_mnemonic(_("Show _T= abs")); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->show_tabs_item); @@ -2501,8 +2544,6 @@ static GtkWidget *gd_create_menu_view(GtkDisplayState= *s, DisplayOptions *opts) GTK_ACCEL_LABEL(gtk_bin_get_child(GTK_BIN(s->show_menubar_item= ))), GDK_KEY_m, HOTKEY_MODIFIERS); gtk_menu_shell_append(GTK_MENU_SHELL(view_menu), s->show_menubar_item); - - return view_menu; } =20 static void gd_create_menus(GtkDisplayState *s, DisplayOptions *opts) @@ -2511,7 +2552,7 @@ static void gd_create_menus(GtkDisplayState *s, Displ= ayOptions *opts) =20 s->accel_group =3D gtk_accel_group_new(); s->machine_menu =3D gd_create_menu_machine(s); - s->view_menu =3D gd_create_menu_view(s, opts); + gd_create_menu_view(s, opts); =20 s->machine_menu_item =3D gtk_menu_item_new_with_mnemonic(_("_Machine")= ); gtk_menu_item_set_submenu(GTK_MENU_ITEM(s->machine_menu_item), --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168883; cv=none; d=zohomail.com; s=zohoarc; b=Asvf9ObWrrL4oihLKsZ9xJ9s00W5dvd83AguQjeeWxBB/MRW8F63RWObbgVKMjr1QjERnMRZAmjWQ1yKBZduuELxl44uBPg7YnFBke26V1BN/g1y099LAiR4WbrzJeNYAWMr4IS0yOlXL8t2qKva6wuniOr/YCa38FvUEPuLTns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168883; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=J2hVP0nr0sq/C2NkLYrXw5Jgv60Hz1Ty7BafXMzfQbE=; b=V5UKeSthtbY6Cnrb3SN3+ihKfU938LVsGRlu+3by8UBHnwsWQGhl0xP75XeJ3dSnWxAu/gk3Fu804iYezAIVVkF0rh7a89M38RWDzP4TQnZbZBy9k2l4y4Ijyqep9Y3dG4Zv9rmkMqK3o6YoM1vbNXJ3XIjl52icG3rji7zmexc= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168883358366.39950647788487; Thu, 11 Jun 2026 02:08:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbN1-0006RB-RY; Thu, 11 Jun 2026 05:06:39 -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 1wXbMu-0006GX-EN for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbMs-0005O2-Rq for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:32 -0400 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-XUDNDsemNSeSMrtWAf0JIg-1; Thu, 11 Jun 2026 05:06:27 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D7748195605A; Thu, 11 Jun 2026 09:06:25 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8D6E51800347; Thu, 11 Jun 2026 09:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J2hVP0nr0sq/C2NkLYrXw5Jgv60Hz1Ty7BafXMzfQbE=; b=UcwIC3CAEo0Y+GwhuX/jpnYD8ytinWxG1ukh1bWXq7CLR1s/99zU0CWb0dI/wcJJ9ghCes 2uqlbrr7tqdKMaNXKlioS5QoB7hxtZqkxGjkZ7h+BhhXi6Kx8YFlTddtG/ARpHcO3tYek/ HYbpxyQWt8Rjyf41TfL/iiMAa2Zk7D8= X-MC-Unique: XUDNDsemNSeSMrtWAf0JIg-1 X-Mimecast-MFC-AGG-ID: XUDNDsemNSeSMrtWAf0JIg_1781168786 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:46 +0400 Subject: [PATCH v3 31/35] ui/gtk: handle console hotplug/unplug events MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-31-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4058; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=DEvqGsGEWMW9RpYRMNCT4E2Ku7Pud+lgNF7rPteiP5s=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnh+mz/21jPxhxPsTejkdf18b0DNVWFERG3R cVrQeOGqLeJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54QAKCRDa6OEJdZac 5Zn8EACGKd8f7dqXmN8XlSMK8hN66WLOf4RwTtS+fQ8z842lXKGYYFLBNlFqNWAGqbwSwa8p1Ri l9Yh2rZGV+7s5DfjUpLyPp/tm3IZu+MlXSQcyGwQfzEN5JaStX5TCZR/3tt3H3K9UUx3Js/M1vi JHGyUnCcGi0Qz2WO+H4PRGUXw8ny+dvJVvJsO474DWllYmWsG0JcAyBfWjcErMfyGeVgC5O1qRg Af+ZOnC9fe+gcEepnYKjjNcziAHfkaJYDUgujK2km8ySwHoBLiK/5rRsupr2BMKqCbAazsSOn8G 5a1OI7XbEcZrFsnNJRryDtYRveu1YEDQktoKC41LepiKz/8xj8ensTM4crUuGu75kPpBUQwTfjY FEItemlH3r2wQRlsHPYr8+3rHxxIE4pRolJMfaDBd8jlq+xGsBYRqz3pYJafXcFRMJQKvkM9Ko9 w/aFLsm9MlkZ4d7f2OimccKP9CcL6L1fuoEeyd2Q+1k05GkVlO1p9JuWuenZFKFG7/X/uyuZApx wzn3ebOk/4TV7I3lLoFL5966v/NJVwyapSZwNUgb5tyBtqV0DzN6iFQ+JYX6oZfonR6HGWZpdug yGpcgBuZnl28DITRU2zyvn76TfVYpm7vNswhHbGbohw43gIfFLTQ/BmRglvNwk8DjOhtUbpADyn 1dIycCe0PoU5ldg== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168884751158500 Register a console notifier so the GTK display dynamically creates and destroys VirtualConsole tabs when graphic consoles are added or removed at runtime (e.g. vfio-pci with display=3Don hotplug). Add skips consoles that already have a VC binding, remove skips unknown consoles. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/gtk.h | 1 + ui/gtk.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++= +++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 53d0e447a23..5c9c34a069e 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -141,6 +141,7 @@ struct GtkDisplayState { GdkCursor *null_cursor; Notifier mouse_mode_notifier; VMChangeStateEntry *vmse; + Notifier console_notifier; gboolean free_scale; gboolean keep_aspect_ratio; =20 diff --git a/ui/gtk.c b/ui/gtk.c index e7a9156f206..7078d89d679 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2332,7 +2332,8 @@ static bool gd_scale_valid(double scale) return scale >=3D VC_SCALE_MIN && scale <=3D VC_SCALE_MAX; } =20 -static void add_gfx_console(GtkDisplayState *s, QemuConsole *con) +static VirtualConsole * +add_gfx_console(GtkDisplayState *s, QemuConsole *con) { VirtualConsole *vc =3D g_new0(VirtualConsole, 1); const DisplayChangeListenerOps *ops =3D &dcl_ops; @@ -2414,6 +2415,74 @@ static void add_gfx_console(GtkDisplayState *s, Qemu= Console *con) qemu_console_register_listener(con, &vc->gfx.dcl, ops); =20 gd_connect_vc_gfx_signals(vc); + return vc; +} + +static void gd_vc_add_gfx(GtkDisplayState *s, QemuConsole *con) +{ + VirtualConsole *vc; + int i; + + for (i =3D 0; i < (int)s->vcs->len; i++) { + VirtualConsole *v =3D g_ptr_array_index(s->vcs, i); + if (v->type =3D=3D GD_VC_GFX && v->gfx.dcl.con =3D=3D con) { + return; + } + } + + vc =3D add_gfx_console(s, con); + gtk_widget_show_all(vc->tab_item); + gtk_widget_realize(vc->gfx.drawing_area); + + if (s->free_scale) { + gd_update_windowsize(vc); + } + + gd_update_caption(s); + gd_rebuild_vc_menu(s); +} + +static void gd_vc_remove_gfx(GtkDisplayState *s, QemuConsole *con) +{ + VirtualConsole *vc =3D NULL; + guint idx; + + for (idx =3D 0; idx < s->vcs->len; idx++) { + VirtualConsole *v =3D g_ptr_array_index(s->vcs, idx); + if (v->type =3D=3D GD_VC_GFX && v->gfx.dcl.con =3D=3D con) { + vc =3D v; + break; + } + } + if (!vc) { + return; + } + + if (s->kbd_owner =3D=3D vc) { + gd_ungrab_keyboard(s); + } + if (s->ptr_owner =3D=3D vc) { + gd_ungrab_pointer(s); + } + + g_ptr_array_remove_index(s->vcs, idx); + gd_rebuild_vc_menu(s); + gd_update_caption(s); +} + +static void gd_console_notify(Notifier *n, void *data) +{ + GtkDisplayState *s =3D container_of(n, GtkDisplayState, console_notifi= er); + QemuConsoleEvent *event =3D data; + + switch (event->type) { + case QEMU_CONSOLE_ADDED: + gd_vc_add_gfx(s, event->con); + break; + case QEMU_CONSOLE_REMOVED: + gd_vc_remove_gfx(s, event->con); + break; + } } =20 static void gd_create_menu_view(GtkDisplayState *s, DisplayOptions *opts) @@ -2694,6 +2763,9 @@ static void gtk_display_init(DisplayState *ds, Displa= yOptions *opts) =20 gd_create_menus(s, opts); =20 + s->console_notifier.notify =3D gd_console_notify; + qemu_console_add_notifier(&s->console_notifier); + gd_connect_signals(s); =20 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE); @@ -2814,6 +2886,7 @@ static void gtk_display_cleanup(void) return; } qemu_del_vm_change_state_handler(s->vmse); + qemu_console_remove_notifier(&s->console_notifier); qemu_remove_mouse_mode_change_notifier(&s->mouse_mode_notifier); gd_clipboard_cleanup(s); g_signal_handlers_disconnect_by_func(s->notebook, --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168848; cv=none; d=zohomail.com; s=zohoarc; b=keL4UKPKzA5LmNC4WBsyO415fqnwu6BgXAkA0dOnZhT+ilEsTtB+SwbMcJYwI5vqh/sYiWuRt9khXFwEKFpeZg8PfAxa7UFeut32QkjlwPoE4fyXgrvz+yHwQIfHOpVSdWFLpGeMi5hObpC0mYQVdiEJBzUshR5AuLrS2/0FeaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168848; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/NBCtQ/LDlj7bqt4GsZQ8DDG3CW8/CbEEUHOSI/t16A=; b=CGMjm/TR++XYXRwTTrhJfYMwp7An7fntuRh6d5NIZIhXepFOaCkoAuC5R8QHLNkTaAhnUVnADoKrZj6OUZYtmzlCZ9xz199nvSnBZ3BIMx02HfNdIDtBwwhwYWw1w1BotCso619hOd4VQyGbjS/u1V/ZM0tXsqAwwmf/T/2XPFU= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168848893969.0465521518594; Thu, 11 Jun 2026 02:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbN8-0006Xw-9o; Thu, 11 Jun 2026 05:06:46 -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 1wXbN3-0006UX-4q for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbN1-0005Oh-Nw for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:40 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-T3kvi46LN--9YJxVrARlIA-1; Thu, 11 Jun 2026 05:06:33 -0400 Received: from mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A62E51955EB1; Thu, 11 Jun 2026 09:06:31 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-10.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4899836512; Thu, 11 Jun 2026 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/NBCtQ/LDlj7bqt4GsZQ8DDG3CW8/CbEEUHOSI/t16A=; b=Ih+7Wub3LTn2rJYVKCzTsff328zVQrxhFqtsAax/3/1Lz6gOwgA79vjo25CTSX/3xq+vtf DuVWmeG8cvo3nD4BZvbePzyLxB1SfBCn3vYTkIaX6MgcJjftLFkwekVCDy/dqFLPJBld3D XFDv0Oy7qjZqcnLSQj8xB32wN8vlIik= X-MC-Unique: T3kvi46LN--9YJxVrARlIA-1 X-Mimecast-MFC-AGG-ID: T3kvi46LN--9YJxVrARlIA_1781168791 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:47 +0400 Subject: [PATCH v3 32/35] ui/console: register console in QOM tree dynamically MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-32-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=2283; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=+6tAA5uwDh2I1DKjrGBRjiPVFRwcgi1oOVH5ZTlowwM=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnniMxt9fu9PYotD0qpTyNl0u5bcsrrtuk3sv exINchuFPSJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54gAKCRDa6OEJdZac 5X5TD/0ZyynYvj+CUVmcmQTJUj00XPrQVRtiPiWd817cRDhhMsWUk+cY3MLnXd0rk9VNovoIo9O F9ClMpLqHvIaKVwz5p1/kn1Pa70ydJvHz6Fyd9Qp3xa0mBVFl4sjrJYzXz21MmfL0rOEyo4kD9U UWZTO6nn5LfENCIQmqplzn1OcxI82NWGsA0yod+BaZyr9Q7f/7fdxn4VprbUIOLUqcn4TDSBqA7 HX7nbSV/W4zUxSOUNM7kvxBsfgglD/iHCM8hxdDU43ffz/xnzHsrVLkG0LJDyl2ClXa9Xa/yrGW /To1TNMvXrRQ7NHdRREYjCgfc/iekPmApRjQig8ww38p4aKeyHtgz0dxplNhfxBjok9CKdb2hw+ +Z4rmOhEo22ViS6H+MbJjtUx0HbwMQFiuZWw8VK+UEHjjZWWRlvCUjRxBsLBahhDQfyFqnpNr+z d7FjG6yRuClQoFYcYwqKJ64s6zqlggDSfSMrKSjCXbtuIJULE89SvHiH/hAeTCSt7VXQWEeYaUV 4XTOBiN3NBAnpjg/uIZmQYY3hKBFikTXA5KkpcJX6oWZyVmko+19ddYKmtJamzYIrnyLrARya+d ZUlHhj5XylODNHoU9CMefYYtVboTvGTYfnMDwJ18S8JcgBQfdNdnt5DwZhlLwfDWdnEQPAn/wHR cdAL6muSeL/kZoQ== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.6 on 10.30.177.95 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168850539158500 Consoles created after init_displaystate() (e.g. hotplugged display devices) were never added to the /backend/console[N] QOM tree. Extract qemu_console_add_to_qom() and call it from qemu_console_register() when the display is already initialized. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ui/console.c b/ui/console.c index 975eaf15706..db9aaf85f59 100644 --- a/ui/console.c +++ b/ui/console.c @@ -68,6 +68,7 @@ struct DisplayState { uint64_t last_update; uint64_t update_interval; bool refreshing; + bool initialized; =20 QLIST_HEAD(, DisplayChangeListener) listeners; NotifierList console_notifiers; @@ -376,6 +377,13 @@ void qemu_text_console_put_string(QemuTextConsole *s, = const char *str, int len) } } =20 +static void qemu_console_add_to_qom(QemuConsole *con) +{ + g_autofree gchar *name =3D g_strdup_printf("console[%d]", con->index); + object_property_add_child(object_get_container("backend"), + name, OBJECT(con)); +} + static void qemu_console_register(QemuConsole *c) { @@ -413,6 +421,10 @@ qemu_console_register(QemuConsole *c) } } } + + if (c->ds->initialized) { + qemu_console_add_to_qom(c); + } } =20 static void @@ -1089,20 +1101,19 @@ void qemu_console_remove_notifier(Notifier *notifie= r) */ DisplayState *init_displaystate(void) { - gchar *name; + DisplayState *ds =3D get_alloc_displaystate(); QemuConsole *con; =20 QTAILQ_FOREACH(con, &consoles, next) { /* Hook up into the qom tree here (not in object_new()), once * all QemuConsoles are created and the order / numbering * doesn't change any more */ - name =3D g_strdup_printf("console[%d]", con->index); - object_property_add_child(object_get_container("backend"), - name, OBJECT(con)); - g_free(name); + qemu_console_add_to_qom(con); } =20 - return display_state; + ds->initialized =3D true; + + return ds; } =20 void qemu_graphic_console_set_hwops(QemuConsole *con, --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168832; cv=none; d=zohomail.com; s=zohoarc; b=EfaIAf5nsqM2wlCa7sylHgSJ/W51kuE02rwHdsI1lQFTEn0aDUzBR/I2ibBydiMgKRrZV4iDEyaH4B735OmYUXrrIcf/xI2t9nkPRjK9CwKbnMFkApw7oYOxOoeyMgVANoO9MwX0ZaQlrAMfRQdEcxX3S/9b8x3Po4oxMpAQ2q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168832; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OxlChsVADaARWyTRMZ3NG8G9plRASvkV/Hq7x8L/VPE=; b=Tkbn56/pYuF9UvSeHXPB84pLDOTwyXTFHhJwRgnoGawRAVbchLOt+0akP7Y2bV7PV1lpWWzi0obd2iUBp8IZpOOSMQIC8JglBKY2GcUwGTHYnHmFkdZfvJ0oC/Dx75vthNzM9HRcijIgYm6YLZzzd/+L1cJA5CBMvfVJJfS37wQ= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168832501895.2332924027739; Thu, 11 Jun 2026 02:07:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbNA-0006bA-PU; Thu, 11 Jun 2026 05:06:48 -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 1wXbN8-0006aE-LD for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbN7-0005P6-7x for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:46 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-qj-Kpl-rMzauFO_EBCrlqw-1; Thu, 11 Jun 2026 05:06:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86019180ACD1; Thu, 11 Jun 2026 09:06:38 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 368E91954B0D; Thu, 11 Jun 2026 09:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OxlChsVADaARWyTRMZ3NG8G9plRASvkV/Hq7x8L/VPE=; b=dcECVlMv5WOHc06WyZWL89OOvbtUXTvoaZJmUP+qg13GF/zKWSNAwOp5FKxGIMMPRKUR0G xT06imrj7Y7HLonFMhSpOxqJlgp3mZyY8fMy82ZNpcWu8pkPZ47tDF01TPD+Ss9xkbyp2E koDAk6Sinc/YEMMhjzzjedFj76wRW7o= X-MC-Unique: qj-Kpl-rMzauFO_EBCrlqw-1 X-Mimecast-MFC-AGG-ID: qj-Kpl-rMzauFO_EBCrlqw_1781168798 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:48 +0400 Subject: [PATCH v3 33/35] ui/console: unregister console from QOM tree on close MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-33-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=1322; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=mvCtk0KdkrQ8473OU30MMLcq6u1bq2unAsGOAvd3VMw=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnniSjiyg5zpGulj+0BiQwS6hNyvCmYq6j/oW VCwjABPa96JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54gAKCRDa6OEJdZac 5UAWD/0TWshkyrQdT6v6MQGuIFdIdLpcClysgrlbNcueWBlWBaT/YhkDgLRD0O2gPPGEN0yEo8k bbnhzYBwigozHhh+mfNlCMyuy8M9jSF1KEVTn9wVFjmLq/xfWebjtDE/HLzXbXeY58/kNLhEIMy iXNlNNSbTi/iZxbqWsv+rLx1OcI89pLdZ4I8vamggMl9xVRRJRWmGOfqGkgF/2XA1Uv5d7Ff/dO d51ov6mP/99hjjvINTKTYCEXbfNoul6IkkTIiBAb65/y+6/ox/enGSyt6HyZ7nOk+TWiezNK0Z5 MsjMRqCFmK8xikag8gGpYaWVSBKGnvSeU5Z3WeHY5O2JrfGOuETnkLUb2ZaMlb5rVWfSUOV7sSd nCxvXsido68EJGqqtGHGSXbGS08jhf5anJcnhTfTUz14y/zUeNu3ZsGM3Es6bYXMgGg9yQPErII E67uRG5IkpjH+LkmYxsGJEOKvKozvkJZyIoro/mflRe6BZRnqnS8uM7+mTCclAqGl8NsHJJ2YdG 81/gnWRSR8i8NQUNCp/HoWtCRWPrfLvukAhyEteUZnZXEtVGFdZ8aKKrSh3KWRsJJ5N4Gb1fMKT X05NDD9XZWJ+tRX9ux62xEoDVNWPrL34XKyqLYn5URt+P1uik6YSvBB+frnwrRnIDb4kGQAS6fk Dj+zVUVqUH0g6lw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1781168834450158500 Call object_unparent() in graphic_console_close() to remove the console from /backend/console[N]. This drops the QOM tree reference, while the initial object_new() reference keeps the console alive for potential reuse. When graphic_console_init() reuses a closed console, re-register it in the QOM tree. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/console.c b/ui/console.c index db9aaf85f59..a8a2a247d8f 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1140,6 +1140,9 @@ QemuConsole *qemu_graphic_console_create(DeviceState = *dev, uint32_t head, trace_console_gfx_reuse(s->index); width =3D qemu_console_get_width(s, 0); height =3D qemu_console_get_height(s, 0); + if (s->ds->initialized) { + qemu_console_add_to_qom(s); + } } else { trace_console_gfx_new(); s =3D (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE); @@ -1180,6 +1183,7 @@ void qemu_graphic_console_close(QemuConsole *con) } surface =3D qemu_create_placeholder_surface(width, height, unplugged); qemu_console_set_surface(con, surface); + object_unparent(OBJECT(con)); } =20 QemuConsole *qemu_console_lookup_default(void) --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168912; cv=none; d=zohomail.com; s=zohoarc; b=exxuN0ohjMPU5I04sjetjOQ9o2eTrTZq+HWuunAshBjbDa4JqHEeRAWL3+Kv1JgfqEVR6FQNyeQlGkUrQSNGJBLp1r/1AZ35kaWQ/Q/ekKRCfQACwtJdvdqz9VMooRlftbLtZDI0wKN78QLPzqX933+zIWsVxXqUSkPR5sOiVFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168912; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l+ySMPhR2kN57PncwepNCQ/27reuJ52ovLQsDP1Z834=; b=YmcG3RCM7G4ORihLh/I0naVrKHX72RpTRnkN/vA2/ND+7w6y3Di4C1nSg40n+9LNKU29EeZhqBt4rdZehBdki09XTYX0S2uSXy1uPX0WIZNiw8vW4V3QG7DaIqI7Vx+QyM4ExXCWN/Yu1/gxpUXADtuoollQtcP49df+9Zu1e2A= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168912220667.4263051659506; Thu, 11 Jun 2026 02:08:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbNI-0006uo-9b; Thu, 11 Jun 2026 05:06:56 -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 1wXbNG-0006l6-OF for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbNE-0005RI-1h for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-lErlFTxBPN6DAPzZfHe11g-1; Thu, 11 Jun 2026 05:06:45 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0D9D01977013; Thu, 11 Jun 2026 09:06:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AD5F31954105; Thu, 11 Jun 2026 09:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l+ySMPhR2kN57PncwepNCQ/27reuJ52ovLQsDP1Z834=; b=JfE5g/kiDAvK0bayByTG+yGrqRe1YwiYCuARvf2iA8qG4qJh7BiXsdiGUnWjm6CKr1QspK C/qPnz6pdBrluvRi+cCQ07q0tnD1/ngEDSDCN9M30/o4mC1taOUHozavpYM8ZyTkWeV43L uQwFooBm8AZe5pL/7IXqChMIooy1ZGo= X-MC-Unique: lErlFTxBPN6DAPzZfHe11g-1 X-Mimecast-MFC-AGG-ID: lErlFTxBPN6DAPzZfHe11g_1781168804 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:49 +0400 Subject: [PATCH v3 34/35] ui/dbus: handle console hotplug/unplug events MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-34-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=6566; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=ciTaD8CwpnHypf+DeGHoeLKIoaO9niQfDZUXGaoqXr4=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnit+aKu/DyIXLWuAiXR3Pf55o/LYXiuubvd /IyhGNW7jOJAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54gAKCRDa6OEJdZac 5VyOD/9DPQ2sBYVpT1dQ+90dxvSbKyoBWGmCBmLmaMrCJlfPxro3vPt9NZ35GwJvJnCq8BJ4Yl9 TpEHF3f7TJMdmrz36D+l+2DPBfmnGiBP9H5H4tUujCWj6NbKfVrIh6yqeaLbuVtE18zOdg7Slzp D2/OJXMEEjpeYdcHSnpMi7K/TKljTsBfAZxAy1D9WEtYp7ZVp+mjIhLmdezoNSrGuRwg7xbDFPP oZOWF+QaMpXDEulZMmFVHopouPHM1EVprQjxoqd8ht28ilTzD1SmypqjUftb3mqn5iYgeokUydT X24plWoniD0QkGm5c5T4XzcoTAqWM7WmmFFhTLbvwYxTtDFPb065j4aYabqjrA/ETzx8ToMwVFJ Kc8AbmRknqbb29n1CFM4WAJ4shikBqZvm/7QMJfCEDPolUkx7ZK1EsWbTlvrcg8PrhI7c7/0LHQ NWIHXirCa2HaTkctn/CPZfSgjUva1qM3f+OjxaDCkb/wXX6PH4uhc5du8ah0Vrnz9ub7tD63osq r8UDV7t4SKxDy62YcJ6BLZC6xYPTk48XJ+hyIEDXcmDIW61OdLexzxXhnR+l+AAei+Hzw4wCs2B id+H2F2lXXu5hBFHUljrjc3QCxcDhD17cYjgKhqyv/6dxRtF2eHE3UPXGRrjsUK8jEbxc8pxyGw 3L0IY0EVPZ3RTqA== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168912888158500 Subscribe to QemuConsoleEvent notifications to dynamically add and remove D-Bus display consoles. This mirrors the GTK backend's handling added in the previous commits. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus.h | 3 ++ ui/dbus-console.c | 5 +++ ui/dbus.c | 93 +++++++++++++++++++++++++++++++++++++++++++++------= ---- 3 files changed, 84 insertions(+), 17 deletions(-) diff --git a/ui/dbus.h b/ui/dbus.h index e4e78590b49..d2cc176648a 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -60,6 +60,7 @@ struct DBusDisplay { DBusClipboardRequest clipboard_request[QEMU_CLIPBOARD_SELECTION__COUNT= ]; =20 Notifier notifier; + Notifier console_notifier; }; =20 #ifdef WIN32 @@ -86,6 +87,8 @@ dbus_display_console_new(DBusDisplay *display, QemuConsol= e *con); int dbus_display_console_get_index(DBusDisplayConsole *ddc); =20 +QemuConsole * +dbus_display_console_get_qemu_console(DBusDisplayConsole *ddc); =20 extern const DisplayChangeListenerOps dbus_console_dcl_ops; =20 diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 63d21493101..12f7decfb60 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -533,6 +533,11 @@ int dbus_display_console_get_index(DBusDisplayConsole = *ddc) return qemu_console_get_index(ddc->dcl.con); } =20 +QemuConsole *dbus_display_console_get_qemu_console(DBusDisplayConsole *ddc) +{ + return ddc->dcl.con; +} + DBusDisplayConsole * dbus_display_console_new(DBusDisplay *display, QemuConsole *con) { diff --git a/ui/dbus.c b/ui/dbus.c index b23cb44c535..7be0f8e2611 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -142,6 +142,9 @@ dbus_display_finalize(Object *o) { DBusDisplay *dd =3D DBUS_DISPLAY(o); =20 + if (dd->console_notifier.notify) { + qemu_console_remove_notifier(&dd->console_notifier); + } if (dd->notifier.notify) { dbus_display_notifier_remove(&dd->notifier); } @@ -164,14 +167,35 @@ dbus_display_finalize(Object *o) dbus_display =3D NULL; } =20 +static void +dbus_update_console_ids(DBusDisplay *dd) +{ + g_autoptr(GArray) arr =3D g_array_new(FALSE, FALSE, sizeof(guint32)); + + for (guint i =3D 0; i < dd->consoles->len; i++) { + DBusDisplayConsole *ddc =3D g_ptr_array_index(dd->consoles, i); + guint32 idx =3D dbus_display_console_get_index(ddc); + g_array_append_val(arr, idx); + } + + g_object_set(dd->iface, "console-ids", + g_variant_new_fixed_array(G_VARIANT_TYPE("u"), + arr->data, arr->len, + sizeof(guint32)), + NULL); +} + static bool -dbus_display_add_console(DBusDisplay *dd, int idx, Error **errp) +dbus_display_add_console(DBusDisplay *dd, QemuConsole *con, Error **errp) { - QemuConsole *con; DBusDisplayConsole *dbus_console; =20 - con =3D qemu_console_lookup_by_index(idx); - assert(con); + for (guint i =3D 0; i < dd->consoles->len; i++) { + DBusDisplayConsole *ddc =3D g_ptr_array_index(dd->consoles, i); + if (dbus_display_console_get_qemu_console(ddc) =3D=3D con) { + return true; + } + } =20 if (qemu_console_is_graphic(con) && dd->gl_mode !=3D DISPLAY_GL_MODE_OFF) { @@ -179,20 +203,58 @@ dbus_display_add_console(DBusDisplay *dd, int idx, Er= ror **errp) } =20 dbus_console =3D dbus_display_console_new(dd, con); - g_ptr_array_insert(dd->consoles, idx, dbus_console); + g_ptr_array_add(dd->consoles, dbus_console); g_dbus_object_manager_server_export(dd->server, G_DBUS_OBJECT_SKELETON(dbus_consol= e)); + dbus_update_console_ids(dd); return true; } =20 +static void +dbus_display_remove_console(DBusDisplay *dd, QemuConsole *con) +{ + for (guint i =3D 0; i < dd->consoles->len; i++) { + DBusDisplayConsole *ddc =3D g_ptr_array_index(dd->consoles, i); + if (dbus_display_console_get_qemu_console(ddc) =3D=3D con) { + if (display_opengl) { + qemu_console_set_display_gl_ctx(con, NULL); + } + g_dbus_object_manager_server_unexport( + dd->server, + g_dbus_object_get_object_path(G_DBUS_OBJECT(ddc))); + g_ptr_array_remove_index(dd->consoles, i); + dbus_update_console_ids(dd); + break; + } + } +} + +static void +dbus_console_notify(Notifier *n, void *data) +{ + DBusDisplay *dd =3D container_of(n, DBusDisplay, console_notifier); + QemuConsoleEvent *event =3D data; + + switch (event->type) { + case QEMU_CONSOLE_ADDED: { + Error *err =3D NULL; + if (!dbus_display_add_console(dd, event->con, &err)) { + error_report_err(err); + } + break; + } + case QEMU_CONSOLE_REMOVED: + dbus_display_remove_console(dd, event->con); + break; + } +} + static void dbus_display_complete(UserCreatable *uc, Error **errp) { DBusDisplay *dd =3D DBUS_DISPLAY(uc); g_autoptr(GError) err =3D NULL; g_autofree char *uuid =3D qemu_uuid_unparse_strdup(&qemu_uuid); - g_autoptr(GArray) consoles =3D NULL; - GVariant *console_ids; int idx; =20 if (!object_resolve_path_type("", TYPE_DBUS_DISPLAY, NULL)) { @@ -233,27 +295,24 @@ dbus_display_complete(UserCreatable *uc, Error **errp) } } =20 - consoles =3D g_array_new(FALSE, FALSE, sizeof(guint32)); for (idx =3D 0;; idx++) { - if (!qemu_console_lookup_by_index(idx)) { + QemuConsole *con =3D qemu_console_lookup_by_index(idx); + if (!con) { break; } - if (!dbus_display_add_console(dd, idx, errp)) { + if (!dbus_display_add_console(dd, con, errp)) { return; } - g_array_append_val(consoles, idx); } =20 - console_ids =3D g_variant_new_from_data( - G_VARIANT_TYPE("au"), - consoles->data, consoles->len * sizeof(guint32), TRUE, - (GDestroyNotify)g_array_unref, consoles); - g_steal_pointer(&consoles); g_object_set(dd->iface, "name", qemu_name ?: "QEMU " QEMU_VERSION, "uuid", uuid, - "console-ids", console_ids, NULL); + dbus_update_console_ids(dd); + + dd->console_notifier.notify =3D dbus_console_notify; + qemu_console_add_notifier(&dd->console_notifier); =20 if (dd->bus) { g_dbus_object_manager_server_set_connection(dd->server, dd->bus); --=20 2.54.0 From nobody Wed Jun 24 02:12:55 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168882; cv=none; d=zohomail.com; s=zohoarc; b=bxtc5CfTw2V2lgynGq53aQOzX3BRwzAacmj/OFjxhV1/zwtdCU3CBgTlMCm8Z6vJKjegUnGbMa06cVD704QXsW1mm6Yi6gaL67fPHhCA8oYJV8fPpSseNe3T8vEOknK1bzzvF3grhJAvf2+IAn+79NOKqMP5LT4ylrqTxbm6z0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168882; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xbxN/mAMtJtduNKSGnc8CLMOmhvQhZe+7JMf8JBpoeE=; b=CSmAML0W3lTS82kMGHLoUUoUL0fKr1iY2zpwHM1iKrTMSq95HNbmSQtw9b+b4E6hAMteljB7rKELLNVMaEqhmyBQY6zKeaaaVSYw5tibDP1Dh7xdLiwwV8y0Wp5IVM0KXuzzcmNquUAwb7GrJadBjf6gc8fFnCKCHqJxUdWTf14= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168882583799.4670169739086; Thu, 11 Jun 2026 02:08:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbNI-0006ux-8N; Thu, 11 Jun 2026 05:06:56 -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 1wXbNG-0006l8-Nj for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbNE-0005Rl-Cl for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-qJQVMabLMcKHmRY_jFsaZA-1; Thu, 11 Jun 2026 05:06:50 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 608ED1977000; Thu, 11 Jun 2026 09:06:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C36D180029C; Thu, 11 Jun 2026 09:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xbxN/mAMtJtduNKSGnc8CLMOmhvQhZe+7JMf8JBpoeE=; b=gMB++L5BXMa26agA+/IgIhByv7WscCZVUlHF+x04qZDEjmpfUDipuKPO/01T80vdOWp0Uf FlBGaRrphqVjfDUltkmd5A0wOFH22PiImrRTzd6dvEdpxq5JSk+u7xSQt/gWHLMK2u6J1B csBkprj3iuiURfU76qhqcRfqQybFSdY= X-MC-Unique: qJQVMabLMcKHmRY_jFsaZA-1 X-Mimecast-MFC-AGG-ID: qJQVMabLMcKHmRY_jFsaZA_1781168809 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:50 +0400 Subject: [PATCH v3 35/35] tests/qtest: add D-Bus display hotplug test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-35-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4986; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Qj9RcQ/RNJdYxcuio5b6l1xNzAqRshVBUlgn/gQCRCY=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnikT97l5ywP8O8xqU6gZXikDy2DzgyrFnru uQF4EgyI42JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54gAKCRDa6OEJdZac 5W93D/41fK0YK2qNSFioSwH3D05vQDvqsho+2t7+xgROkKtTNHZRuXFwDgrUnHWg5PO4z8Ob0HA GW+zCEb75dNm8TS0XEsAiehpTvHOmXyYLAgl5zJlvH15FQ2iDT5hV6REKTdmPzet7M/PsUhKybY voS0PIybbA8n50ZQb8k/ejrxPuZb93Ryp/7BUdB5WbhYKZ6uBe8ATIUVuvrHeirRiXwTHJ/i1uu Xex0G9qE4A0L0UyBCFax5eqje6cw7IvH2bCzojCJaWnRh60t5JoMPOj0iRfzfdczKzpAH36FEvF 2yA7rvL2KntxeDvZxdPNNjImNuf73QZoH/xyqGBrIvKKrJh+7pFiA7m5HFwvzpGlYIXDdxe2w9R J9TOtUMxgOlZ8J7hb+zH441v2zxhimwasfsSc4ALFMXJiH56BJrUKBgSd48eG9u63f+AfjEBtrJ e7bkjLsHFXHrDkwBOjheb/SSZYmV4BXj6ahfys4r6EvvLwVJBvz0MqSf4uqIayWJM06w8PXnCYh VXtm6ZoMhe4MOFBUS8R0xq8KBDnvohvP5ifwLkTnqFDPCKfPeyQ+dbbhH37qOiYf9+1XCAzEoTa h5P7pozQOnKtrY4l4DqFh7CEFHxFqes+JJ1dMdw7nCB11B26z7P12i5v+pFFKMwdO3B1IfKu4X0 fAT6mn6nVFIbGYw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1781168884697158500 Add a qtest that verifies display consoles are dynamically added and removed over D-Bus when a bochs-display device is hotplugged and unplugged on a q35 machine. The test plugs device_add a bochs-display, waits for the DEVICE_ADDED QMP event, and checks that the D-Bus VM interface reports a second console. It then device_del it, forces a system reset (q35 removal is ACPI-based and needs guest cooperation qtest cannot provide), waits for DEVICE_DELETED, and checks the console count again. Reviewed-by: Fabiano Rosas Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/dbus-display-test.c | 101 ++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-tes= t.c index 5773776cad5..7838ce7323f 100644 --- a/tests/qtest/dbus-display-test.c +++ b/tests/qtest/dbus-display-test.c @@ -7,6 +7,8 @@ #include #include #include "libqtest.h" +#include "qobject/qdict.h" +#include "qobject/qstring.h" #include "ui/dbus-display1.h" =20 static GDBusConnection* @@ -38,11 +40,11 @@ test_dbus_p2p_from_fd(int fd) } =20 static void -test_setup(QTestState **qts, GDBusConnection **conn) +test_setup_args(QTestState **qts, GDBusConnection **conn, const char *args) { int pair[2]; =20 - *qts =3D qtest_init("-display dbus,p2p=3Dyes -name dbus-test"); + *qts =3D qtest_init(args); =20 g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), =3D=3D= , 0); =20 @@ -52,6 +54,12 @@ test_setup(QTestState **qts, GDBusConnection **conn) g_dbus_connection_start_message_processing(*conn); } =20 +static void +test_setup(QTestState **qts, GDBusConnection **conn) +{ + test_setup_args(qts, conn, "-display dbus,p2p=3Dyes -name dbus-test"); +} + static void test_dbus_display_vm(void) { @@ -360,6 +368,92 @@ test_dbus_display_keyboard(void) qtest_quit(qts); } =20 +static gsize +get_console_ids_count(GDBusConnection *conn) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(QemuDBusDisplay1VMProxy) vm =3D NULL; + GVariant *console_ids; + gsize n_ids =3D 0; + + vm =3D QEMU_DBUS_DISPLAY1_VM_PROXY( + qemu_dbus_display1_vm_proxy_new_sync( + conn, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + DBUS_DISPLAY1_ROOT "/VM", + NULL, + &err)); + g_assert_no_error(err); + + console_ids =3D qemu_dbus_display1_vm_get_console_ids( + QEMU_DBUS_DISPLAY1_VM(vm)); + if (console_ids) { + n_ids =3D g_variant_n_children(console_ids); + } + return n_ids; +} + +static void +wait_device_event(QTestState *qts, const char *event_name, const char *id) +{ + QDict *resp, *data; + QString *qstr; + + for (;;) { + resp =3D qtest_qmp_eventwait_ref(qts, event_name); + data =3D qdict_get_qdict(resp, "data"); + if (!data || !qdict_get(data, "device")) { + qobject_unref(resp); + continue; + } + qstr =3D qobject_to(QString, qdict_get(data, "device")); + if (!strcmp(qstring_get_str(qstr), id)) { + qobject_unref(resp); + break; + } + qobject_unref(resp); + } +} + +static void +test_dbus_display_hotplug(void) +{ + g_autoptr(GDBusConnection) conn =3D NULL; + QTestState *qts =3D NULL; + gsize n; + + test_setup_args(&qts, &conn, + "-machine q35" + " -device pcie-root-port,id=3Drp0" + " -display dbus,p2p=3Dyes" + " -name dbus-test"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 1); + + qtest_qmp_device_add(qts, "bochs-display", "bochs0", + "{'bus': 'rp0'}"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 2); + + /* + * On q35, PCI device removal is ACPI-based and requires guest + * acknowledgement. Since qtest has no guest OS, issue the delete + * request and force removal via system reset. + */ + qtest_qmp_device_del_send(qts, "bochs0"); + qtest_system_reset_nowait(qts); + wait_device_event(qts, "DEVICE_DELETED", "bochs0"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 1); + + g_clear_object(&conn); + qtest_quit(qts); +} + int main(int argc, char **argv) { @@ -369,6 +463,9 @@ main(int argc, char **argv) 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/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 return g_test_run(); } --=20 2.54.0