From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954617; cv=none; d=zohomail.com; s=zohoarc; b=SF+wj8moV3G2JSfMWpkG1R8xcnhK1EyoWoJbq5zVcEJulCweOjttJQTMVx0YMtu6YUFo/n/wIe03iJNKHjMgPD3OK3wevNtHUTgNW/Vx5ldPERLloRc/QBgzm6Yng++0DZ/owfezWJ2+pRh+qUmdQz3e0ooIgDBhM0d9FYbL2oA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954617; 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=O6C1hDu3cQzCMMLEEH03Ybt186w7zh//uiMvt3AxpV4=; b=Rg0g+wpknUM4BolOCn3HQBTzXrWYGp1rgPKrL6PMFAG6YdhZ4kAGSVQH8vVYxR0MVk5HIE4dDtgH82rOgDAXzjxK5bg1PTszPdTF08gaWYQg00zjj+cvVa2QS86Mvbh1hQfEov0kfzUfe0qS6m2EFCYQ6IC/IG+nl1P8T2X5DBE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954617248960.5967316931998; Thu, 3 Oct 2024 04:23:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvJ-0000h8-1U; Thu, 03 Oct 2024 07:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvE-0000ft-9Y for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:07 -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 1swJvC-0004pm-UF for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:04 -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-98-GSEgY-g6PdyDpPfjUZQGJw-1; Thu, 03 Oct 2024 07:22:55 -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 7B96A19560AB; Thu, 3 Oct 2024 11:22:54 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 04AC919560A3; Thu, 3 Oct 2024 11:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954581; 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=O6C1hDu3cQzCMMLEEH03Ybt186w7zh//uiMvt3AxpV4=; b=TYzjfFBKyyr3YGKIWadBM4kLNFTBm6B47KQXpRuw3uFnrw4ERTNRvmOxPgi4vCS1J62e98 4Ua8YocwjI0DfRnw+tycOX85WsPF4FmEVAEy6/IrM92wqr2izH5EDzA5TGDNpdj3PzNChI cvPL1tWPXamBdl3zXbercW1Y7D63HDM= X-MC-Unique: GSEgY-g6PdyDpPfjUZQGJw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 01/16] hw/audio/hda: free timer on exit Date: Thu, 3 Oct 2024 15:22:28 +0400 Message-ID: <20241003112244.3340697-2-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954619077116600 From: Marc-Andr=C3=A9 Lureau Fixes: 280c1e1cd ("audio/hda: create millisecond timers that handle IO") Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/audio/hda-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index b40eec9604..74c0292284 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -751,7 +751,7 @@ static void hda_audio_exit(HDACodecDevice *hda) continue; } if (a->use_timer) { - timer_del(st->buft); + timer_free(st->buft); } if (st->output) { AUD_close_out(&a->card, st->voice.out); --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954617; cv=none; d=zohomail.com; s=zohoarc; b=ZJeh2AazDLpy3wSltDt59qWGrEoG7wriwtjemJeEdsykoJNLnIvwDQTZnKfBWZ/2ClkTJguNc/fxMvympA+M+PZ96Bb4mAoV/QrTzb/FBDtwgAYCdqCXByVM8lGi74erNMUGN1aCTxdR7VJz4ZvOIj/7f/sDujQLdUlTMg7L/0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954617; 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=pHm6wTPTzUjfAO4AzpcMzfTLULgYF6KhJ4rnk6cMfEI=; b=VYV+F+QYaU4bpU4/62uQnh5lJCAzpO54C6R4nYxV7Ymb1JeJ7PjCJ9i/I83f+/oWMWi+OFUPxAXA3nG8s3tY7Hsi6cFO7D8hMXyKfQlYvPctXR3/fqKk3ygNzoYWbl5CsHG7K/s0qU1y4Ik8DVtrA/m1is+urorD7lIwnJrir4w= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954617318148.91589759486055; Thu, 3 Oct 2024 04:23:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvN-0000ie-RT; Thu, 03 Oct 2024 07:23:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvL-0000ho-08 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:11 -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 1swJvG-0004q9-FM for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:10 -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-447-_ZMQ2v7pNvq1Fpysyg6O_w-1; Thu, 03 Oct 2024 07:23: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 D4F491955F54; Thu, 3 Oct 2024 11:22:59 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EA60019560A3; Thu, 3 Oct 2024 11:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954584; 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=pHm6wTPTzUjfAO4AzpcMzfTLULgYF6KhJ4rnk6cMfEI=; b=V0j8BlVS4+G+Wlvt9rD+4lxLyNCaUIaPnoTIJ4uEE4CqD9IE00dYZmLGflQyyfGftkpt5y +zLpWUUNIn2Xhkv6+mdgdWsB71Hug5tHsJDgCEOC6FgMdqNh8lvB9Is0c9fY9K2Y4EToAy uyf6YwZNuj1ePqvgmhR71t/hSGeiLig= X-MC-Unique: _ZMQ2v7pNvq1Fpysyg6O_w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 02/16] hw/audio/hda: fix memory leak on audio setup Date: Thu, 3 Oct 2024 15:22:29 +0400 Message-ID: <20241003112244.3340697-3-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954619118116600 From: Marc-Andr=C3=A9 Lureau When SET_STREAM_FORMAT is called, we should clear the existing setup. Factor out common function to close a stream. Direct leak of 144 byte(s) in 3 object(s) allocated from: #0 0x7f91d38f7350 in calloc (/lib64/libasan.so.8+0xf7350) (BuildId: a4a= d7eb954b390cf00f07fa10952988a41d9fc7a) #1 0x7f91d2ab7871 in g_malloc0 (/lib64/libglib-2.0.so.0+0x64871) (Build= Id: 36b60dbd02e796145a982d0151ce37202ec05649) #2 0x562fa2f447ee in timer_new_full /home/elmarco/src/qemu/include/qemu= /timer.h:538 #3 0x562fa2f4486f in timer_new /home/elmarco/src/qemu/include/qemu/time= r.h:559 #4 0x562fa2f448a9 in timer_new_ns /home/elmarco/src/qemu/include/qemu/t= imer.h:577 #5 0x562fa2f47955 in hda_audio_setup ../hw/audio/hda-codec.c:490 #6 0x562fa2f4897e in hda_audio_command ../hw/audio/hda-codec.c:605 Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/audio/hda-codec.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/hw/audio/hda-codec.c b/hw/audio/hda-codec.c index 74c0292284..bc661504cf 100644 --- a/hw/audio/hda-codec.c +++ b/hw/audio/hda-codec.c @@ -472,6 +472,24 @@ static void hda_audio_set_amp(HDAAudioStream *st) } } =20 +static void hda_close_stream(HDAAudioState *a, HDAAudioStream *st) +{ + if (st->node =3D=3D NULL) { + return; + } + if (a->use_timer) { + timer_free(st->buft); + st->buft =3D NULL; + } + if (st->output) { + AUD_close_out(&a->card, st->voice.out); + st->voice.out =3D NULL; + } else { + AUD_close_in(&a->card, st->voice.in); + st->voice.in =3D NULL; + } +} + static void hda_audio_setup(HDAAudioStream *st) { bool use_timer =3D st->state->use_timer; @@ -484,6 +502,7 @@ static void hda_audio_setup(HDAAudioStream *st) trace_hda_audio_format(st->node->name, st->as.nchannels, fmt2name[st->as.fmt], st->as.freq); =20 + hda_close_stream(st->state, st); if (st->output) { if (use_timer) { cb =3D hda_audio_output_cb; @@ -741,23 +760,11 @@ static void hda_audio_init(HDACodecDevice *hda, static void hda_audio_exit(HDACodecDevice *hda) { HDAAudioState *a =3D HDA_AUDIO(hda); - HDAAudioStream *st; int i; =20 dprint(a, 1, "%s\n", __func__); for (i =3D 0; i < ARRAY_SIZE(a->st); i++) { - st =3D a->st + i; - if (st->node =3D=3D NULL) { - continue; - } - if (a->use_timer) { - timer_free(st->buft); - } - if (st->output) { - AUD_close_out(&a->card, st->voice.out); - } else { - AUD_close_in(&a->card, st->voice.in); - } + hda_close_stream(a, a->st + i); } AUD_remove_card(&a->card); } --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954712; cv=none; d=zohomail.com; s=zohoarc; b=YY2aPX2pefxLIFhOtrC/8wWoxV5xQ9jRpBcTN5JkWTlcThLEGzzwtyE8xlsBW4q2gWqkrk5YRTglSzKY3FwCgMYRAMOHrtr8p+KK7ckT9F5xZhLzuHeSTraJ7KsGLgDClbK87eytcGRKWwrM76KrOMFNjk6lKRzKlDtS43UMz2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954712; 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=86ceFnNE2QxUGMH5aNQsOPerJ6Kaqcad11z/XVaCSLY=; b=ZYeLEq96x1t0a1MJMTVrxPDy7CZ3uqIBTdUyy5jVTWgm1Zo93FOwznsBpDvl34zZvjx//iRkdzQLZ43r5LvhVDJ/6iq+5zjWVXWDZhbx8pePtHcixYX+Dy2cw+ehVID9PorIPI33Uv8zISYAd/8oI5/Zk/qWNAc9AdHVFE1Tt+g= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954712682658.7139327066037; Thu, 3 Oct 2024 04:25:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvP-0000jH-AM; Thu, 03 Oct 2024 07:23:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvL-0000hv-9r for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:11 -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 1swJvJ-0004qy-QX for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:11 -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-479-VxwNOj-ROwmLylE9hT9aDQ-1; Thu, 03 Oct 2024 07:23:06 -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 F12FE195608C; Thu, 3 Oct 2024 11:23:04 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A8F081955E8C; Thu, 3 Oct 2024 11:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954589; 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=86ceFnNE2QxUGMH5aNQsOPerJ6Kaqcad11z/XVaCSLY=; b=aWkFTA86Ud59Dc37UUbbRMMb22FN4bntTfjqaCdCuOvoqyURjXlsokzWJXIEGPy6BJ/Fww IXZSRXHmrMx3kuGhJJqRZQ8HkOU66jdQNiyLWjut5gEYpjA+8BAwY09ahRfFDxZEn0Djmh Qw+fcAWpaMyLpgv4/L17qVbPodJ82eI= X-MC-Unique: VxwNOj-ROwmLylE9hT9aDQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 03/16] ui/dbus: fix leak on message filtering Date: Thu, 3 Oct 2024 15:22:30 +0400 Message-ID: <20241003112244.3340697-4-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954713410116600 From: Marc-Andr=C3=A9 Lureau A filter function that wants to drop a message should return NULL, in which case it must also unref the message itself. Fixes: fa88b85de ("ui/dbus: filter out pending messages when scanout") Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index a54123acea..434bd608f2 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -1001,6 +1001,7 @@ dbus_filter(GDBusConnection *connection, serial =3D g_dbus_message_get_serial(message); if (serial <=3D ddl->out_serial_to_discard) { trace_dbus_filter(serial, ddl->out_serial_to_discard); + g_object_unref(message); return NULL; } =20 --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954692; cv=none; d=zohomail.com; s=zohoarc; b=OT9mpaBUE6DPPgLQ5t8Vj/ORdPwxci/UUpngcUEs/03HJ7N0vbnj+lmIQTyZa2lD0gSIGY49zTmUl3WEwKv3vKT7omabGKppq/up0ueyoPF+wgjtO3N/6X74gxPojmQrs/ulGDoaRFEDrnoTL5/khRYDPeyZrvh/RjykgqVZ+sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954692; 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=k+5a5aBlZpy1qKcXr/Ng3p5ltqt69gTqRbu3f7L7pJo=; b=CWCuBmdCiqQ92/eFSoheNrop878E9q8s5BGYKMC+3/U0gxcQ6whyycB0FYJZ7v8ntET7C5dtxRT6973KxAGrHITAcSJBNGxAcFUT0hwqLH+faWaULSWGTf/H9CpYtOraKH4pRXkja1OoB1hKbix0g9cQjW1CXzuDl3Ol1+SNnlE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954692023856.4880863474305; Thu, 3 Oct 2024 04:24:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvS-0000jh-Cs; Thu, 03 Oct 2024 07:23:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvQ-0000jY-M4 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23: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 1swJvO-0004sU-Tt for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:16 -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-27-aLWmoE6pNVSma5PIWXX0Tg-1; Thu, 03 Oct 2024 07:23:11 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 9B14919560A6; Thu, 3 Oct 2024 11:23:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 468BD1956054; Thu, 3 Oct 2024 11:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954594; 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=k+5a5aBlZpy1qKcXr/Ng3p5ltqt69gTqRbu3f7L7pJo=; b=dwwXrP+7DWzdks3+2GvitzZ9s+eMLkUkqadxhW1iyOMt3hjPvVIuAD5jpGrV8n874xNICO IrSQoBprY7Sq/EwNlWfm48DyEKYmr+tFzXUsX+0lP8rjKaNmYC6P4kKy3xvE/tkxj1ZPoc Xy3mTYpwlczqxGFmYLp80qXYOJmIs40= X-MC-Unique: aLWmoE6pNVSma5PIWXX0Tg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 04/16] ui/win32: fix potential use-after-free with dbus shared memory Date: Thu, 3 Oct 2024 15:22:31 +0400 Message-ID: <20241003112244.3340697-5-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954693461116600 From: Marc-Andr=C3=A9 Lureau DisplaySurface may be free before the pixman image is freed, since the image is refcounted and used by different objects, including pending dbus messages. Furthermore, setting the destroy function in create_displaysurface_from() isn't appropriate, as it may not be used, and may be overriden as in ramfb. Set the destroy function when the shared handle is set, use the HANDLE directly for destroy data, using a single common helper qemu_pixman_win32_image_destroy(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/qemu-pixman.h | 2 ++ hw/display/virtio-gpu.c | 14 ++------------ ui/console.c | 24 ++---------------------- ui/qemu-pixman.c | 15 +++++++++++++++ 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index ef13a8210c..e3dd72b9e3 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -97,6 +97,8 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, =20 void qemu_pixman_image_unref(pixman_image_t *image); =20 +void qemu_pixman_win32_image_destroy(pixman_image_t *image, void *data); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(pixman_image_t, qemu_pixman_image_unref) =20 #endif /* QEMU_PIXMAN_H */ diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3281842bfe..017a0f170c 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -238,16 +238,6 @@ static uint32_t calc_image_hostmem(pixman_format_code_= t pformat, return height * stride; } =20 -#ifdef WIN32 -static void -win32_pixman_image_destroy(pixman_image_t *image, void *data) -{ - HANDLE handle =3D data; - - qemu_win32_map_free(pixman_image_get_data(image), handle, &error_warn); -} -#endif - static void virtio_gpu_resource_create_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *= cmd) { @@ -308,7 +298,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, bits, c2d.height ? res->hostmem / c2d.height : 0); #ifdef WIN32 if (res->image) { - pixman_image_set_destroy_function(res->image, win32_pixman_ima= ge_destroy, res->handle); + pixman_image_set_destroy_function(res->image, qemu_pixman_win3= 2_image_destroy, res->handle); } #endif } @@ -1327,7 +1317,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, return -EINVAL; } #ifdef WIN32 - pixman_image_set_destroy_function(res->image, win32_pixman_image_d= estroy, res->handle); + pixman_image_set_destroy_function(res->image, qemu_pixman_win32_im= age_destroy, res->handle); #endif =20 res->addrs =3D g_new(uint64_t, res->iov_cnt); diff --git a/ui/console.c b/ui/console.c index 105a0e2c70..8f416ff0b9 100644 --- a/ui/console.c +++ b/ui/console.c @@ -461,24 +461,6 @@ void qemu_displaysurface_win32_set_handle(DisplaySurfa= ce *surface, surface->handle =3D h; surface->handle_offset =3D offset; } - -static void -win32_pixman_image_destroy(pixman_image_t *image, void *data) -{ - DisplaySurface *surface =3D data; - - if (!surface->handle) { - return; - } - - assert(surface->handle_offset =3D=3D 0); - - qemu_win32_map_free( - pixman_image_get_data(surface->image), - surface->handle, - &error_warn - ); -} #endif =20 DisplaySurface *qemu_create_displaysurface(int width, int height) @@ -504,6 +486,8 @@ DisplaySurface *qemu_create_displaysurface(int width, i= nt height) =20 #ifdef WIN32 qemu_displaysurface_win32_set_handle(surface, handle, 0); + pixman_image_set_destroy_function(surface->image, + qemu_pixman_win32_image_destroy, han= dle); #endif return surface; } @@ -519,10 +503,6 @@ DisplaySurface *qemu_create_displaysurface_from(int wi= dth, int height, width, height, (void *)data, linesize); assert(surface->image !=3D NULL); -#ifdef WIN32 - pixman_image_set_destroy_function(surface->image, - win32_pixman_image_destroy, surface); -#endif =20 return surface; } diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 6cada8b45e..3870e1a215 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -4,6 +4,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "ui/console.h" #include "standard-headers/drm/drm_fourcc.h" #include "trace.h" @@ -267,3 +268,17 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, pixman_image_unref(ibg); } #endif /* CONFIG_PIXMAN */ + +#ifdef WIN32 +void +qemu_pixman_win32_image_destroy(pixman_image_t *image, void *data) +{ + HANDLE handle =3D data; + + qemu_win32_map_free( + pixman_image_get_data(image), + handle, + &error_warn + ); +} +#endif --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954700; cv=none; d=zohomail.com; s=zohoarc; b=bA0M6Iibrgc91lkti8rwitNOAp5GCA0HxuzCLS4B/wdDbUmjZ3u5GEB1iNClW8fkICQya4aSOy/z1oD3dKKC+K5BXtUNMvtJ4Nvt9LFtsH2Mlf6qKm/brq/j/XSs411ioMfkxPGE50/l71N1sWJ7V0tfyFpn4p7V5C7IkTzBCIg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954700; 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=z8wnl9Xm4zTLeRDOZvj5ql8gVTEheWi63WNCj5w4Mwo=; b=GAvYQCCJ83U27WYdmfCjsCIT8j/GRHU6AtY2USefcNYYrs0x/KFVUwbdtocRyW3NU/dMtaIz1noAgax8LohoNuDKLKJXgifsqm44h9hyypAw60sVjAZUDEoKuPZdmd61WJ6GcPfRnSiRicdvzD7+Yo0COcrukBfLf9Z/JGtW4nA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954700201133.95535549485328; Thu, 3 Oct 2024 04:25:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvU-0000lt-Om; Thu, 03 Oct 2024 07:23:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvS-0000jj-JY for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:18 -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 1swJvQ-0004sy-Vk for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:18 -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-483-HRQBx9dwPBS-iLTidsccPw-1; Thu, 03 Oct 2024 07:23:15 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 EEB1F19560AB; Thu, 3 Oct 2024 11:23:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D8A4E195605F; Thu, 3 Oct 2024 11:23:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954596; 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=z8wnl9Xm4zTLeRDOZvj5ql8gVTEheWi63WNCj5w4Mwo=; b=SFgG2AWHb4L0FUA/NRTOziJwjpuBuJyewN0BCqKoZUho/lzH+sC8p+0RLVrY8XKscUPnle VIcoK66QGlrE3+YRTwp+Bw0a1xyhCEsYHoTpcyWFB4BCVXvaFbpx/8TPPvRT55hMkoZh9l hgZiJ/F/Bb8w8/8oKa3RaXvxQJS118s= X-MC-Unique: HRQBx9dwPBS-iLTidsccPw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 05/16] ui/dbus: fix filtering all update messages Date: Thu, 3 Oct 2024 15:22:32 +0400 Message-ID: <20241003112244.3340697-6-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954701343116600 From: Marc-Andr=C3=A9 Lureau Filtering pending messages when a new scanout is given shouldn't discard pending cursor changes, for example. Since filtering happens in a different thread, use atomic set/get. Fixes: fa88b85dea ("ui/dbus: filter out pending messages when scanout") Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 434bd608f2..a70cad3a90 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -26,6 +26,7 @@ #include "qapi/error.h" #include "sysemu/sysemu.h" #include "dbus.h" +#include "glib.h" #ifdef G_OS_UNIX #include #endif @@ -85,7 +86,7 @@ struct _DBusDisplayListener { #endif =20 guint dbus_filter; - guint32 out_serial_to_discard; + guint32 display_serial_to_discard; }; =20 G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT) @@ -93,10 +94,12 @@ G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listene= r, G_TYPE_OBJECT) static void dbus_gfx_update(DisplayChangeListener *dcl, int x, int y, int w, int h); =20 -static void ddl_discard_pending_messages(DBusDisplayListener *ddl) +static void ddl_discard_display_messages(DBusDisplayListener *ddl) { - ddl->out_serial_to_discard =3D g_dbus_connection_get_last_serial( + guint32 serial =3D g_dbus_connection_get_last_serial( g_dbus_proxy_get_connection(G_DBUS_PROXY(ddl->proxy))); + + g_atomic_int_set(&ddl->display_serial_to_discard, serial); } =20 #ifdef CONFIG_OPENGL @@ -290,7 +293,7 @@ static void dbus_scanout_dmabuf(DisplayChangeListener *= dcl, return; } =20 - ddl_discard_pending_messages(ddl); + ddl_discard_display_messages(ddl); =20 width =3D qemu_dmabuf_get_width(dmabuf); height =3D qemu_dmabuf_get_height(dmabuf); @@ -338,7 +341,7 @@ static bool dbus_scanout_map(DBusDisplayListener *ddl) return false; } =20 - ddl_discard_pending_messages(ddl); + ddl_discard_display_messages(ddl); =20 if (!qemu_dbus_display1_listener_win32_map_call_scanout_map_sync( ddl->map_proxy, @@ -401,7 +404,7 @@ dbus_scanout_share_d3d_texture( return false; } =20 - ddl_discard_pending_messages(ddl); + ddl_discard_display_messages(ddl); =20 qemu_dbus_display1_listener_win32_d3d11_call_scanout_texture2d( ddl->d3d11_proxy, @@ -659,7 +662,7 @@ static void ddl_scanout(DBusDisplayListener *ddl) surface_stride(ddl->ds) * surface_height(ddl->ds), TRUE, (GDestroyNotify)pixman_image_unref, pixman_image_ref(ddl->ds->imag= e)); =20 - ddl_discard_pending_messages(ddl); + ddl_discard_display_messages(ddl); =20 qemu_dbus_display1_listener_call_scanout( ddl->proxy, surface_width(ddl->ds), surface_height(ddl->ds), @@ -992,17 +995,34 @@ dbus_filter(GDBusConnection *connection, gpointer user_data) { DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(user_data); - guint32 serial; + const gchar *member =3D NULL; + guint32 serial, discard_serial; =20 if (incoming) { return message; } =20 serial =3D g_dbus_message_get_serial(message); - if (serial <=3D ddl->out_serial_to_discard) { - trace_dbus_filter(serial, ddl->out_serial_to_discard); - g_object_unref(message); - return NULL; + + discard_serial =3D g_atomic_int_get(&ddl->display_serial_to_discard); + if (serial <=3D discard_serial) { + member =3D g_dbus_message_get_member(message); + if (g_strv_contains((const gchar *[]) { + "Scanout", + "Update", +#ifdef CONFIG_GBM + "ScanoutDMABUF", + "UpdateDMABUF", +#endif + "ScanoutMap", + "UpdateMap", + "Disable", + NULL, + }, member)) { + trace_dbus_filter(serial, discard_serial); + g_object_unref(message); + return NULL; + } } =20 return message; --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954705; cv=none; d=zohomail.com; s=zohoarc; b=Pv2pzJOyy1EWNOKFfvs/CKPEx1BlzuykRtObUTpgVCBdtdmtE//bUhzaqD3KVYvpj/kBACivG5RiWaecWYFZsNkKz001k1cPpngUeWHWYVoHop1V+dEY2RyH0vRg9UZj3S2zwXzWB9ZsU+/4Q4WTl4jsA3+rQSO6DzpE1wGhh4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954705; 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=fT3Q75y9U/TwgYuHTQ23ZMlJcVZ68x1SDstEaJ1IH8s=; b=I4VEEsQdxIHypvkaeCc7nz23lYoYtA/MOzUVTYoERXw0a9S+aTq+AzgiJcD8krocQCCXjRycPUrKUgFiZ14phkATD4TUVRp/F57t/I5v/5EcszMXY1jhUMDb0ZFO9/NEtyApWiilVPZ6Ayn0VfJwlfZk2IC8XcjsURglT48g2Hc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954705005566.622561069555; Thu, 3 Oct 2024 04:25:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvY-0000nl-Uc; Thu, 03 Oct 2024 07:23:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJvY-0000nQ-86 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:24 -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 1swJvW-0004uG-Te for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:24 -0400 Received: from mx-prod-mc-04.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-55-W-nQY8KDOtetA3UHXT-ixw-1; Thu, 03 Oct 2024 07:23:21 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD55B193579B; Thu, 3 Oct 2024 11:23:18 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 32A4E19560AE; Thu, 3 Oct 2024 11:23:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954602; 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=fT3Q75y9U/TwgYuHTQ23ZMlJcVZ68x1SDstEaJ1IH8s=; b=BLGa23o5/mUl0HDEHHj+mxuMSW8hPKAwOFi6aXT/m4AKJlOH87hxswum5UPAgHZB0MIP3q nrRKzW/ZiaDAtVoMMcSj5L2M1ARE8gy42KhMV1AU95exQ1TkpWA9k9nHUoCO0u+jdcUXxW hb65sKxOZK5GqKVvpTXN2Op6NPTiMqY= X-MC-Unique: W-nQY8KDOtetA3UHXT-ixw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 06/16] ui/dbus: discard display messages on disable Date: Thu, 3 Oct 2024 15:22:33 +0400 Message-ID: <20241003112244.3340697-7-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954705325116600 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index a70cad3a90..23a4633fa4 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -107,6 +107,8 @@ static void dbus_scanout_disable(DisplayChangeListener = *dcl) { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 + ddl_discard_display_messages(ddl); + qemu_dbus_display1_listener_call_disable( ddl->proxy, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); } --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954676; cv=none; d=zohomail.com; s=zohoarc; b=GbpRrJDVlAAgmqcIa2S6p3iRSa7eDxndtxpSbAoWzyXi6FGva7xWYIJ+vQlbnuRxySjS1IDicR5CKiE4Rc6T3cZ2wzHHDQR+6IlYo4tbpPpvNJmn1H9LLif+yQmB5Rh/UReDdNaerUZ3FznuujDdrTNdN2YVLt6Er4cS9VL42Lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954676; 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=ZENKUukW7gMehbQn4GRO0qFPgQRF/WoC6lO4OjmVRlQ=; b=bkp2fb6gX6v7pTnGnNJMZBODPlbzFzNUp5EeE1hz+TpO/vmATtUPbn6PwVxENGj73mQXUuHA3IXgGmo5utMmcR0lpgn7lTtcQ8tR3w17tqMeI3nKmqnHjFOO1M9o0hd69yjgeb7kJp/RdaQDc3s8Q+VxTJXZnzTizVke8uWZxXE= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954676682656.4808973834837; Thu, 3 Oct 2024 04:24:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJvf-0000qA-Ow; Thu, 03 Oct 2024 07:23:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJve-0000pQ-9e for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:30 -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 1swJvc-0004vd-R7 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:23:30 -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-621-ljZDcF7FPWqhQPJ2LsdILw-1; Thu, 03 Oct 2024 07:23:25 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED2791955E84; Thu, 3 Oct 2024 11:23:23 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 50088300019D; Thu, 3 Oct 2024 11:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954608; 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=ZENKUukW7gMehbQn4GRO0qFPgQRF/WoC6lO4OjmVRlQ=; b=OFpCGy0l8sfE6NyHezNzbr1A9KZ0KyXc7+G9KNs2JdEbqZ7hNhkyXU6/BqmJDx2elo8zzi Om6No7+mlXhWc+P4drZ6xOj9U7XRWqBmuO79hW9osN39s1GjcOZ6dWqavPpC+Eg3sjDWh8 jsK92JrtkEoX3e/MUM2VHl8UP48s6zU= X-MC-Unique: ljZDcF7FPWqhQPJ2LsdILw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 07/16] ui/dbus: discard pending CursorDefine on new one Date: Thu, 3 Oct 2024 15:22:34 +0400 Message-ID: <20241003112244.3340697-8-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954677362116600 From: Marc-Andr=C3=A9 Lureau Similar to scanout updates, let's discard pending cursor changes. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 23 +++++++++++++++++++++++ roms/openbios | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 23a4633fa4..020c05198b 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -87,6 +87,7 @@ struct _DBusDisplayListener { =20 guint dbus_filter; guint32 display_serial_to_discard; + guint32 cursor_serial_to_discard; }; =20 G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT) @@ -102,6 +103,14 @@ static void ddl_discard_display_messages(DBusDisplayLi= stener *ddl) g_atomic_int_set(&ddl->display_serial_to_discard, serial); } =20 +static void ddl_discard_cursor_messages(DBusDisplayListener *ddl) +{ + guint32 serial =3D g_dbus_connection_get_last_serial( + g_dbus_proxy_get_connection(G_DBUS_PROXY(ddl->proxy))); + + g_atomic_int_set(&ddl->cursor_serial_to_discard, serial); +} + #ifdef CONFIG_OPENGL static void dbus_scanout_disable(DisplayChangeListener *dcl) { @@ -502,6 +511,8 @@ static void dbus_cursor_dmabuf(DisplayChangeListener *d= cl, return; } =20 + ddl_discard_cursor_messages(ddl); + egl_dmabuf_import_texture(dmabuf); texture =3D qemu_dmabuf_get_texture(dmabuf); if (!texture) { @@ -745,6 +756,8 @@ static void dbus_cursor_define(DisplayChangeListener *d= cl, DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); GVariant *v_data =3D NULL; =20 + ddl_discard_cursor_messages(ddl); + v_data =3D g_variant_new_from_data( G_VARIANT_TYPE("ay"), c->data, @@ -1027,6 +1040,16 @@ dbus_filter(GDBusConnection *connection, } } =20 + discard_serial =3D g_atomic_int_get(&ddl->cursor_serial_to_discard); + if (serial <=3D discard_serial) { + member =3D g_dbus_message_get_member(message); + if (g_strv_contains((const gchar *[]) { "CursorDefine", NULL }, me= mber)) { + trace_dbus_filter(serial, discard_serial); + g_object_unref(message); + return NULL; + } + } + return message; } =20 diff --git a/roms/openbios b/roms/openbios index c3a19c1e54..af97fd7af5 160000 --- a/roms/openbios +++ b/roms/openbios @@ -1 +1 @@ -Subproject commit c3a19c1e54977a53027d6232050e1e3e39a98a1b +Subproject commit af97fd7af5e7c18f591a7b987291d3db4ffb28b5 --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954705; cv=none; d=zohomail.com; s=zohoarc; b=EIihzC5nHG7uT8KoUn8y8XVOOgpWgOBRDaHu+c3HJVbfjWwe2oB8BSHqZexvYhueomstSvlknrt3qQEEkgDJnE2fUnFL/VfT7BfB/Fny+xa8M162lzuGXhtXAaaKEJyqqSWA0K/voklugtZ4AEAhlmMAsFa18piXnF4HcbfObNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954705; 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=x4RgxPEZ+83XTh0E5h/0jQL2wf1ulFytIkVzyIHRDpk=; b=cbFNkEkNYp0aWy77TLdZMl7PIkUjBPex+fwf6BoAcRnr/jRNA5ZD2CNBzMyW+InUfK8uHq8b1tI4agCv62hnt3flpNDZRs38BPIT+yjyd1jv+cWkD4YvS69RW35trUxh2HyhNvAFh75RZCLWGS2/vR5UFBqZ2k6htIO17cIz0VA= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172795470551419.43999218295596; Thu, 3 Oct 2024 04:25:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwE-0001Hk-W1; Thu, 03 Oct 2024 07:24:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwC-00016v-84 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:04 -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 1swJwA-0004wO-DN for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:03 -0400 Received: from mx-prod-mc-04.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-436-dUXTT1lvMw28hUKF_lX86g-1; Thu, 03 Oct 2024 07:23:29 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D149119560A5; Thu, 3 Oct 2024 11:23:28 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 547F61956086; Thu, 3 Oct 2024 11:23:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954613; 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=x4RgxPEZ+83XTh0E5h/0jQL2wf1ulFytIkVzyIHRDpk=; b=SWzqMbBSB+H2MfNXp8XVoZ+3Y1Lmyz8FW/uSVnbKbHKaVLlExejV9pBDWxnuk77J7+0eB8 CUhpoB90fhVPbDUYHH0DChEz+l5g48o1CvjNSve/8R6MlSSfqdqkfF4l6I6BQJMBaIZ2// smovI6sP8hNeNmmmHyq6zTE3Sdgtmb0= X-MC-Unique: dUXTT1lvMw28hUKF_lX86g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 08/16] util/memfd: report potential errors on free Date: Thu, 3 Oct 2024 15:22:35 +0400 Message-ID: <20241003112244.3340697-9-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954707298116600 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- util/memfd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/memfd.c b/util/memfd.c index 4a3c07e0be..8a2e906962 100644 --- a/util/memfd.c +++ b/util/memfd.c @@ -28,6 +28,7 @@ #include "qemu/osdep.h" =20 #include "qapi/error.h" +#include "qemu/error-report.h" #include "qemu/memfd.h" #include "qemu/host-utils.h" =20 @@ -149,11 +150,15 @@ err: void qemu_memfd_free(void *ptr, size_t size, int fd) { if (ptr) { - munmap(ptr, size); + if (munmap(ptr, size) !=3D 0) { + error_report("memfd munmap() failed: %s", strerror(errno)); + } } =20 if (fd !=3D -1) { - close(fd); + if (close(fd) !=3D 0) { + error_report("memfd close() failed: %s", strerror(errno)); + } } } =20 --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954726; cv=none; d=zohomail.com; s=zohoarc; b=kvdRxaK1YMITGXbv6oviPqOkfRlDUbWQeersA5pbjwUrNFvsBXQmaHJdNEdBgBiCP9mvI+mQhnotgE+/cWx1TyTVo22rrMd+MAEBvuDcfTUdtgULs1UoeZnygOAOOeBvDCIbRHPXpg6bU0ION8/uoW0Q2yxwfi2NpIflLAzEiuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954726; 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=ZQg67E1IJjAhY1Pn9xg3BZY0ftT3elkl0R27HI1slrM=; b=XbYp+jMNGuz/pry3iZHxurnRruKpwzs6lIeBdIxkf1yux+Txf9jJdGmMovIj8dpmTVOXPbLv40A+ejxnakWzDioJ+5UKglWXfKRMlhdxCKxi5c+6LYjvJfUDGUKwIIj6DsfWEUR1oTaGzYj66BN2weV4C1fp2I5E3ndTKHWnjMU= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954726017568.6566867174828; Thu, 3 Oct 2024 04:25:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwM-0001q3-CY; Thu, 03 Oct 2024 07:24:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwG-0001Pl-Lp for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:08 -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 1swJwC-0004xj-29 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:08 -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-148-NTCjL42uOw6GGt4IbeNUqw-1; Thu, 03 Oct 2024 07:23:35 -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 00E9219560A1; Thu, 3 Oct 2024 11:23:34 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1BC2C19560A3; Thu, 3 Oct 2024 11:23:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954618; 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=ZQg67E1IJjAhY1Pn9xg3BZY0ftT3elkl0R27HI1slrM=; b=UMD5RsFKLYPCClCTEUJrfv7vzwtjoDzs1b5Bb6ZJ36YdWikPJDv5yMKmF8AmwIYugNws4g Lt7p1JiA/is5+pvKe9xPlmRdF7gde3DKN4NA4CxDYYcvc6xZiNpfHkhlNbYmN/zI0ldFe7 V2AZ0RYCzP06aGf3ulhWKKIHJJXi/6o= X-MC-Unique: NTCjL42uOw6GGt4IbeNUqw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 09/16] ui/pixman: generalize shared_image_destroy Date: Thu, 3 Oct 2024 15:22:36 +0400 Message-ID: <20241003112244.3340697-10-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954727366116600 From: Marc-Andr=C3=A9 Lureau Learn to free memfd-allocated shared memory. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/qemu-pixman.h | 2 +- hw/display/virtio-gpu.c | 4 ++-- ui/console.c | 2 +- ui/qemu-pixman.c | 20 ++++++++++++-------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/ui/qemu-pixman.h b/include/ui/qemu-pixman.h index e3dd72b9e3..a97f56d09a 100644 --- a/include/ui/qemu-pixman.h +++ b/include/ui/qemu-pixman.h @@ -97,7 +97,7 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, =20 void qemu_pixman_image_unref(pixman_image_t *image); =20 -void qemu_pixman_win32_image_destroy(pixman_image_t *image, void *data); +void qemu_pixman_shared_image_destroy(pixman_image_t *image, void *data); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(pixman_image_t, qemu_pixman_image_unref) =20 diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 017a0f170c..77f6e76f23 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -298,7 +298,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g, bits, c2d.height ? res->hostmem / c2d.height : 0); #ifdef WIN32 if (res->image) { - pixman_image_set_destroy_function(res->image, qemu_pixman_win3= 2_image_destroy, res->handle); + pixman_image_set_destroy_function(res->image, qemu_pixman_shar= ed_image_destroy, res->handle); } #endif } @@ -1317,7 +1317,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, return -EINVAL; } #ifdef WIN32 - pixman_image_set_destroy_function(res->image, qemu_pixman_win32_im= age_destroy, res->handle); + pixman_image_set_destroy_function(res->image, qemu_pixman_shared_i= mage_destroy, res->handle); #endif =20 res->addrs =3D g_new(uint64_t, res->iov_cnt); diff --git a/ui/console.c b/ui/console.c index 8f416ff0b9..fdd76c2be4 100644 --- a/ui/console.c +++ b/ui/console.c @@ -487,7 +487,7 @@ DisplaySurface *qemu_create_displaysurface(int width, i= nt height) #ifdef WIN32 qemu_displaysurface_win32_set_handle(surface, handle, 0); pixman_image_set_destroy_function(surface->image, - qemu_pixman_win32_image_destroy, han= dle); + qemu_pixman_shared_image_destroy, ha= ndle); #endif return surface; } diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 3870e1a215..43050ab7c5 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "ui/console.h" +#include "qemu/memfd.h" #include "standard-headers/drm/drm_fourcc.h" #include "trace.h" =20 @@ -269,16 +270,19 @@ void qemu_pixman_glyph_render(pixman_image_t *glyph, } #endif /* CONFIG_PIXMAN */ =20 -#ifdef WIN32 void -qemu_pixman_win32_image_destroy(pixman_image_t *image, void *data) +qemu_pixman_shared_image_destroy(pixman_image_t *image, void *data) { + void *ptr =3D pixman_image_get_data(image); + +#ifndef WIN32 + int shmfd =3D GPOINTER_TO_INT(data); + size_t size =3D pixman_image_get_height(image) * pixman_image_get_stri= de(image); + + qemu_memfd_free(ptr, size, shmfd); +#else HANDLE handle =3D data; =20 - qemu_win32_map_free( - pixman_image_get_data(image), - handle, - &error_warn - ); -} + qemu_win32_map_free(ptr, handle, &error_warn); #endif +} --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954658; cv=none; d=zohomail.com; s=zohoarc; b=B4exHjAjDYwivV59NgSqrufcrMIncbFk9+fmeO40P0PhKDkQj0tiYxrF6/A4XOGpL2a93cEjvxLATyNq0SRphWxGVGfzNOIPsKQyjzvtrkw6hhm8nBtgwmPm0KTk9UIrIYm9fegKs8Mm/An890YdHLCGXbso9N01/eGRXweqRro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954658; 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=LbA5VfDAr/RwkKCrilX42feGwXJTiuFwpzMtEmeaq7Y=; b=gEQzEmgno6qI43iPAa1lAH0DvTWwKjm6s1RTv/fAuNYBHEAloWCGC67dXUk3kJQXun6TVSEIZQ1NxkfmB2NBMhsH7m4Mlc/3vi8Vpou7GrnS6f9rWPiimCWYmPDqPPmX2u+NUuOvphDwsQZT148HfNczYqVr+ceh4sHN48F7xXQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954658333281.3948585463095; Thu, 3 Oct 2024 04:24:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwH-0001Ri-9E; Thu, 03 Oct 2024 07:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwE-0001F6-36 for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:06 -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 1swJwB-0004yP-2M for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:05 -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-267-Hc2NFTKTMo6-korZlr0z-Q-1; Thu, 03 Oct 2024 07:23:40 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 B51B11955E84; Thu, 3 Oct 2024 11:23:38 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5D2781956054; Thu, 3 Oct 2024 11:23:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954623; 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=LbA5VfDAr/RwkKCrilX42feGwXJTiuFwpzMtEmeaq7Y=; b=bGxmtQTiP/63wYQvWrcoRLgAW4l65cwETZssUw56tCXY2fyD5TKVAWzRnPDY7S1wfZwqbH x/BwLuFkAUSOpI+hukavK1+SgXZ3u2dk2rF7ypLpJFvljpGapkvn2SqqAZpPWAWjQ4qKpj m7Za2QuNxpUlTND26reuBo9R2plDQOs= X-MC-Unique: Hc2NFTKTMo6-korZlr0z-Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 10/16] ui/dbus: do not limit to one listener per connection / bus name Date: Thu, 3 Oct 2024 15:22:37 +0400 Message-ID: <20241003112244.3340697-11-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954659184116600 From: Marc-Andr=C3=A9 Lureau This is an arbitrary limitation that doesn't concern QEMU directly and may make some use cases unnecessarily more complicated. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-console.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 578b67f62b..5eb1d40d16 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -41,7 +41,7 @@ struct _DBusDisplayConsole { DisplayChangeListener dcl; =20 DBusDisplay *display; - GHashTable *listeners; + GPtrArray *listeners; QemuDBusDisplay1Console *iface; =20 QemuDBusDisplay1Keyboard *iface_kbd; @@ -142,8 +142,7 @@ dbus_display_console_init(DBusDisplayConsole *object) { DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); =20 - ddc->listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, - NULL, g_object_unref); + ddc->listeners =3D g_ptr_array_new_with_free_func(g_object_unref); ddc->dcl.ops =3D &dbus_console_dcl_ops; } =20 @@ -157,7 +156,7 @@ dbus_display_console_dispose(GObject *object) g_clear_object(&ddc->iface_mouse); g_clear_object(&ddc->iface_kbd); g_clear_object(&ddc->iface); - g_clear_pointer(&ddc->listeners, g_hash_table_unref); + g_clear_pointer(&ddc->listeners, g_ptr_array_unref); g_clear_pointer(&ddc->kbd, qkbd_state_free); =20 G_OBJECT_CLASS(dbus_display_console_parent_class)->dispose(object); @@ -179,7 +178,7 @@ listener_vanished_cb(DBusDisplayListener *listener) =20 trace_dbus_listener_vanished(name); =20 - g_hash_table_remove(ddc->listeners, name); + g_ptr_array_remove_fast(ddc->listeners, listener); qkbd_state_lift_all_keys(ddc->kbd); } =20 @@ -267,16 +266,6 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, DBusDisplayListener *listener; int fd; =20 - if (sender && g_hash_table_contains(ddc->listeners, sender)) { - g_dbus_method_invocation_return_error( - invocation, - DBUS_DISPLAY_ERROR, - DBUS_DISPLAY_ERROR_INVALID, - "`%s` is already registered!", - sender); - return DBUS_METHOD_INVOCATION_HANDLED; - } - #ifdef G_OS_WIN32 if (!dbus_win32_import_socket(invocation, arg_listener, &fd)) { return DBUS_METHOD_INVOCATION_HANDLED; @@ -331,9 +320,7 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 - g_hash_table_insert(ddc->listeners, - (gpointer)dbus_display_listener_get_bus_name(liste= ner), - listener); + g_ptr_array_add(ddc->listeners, listener); g_object_connect(listener_conn, "swapped-signal::closed", listener_vanished_cb, liste= ner, NULL); --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954731; cv=none; d=zohomail.com; s=zohoarc; b=b0nqcr5ygu2E8nFZP3KXNbDh6TqoNYgEnLP/8dfndHOJO2HeBSdmF2HHNu1LNNkIO5AKBqFFgXXbIEbXQXoBINCOa3Yeu8L9Zk513PdQyQay0u5OY/OyqncVxmaV+X2nQj+TXeZ1bhlfKHjUrx9nRWIc5TrK432lCrq/EKgkv0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954731; 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=UU2orHXi/BSaeuFJ2dFG3p9R7+3Imog/8OR1UiqXm3s=; b=V2ap/cvrHGD7DuwtNwAemlYaY2ifWjvasDdwRAXmOaa4QH0tu7gsUKFoUDPmWWLifgL0XIfLMV2yGpAscqGv0RwqEBT91dlPG1dwuCvckTXj0kBKpH6SHSs7DGxExJszkkS8lskMyvP9QaVGZJng8sCoJ4G5VNK7qcL6EpJu0hg= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954731016410.84906939791927; Thu, 3 Oct 2024 04:25:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwL-0001it-4g; Thu, 03 Oct 2024 07:24:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwF-0001Jn-4p for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:07 -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 1swJwB-0004zU-1y for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:06 -0400 Received: from mx-prod-mc-02.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-424-ii7wm8c-MYyFFceob_Q33g-1; Thu, 03 Oct 2024 07:23:45 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 34E62195423C; Thu, 3 Oct 2024 11:23:43 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 24F311956054; Thu, 3 Oct 2024 11:23:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954630; 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=UU2orHXi/BSaeuFJ2dFG3p9R7+3Imog/8OR1UiqXm3s=; b=TI04sUkB9BMIhD7h0KbMtiLEj7GfcaCuNGTXo8E9k6t9X4ik3RlWlsPMmmmrhNHnspVsZY j7XgQhm+2Ov9hm1L/iRsqjXS5GGPGffPM1Ol9rqtTloZ2WiAxNBJTZoIvMLXUqgjq/HPDL LBJC9iBRsgO7vU1rz2pNcp/4AQSSTPU= X-MC-Unique: ii7wm8c-MYyFFceob_Q33g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 11/16] ui/dbus: add trace for can_share_map Date: Thu, 3 Oct 2024 15:22:38 +0400 Message-ID: <20241003112244.3340697-12-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954731399116600 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 1 + ui/trace-events | 1 + 2 files changed, 2 insertions(+) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 020c05198b..f55e197768 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -1083,6 +1083,7 @@ dbus_display_listener_new(const char *bus_name, ddl->console =3D console; =20 dbus_display_listener_setup_shared_map(ddl); + trace_dbus_can_share_map(ddl->can_share_map); dbus_display_listener_setup_d3d11(ddl); =20 con =3D qemu_console_lookup_by_index(dbus_display_console_get_index(co= nsole)); diff --git a/ui/trace-events b/ui/trace-events index fb253c1666..3da0d5e280 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -166,6 +166,7 @@ dbus_clipboard_unregister(const char *bus_name) "peer %= s" dbus_scanout_texture(uint32_t tex_id, bool backing_y_0_top, uint32_t backi= ng_width, uint32_t backing_height, uint32_t x, uint32_t y, uint32_t w, uint= 32_t h) "tex_id:%u y0top:%d back:%ux%u %u+%u-%ux%u" dbus_gl_gfx_switch(void *p) "surf: %p" dbus_filter(unsigned int serial, unsigned int filter) "serial=3D%u (<=3D %= u)" +dbus_can_share_map(bool share) "can_share_map: %d" =20 # egl-helpers.c egl_init_d3d11_device(void *p) "d3d device: %p" --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954748; cv=none; d=zohomail.com; s=zohoarc; b=KNGn3+s5w+jDTh/fZpHkUacVbbAJz8r1L1boR15aVRza/TFb3df5/Pc3xRnruYHbnYtAfYYXbKf1XXUno3+NkADYQ22++HEkyQXVw8iNgxJKvC/t4k4RuiKrq8w2VJVNA+6Cd3lqwDr3jpP6RhVPbGPE3syNp+50RDpBdRcwVBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954748; 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=VcKY8NbRO5rE3QymUOzFCDyaN/n6+6K2gQ+Ykq/T3aU=; b=QSvcChKr598+qwXNMsunWzF9HfC7j/4iBwUJczThwOJhJH4XssVRrX7nqjOVbA0ofda25lgZwaVyO2jgWH/oyndTF9OQPzHNtsJM7b9Y2Ig1a+awABAMB/cDJ89Cx0w2spLmk9+O+NYszUOHaDU9GvsuO2s/Xmy2dh5by0z3BHw= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172795474814076.88880386617927; Thu, 3 Oct 2024 04:25:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwN-0001vu-8C; Thu, 03 Oct 2024 07:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwF-0001Mo-PR for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:07 -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 1swJwB-0004zf-AU for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:07 -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-320-qBOFjRvwO-eonGj18PX_hA-1; Thu, 03 Oct 2024 07:23:49 -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 E5D801956096; Thu, 3 Oct 2024 11:23:47 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9C47E19560A3; Thu, 3 Oct 2024 11:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954632; 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=VcKY8NbRO5rE3QymUOzFCDyaN/n6+6K2gQ+Ykq/T3aU=; b=hvZxb6xtcxDhXNsXtjJf/iQtfgEb5rOqkXijWLPrQCIo4fFUIgIWQFv04Qc13+JshnwGmb YTT3lRNLnWnpKhhlN3+Ozwtl9I2+zqsm7OBQkSg4xNglKAwCMXCNOxUQJ7A7Fd58lmShEZ iGRUHxdcTEHQWo8ccGwvFNcs6FQuh1s= X-MC-Unique: qBOFjRvwO-eonGj18PX_hA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 12/16] ui/surface: allocate shared memory on !win32 Date: Thu, 3 Oct 2024 15:22:39 +0400 Message-ID: <20241003112244.3340697-13-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954749552116600 From: Marc-Andr=C3=A9 Lureau Use qemu_memfd_alloc() to allocate the display surface memory, which will fallback on tmpfile/mmap() on systems without memfd, and allow to share the display with other processes. This is similar to how display memory is allocated on win32 since commit 09b4c198 ("console/win32: allocate shareable display surface"). Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/surface.h | 8 ++++++++ ui/console.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/ui/surface.h b/include/ui/surface.h index 345b19169d..dacf12ffe2 100644 --- a/include/ui/surface.h +++ b/include/ui/surface.h @@ -23,6 +23,10 @@ typedef struct DisplaySurface { GLenum gltype; GLuint texture; #endif +#ifndef WIN32 + int shmfd; + uint32_t shmfd_offset; +#endif #ifdef WIN32 HANDLE handle; uint32_t handle_offset; @@ -37,6 +41,10 @@ DisplaySurface *qemu_create_displaysurface_from(int widt= h, int height, DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); DisplaySurface *qemu_create_placeholder_surface(int w, int h, const char *msg); +#ifndef WIN32 +void qemu_displaysurface_set_shmfd(DisplaySurface *surface, + int shmfd, uint32_t offset); +#endif #ifdef WIN32 void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, HANDLE h, uint32_t offset); diff --git a/ui/console.c b/ui/console.c index fdd76c2be4..56f2462c3d 100644 --- a/ui/console.c +++ b/ui/console.c @@ -37,6 +37,7 @@ #include "trace.h" #include "exec/memory.h" #include "qom/object.h" +#include "qemu/memfd.h" =20 #include "console-priv.h" =20 @@ -452,6 +453,17 @@ qemu_graphic_console_init(Object *obj) { } =20 +#ifndef WIN32 +void qemu_displaysurface_set_shmfd(DisplaySurface *surface, + int shmfd, uint32_t offset) +{ + assert(surface->shmfd =3D=3D -1); + + surface->shmfd =3D shmfd; + surface->shmfd_offset =3D offset; +} +#endif + #ifdef WIN32 void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, HANDLE h, uint32_t offset) @@ -469,12 +481,16 @@ DisplaySurface *qemu_create_displaysurface(int width,= int height) void *bits =3D NULL; #ifdef WIN32 HANDLE handle =3D NULL; +#else + int shmfd =3D -1; #endif =20 trace_displaysurface_create(width, height); =20 #ifdef WIN32 bits =3D qemu_win32_map_alloc(width * height * 4, &handle, &error_abor= t); +#else + bits =3D qemu_memfd_alloc("displaysurface", width * height * 4, 0, &sh= mfd, &error_abort); #endif =20 surface =3D qemu_create_displaysurface_from( @@ -486,9 +502,13 @@ DisplaySurface *qemu_create_displaysurface(int width, = int height) =20 #ifdef WIN32 qemu_displaysurface_win32_set_handle(surface, handle, 0); - pixman_image_set_destroy_function(surface->image, - qemu_pixman_shared_image_destroy, ha= ndle); + void *data =3D handle; +#else + qemu_displaysurface_set_shmfd(surface, shmfd, 0); + void *data =3D GINT_TO_POINTER(shmfd); #endif + pixman_image_set_destroy_function(surface->image, qemu_pixman_shared_i= mage_destroy, data); + return surface; } =20 @@ -499,6 +519,9 @@ DisplaySurface *qemu_create_displaysurface_from(int wid= th, int height, DisplaySurface *surface =3D g_new0(DisplaySurface, 1); =20 trace_displaysurface_create_from(surface, width, height, format); +#ifndef WIN32 + surface->shmfd =3D -1; +#endif surface->image =3D pixman_image_create_bits(format, width, height, (void *)data, linesize); @@ -512,6 +535,9 @@ DisplaySurface *qemu_create_displaysurface_pixman(pixma= n_image_t *image) DisplaySurface *surface =3D g_new0(DisplaySurface, 1); =20 trace_displaysurface_create_pixman(surface); +#ifndef WIN32 + surface->shmfd =3D -1; +#endif surface->image =3D pixman_image_ref(image); =20 return surface; --=20 2.45.2.827.g557ae147e6 From nobody Sat Nov 23 23:25:59 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1727954718; cv=none; d=zohomail.com; s=zohoarc; b=O9UYzP0c9IIJ158vUCQin1CXBXgI9XEI8AJk5brNa6bGbSsqKzd8Jn75b2Rz5meMBShBHF1wlQa075iPJbufmoBsvg/ZxPAiyVAIPmZb4CdM4jB2Or66S3mcwjkWNygQp1IQWGr25SL0fYNgELf9utBE+ne8BvsSeweLrg2q3+M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727954718; 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=WfcQ4b5SI+4FXetDTYi/1ouyGBuP9W7sNYnRn2XsVrY=; b=lhXkZOvOM6s32Gj4omfShiF5t8UcFOHS0Rf25jRMASgDVgYAXt1Cun/RoRz7TxB5xJb8oH8JPQ7w9PwUZl4zPBzP6Xhv1Q+m5GiQYB9LilaK8/fCR1Mr8CI9xijHcwNhLZFJGlvw6dO/y5ixKusVUkrP+vAh8gLQzYw2QZZoqDk= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1727954718400931.1398778111029; Thu, 3 Oct 2024 04:25:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swJwK-0001aZ-3u; Thu, 03 Oct 2024 07:24:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1swJwF-0001Lu-EK for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24:07 -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 1swJwB-000507-9s for qemu-devel@nongnu.org; Thu, 03 Oct 2024 07:24: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-513-zhwzUBegOrSmnOlo6Pb04g-1; Thu, 03 Oct 2024 07:23:54 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DA0881955EB4; Thu, 3 Oct 2024 11:23:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.36]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A97FF30000DF; Thu, 3 Oct 2024 11:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727954635; 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=WfcQ4b5SI+4FXetDTYi/1ouyGBuP9W7sNYnRn2XsVrY=; b=eLEYHdxxLq0XpG+j4YfMxlZl5sbMlipZGfWKyF5oS++SXHqVvwVrGDayJyzyyCo2cN8fG2 1VEFeJQ/F6bSdclwOzxEEtCI9hl0pqsnIqpygaHJD+atB8kSnj315rtWjsY6gQq3rX2N6y D04XXF70GeoXH3i8Q3Mhk+LpIXSkdEU= X-MC-Unique: zhwzUBegOrSmnOlo6Pb04g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, "Michael S. Tsirkin" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier , Gerd Hoffmann , belmouss@redhat.com, Akihiko Odaki , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PATCH 13/16] ui/dbus: add Listener.Unix.Map interface XML Date: Thu, 3 Oct 2024 15:22:40 +0400 Message-ID: <20241003112244.3340697-14-marcandre.lureau@redhat.com> In-Reply-To: <20241003112244.3340697-1-marcandre.lureau@redhat.com> References: <20241003112244.3340697-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=lists.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, 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_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=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: 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: 1727954719436116600 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-display1.xml | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index ce35d64eea..4ae14288bc 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -469,6 +469,51 @@ =20 + + + + + + + + + + + + + + + + + + + + +