From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070146; cv=none; d=zohomail.com; s=zohoarc; b=BXiGPgngkYTK3G8XYHwMwu6an9CQnNXahv1ma2Xt10aETbfJ9pLXtuoguIx2G5dbQKCdJlYm++lMgO8Czx/7IBSFcA8gy+G3/PfD5BCpY6uymzStaFQVTrk9tLWSvbU7ktKnoh0uMC4e6KABl03HcQ3Tld+XkIrQm0aEL8Ir8WU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070146; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=03CeoIGOe6igCvSlLszqsEglPU2lZ3zSzXY24jpw39M=; b=iEHilfko8FfoXS4t3NQTJrGB/FZGusKcnkl9Ds9GlCG7fG1gbHR1UQwdrHjUEcgfDiOYFLyOU0asph+hNOXm5UVaKpiYM4j0KzC/vLT7VSmLvZIWy7BUUgBd5fIJQ/CnvYU+8NqRowT+JQZsYQ3KFjuaOQgYwEJuYSGBf3+lO7k= 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 1640070146606942.4047832433145; Mon, 20 Dec 2021 23:02:26 -0800 (PST) Received: from localhost ([::1]:56234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZAH-0003HT-GC for importer@patchew.org; Tue, 21 Dec 2021 02:02:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ7U-0001Ha-63 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 01:59:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45708) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ7R-0001db-HJ for qemu-devel@nongnu.org; Tue, 21 Dec 2021 01:59:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-YwDO59v1PjOpJDqcV_beiQ-1; Tue, 21 Dec 2021 01:59:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5051136393; Tue, 21 Dec 2021 06:59:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86DCD7E8EF; Tue, 21 Dec 2021 06:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640069968; 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=03CeoIGOe6igCvSlLszqsEglPU2lZ3zSzXY24jpw39M=; b=BScEfBok7EaAjOkINnd4oXZoiDQNB8MSzB/rxXbBVYnxgNTDjM6BHy5yyBE2gF5Crx4SHT IdoPMH4mcgBhj9KM8aUgyCfvcxTarW5dA57apJG69kqU2fZkw1DBr+ff83RfR64FPmSbmu FoIPM0Wm7lC20mIrlPrjV5IyD5eV3R0= X-MC-Unique: YwDO59v1PjOpJDqcV_beiQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 01/36] ui/vdagent: add CHECK_SPICE_PROTOCOL_VERSION Date: Tue, 21 Dec 2021 10:58:20 +0400 Message-Id: <20211221065855.142578-2-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070147123100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- meson.build | 5 +++++ ui/vdagent.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/meson.build b/meson.build index f45ecf31bdbe..1c70839bbf17 100644 --- a/meson.build +++ b/meson.build @@ -1497,6 +1497,11 @@ config_host_data.set('CONFIG_ZSTD', zstd.found()) config_host_data.set('CONFIG_FUSE', fuse.found()) config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) config_host_data.set('CONFIG_SPICE_PROTOCOL', spice_protocol.found()) +if spice_protocol.found() +config_host_data.set('CONFIG_SPICE_PROTOCOL_MAJOR', spice_protocol.version= ().split('.')[0]) +config_host_data.set('CONFIG_SPICE_PROTOCOL_MINOR', spice_protocol.version= ().split('.')[1]) +config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', spice_protocol.version= ().split('.')[2]) +endif config_host_data.set('CONFIG_SPICE', spice.found()) config_host_data.set('CONFIG_X11', x11.found()) config_host_data.set('CONFIG_CFI', get_option('cfi')) diff --git a/ui/vdagent.c b/ui/vdagent.c index 19e8fbfc96f1..1f8fc77ee8f3 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -17,6 +17,14 @@ =20 #include "spice/vd_agent.h" =20 +#define CHECK_SPICE_PROTOCOL_VERSION(major, minor, micro) \ + (CONFIG_SPICE_PROTOCOL_MAJOR > (major) || \ + (CONFIG_SPICE_PROTOCOL_MAJOR =3D=3D (major) && \ + CONFIG_SPICE_PROTOCOL_MINOR > (minor)) || \ + (CONFIG_SPICE_PROTOCOL_MAJOR =3D=3D (major) && \ + CONFIG_SPICE_PROTOCOL_MINOR =3D=3D (minor) && \ + CONFIG_SPICE_PROTOCOL_MICRO >=3D (micro))) + #define VDAGENT_BUFFER_LIMIT (1 * MiB) #define VDAGENT_MOUSE_DEFAULT true #define VDAGENT_CLIPBOARD_DEFAULT false --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070455; cv=none; d=zohomail.com; s=zohoarc; b=MDMTExBlBtbaDoieAKnIOID2IfO6Ra7kStFsq8W6ew3LGAKE5z6Zmd07n1LXn2zY2wytcobceAx6vJ9ONkysgFUvwMa+N5zXExW1kYCx9m0JJoVwyYWtpFIIC+7/0tj8bXqc0TZvPycnVlhcWQTKAMqVDYrtHe0jPCMaKrcH1aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070455; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1NPxNJl2P8NzMZgu63BRXG6ySBfg6/iOpK/WPgt+1bc=; b=V7hsOwzS5ufhpdYlQfpnvu31Vq4Erh4exj8jU/+98V55xx4LQu0bfehGB2jgOV1iPpKqOPgiE+5y3N5QJtKD8YMSAP8p+qTFTLsdbxnrcY0Q81IxgoXqCkd91smq62GdPyGb96t2Sw9Q4xAix+VPj199QnUOUFIni60GSenroXI= 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 1640070455389930.5757973747558; Mon, 20 Dec 2021 23:07:35 -0800 (PST) Received: from localhost ([::1]:36398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZFG-0000zY-EC for importer@patchew.org; Tue, 21 Dec 2021 02:07:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ7f-0001dB-NK for qemu-devel@nongnu.org; Tue, 21 Dec 2021 01:59:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37196) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ7e-0001fO-8D for qemu-devel@nongnu.org; Tue, 21 Dec 2021 01:59:43 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-416-Uhkzp8O_ORiWhDlIU8D2Ww-1; Tue, 21 Dec 2021 01:59:40 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3C0A801B31; Tue, 21 Dec 2021 06:59:39 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15FED38E02; Tue, 21 Dec 2021 06:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640069981; 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=1NPxNJl2P8NzMZgu63BRXG6ySBfg6/iOpK/WPgt+1bc=; b=iBjMyPHpXt2grXKZvaES/v1AOT7fe2vTb0nCBjdXmRnMMccEiNwnRhXAFOf0KI0EmrTw8t pKUp33J4IMd3c3FFCZCQA006XrlTD0sf/dYi65vlDMQ2L9SCEYGglP7+76ZhyGZqwN59CY sreTTS69rSnuVsfUH+vSxb/uwTVTkqg= X-MC-Unique: Uhkzp8O_ORiWhDlIU8D2Ww-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 02/36] ui/vdagent: replace #if 0 with protocol version check Date: Tue, 21 Dec 2021 10:58:21 +0400 Message-Id: <20211221065855.142578-3-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070457051100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/vdagent.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/vdagent.c b/ui/vdagent.c index 1f8fc77ee8f3..64e00170017f 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -87,8 +87,10 @@ static const char *cap_name[] =3D { [VD_AGENT_CAP_MONITORS_CONFIG_POSITION] =3D "monitors-config-pos= ition", [VD_AGENT_CAP_FILE_XFER_DISABLED] =3D "file-xfer-disabled", [VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS] =3D "file-xfer-detailed-= errors", -#if 0 +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 0) [VD_AGENT_CAP_GRAPHICS_DEVICE_INFO] =3D "graphics-device-inf= o", +#endif +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1) [VD_AGENT_CAP_CLIPBOARD_NO_RELEASE_ON_REGRAB] =3D "clipboard-no-releas= e-on-regrab", [VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL] =3D "clipboard-grab-seri= al", #endif @@ -110,7 +112,7 @@ static const char *msg_name[] =3D { [VD_AGENT_CLIENT_DISCONNECTED] =3D "client-disconnected", [VD_AGENT_MAX_CLIPBOARD] =3D "max-clipboard", [VD_AGENT_AUDIO_VOLUME_SYNC] =3D "audio-volume-sync", -#if 0 +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 0) [VD_AGENT_GRAPHICS_DEVICE_INFO] =3D "graphics-device-info", #endif }; @@ -128,7 +130,7 @@ static const char *type_name[] =3D { [VD_AGENT_CLIPBOARD_IMAGE_BMP] =3D "bmp", [VD_AGENT_CLIPBOARD_IMAGE_TIFF] =3D "tiff", [VD_AGENT_CLIPBOARD_IMAGE_JPG] =3D "jpg", -#if 0 +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 3) [VD_AGENT_CLIPBOARD_FILE_LIST] =3D "files", #endif }; --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070943; cv=none; d=zohomail.com; s=zohoarc; b=KG9gyYxqG6Z2wzVENDePS4tqbwxq5efmv3/v483BtXQq+372wMh/Calcq8zXamg3wT5TfLwr2PuJciwMWuxZr/7BbhTpaz2YlS9yuYtfuXk9JeSPF6MPHqWgvfMhc3ApB08uSeBWBz/H6mpTQZ0iIMq0y86GHKfb1y4IHWS5mBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AiN9BUutgkzLtBp/GAyVU25mmPg2j5ZZqIuXUaGx4/4=; b=Tg787ZFURePz963MoVkdxRGwKDqaO7cB5JFf3z/kSEfVLbkAQ3lx4zrCfNiQjXPOxFcRxLHSpbH/oTsFdcQ7oNsoczcBJGWh5pHBa7VzczLMBgQ5MpXKItPo/x/H53ajFNKHnZEBT3nMNOpxV2C5vmZ2vpl0//ZIGXZWqQssd6U= 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 1640070943929186.43156054783447; Mon, 20 Dec 2021 23:15:43 -0800 (PST) Received: from localhost ([::1]:45214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZN7-0007an-Eq for importer@patchew.org; Tue, 21 Dec 2021 02:15:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ85-00025U-B2 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56247) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ83-0001hn-3w for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-438-nav0vnlmOQCRQXMN_zZPew-1; Tue, 21 Dec 2021 01:59:58 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 664E0802C91; Tue, 21 Dec 2021 06:59:57 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 708BD838DF; Tue, 21 Dec 2021 06:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070006; 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=AiN9BUutgkzLtBp/GAyVU25mmPg2j5ZZqIuXUaGx4/4=; b=NqEbJCJTg55RSbedWoI01MajEelMRVo8p4gSGJM04gKLPZ7Y6blUSqH5cSbbBTyDe1yzod SINxw5OYkNkKwS3vojkGtYLk/l9SfkDrOr5n6ynU4l/ClO7KkoHkL+QkfLxyKrpolse5pI Py+FErDZqdMrZV6YFVpGMrLa9Ruhxzw= X-MC-Unique: nav0vnlmOQCRQXMN_zZPew-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 03/36] ui: generalize clipboard notifier Date: Tue, 21 Dec 2021 10:58:22 +0400 Message-Id: <20211221065855.142578-4-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070945834100001 From: Marc-Andr=C3=A9 Lureau Use a QemuClipboardNotify union type for extendable clipboard events. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 32 ++++++++++++++++++++++++++++++-- ui/clipboard.c | 12 ++++++++---- ui/gtk-clipboard.c | 20 ++++++++++++++++---- ui/vdagent.c | 27 ++++++++++++++++++--------- ui/vnc-clipboard.c | 20 +++++++++++++++----- ui/vnc.c | 2 +- ui/cocoa.m | 17 +++++++++++++---- 7 files changed, 101 insertions(+), 29 deletions(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 6298986b15c3..d82cf314811c 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -20,8 +20,10 @@ */ =20 typedef enum QemuClipboardType QemuClipboardType; +typedef enum QemuClipboardNotifyType QemuClipboardNotifyType; typedef enum QemuClipboardSelection QemuClipboardSelection; typedef struct QemuClipboardPeer QemuClipboardPeer; +typedef struct QemuClipboardNotify QemuClipboardNotify; typedef struct QemuClipboardInfo QemuClipboardInfo; =20 /** @@ -55,18 +57,44 @@ enum QemuClipboardSelection { * struct QemuClipboardPeer * * @name: peer name. - * @update: notifier for clipboard updates. + * @notifier: notifier for clipboard updates. * @request: callback for clipboard data requests. * * Clipboard peer description. */ struct QemuClipboardPeer { const char *name; - Notifier update; + Notifier notifier; void (*request)(QemuClipboardInfo *info, QemuClipboardType type); }; =20 +/** + * enum QemuClipboardNotifyType + * + * @QEMU_CLIPBOARD_UPDATE_INFO: clipboard info update + * + * Clipboard notify type. + */ +enum QemuClipboardNotifyType { + QEMU_CLIPBOARD_UPDATE_INFO, +}; + +/** + * struct QemuClipboardNotify + * + * @type: the type of event. + * @info: a QemuClipboardInfo event. + * + * Clipboard notify data. + */ +struct QemuClipboardNotify { + QemuClipboardNotifyType type; + union { + QemuClipboardInfo *info; + }; +}; + /** * struct QemuClipboardInfo * diff --git a/ui/clipboard.c b/ui/clipboard.c index d7b008d62a07..743b39edf424 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -8,7 +8,7 @@ static QemuClipboardInfo *cbinfo[QEMU_CLIPBOARD_SELECTION__= COUNT]; =20 void qemu_clipboard_peer_register(QemuClipboardPeer *peer) { - notifier_list_add(&clipboard_notifiers, &peer->update); + notifier_list_add(&clipboard_notifiers, &peer->notifier); } =20 void qemu_clipboard_peer_unregister(QemuClipboardPeer *peer) @@ -18,8 +18,7 @@ void qemu_clipboard_peer_unregister(QemuClipboardPeer *pe= er) for (i =3D 0; i < QEMU_CLIPBOARD_SELECTION__COUNT; i++) { qemu_clipboard_peer_release(peer, i); } - - notifier_remove(&peer->update); + notifier_remove(&peer->notifier); } =20 bool qemu_clipboard_peer_owns(QemuClipboardPeer *peer, @@ -44,10 +43,15 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *pee= r, =20 void qemu_clipboard_update(QemuClipboardInfo *info) { + QemuClipboardNotify notify =3D { + .type =3D QEMU_CLIPBOARD_UPDATE_INFO, + .info =3D info, + }; g_autoptr(QemuClipboardInfo) old =3D NULL; + assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT); =20 - notifier_list_notify(&clipboard_notifiers, info); + notifier_list_notify(&clipboard_notifiers, ¬ify); =20 old =3D cbinfo[info->selection]; cbinfo[info->selection] =3D qemu_clipboard_info_ref(info); diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 35b7a2c22838..44ff810234ff 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -74,10 +74,9 @@ static void gd_clipboard_clear(GtkClipboard *clipboard, gd->cbowner[s] =3D false; } =20 -static void gd_clipboard_notify(Notifier *notifier, void *data) +static void gd_clipboard_update_info(GtkDisplayState *gd, + QemuClipboardInfo *info) { - GtkDisplayState *gd =3D container_of(notifier, GtkDisplayState, cbpeer= .update); - QemuClipboardInfo *info =3D data; QemuClipboardSelection s =3D info->selection; bool self_update =3D info->owner =3D=3D &gd->cbpeer; =20 @@ -118,6 +117,19 @@ static void gd_clipboard_notify(Notifier *notifier, vo= id *data) */ } =20 +static void gd_clipboard_notify(Notifier *notifier, void *data) +{ + GtkDisplayState *gd =3D + container_of(notifier, GtkDisplayState, cbpeer.notifier); + QemuClipboardNotify *notify =3D data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + gd_clipboard_update_info(gd, notify->info); + return; + } +} + static void gd_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type) { @@ -172,7 +184,7 @@ static void gd_owner_change(GtkClipboard *clipboard, void gd_clipboard_init(GtkDisplayState *gd) { gd->cbpeer.name =3D "gtk"; - gd->cbpeer.update.notify =3D gd_clipboard_notify; + gd->cbpeer.notifier.notify =3D gd_clipboard_notify; gd->cbpeer.request =3D gd_clipboard_request; qemu_clipboard_peer_register(&gd->cbpeer); =20 diff --git a/ui/vdagent.c b/ui/vdagent.c index 64e00170017f..de827aad27ab 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -417,10 +417,9 @@ static void vdagent_send_empty_clipboard_data(VDAgentC= hardev *vd, vdagent_send_clipboard_data(vd, info, type); } =20 -static void vdagent_clipboard_notify(Notifier *notifier, void *data) +static void vdagent_clipboard_update_info(VDAgentChardev *vd, + QemuClipboardInfo *info) { - VDAgentChardev *vd =3D container_of(notifier, VDAgentChardev, cbpeer.u= pdate); - QemuClipboardInfo *info =3D data; QemuClipboardSelection s =3D info->selection; QemuClipboardType type; bool self_update =3D info->owner =3D=3D &vd->cbpeer; @@ -449,6 +448,19 @@ static void vdagent_clipboard_notify(Notifier *notifie= r, void *data) } } =20 +static void vdagent_clipboard_notify(Notifier *notifier, void *data) +{ + VDAgentChardev *vd =3D + container_of(notifier, VDAgentChardev, cbpeer.notifier); + QemuClipboardNotify *notify =3D data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + vdagent_clipboard_update_info(vd, notify->info); + return; + } +} + static void vdagent_clipboard_request(QemuClipboardInfo *info, QemuClipboardType qtype) { @@ -658,9 +670,9 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, V= DAgentMessage *msg) if (have_mouse(vd) && vd->mouse_hs) { qemu_input_handler_activate(vd->mouse_hs); } - if (have_clipboard(vd) && vd->cbpeer.update.notify =3D=3D NULL) { + if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) { vd->cbpeer.name =3D "vdagent"; - vd->cbpeer.update.notify =3D vdagent_clipboard_notify; + vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; vd->cbpeer.request =3D vdagent_clipboard_request; qemu_clipboard_peer_register(&vd->cbpeer); } @@ -799,7 +811,7 @@ static void vdagent_disconnect(VDAgentChardev *vd) if (vd->mouse_hs) { qemu_input_handler_deactivate(vd->mouse_hs); } - if (vd->cbpeer.update.notify) { + if (vd->cbpeer.notifier.notify) { qemu_clipboard_peer_unregister(&vd->cbpeer); memset(&vd->cbpeer, 0, sizeof(vd->cbpeer)); } @@ -807,11 +819,8 @@ static void vdagent_disconnect(VDAgentChardev *vd) =20 static void vdagent_chr_set_fe_open(struct Chardev *chr, int fe_open) { - VDAgentChardev *vd =3D QEMU_VDAGENT_CHARDEV(chr); - if (!fe_open) { trace_vdagent_close(); - vdagent_disconnect(vd); return; } =20 diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c index 67284b556cd8..6a0b1058840e 100644 --- a/ui/vnc-clipboard.c +++ b/ui/vnc-clipboard.c @@ -189,10 +189,8 @@ static void vnc_clipboard_provide(VncState *vs, vnc_flush(vs); } =20 -static void vnc_clipboard_notify(Notifier *notifier, void *data) +static void vnc_clipboard_update_info(VncState *vs, QemuClipboardInfo *inf= o) { - VncState *vs =3D container_of(notifier, VncState, cbpeer.update); - QemuClipboardInfo *info =3D data; QemuClipboardType type; bool self_update =3D info->owner =3D=3D &vs->cbpeer; uint32_t flags =3D 0; @@ -223,6 +221,18 @@ static void vnc_clipboard_notify(Notifier *notifier, v= oid *data) } } =20 +static void vnc_clipboard_notify(Notifier *notifier, void *data) +{ + VncState *vs =3D container_of(notifier, VncState, cbpeer.notifier); + QemuClipboardNotify *notify =3D data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + vnc_clipboard_update_info(vs, notify->info); + return; + } +} + static void vnc_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type) { @@ -316,9 +326,9 @@ void vnc_server_cut_text_caps(VncState *vs) caps[1] =3D 0; vnc_clipboard_send(vs, 2, caps); =20 - if (!vs->cbpeer.update.notify) { + if (!vs->cbpeer.notifier.notify) { vs->cbpeer.name =3D "vnc"; - vs->cbpeer.update.notify =3D vnc_clipboard_notify; + vs->cbpeer.notifier.notify =3D vnc_clipboard_notify; vs->cbpeer.request =3D vnc_clipboard_request; qemu_clipboard_peer_register(&vs->cbpeer); } diff --git a/ui/vnc.c b/ui/vnc.c index af02522e8416..9b603382e75e 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1354,7 +1354,7 @@ void vnc_disconnect_finish(VncState *vs) /* last client gone */ vnc_update_server_surface(vs->vd); } - if (vs->cbpeer.update.notify) { + if (vs->cbpeer.notifier.notify) { qemu_clipboard_peer_unregister(&vs->cbpeer); } =20 diff --git a/ui/cocoa.m b/ui/cocoa.m index 68a6302184ab..6640a2e80ebb 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1808,14 +1808,12 @@ static void cocoa_clipboard_request(QemuClipboardIn= fo *info, =20 static QemuClipboardPeer cbpeer =3D { .name =3D "cocoa", - .update =3D { .notify =3D cocoa_clipboard_notify }, + .notifier =3D { .notify =3D cocoa_clipboard_notify }, .request =3D cocoa_clipboard_request }; =20 -static void cocoa_clipboard_notify(Notifier *notifier, void *data) +static void cocoa_clipboard_update_info(QemuClipboardInfo *info) { - QemuClipboardInfo *info =3D data; - if (info->owner =3D=3D &cbpeer || info->selection !=3D QEMU_CLIPBOARD_= SELECTION_CLIPBOARD) { return; } @@ -1831,6 +1829,17 @@ static void cocoa_clipboard_notify(Notifier *notifie= r, void *data) qemu_event_set(&cbevent); } =20 +static void cocoa_clipboard_notify(Notifier *notifier, void *data) +{ + QemuClipboardNotify *notify =3D data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + cocoa_clipboard_update_info(notify->info); + return; + } +} + static void cocoa_clipboard_request(QemuClipboardInfo *info, QemuClipboardType type) { --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070225; cv=none; d=zohomail.com; s=zohoarc; b=LRyn0ZV5/g0peygn7O6toLRt+WrBIJ/s1takPRgzWLn/0tOsNVi3CsBt0XxRMO+t3I9zgcs9XBxalSZTgCWYf5b7ToCMLyJBlCusnABPNi2qKuIU8GZdoqqzM/jEptqrpwzyrDcgME8iosgL/wlMUgZ9GGvBypdwSBkf/od5vo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070225; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BdzU92WGn1A58ygWK4ITnPJIjSHful7PtBJGOw21P0U=; b=cUHdnsV5a+tvNp33hIFWNBEE7xSzKhT/8eAWVBjpvTy8P/5fcFaWmxzgcAe+jtID/89zpFaN/y5Q+1HK5U93z40acnfV1AtG2asAkfyqpL46YKTB9uQVims9EEeqPD3vMbWV1VjSMy6DOXOYzH/mbssLMsR/BC7cJo7zCoRY/Iw= 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 1640070225697525.5699585757967; Mon, 20 Dec 2021 23:03:45 -0800 (PST) Received: from localhost ([::1]:58660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZBY-0004wt-7b for importer@patchew.org; Tue, 21 Dec 2021 02:03:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ8T-0002To-UC for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ8R-0001kG-SN for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:33 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-suZsMAncMyqYMzNHyb2DCw-1; Tue, 21 Dec 2021 02:00:26 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 947161853020; Tue, 21 Dec 2021 07:00:25 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E91077451; Tue, 21 Dec 2021 07:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070031; 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=BdzU92WGn1A58ygWK4ITnPJIjSHful7PtBJGOw21P0U=; b=So5P9TedgbDfjFOsKmvk2MMd4VVbgM8WkCvbA24hV7xESUTqYSFlpEKNrrg63+UOlFGBpc Y3EJ+av8kmec5kMnBvBi7rB5GL+jbnNGIZqWkU9bj3NtZsFS3ZFeDgZ1by0rxojWoWSWX/ FSazkGP7PQjNLOk5mobNNfwvjWmLyw8= X-MC-Unique: suZsMAncMyqYMzNHyb2DCw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 04/36] ui/vdagent: add serial capability support Date: Tue, 21 Dec 2021 10:58:23 +0400 Message-Id: <20211221065855.142578-5-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070226995100001 From: Marc-Andr=C3=A9 Lureau The Spice agent implements a simple serial mechanism to avoid clipboard races between client & guest. See: https://gitlab.freedesktop.org/spice/spice-protocol/-/commit/045a6978d6dbbf= 7046affc5c321fa8177c8cce56 Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 4 ++++ ui/vdagent.c | 39 ++++++++++++++++++++++++++++++++++++++- ui/trace-events | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index d82cf314811c..e590b453c8b7 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -102,6 +102,8 @@ struct QemuClipboardNotify { * @owner: clipboard owner. * @selection: clipboard selection. * @types: clipboard data array (one entry per type). + * @has_serial: whether @serial is available. + * @serial: the grab serial counter. * * Clipboard content data and metadata. */ @@ -109,6 +111,8 @@ struct QemuClipboardInfo { uint32_t refcount; QemuClipboardPeer *owner; QemuClipboardSelection selection; + bool has_serial; + uint32_t serial; struct { bool available; bool requested; diff --git a/ui/vdagent.c b/ui/vdagent.c index de827aad27ab..b4fdae69177f 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -59,6 +59,7 @@ struct VDAgentChardev { =20 /* clipboard */ QemuClipboardPeer cbpeer; + uint32_t last_serial[QEMU_CLIPBOARD_SELECTION__COUNT]; uint32_t cbpending[QEMU_CLIPBOARD_SELECTION__COUNT]; }; typedef struct VDAgentChardev VDAgentChardev; @@ -203,6 +204,9 @@ static void vdagent_send_caps(VDAgentChardev *vd) if (vd->clipboard) { caps->caps[0] |=3D (1 << VD_AGENT_CAP_CLIPBOARD_BY_DEMAND); caps->caps[0] |=3D (1 << VD_AGENT_CAP_CLIPBOARD_SELECTION); +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1) + caps->caps[0] |=3D (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL); +#endif } =20 vdagent_send_msg(vd, msg); @@ -333,7 +337,8 @@ static void vdagent_send_clipboard_grab(VDAgentChardev = *vd, { g_autofree VDAgentMessage *msg =3D g_malloc0(sizeof(VDAgentMessage) + - sizeof(uint32_t) * (QEMU_CLIPBOARD_TYPE__COUNT + 1)); + sizeof(uint32_t) * (QEMU_CLIPBOARD_TYPE__COUNT + 1) + + sizeof(uint32_t)); uint8_t *s =3D msg->data; uint32_t *data =3D (uint32_t *)msg->data; uint32_t q, type; @@ -346,6 +351,19 @@ static void vdagent_send_clipboard_grab(VDAgentChardev= *vd, return; } =20 +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1) + if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) { + if (!info->has_serial) { + /* client should win */ + info->serial =3D vd->last_serial[info->selection]++; + info->has_serial =3D true; + } + *data =3D info->serial; + data++; + msg->size +=3D sizeof(uint32_t); + } +#endif + for (q =3D 0; q < QEMU_CLIPBOARD_TYPE__COUNT; q++) { type =3D type_qemu_to_vdagent(q); if (type !=3D VD_AGENT_CLIPBOARD_NONE && info->types[q].available)= { @@ -494,6 +512,24 @@ static void vdagent_clipboard_recv_grab(VDAgentChardev= *vd, uint8_t s, uint32_t =20 trace_vdagent_cb_grab_selection(GET_NAME(sel_name, s)); info =3D qemu_clipboard_info_new(&vd->cbpeer, s); +#if CHECK_SPICE_PROTOCOL_VERSION(0, 14, 1) + if (vd->caps & (1 << VD_AGENT_CAP_CLIPBOARD_GRAB_SERIAL)) { + if (size < sizeof(uint32_t)) { + /* this shouldn't happen! */ + return; + } + + info->has_serial =3D true; + info->serial =3D *(uint32_t *)data; + if (info->serial < vd->last_serial[s]) { + /* discard lower-ordering guest grab */ + return; + } + vd->last_serial[s] =3D info->serial; + data +=3D sizeof(uint32_t); + size -=3D sizeof(uint32_t); + } +#endif if (size > sizeof(uint32_t) * 10) { /* * spice has 6 types as of 2021. Limiting to 10 entries @@ -671,6 +707,7 @@ static void vdagent_chr_recv_caps(VDAgentChardev *vd, V= DAgentMessage *msg) qemu_input_handler_activate(vd->mouse_hs); } if (have_clipboard(vd) && vd->cbpeer.notifier.notify =3D=3D NULL) { + memset(vd->last_serial, 0, sizeof(vd->last_serial)); vd->cbpeer.name =3D "vdagent"; vd->cbpeer.notifier.notify =3D vdagent_clipboard_notify; vd->cbpeer.request =3D vdagent_clipboard_request; diff --git a/ui/trace-events b/ui/trace-events index b9c0dd0fa11d..e832c3e3659d 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -135,3 +135,4 @@ vdagent_recv_msg(const char *name, uint32_t size) "msg = %s, size %d" vdagent_peer_cap(const char *name) "cap %s" vdagent_cb_grab_selection(const char *name) "selection %s" vdagent_cb_grab_type(const char *name) "type %s" +vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=3D= %u, received=3D%u" --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070708; cv=none; d=zohomail.com; s=zohoarc; b=Uemk7h8qQ4Ox+/kXeu0OcJxOP7j1jHA7GeYnoIiV+7rfjUOP8MZA5yRZQlBZw1abe75jCILYbUp7pUayz02jwvd39W+4iUAvmFyrMqYSrpX9QfaRfiW+ec04taHEGBtS/4CZNv2raicYpeHjX7UwechOyWzWeIWKxRvibCd+7ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070708; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ik1aOcvACZNdTpGkn7ShOwvsQ23obbqSt5eucpHy45k=; b=IYlJXhpg8iapuCmTXdg4ix/WYBoUP5UGze1Z4heL+h1iUTxKPeWjzIE0FpQb5MLaOnNuWrLUSzc39q5GQIHCNBjVzlj8QaiFggj/m4IAJT6fixuvU0MzcM5b+2G/Y4HIB9zzCv7Jm5W6hToJLOW/Wf03eewVRwE6hcc5PQxf49I= 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 1640070708796195.8396676186362; Mon, 20 Dec 2021 23:11:48 -0800 (PST) Received: from localhost ([::1]:39194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZJL-0002wF-OL for importer@patchew.org; Tue, 21 Dec 2021 02:11:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ8u-0002wx-9L for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ8s-0001mt-LN for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:00:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-1bFv8cxCNumrEa6giY2gpw-1; Tue, 21 Dec 2021 02:00:53 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC5D8185302C; Tue, 21 Dec 2021 07:00:51 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08BC37EA37; Tue, 21 Dec 2021 07:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070057; 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=Ik1aOcvACZNdTpGkn7ShOwvsQ23obbqSt5eucpHy45k=; b=TRP4pJ0jGieLggW0k75x/FMftFY9whqkWsWDaclNSTjqa9rsZcuk9FQNlg9rYeQ9yiAaIe u6R2AoelaNk6Lo4a3WMPvfKbSxo6e3DcSDSvdS40Hp+aOZKRiNFlNwj28BiHyMXHONWSXy EUGHhcaTvRvDHH7OqOQkofWjztyJY1A= X-MC-Unique: 1bFv8cxCNumrEa6giY2gpw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 05/36] ui/clipboard: add qemu_clipboard_check_serial() Date: Tue, 21 Dec 2021 10:58:24 +0400 Message-Id: <20211221065855.142578-6-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070709578100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 10 ++++++++++ ui/clipboard.c | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index e590b453c8b7..2c6488c1eec8 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -172,6 +172,16 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *pe= er, */ QemuClipboardInfo *qemu_clipboard_info(QemuClipboardSelection selection); =20 +/** + * qemu_clipboard_check_serial + * + * @info: clipboard info. + * @client: whether to check from the client context and priority. + * + * Return TRUE if the @info has a higher serial than the current clipboard. + */ +bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client); + /** * qemu_clipboard_info_new * diff --git a/ui/clipboard.c b/ui/clipboard.c index 743b39edf424..ffbd80e5c60e 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -41,6 +41,21 @@ void qemu_clipboard_peer_release(QemuClipboardPeer *peer, } } =20 +bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client) +{ + if (!info->has_serial || + !cbinfo[info->selection] || + !cbinfo[info->selection]->has_serial) { + return true; + } + + if (client) { + return cbinfo[info->selection]->serial >=3D info->serial; + } else { + return cbinfo[info->selection]->serial > info->serial; + } +} + void qemu_clipboard_update(QemuClipboardInfo *info) { QemuClipboardNotify notify =3D { --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071416; cv=none; d=zohomail.com; s=zohoarc; b=XqItGsC8rhTe6b9w4RLs9jumknjTqDxtxot3xhhmzVd0go4U99juAMs9AfI1BchZGcWB85nY+hzaeiY2+isxiY6z4fpS+VIwnKJ6gjYI7E5sycrQ75rAjOqsERZWd6XbS7oX2VecIWwfF0H3dGIIimprs8NbvlcsFRPj4x9pLVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071416; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BH0xbodMY0GS97ELdCoaOxwLcuU/2uZZIpjpdJ/PM/U=; b=GQ/AkyoSx39hQjGXvq5/DSowMFEWNJIxk5q/3vHTjp6LkU3SVI1rk4c4/x89GZP7Pola9Tve2L7dnGLUv0gf68cCmHn7ytnxYwviSEwK8RC5pQwodRlq6IBc1quy7s15c3nb1LAU0yteMckSKr6ig6vVI9ViIedLKkEzmUA1J1c= 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 16400714162561000.2122586476877; Mon, 20 Dec 2021 23:23:36 -0800 (PST) Received: from localhost ([::1]:54236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZUl-0005bQ-Am for importer@patchew.org; Tue, 21 Dec 2021 02:23:35 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9S-0003Hp-Mq for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9O-0001qZ-Q7 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:34 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-615-An3jrUifPSy7K9XctAoAtQ-1; Tue, 21 Dec 2021 02:01:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B1051023F4E; Tue, 21 Dec 2021 07:01:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0ABC47EFC0; Tue, 21 Dec 2021 07:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070088; 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=BH0xbodMY0GS97ELdCoaOxwLcuU/2uZZIpjpdJ/PM/U=; b=WUpawU686LArtP2M4rqm7oS88a853XNw2oPcjO+rCaQ5cDwB7Rny1TTx0dFk2gwju+nloS +V9+P6NrnHzYRtsacMhrJbGCJhrn4SHGup3+IZ1yMQApLxnjCb1w/muZON67yd8+xdiJmH X/g4vSHYK3Ewd1RVek5Gn5oA8mKsWNo= X-MC-Unique: An3jrUifPSy7K9XctAoAtQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 06/36] ui/clipboard: add a clipboard reset serial event Date: Tue, 21 Dec 2021 10:58:25 +0400 Message-Id: <20211221065855.142578-7-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071416826100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/clipboard.h | 9 +++++++++ ui/clipboard.c | 7 +++++++ ui/gtk-clipboard.c | 3 +++ ui/vdagent.c | 12 ++++++++++++ ui/vnc-clipboard.c | 3 +++ ui/cocoa.m | 3 +++ 6 files changed, 37 insertions(+) diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 2c6488c1eec8..ce76aa451f64 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -73,11 +73,13 @@ struct QemuClipboardPeer { * enum QemuClipboardNotifyType * * @QEMU_CLIPBOARD_UPDATE_INFO: clipboard info update + * @QEMU_CLIPBOARD_RESET_SERIAL: reset clipboard serial * * Clipboard notify type. */ enum QemuClipboardNotifyType { QEMU_CLIPBOARD_UPDATE_INFO, + QEMU_CLIPBOARD_RESET_SERIAL, }; =20 /** @@ -230,6 +232,13 @@ void qemu_clipboard_info_unref(QemuClipboardInfo *info= ); */ void qemu_clipboard_update(QemuClipboardInfo *info); =20 +/** + * qemu_clipboard_reset_serial + * + * Reset the clipboard serial. + */ +void qemu_clipboard_reset_serial(void); + /** * qemu_clipboard_request * diff --git a/ui/clipboard.c b/ui/clipboard.c index ffbd80e5c60e..82572ea1169b 100644 --- a/ui/clipboard.c +++ b/ui/clipboard.c @@ -129,6 +129,13 @@ void qemu_clipboard_request(QemuClipboardInfo *info, info->owner->request(info, type); } =20 +void qemu_clipboard_reset_serial(void) +{ + QemuClipboardNotify notify =3D { .type =3D QEMU_CLIPBOARD_RESET_SERIAL= }; + + notifier_list_notify(&clipboard_notifiers, ¬ify); +} + void qemu_clipboard_set_data(QemuClipboardPeer *peer, QemuClipboardInfo *info, QemuClipboardType type, diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 44ff810234ff..e0b8b283fef8 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -127,6 +127,9 @@ static void gd_clipboard_notify(Notifier *notifier, voi= d *data) case QEMU_CLIPBOARD_UPDATE_INFO: gd_clipboard_update_info(gd, notify->info); return; + case QEMU_CLIPBOARD_RESET_SERIAL: + /* ignore */ + return; } } =20 diff --git a/ui/vdagent.c b/ui/vdagent.c index b4fdae69177f..7ea4bc5d9a26 100644 --- a/ui/vdagent.c +++ b/ui/vdagent.c @@ -466,6 +466,15 @@ static void vdagent_clipboard_update_info(VDAgentChard= ev *vd, } } =20 +static void vdagent_clipboard_reset_serial(VDAgentChardev *vd) +{ + Chardev *chr =3D CHARDEV(vd); + + /* reopen the agent connection to reset the serial state */ + qemu_chr_be_event(chr, CHR_EVENT_CLOSED); + qemu_chr_be_event(chr, CHR_EVENT_OPENED); +} + static void vdagent_clipboard_notify(Notifier *notifier, void *data) { VDAgentChardev *vd =3D @@ -476,6 +485,9 @@ static void vdagent_clipboard_notify(Notifier *notifier= , void *data) case QEMU_CLIPBOARD_UPDATE_INFO: vdagent_clipboard_update_info(vd, notify->info); return; + case QEMU_CLIPBOARD_RESET_SERIAL: + vdagent_clipboard_reset_serial(vd); + return; } } =20 diff --git a/ui/vnc-clipboard.c b/ui/vnc-clipboard.c index 6a0b1058840e..d48f75eb1ab4 100644 --- a/ui/vnc-clipboard.c +++ b/ui/vnc-clipboard.c @@ -230,6 +230,9 @@ static void vnc_clipboard_notify(Notifier *notifier, vo= id *data) case QEMU_CLIPBOARD_UPDATE_INFO: vnc_clipboard_update_info(vs, notify->info); return; + case QEMU_CLIPBOARD_RESET_SERIAL: + /* ignore */ + return; } } =20 diff --git a/ui/cocoa.m b/ui/cocoa.m index 6640a2e80ebb..7ca429fa8078 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1837,6 +1837,9 @@ static void cocoa_clipboard_notify(Notifier *notifier= , void *data) case QEMU_CLIPBOARD_UPDATE_INFO: cocoa_clipboard_update_info(notify->info); return; + case QEMU_CLIPBOARD_RESET_SERIAL: + /* ignore */ + return; } } =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070453; cv=none; d=zohomail.com; s=zohoarc; b=QZCWQNpTFJT8WxLlH9mFyqMP6gJqH2qt9k6CBJfO/eqVgAC3ZOw0RHTstdXV/0L4dL9+ZqkXxV+tfRXyxQqvvb1nrRqC6INKDbekkTGwW6Y/Qb5LXLWIpR4Oi2/WzjQ2QKh5CTV2k2L9Sww04Pr0MS4OKtjfUOdvxflTPYNcPOg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070453; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5pLW6Cme3VcZrYC4e2lTvFeR9Mk26lpto9yy3Q7+WTY=; b=Ud0A28C8z/javemjofPBXzJcRfLePWTs/Iie8FPmjI6Fb1JRMJtgPsWi7wFyrXkRbmwBMS2Y0ki8aU9XD8w9JPiXaZZdApo4JlWEYOjPuZ04QO17iRCqG4SrYGjMZzfgOETpQ6bPoZrNEHae2d6XwUA5kPt4bj+UENhQG3UZaR0= 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 1640070453956118.09536492009693; Mon, 20 Dec 2021 23:07:33 -0800 (PST) Received: from localhost ([::1]:36292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZFE-0000va-IH for importer@patchew.org; Tue, 21 Dec 2021 02:07:32 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9b-0003LL-0f for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9Z-0001ww-F0 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:42 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-189-0lJf-JthPN6cUSglB9pH0w-1; Tue, 21 Dec 2021 02:01:37 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A949C801B25; Tue, 21 Dec 2021 07:01:36 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66B117A410; Tue, 21 Dec 2021 07:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070100; 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=5pLW6Cme3VcZrYC4e2lTvFeR9Mk26lpto9yy3Q7+WTY=; b=E/VdqlsdGqlyLSccspM8R1jK36fIBYS2Sp329rq4zZllYEjyCCe3trbdlNItwdaE936xNP KcVcSjojDfr2IVKsg9JHEn1m/1o45+coVox08lWLWYhh6klT3ETkcDhI/K1fSqN3E7yC2m 9pj9nqYeHBkKJCVJS7r3vWq5kM3DEa0= X-MC-Unique: 0lJf-JthPN6cUSglB9pH0w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 07/36] hw/display: report an error if virgl initialization failed Date: Tue, 21 Dec 2021 10:58:26 +0400 Message-Id: <20211221065855.142578-8-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070454857100001 From: Marc-Andr=C3=A9 Lureau Currently, virgl initialization error is silent. Make it verbose instead. (this is likely going to bug later on, as the device isn't fully initialized) Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/virtio-gpu-virgl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 18d054922fea..0d87de65d79a 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -609,6 +609,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) =20 ret =3D virgl_renderer_init(g, 0, &virtio_gpu_3d_cbs); if (ret !=3D 0) { + error_report("virgl could not be initialized: %d", ret); return ret; } =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070920; cv=none; d=zohomail.com; s=zohoarc; b=ZjK6z1pYoiedHnn++ycO8qNPRsg5ijp4CB047reyawYYPKxAfBb5ASgv5pD9DK/h0CtxmbBbDQxBiQc1a+gLUkeGMwrCfQL8fFUa31q4dOANTEYU56e/pbSt0b8i6rf8cCMHvRG/LhkL1D40ZtHQ7WITsGmuOgUia1oxuguEaV0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5T1rWyDX3wH+c9zfbdZrfj9a0NfwEv2ASTEHlbqLIDc=; b=FlxrAqGESW1/7vxz8lXYMr8/dkPsQiLPMqebESX/9jut8OG5oWCrZjfQTx284hGrrGErz9+bWo21T5rcQP4h1utHRmmB3HdpGh2XcZn2oLgA/0+W6kwqBzbp9HTafTZMk0MXn5mgT6fxF+gjWXRcjLTNECCp/1XSmQqzNlrL+5Q= 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 1640070920558708.4357269598005; Mon, 20 Dec 2021 23:15:20 -0800 (PST) Received: from localhost ([::1]:44890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZMj-0007NV-NT for importer@patchew.org; Tue, 21 Dec 2021 02:15:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9n-0003ZX-3p for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:55 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9l-000215-Ch for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:01:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-9vfH_rknPI6mMco9Sq2jlQ-1; Tue, 21 Dec 2021 02:01:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ACBF4814316; Tue, 21 Dec 2021 07:01:50 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id E753B77444; Tue, 21 Dec 2021 07:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070112; 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=5T1rWyDX3wH+c9zfbdZrfj9a0NfwEv2ASTEHlbqLIDc=; b=dxswKkSN60pXfzozgFOD3VKVD9huPOHcvaNEcwzKu3yhl08+MQpxkTOGbBEMrA95I0PBXH DZIPKevZNfi2DzJfmrEd/92YcH0AaUrlMSFWTrED9FQD55SsBDQP1iZ+Jyixun0C4C5hIs +6KWPwW79D4kwIXq/ZxZOk7Rq3+Xi+0= X-MC-Unique: 9vfH_rknPI6mMco9Sq2jlQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 08/36] virtio-gpu: use VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP Date: Tue, 21 Dec 2021 10:58:27 +0400 Message-Id: <20211221065855.142578-9-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070922412100001 From: Marc-Andr=C3=A9 Lureau It's part of Linux headers for a while now. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/display/virtio-gpu-virgl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 0d87de65d79a..73cb92c8d5c6 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -175,7 +175,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, virgl_renderer_force_ctx_0(); dpy_gl_scanout_texture( g->parent_obj.scanout[ss.scanout_id].con, info.tex_id, - info.flags & 1 /* FIXME: Y_0_TOP */, + info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height); } else { --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070330; cv=none; d=zohomail.com; s=zohoarc; b=Yezpd7MDEgjuUKE8I3jb3nJo93Yhn2fws6Qu/g4ssKuapUXrcOwxvrVRol4qYOuXy1oAK/SBfhX6/cTddaKEcFayRtds9MiFqjAIEwUCVQDO6+rdPDFumBvyP7lMktpmj6CRi+ybk++yDHox/bUWNtfO4yXU1H8JfmN5o8keCHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070330; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hE9YWsmTm38tqLhb1PCblibvG6EgJPixnrLwcacfk3s=; b=UN/cMKst++AiLuFAj7uAqBQRPyKi2Jt4JPTSRIEVQyds9epvim3s+adz/hViMVOEtA+EXAiQF49aGyaT/q7UO6UvrwuZDEF5SCDfSZnI8Gp2lynFxOYYO055QYr/U09wv9xe+8RImIBgf+BnTwED2ORiBM2mvNZekLDmHJvQ1b0= 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 1640070330294751.1872372901122; Mon, 20 Dec 2021 23:05:30 -0800 (PST) Received: from localhost ([::1]:32908 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZDF-0006yL-5B for importer@patchew.org; Tue, 21 Dec 2021 02:05:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZA0-0003pR-JJ for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZ9v-00021U-2p for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-g8UtPxARPmmHg4cOAdNKjA-1; Tue, 21 Dec 2021 02:01:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 918551006AA5; Tue, 21 Dec 2021 07:01:55 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D484838E4; Tue, 21 Dec 2021 07:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070122; 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=hE9YWsmTm38tqLhb1PCblibvG6EgJPixnrLwcacfk3s=; b=IZZs3ElGUnLJJ1VOop5yDtG6A+npK08WOdWePiVYG+gjbFdi/cA/7OwPf3ni5B6y6h++Y7 80z4KS1qS2gGKHyVbijl5C+FTvYA6vzmR4xYOPt8qg8Kd1dYEq4JaNjNvodTFSSnoj5+uh PviGR0PVoi1E3idLucSrqEbx8/8MGv0= X-MC-Unique: g8UtPxARPmmHg4cOAdNKjA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 09/36] ui: do not delay further remote resize Date: Tue, 21 Dec 2021 10:58:28 +0400 Message-Id: <20211221065855.142578-10-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070330827100001 From: Marc-Andr=C3=A9 Lureau A remote client, such as Spice, will already avoid flooding the stream by delaying the resize requests. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 2 +- ui/console.c | 5 +++-- ui/gtk.c | 2 +- ui/sdl2.c | 2 +- ui/spice-display.c | 2 +- ui/vnc.c | 2 +- ui/cocoa.m | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 6d678924f6fd..65e6bbcab8ae 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -292,7 +292,7 @@ void unregister_displaychangelistener(DisplayChangeList= ener *dcl); =20 bool dpy_ui_info_supported(QemuConsole *con); const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con); -int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info); +int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay); =20 void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h); void dpy_gfx_update_full(QemuConsole *con); diff --git a/ui/console.c b/ui/console.c index 29a3e3f0f51c..dcc21eb5b244 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1538,7 +1538,7 @@ const QemuUIInfo *dpy_get_ui_info(const QemuConsole *= con) return &con->ui_info; } =20 -int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info) +int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay) { if (con =3D=3D NULL) { con =3D active_console; @@ -1558,7 +1558,8 @@ int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *inf= o) * go notify the guest. */ con->ui_info =3D *info; - timer_mod(con->ui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + 1000= ); + timer_mod(con->ui_timer, + qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + (delay ? 1000 : 0)); return 0; } =20 diff --git a/ui/gtk.c b/ui/gtk.c index 428f02f2dfe1..c0d8a9f061ee 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -698,7 +698,7 @@ static void gd_set_ui_info(VirtualConsole *vc, gint wid= th, gint height) memset(&info, 0, sizeof(info)); info.width =3D width; info.height =3D height; - dpy_set_ui_info(vc->gfx.dcl.con, &info); + dpy_set_ui_info(vc->gfx.dcl.con, &info, true); } =20 #if defined(CONFIG_OPENGL) diff --git a/ui/sdl2.c b/ui/sdl2.c index 17c0ec30ebff..9ba3bc49e798 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -561,7 +561,7 @@ static void handle_windowevent(SDL_Event *ev) memset(&info, 0, sizeof(info)); info.width =3D ev->window.data1; info.height =3D ev->window.data2; - dpy_set_ui_info(scon->dcl.con, &info); + dpy_set_ui_info(scon->dcl.con, &info, true); } sdl2_redraw(scon); break; diff --git a/ui/spice-display.c b/ui/spice-display.c index f59c69882d91..52d9f3260aab 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -692,7 +692,7 @@ static int interface_client_monitors_config(QXLInstance= *sin, } =20 trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height); - dpy_set_ui_info(ssd->dcl.con, &info); + dpy_set_ui_info(ssd->dcl.con, &info, false); return 1; } =20 diff --git a/ui/vnc.c b/ui/vnc.c index 9b603382e75e..1ed1c7efc688 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2596,7 +2596,7 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) memset(&info, 0, sizeof(info)); info.width =3D w; info.height =3D h; - dpy_set_ui_info(vs->vd->dcl.con, &info); + dpy_set_ui_info(vs->vd->dcl.con, &info, false); vnc_desktop_resize_ext(vs, 4 /* Request forwarded */); } else { vnc_desktop_resize_ext(vs, 3 /* Invalid screen layout */); diff --git a/ui/cocoa.m b/ui/cocoa.m index 7ca429fa8078..69745c483b45 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -552,7 +552,7 @@ QemuCocoaView *cocoaView; info.width =3D frameSize.width; info.height =3D frameSize.height; =20 - dpy_set_ui_info(dcl.con, &info); + dpy_set_ui_info(dcl.con, &info, TRUE); } =20 - (void)viewDidMoveToWindow --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071372; cv=none; d=zohomail.com; s=zohoarc; b=UUvjuyMyzcLtM1imjKo/eFPWChutSxWRDlrimbT3dxRfYdJl+h6rgCzGW6vPG7J3LgCUu8sXoLaWmGMfnU4rqj4BJeGoJF1WXo+pIZN+Zaro2s6cja2oGivKekOkktqNxMMKenI+Y5h3BOAIAaqUAjT/xPOVo9fYetltebIgTmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071372; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yy7mIZIXs4aytO347LRaT/OfoSNmk0dCfOOTskWgU68=; b=aBUpUZbI7hEv1kg9nS1wMtvfVJh9eicvFa9iI2FSMFj2sDFeQAFyaltRhjaN9m3BNyt/oXLCjwoXPbvjRkxpfaiQrbtFGDvEV2mP2zjf8/CQhBmGHbUsOMGtPKL2hGICHc0+eXxwiOKmgbIv5VCEKJdzfGiVDLfLHbta2LCiLb8= 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 16400713725211015.6268238393961; Mon, 20 Dec 2021 23:22:52 -0800 (PST) Received: from localhost ([::1]:53518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZU1-00057G-PL for importer@patchew.org; Tue, 21 Dec 2021 02:22:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZA1-0003rm-PA for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59424) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZA0-00021e-39 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-648-aKw7BnK-OJKy4qszrlgxig-1; Tue, 21 Dec 2021 02:02:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64C82802C92; Tue, 21 Dec 2021 07:02:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ED0538E09; Tue, 21 Dec 2021 07:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070127; 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=Yy7mIZIXs4aytO347LRaT/OfoSNmk0dCfOOTskWgU68=; b=fDxXZqaLxjEcAO0WvnVAe2nETmScfFgfqmiGN7qLwySQJ+qxn5oCceFD2Ns1p3UwQE7bjW EjGADdunxiik60UpGoUhTP6Gp6KSE548y/6/3rhMR1yS6c4RHpugAc7YO1T5gaqmwSWY7d KzoTMgHn5RutBe7pL+jIq4j/ywkiOoY= X-MC-Unique: aKw7BnK-OJKy4qszrlgxig-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 10/36] ui: factor out qemu_console_set_display_gl_ctx() Date: Tue, 21 Dec 2021 10:58:29 +0400 Message-Id: <20211221065855.142578-11-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071374164100001 From: Marc-Andr=C3=A9 Lureau The next patch will make use of this function to dissociate DisplayChangeListener from GL context. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/ui/console.h | 3 +++ ui/console.c | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 65e6bbcab8ae..fb10e6d60cd7 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -411,6 +411,9 @@ void graphic_hw_gl_flushed(QemuConsole *con); =20 void qemu_console_early_init(void); =20 +void qemu_console_set_display_gl_ctx(QemuConsole *con, + DisplayChangeListener *dcl); + QemuConsole *qemu_console_lookup_by_index(unsigned int index); QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head= ); QemuConsole *qemu_console_lookup_by_device_name(const char *device_id, diff --git a/ui/console.c b/ui/console.c index dcc21eb5b244..7b83e6cdea77 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1443,6 +1443,19 @@ static bool dpy_compatible_with(QemuConsole *con, return true; } =20 +void qemu_console_set_display_gl_ctx(QemuConsole *con, + DisplayChangeListener *dcl) +{ + /* display has opengl support */ + assert(dcl->con); + if (dcl->con->gl) { + fprintf(stderr, "can't register two opengl displays (%s, %s)\n", + dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name); + exit(1); + } + dcl->con->gl =3D dcl; +} + void register_displaychangelistener(DisplayChangeListener *dcl) { static const char nodev[] =3D @@ -1453,14 +1466,7 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) assert(!dcl->ds); =20 if (dcl->ops->dpy_gl_ctx_create) { - /* display has opengl support */ - assert(dcl->con); - if (dcl->con->gl) { - fprintf(stderr, "can't register two opengl displays (%s, %s)\n= ", - dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name); - exit(1); - } - dcl->con->gl =3D dcl; + qemu_console_set_display_gl_ctx(dcl->con, dcl); } =20 if (dcl->con) { --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071913; cv=none; d=zohomail.com; s=zohoarc; b=AkUP+D0He0Tpjvm1MM16tu33t6kmM224f8mPhUQKQKpQP6FHvVdohznaPOcTq7DxtJJqmR+UEZw8eVO3dkXccUphiU7mn2Y6JvHRVKacjHY4owqj9dybXqJxrXMxlX7PqpeIu2hPMLn9ttyX230ggYqyurtjumDr+FZCePlgDNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2gixnKrZkqUGvGNbm+vktxqOAHCbEyotYV6HIRvHvAc=; b=irygcCCoYjMYnQvaZHcX6QVFt7i3FpEl33RZheF5QRZ7TB6Jqyla6Y6+paTrZdROuLb16IjRhtzVTxoIvJIOrLWJtDacF1VGcUSVzFZDXkkFgNx1tnHeB91J8XgLvU1i4pUBNyYV4ki2coJDUcD5yD6y9vt5eNZpMbcrooISW98= 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 1640071913379256.5010151644884; Mon, 20 Dec 2021 23:31:53 -0800 (PST) Received: from localhost ([::1]:34782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZcl-0003IL-C9 for importer@patchew.org; Tue, 21 Dec 2021 02:31:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAB-0004C5-9O for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZA9-00022S-Hn for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661-WLjTTdToNpS81pa9vnG5Zg-1; Tue, 21 Dec 2021 02:02:11 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A6F181006AA9; Tue, 21 Dec 2021 07:02:10 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF6277EA2E; Tue, 21 Dec 2021 07:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070136; 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=2gixnKrZkqUGvGNbm+vktxqOAHCbEyotYV6HIRvHvAc=; b=ONH9ztYOFi++8rsM3Oqmbb3w317GN8yJbXMT2dugsVg3itqJy/3x0Js1rek8WwJ17keXUI LOgugGAsvXc3GjeIyseKk9WSU13CVHEQba5VLk+SHcB3VuV0FqS2tUR/xMoJazYKz5ahUS z9tcvtvKmSl4qe7gwh6lhlksGQwy+N0= X-MC-Unique: WLjTTdToNpS81pa9vnG5Zg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 11/36] ui: associate GL context outside of display listener registration Date: Tue, 21 Dec 2021 10:58:30 +0400 Message-Id: <20211221065855.142578-12-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071914015100001 From: Marc-Andr=C3=A9 Lureau Consoles can have an associated GL context, without listeners (they may be added or removed later on). Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/console.c | 7 +++++-- ui/egl-headless.c | 1 + ui/gtk.c | 3 +++ ui/sdl2.c | 3 +++ ui/spice-display.c | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ui/console.c b/ui/console.c index 7b83e6cdea77..87f897e46dc4 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1465,8 +1465,11 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) =20 assert(!dcl->ds); =20 - if (dcl->ops->dpy_gl_ctx_create) { - qemu_console_set_display_gl_ctx(dcl->con, dcl); + if (dcl->con && dcl->con->gl && + dcl->con->gl !=3D dcl) { + error_report("Display %s is incompatible with the GL context", + dcl->ops->dpy_name); + exit(1); } =20 if (dcl->con) { diff --git a/ui/egl-headless.c b/ui/egl-headless.c index a26a2520c496..08327c40c6ee 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -197,6 +197,7 @@ static void egl_headless_init(DisplayState *ds, Display= Options *opts) edpy->dcl.con =3D con; edpy->dcl.ops =3D &egl_ops; edpy->gls =3D qemu_gl_init_shader(); + qemu_console_set_display_gl_ctx(con, &edpy->dcl); register_displaychangelistener(&edpy->dcl); } } diff --git a/ui/gtk.c b/ui/gtk.c index c0d8a9f061ee..25896023ffe7 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2083,6 +2083,9 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, vc->gfx.kbd =3D qkbd_state_init(con); vc->gfx.dcl.con =3D con; =20 + if (display_opengl) { + qemu_console_set_display_gl_ctx(con, &vc->gfx.dcl); + } register_displaychangelistener(&vc->gfx.dcl); =20 gd_connect_vc_gfx_signals(vc); diff --git a/ui/sdl2.c b/ui/sdl2.c index 9ba3bc49e798..bb186a381acd 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -866,6 +866,9 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) #endif sdl2_console[i].dcl.con =3D con; sdl2_console[i].kbd =3D qkbd_state_init(con); + if (display_opengl) { + qemu_console_set_display_gl_ctx(con, &sdl2_console[i].dcl); + } register_displaychangelistener(&sdl2_console[i].dcl); =20 #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11) diff --git a/ui/spice-display.c b/ui/spice-display.c index 52d9f3260aab..2c204bceee27 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1156,6 +1156,9 @@ static void qemu_spice_display_init_one(QemuConsole *= con) =20 qemu_spice_create_host_memslot(ssd); =20 + if (spice_opengl) { + qemu_console_set_display_gl_ctx(con, &ssd->dcl); + } register_displaychangelistener(&ssd->dcl); } =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071135; cv=none; d=zohomail.com; s=zohoarc; b=nyE/HVUsKJG/rzrH3+wxwKvC47xGNstuLOFwWHZgGumD+fgMy7SANhj8j5HevsUUF1QjA4xhG369xcaKF4lO46ZSL0AbLAC+lxFsm4Ybt1qevRz3gHmORjjuoQOsxnBeaznM+uEIERVI9xivyJ2WSGiXGnaWb5rz3afLChv8Zzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071135; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oNXmFK4YyLv1sjoSdTZFSAPfzmwLAVcRBp73aEfewwg=; b=ChZ4FZUxT1uYXKoYZItI28vl9k/9REoIeJMfqCkO5iRmbTBfheigk0Dcg3dunSh/b5bmqwNo5tkX71DuQwzXoL2b/ZkbHoLaZdNiLNjlB2YAXQ2EAZCQqPqLbtsCwHLGNBsvX+LQ2HFiAanPskFHH6cAiHMlvVrTJPAhrV9O4YA= 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 1640071135098316.76280322859327; Mon, 20 Dec 2021 23:18:55 -0800 (PST) Received: from localhost ([::1]:47824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZQD-00015t-Su for importer@patchew.org; Tue, 21 Dec 2021 02:18:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAL-0004Vc-Um for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52665) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAJ-00022p-J2 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-391-tTTaU49kOn2IH4foMbLXtQ-1; Tue, 21 Dec 2021 02:02:25 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C55AA8042DB; Tue, 21 Dec 2021 07:02:24 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B92077444; Tue, 21 Dec 2021 07:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070147; 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=oNXmFK4YyLv1sjoSdTZFSAPfzmwLAVcRBp73aEfewwg=; b=E3kX8V9uujVFq5NAuvdEJHGiyhyeHdLQhBix5e3vlnP4bi8q/KJHEVBhpjvhwgiC2jWJq8 nE6sXfp5oxA6XOEKADdoA5c4oEKejbdSaI0Moqfcy/i4A3DYG3akco29a6LMgPl7unjpVm 8tinHUt2+FRnIfUB1wWDOYL4Z3XFxwE= X-MC-Unique: tTTaU49kOn2IH4foMbLXtQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 12/36] ui: make gl_block use a counter Date: Tue, 21 Dec 2021 10:58:31 +0400 Message-Id: <20211221065855.142578-13-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071137191100001 From: Marc-Andr=C3=A9 Lureau Track multiple callers blocking requests. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/console.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ui/console.c b/ui/console.c index 87f897e46dc4..39f7b66baf54 100644 --- a/ui/console.c +++ b/ui/console.c @@ -79,7 +79,7 @@ struct QemuConsole { DisplaySurface *surface; int dcls; DisplayChangeListener *gl; - bool gl_block; + int gl_block; int window_id; =20 /* Graphic console state. */ @@ -237,10 +237,19 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) { assert(con !=3D NULL); =20 - con->gl_block =3D block; - if (con->hw_ops->gl_block) { - con->hw_ops->gl_block(con->hw, block); + if (block) { + con->gl_block++; + } else { + con->gl_block--; + } + assert(con->gl_block >=3D 0); + if (!con->hw_ops->gl_block) { + return; + } + if ((block && con->gl_block !=3D 1) || (!block && con->gl_block !=3D 0= )) { + return; } + con->hw_ops->gl_block(con->hw, block); } =20 void graphic_hw_gl_flushed(QemuConsole *con) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640070759; cv=none; d=zohomail.com; s=zohoarc; b=E2ecFrUBDX7s3H/sIEuVUANQv8FadL/uMV2OBvfUN4S77p9n3ujsCo5oOgb1YBsmiW/yHg5t60dqMWutQYCkp5p5vS44LRH8Pe1xQXVpQ9kPC+yNvnwaffGW35EC+lxt0by2I+AjTWjUMl+TWaSqZJk+D6TwI4kXvCiTh/SBWvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640070759; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zVIEwc4U/GyNxdlw3OLMiafyh68EowCHnLZunJbM8js=; b=MvjqG/P5FXhyHrXwE9cWf6CbU5/nphasV++nOnOGoW1yu0uBCPDuwleo9WEhs360PfAG+ckwyhgZiK/V1qOKSgrBUgA0rRybH/O5oidNIWja0RuAKGT/u2a7AY3mJWkzlQPlYtXp75A/9Rpaw7u+LORseROxSHrJbeXdKDDa2/U= 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 1640070759188632.1039672508833; Mon, 20 Dec 2021 23:12:39 -0800 (PST) Received: from localhost ([::1]:41608 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZKA-0004tq-0s for importer@patchew.org; Tue, 21 Dec 2021 02:12:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAR-0004fN-Vv for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAQ-00024Q-CG for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-IQobmik0NIWdplQnIxvY7g-1; Tue, 21 Dec 2021 02:02:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9982F2F46; Tue, 21 Dec 2021 07:02:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3B0C7E8EF; Tue, 21 Dec 2021 07:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070153; 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=zVIEwc4U/GyNxdlw3OLMiafyh68EowCHnLZunJbM8js=; b=XneTgXDw7yYn2E0CW7bRtfz/LAKy2GRQDHmpKQtrh4GD/NGlMQy00MiMy/Lm7lwRQ65tFg JxxrNXSwddrjGckKHnVT0OXqgyX3aLlzT7YtzvTWCUOmnL0CKvW8PnwqUQx23pB4of/pkA 1blIT7diIpIz2QeG5ttbVl64XHV9dmg= X-MC-Unique: IQobmik0NIWdplQnIxvY7g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 13/36] ui: add a gl-unblock warning timer Date: Tue, 21 Dec 2021 10:58:32 +0400 Message-Id: <20211221065855.142578-14-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640070760936100001 From: Marc-Andr=C3=A9 Lureau Similar to the one that exists for Spice, so we can investigate if something is locked. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/console.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ui/console.c b/ui/console.c index 39f7b66baf54..fcc4fe6a0aa0 100644 --- a/ui/console.c +++ b/ui/console.c @@ -80,6 +80,7 @@ struct QemuConsole { int dcls; DisplayChangeListener *gl; int gl_block; + QEMUTimer *gl_unblock_timer; int window_id; =20 /* Graphic console state. */ @@ -233,8 +234,14 @@ void graphic_hw_update(QemuConsole *con) } } =20 +static void graphic_hw_gl_unblock_timer(void *opaque) +{ + warn_report("console: no gl-unblock within one second"); +} + void graphic_hw_gl_block(QemuConsole *con, bool block) { + uint64_t timeout; assert(con !=3D NULL); =20 if (block) { @@ -250,6 +257,14 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) return; } con->hw_ops->gl_block(con->hw, block); + + if (block) { + timeout =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); + timeout +=3D 1000; /* one sec */ + timer_mod(con->gl_unblock_timer, timeout); + } else { + timer_del(con->gl_unblock_timer); + } } =20 void graphic_hw_gl_flushed(QemuConsole *con) @@ -1966,6 +1981,8 @@ QemuConsole *graphic_console_init(DeviceState *dev, u= int32_t head, =20 surface =3D qemu_create_placeholder_surface(width, height, noinit); dpy_gfx_replace_surface(s, surface); + s->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, + graphic_hw_gl_unblock_timer, s); return s; } =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071239; cv=none; d=zohomail.com; s=zohoarc; b=Q3pVwhzt6E3RfeH3obfuw2dkpVsgpAHftZnWcWBwomn4fM7XuXH0FHiI5d9B/k6WDi1hOH/YE1OIu+LiAGl2aNdqo37sWi5e7hZKxPWugvn32NIysjAEBJBmF6YqEgiNFK5e5z1cVA8olhyC7qONQiuKNQ10D2g2SZFMbPbsvAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f8UvDTsSg5s/5xh4bXNQhmRbd8oCeKhx4pniuOht2/g=; b=az2zu6SyKMhiTZ0NFbTJyEcotgNuT5dlYGKfpSllb34XPDzIqdHaEmYokK+zn5zcCMot8fTh4dzhXp2CRaF0QMr3aK63FKMHjNBA0TrkHsXtUv914H6j7o7D/rEEMqMQ0b6SGQZXwlEKpQIxC9bTRl9q1FRMelwmoMp/tIwJxBk= 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 1640071239536742.6896123306881; Mon, 20 Dec 2021 23:20:39 -0800 (PST) Received: from localhost ([::1]:50288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZRs-0002l3-QG for importer@patchew.org; Tue, 21 Dec 2021 02:20:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAc-00055i-0P for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40728) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAa-000250-3C for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-590-5xpnZumAOj29DB56ZZSznw-1; Tue, 21 Dec 2021 02:02:42 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 614FC2F25; Tue, 21 Dec 2021 07:02:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5DF57EDB9; Tue, 21 Dec 2021 07:02:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070163; 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=f8UvDTsSg5s/5xh4bXNQhmRbd8oCeKhx4pniuOht2/g=; b=cuBD0mNxTOmn7663HPohsBtWHJJ04qC32LG5Sb8myjlB6yMjqxV8dITYVnyFrZfvRgowev 7SKi9f0LhehEvVZg9BVzQb9RfWonhQLTw85UXv+pEF/kTLS5jgd9fkjRKzShPaSbE977K0 exkOh58+6pJ2TDMrS5PmNj4M6vX1ug4= X-MC-Unique: 5xpnZumAOj29DB56ZZSznw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 14/36] ui: simplify gl unblock & flush Date: Tue, 21 Dec 2021 10:58:33 +0400 Message-Id: <20211221065855.142578-15-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071240271100001 From: Marc-Andr=C3=A9 Lureau GraphicHw.gl_flushed was introduced to notify the device (vhost-user-gpu) that the GL resources (the display scanout) are no longer needed. It was decoupled from QEMU own gl-blocking mechanism, but that difference isn't helping. Instead, we can reuse QEMU gl-blocking and notify virtio_gpu_gl_flushed() when unblocking (to unlock vhost-user-gpu). An extra block/unblock is added arount dpy_gl_update() so existing backends that don't block will have the flush event handled. It will also help when there are no backends associated. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 2 -- hw/display/vhost-user-gpu.c | 2 +- hw/display/virtio-gpu-base.c | 5 ++++- hw/display/virtio-vga.c | 11 ----------- ui/console.c | 12 +++--------- ui/gtk-egl.c | 2 -- ui/gtk-gl-area.c | 2 -- ui/gtk.c | 1 - ui/sdl2-gl.c | 2 -- ui/spice-display.c | 1 - 10 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index fb10e6d60cd7..3ff51b492e5b 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -391,7 +391,6 @@ typedef struct GraphicHwOps { void (*update_interval)(void *opaque, uint64_t interval); int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info); void (*gl_block)(void *opaque, bool block); - void (*gl_flushed)(void *opaque); } GraphicHwOps; =20 QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, @@ -407,7 +406,6 @@ void graphic_hw_update_done(QemuConsole *con); void graphic_hw_invalidate(QemuConsole *con); void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); void graphic_hw_gl_block(QemuConsole *con, bool block); -void graphic_hw_gl_flushed(QemuConsole *con); =20 void qemu_console_early_init(void); =20 diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 49df56cd14e9..09818231bd24 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -254,8 +254,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) vhost_user_gpu_unblock(g); break; } - dpy_gl_update(con, m->x, m->y, m->width, m->height); g->backend_blocked =3D true; + dpy_gl_update(con, m->x, m->y, m->width, m->height); break; } case VHOST_USER_GPU_UPDATE: { diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index c8da4806e0bb..fff0fb4a828a 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -117,6 +117,10 @@ virtio_gpu_gl_block(void *opaque, bool block) g->renderer_blocked--; } assert(g->renderer_blocked >=3D 0); + + if (!block && g->renderer_blocked =3D=3D 0) { + virtio_gpu_gl_flushed(g); + } } =20 static int @@ -143,7 +147,6 @@ static const GraphicHwOps virtio_gpu_ops =3D { .text_update =3D virtio_gpu_text_update, .ui_info =3D virtio_gpu_ui_info, .gl_block =3D virtio_gpu_gl_block, - .gl_flushed =3D virtio_gpu_gl_flushed, }; =20 bool diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index 9e57f61e9edb..b23a75a04b9d 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -68,16 +68,6 @@ static void virtio_vga_base_gl_block(void *opaque, bool = block) } } =20 -static void virtio_vga_base_gl_flushed(void *opaque) -{ - VirtIOVGABase *vvga =3D opaque; - VirtIOGPUBase *g =3D vvga->vgpu; - - if (g->hw_ops->gl_flushed) { - g->hw_ops->gl_flushed(g); - } -} - static int virtio_vga_base_get_flags(void *opaque) { VirtIOVGABase *vvga =3D opaque; @@ -93,7 +83,6 @@ static const GraphicHwOps virtio_vga_base_ops =3D { .text_update =3D virtio_vga_base_text_update, .ui_info =3D virtio_vga_base_ui_info, .gl_block =3D virtio_vga_base_gl_block, - .gl_flushed =3D virtio_vga_base_gl_flushed, }; =20 static const VMStateDescription vmstate_virtio_vga_base =3D { diff --git a/ui/console.c b/ui/console.c index fcc4fe6a0aa0..6f21007737e5 100644 --- a/ui/console.c +++ b/ui/console.c @@ -267,15 +267,6 @@ void graphic_hw_gl_block(QemuConsole *con, bool block) } } =20 -void graphic_hw_gl_flushed(QemuConsole *con) -{ - assert(con !=3D NULL); - - if (con->hw_ops->gl_flushed) { - con->hw_ops->gl_flushed(con->hw); - } -} - int qemu_console_get_window_id(QemuConsole *con) { return con->window_id; @@ -1894,7 +1885,10 @@ void dpy_gl_update(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { assert(con->gl); + + graphic_hw_gl_block(con, true); con->gl->ops->dpy_gl_update(con->gl, x, y, w, h); + graphic_hw_gl_block(con, false); } =20 /***********************************************************/ diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 45cb67712df0..e891b61048a8 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -119,8 +119,6 @@ void gd_egl_draw(VirtualConsole *vc) =20 glFlush(); } - - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 void gd_egl_update(DisplayChangeListener *dcl, diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 01e4e74ee361..f1c7636cba98 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -101,8 +101,6 @@ void gd_gl_area_draw(VirtualConsole *vc) surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh); surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds); } - - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 void gd_gl_area_update(DisplayChangeListener *dcl, diff --git a/ui/gtk.c b/ui/gtk.c index 25896023ffe7..077d38145de8 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -593,7 +593,6 @@ void gd_hw_gl_flushed(void *vcon) close(dmabuf->fence_fd); dmabuf->fence_fd =3D -1; graphic_hw_gl_block(vc->gfx.dcl.con, false); - graphic_hw_gl_flushed(vc->gfx.dcl.con); } =20 /** DisplayState Callbacks (opengl version) **/ diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index a21d2deed916..5b950fbbea2f 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -58,7 +58,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *s= con) =20 surface_gl_render_texture(scon->gls, scon->surface); SDL_GL_SwapWindow(scon->real_window); - graphic_hw_gl_flushed(scon->dcl.con); } =20 void sdl2_gl_update(DisplayChangeListener *dcl, @@ -241,5 +240,4 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top); =20 SDL_GL_SwapWindow(scon->real_window); - graphic_hw_gl_flushed(dcl->con); } diff --git a/ui/spice-display.c b/ui/spice-display.c index 2c204bceee27..ec501f129f07 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -830,7 +830,6 @@ static void qemu_spice_gl_unblock_bh(void *opaque) SimpleSpiceDisplay *ssd =3D opaque; =20 qemu_spice_gl_block(ssd, false); - graphic_hw_gl_flushed(ssd->dcl.con); } =20 static void qemu_spice_gl_block_timer(void *opaque) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072286; cv=none; d=zohomail.com; s=zohoarc; b=JxcvgAgAgaibbX0Amgcy/vO55d18WBsq/+NcMoD72htp4VcZrFuX3mgArctOspuTgPw2E+5LKMHNKsp0VALn3YUoV5TUEW/wwgjaU2fUlTQDvBfLKgf6b3tEJoXhdrp6G+IN8eBRubTlNDW8fXTTJuBWRXekj8ij+kZYb16WtDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072286; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0CTOXlzpGeLk5q64FnEbOBtZCYbNColSGZ3DvHQlAUo=; b=TpA1R8Lb8c+eYCnIyhyuO5J9wDMDuAp7CNnubPf0TM3+z3Jsd/eb7JcSvhI+y42W5gxh2WaWxAuhZikmEk9+8KqEDSYHggC6NF4hnaX8WZhH/+FkI8hF4ZvLyv56nrS2d6zyctP0B0QGHhXQSKIFHfmVrK8P/8pECZ7kqY48Pc4= 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 1640072286403600.6341080769614; Mon, 20 Dec 2021 23:38:06 -0800 (PST) Received: from localhost ([::1]:43418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZin-0001Fd-DT for importer@patchew.org; Tue, 21 Dec 2021 02:38:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAq-0005aJ-2O for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAo-00025O-Dv for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-166-Bt9Gs-qFMLKvki92VgYbww-1; Tue, 21 Dec 2021 02:02:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E4A71006AA7; Tue, 21 Dec 2021 07:02:53 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10E3F7A426; Tue, 21 Dec 2021 07:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070177; 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=0CTOXlzpGeLk5q64FnEbOBtZCYbNColSGZ3DvHQlAUo=; b=IU3L6S9jGsgPCm9aC0bkOxHYj5/j/S2cC0ifaLP3/053hTNlgUCNBHu6rgEjqDFnO8qbko gUEeRJqY9vWrxQonA9mH+9Gh6xLRlm8EKfnrnsDkK60zIKHUfvJvJ6l5BTJcK1zTJUf9F3 1Cz1aXivarRMC+JR6TPCygWwHecZBQI= X-MC-Unique: Bt9Gs-qFMLKvki92VgYbww-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 15/36] ui: dispatch GL events to all listeners Date: Tue, 21 Dec 2021 10:58:34 +0400 Message-Id: <20211221065855.142578-16-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072287137100001 From: Marc-Andr=C3=A9 Lureau For now, only one listener can receive GL events. Let's dispatch to all listeners. (preliminary check ensure there is a single listener now during regitration, and in next patches, compatible listeners only) Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/console.c | 58 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/ui/console.c b/ui/console.c index 6f21007737e5..13c0d001c096 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1824,8 +1824,12 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGL= Context ctx) =20 void dpy_gl_scanout_disable(QemuConsole *con) { - assert(con->gl); - con->gl->ops->dpy_gl_scanout_disable(con->gl); + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; + + QLIST_FOREACH(dcl, &s->listeners, next) { + dcl->ops->dpy_gl_scanout_disable(dcl); + } } =20 void dpy_gl_scanout_texture(QemuConsole *con, @@ -1836,58 +1840,80 @@ void dpy_gl_scanout_texture(QemuConsole *con, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { - assert(con->gl); - con->gl->ops->dpy_gl_scanout_texture(con->gl, backing_id, + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; + + QLIST_FOREACH(dcl, &s->listeners, next) { + dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, backing_y_0_top, backing_width, backing_height, x, y, width, height); + } } =20 void dpy_gl_scanout_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf) { - assert(con->gl); - con->gl->ops->dpy_gl_scanout_dmabuf(con->gl, dmabuf); + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; + + QLIST_FOREACH(dcl, &s->listeners, next) { + dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); + } } =20 void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, bool have_hot, uint32_t hot_x, uint32_t hot_y) { - assert(con->gl); + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; =20 - if (con->gl->ops->dpy_gl_cursor_dmabuf) { - con->gl->ops->dpy_gl_cursor_dmabuf(con->gl, dmabuf, + QLIST_FOREACH(dcl, &s->listeners, next) { + if (dcl->ops->dpy_gl_cursor_dmabuf) { + dcl->ops->dpy_gl_cursor_dmabuf(dcl, dmabuf, have_hot, hot_x, hot_y); + } } } =20 void dpy_gl_cursor_position(QemuConsole *con, uint32_t pos_x, uint32_t pos_y) { - assert(con->gl); + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; =20 - if (con->gl->ops->dpy_gl_cursor_position) { - con->gl->ops->dpy_gl_cursor_position(con->gl, pos_x, pos_y); + QLIST_FOREACH(dcl, &s->listeners, next) { + if (dcl->ops->dpy_gl_cursor_position) { + dcl->ops->dpy_gl_cursor_position(dcl, pos_x, pos_y); + } } } =20 void dpy_gl_release_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf) { - assert(con->gl); + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; =20 - if (con->gl->ops->dpy_gl_release_dmabuf) { - con->gl->ops->dpy_gl_release_dmabuf(con->gl, dmabuf); + QLIST_FOREACH(dcl, &s->listeners, next) { + if (dcl->ops->dpy_gl_release_dmabuf) { + dcl->ops->dpy_gl_release_dmabuf(dcl, dmabuf); + } } } =20 void dpy_gl_update(QemuConsole *con, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; + assert(con->gl); =20 graphic_hw_gl_block(con, true); - con->gl->ops->dpy_gl_update(con->gl, x, y, w, h); + QLIST_FOREACH(dcl, &s->listeners, next) { + dcl->ops->dpy_gl_update(dcl, x, y, w, h); + } graphic_hw_gl_block(con, false); } =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072539; cv=none; d=zohomail.com; s=zohoarc; b=AmQs+pVGFN1O4mskUjH+3kNsP0zdq3k8NWRZdZ9DrOjHMBU6GHp0ZU85pvpFet0iXdA2bywoYwlmbrHCdZZU/0JWr5vLbXF//tzcNSOqWT5yKOK8aomFYeQafbjEyFuBNWAeeJ224/T4hdkPaD+gTbXR1g8Ic7eVriUycZUaMbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072539; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0XmaWU22xZifElMEq63eAPJ22WB/aAoJVypSzIxJk10=; b=aFuU0epTkoYntdFOyNjJaRXUelUGYnOUSdOUa0F88FhJw4gpWPoUE6zkg1KNxna4w7lPdrD8oCYF4GlGSYQULv+bpyMzi4ypkEt5Hkzcgi0NVG0gFSynKBtEzmX10s6Dm9sbMQMVdwwVZomDk9sn/hqfCMsxqUladyMVYJpjvgQ= 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 1640072539521576.5434432241752; Mon, 20 Dec 2021 23:42:19 -0800 (PST) Received: from localhost ([::1]:52192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZms-0007QI-Cs for importer@patchew.org; Tue, 21 Dec 2021 02:42:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAy-0005uh-0t for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZAv-00025l-4H for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-50-XIHM-629MDCEy-zj2PXnxA-1; Tue, 21 Dec 2021 02:03:01 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AA31801B31; Tue, 21 Dec 2021 07:03:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0A857EA36; Tue, 21 Dec 2021 07:02:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070184; 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=0XmaWU22xZifElMEq63eAPJ22WB/aAoJVypSzIxJk10=; b=C1fz0ydqxoHYodzrDtwZDz+t5hf0f5+kq8L5JEy9DzUZkFJ0xNQNHU1+7c0mXXtk87FDSt odnXDFERFRJqeAv0at397a+DTDdaYg2pgCWaIe/exfuRC1TsrjJkNKrXSFDWIvIprNqmPm QgUTY4vLWjSPbiWo66q6PJPw3sHYT/w= X-MC-Unique: XIHM-629MDCEy-zj2PXnxA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 16/36] ui: split the GL context in a different object Date: Tue, 21 Dec 2021 10:58:35 +0400 Message-Id: <20211221065855.142578-17-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072541777100001 From: Marc-Andr=C3=A9 Lureau This will allow to have one GL context but a variable number of listeners. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 34 ++++++++++++++++++++++------------ include/ui/egl-context.h | 6 +++--- include/ui/gtk.h | 11 ++++++----- include/ui/sdl2.h | 7 ++++--- include/ui/spice-display.h | 1 + ui/console.c | 26 ++++++++++++++++---------- ui/egl-context.c | 6 +++--- ui/egl-headless.c | 21 ++++++++++++++------- ui/gtk-egl.c | 10 +++++----- ui/gtk-gl-area.c | 8 ++++---- ui/gtk.c | 24 ++++++++++++++++-------- ui/sdl2-gl.c | 10 +++++----- ui/sdl2.c | 13 +++++++++---- ui/spice-display.c | 18 +++++++++++------- 14 files changed, 119 insertions(+), 76 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 3ff51b492e5b..fe08b4dd040f 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -179,6 +179,7 @@ typedef struct QemuDmaBuf { } QemuDmaBuf; =20 typedef struct DisplayState DisplayState; +typedef struct DisplayGLCtx DisplayGLCtx; =20 typedef struct DisplayChangeListenerOps { const char *dpy_name; @@ -213,16 +214,6 @@ typedef struct DisplayChangeListenerOps { void (*dpy_cursor_define)(DisplayChangeListener *dcl, QEMUCursor *cursor); =20 - /* required if GL */ - QEMUGLContext (*dpy_gl_ctx_create)(DisplayChangeListener *dcl, - QEMUGLParams *params); - /* required if GL */ - void (*dpy_gl_ctx_destroy)(DisplayChangeListener *dcl, - QEMUGLContext ctx); - /* required if GL */ - int (*dpy_gl_ctx_make_current)(DisplayChangeListener *dcl, - QEMUGLContext ctx); - /* required if GL */ void (*dpy_gl_scanout_disable)(DisplayChangeListener *dcl); /* required if GL */ @@ -263,6 +254,26 @@ struct DisplayChangeListener { QLIST_ENTRY(DisplayChangeListener) next; }; =20 +typedef struct DisplayGLCtxOps { + /* + * We only check if the GLCtx is compatible with a DCL via ops. A natu= ral + * evolution of this would be a callback to check some runtime require= ments + * and allow various DCL kinds. + */ + const DisplayChangeListenerOps *compatible_dcl; + + QEMUGLContext (*dpy_gl_ctx_create)(DisplayGLCtx *dgc, + QEMUGLParams *params); + void (*dpy_gl_ctx_destroy)(DisplayGLCtx *dgc, + QEMUGLContext ctx); + int (*dpy_gl_ctx_make_current)(DisplayGLCtx *dgc, + QEMUGLContext ctx); +} DisplayGLCtxOps; + +struct DisplayGLCtx { + const DisplayGLCtxOps *ops; +}; + DisplayState *init_displaystate(void); DisplaySurface *qemu_create_displaysurface_from(int width, int height, pixman_format_code_t forma= t, @@ -409,8 +420,7 @@ void graphic_hw_gl_block(QemuConsole *con, bool block); =20 void qemu_console_early_init(void); =20 -void qemu_console_set_display_gl_ctx(QemuConsole *con, - DisplayChangeListener *dcl); +void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *ctx); =20 QemuConsole *qemu_console_lookup_by_index(unsigned int index); QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head= ); diff --git a/include/ui/egl-context.h b/include/ui/egl-context.h index 9374fe41e32b..c2761d747a4e 100644 --- a/include/ui/egl-context.h +++ b/include/ui/egl-context.h @@ -4,10 +4,10 @@ #include "ui/console.h" #include "ui/egl-helpers.h" =20 -QEMUGLContext qemu_egl_create_context(DisplayChangeListener *dcl, +QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params); -void qemu_egl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ct= x); -int qemu_egl_make_context_current(DisplayChangeListener *dcl, +void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); +int qemu_egl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx); =20 #endif /* EGL_CONTEXT_H */ diff --git a/include/ui/gtk.h b/include/ui/gtk.h index 7d22affd381a..101b147d1b98 100644 --- a/include/ui/gtk.h +++ b/include/ui/gtk.h @@ -35,6 +35,7 @@ typedef struct GtkDisplayState GtkDisplayState; =20 typedef struct VirtualGfxConsole { GtkWidget *drawing_area; + DisplayGLCtx dgc; DisplayChangeListener dcl; QKbdState *kbd; DisplaySurface *ds; @@ -165,7 +166,7 @@ void gd_egl_update(DisplayChangeListener *dcl, void gd_egl_refresh(DisplayChangeListener *dcl); void gd_egl_switch(DisplayChangeListener *dcl, DisplaySurface *surface); -QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl, +QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params); void gd_egl_scanout_disable(DisplayChangeListener *dcl); void gd_egl_scanout_texture(DisplayChangeListener *dcl, @@ -187,7 +188,7 @@ void gd_egl_flush(DisplayChangeListener *dcl, void gd_egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h); void gtk_egl_init(DisplayGLMode mode); -int gd_egl_make_current(DisplayChangeListener *dcl, +int gd_egl_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx); =20 /* ui/gtk-gl-area.c */ @@ -198,9 +199,9 @@ void gd_gl_area_update(DisplayChangeListener *dcl, void gd_gl_area_refresh(DisplayChangeListener *dcl); void gd_gl_area_switch(DisplayChangeListener *dcl, DisplaySurface *surface); -QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, +QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc, QEMUGLParams *params); -void gd_gl_area_destroy_context(DisplayChangeListener *dcl, +void gd_gl_area_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); void gd_gl_area_scanout_dmabuf(DisplayChangeListener *dcl, QemuDmaBuf *dmabuf); @@ -215,7 +216,7 @@ void gd_gl_area_scanout_disable(DisplayChangeListener *= dcl); void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t= h); void gtk_gl_area_init(void); -int gd_gl_area_make_current(DisplayChangeListener *dcl, +int gd_gl_area_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx); =20 /* gtk-clipboard.c */ diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h index f85c117a78f2..71bcf7ebdaee 100644 --- a/include/ui/sdl2.h +++ b/include/ui/sdl2.h @@ -16,6 +16,7 @@ #endif =20 struct sdl2_console { + DisplayGLCtx dgc; DisplayChangeListener dcl; DisplaySurface *surface; DisplayOptions *opts; @@ -65,10 +66,10 @@ void sdl2_gl_switch(DisplayChangeListener *dcl, void sdl2_gl_refresh(DisplayChangeListener *dcl); void sdl2_gl_redraw(struct sdl2_console *scon); =20 -QEMUGLContext sdl2_gl_create_context(DisplayChangeListener *dcl, +QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params); -void sdl2_gl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx= ); -int sdl2_gl_make_context_current(DisplayChangeListener *dcl, +void sdl2_gl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx); +int sdl2_gl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx); =20 void sdl2_gl_scanout_disable(DisplayChangeListener *dcl); diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index ed298d58f06c..a2fbf62c528e 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -86,6 +86,7 @@ typedef struct SimpleSpiceCursor SimpleSpiceCursor; =20 struct SimpleSpiceDisplay { DisplaySurface *ds; + DisplayGLCtx dgc; DisplayChangeListener dcl; void *buf; int bufsize; diff --git a/ui/console.c b/ui/console.c index 13c0d001c096..78583df92035 100644 --- a/ui/console.c +++ b/ui/console.c @@ -78,7 +78,7 @@ struct QemuConsole { DisplayState *ds; DisplaySurface *surface; int dcls; - DisplayChangeListener *gl; + DisplayGLCtx *gl; int gl_block; QEMUTimer *gl_unblock_timer; int window_id; @@ -1458,17 +1458,24 @@ static bool dpy_compatible_with(QemuConsole *con, return true; } =20 -void qemu_console_set_display_gl_ctx(QemuConsole *con, - DisplayChangeListener *dcl) +void qemu_console_set_display_gl_ctx(QemuConsole *con, DisplayGLCtx *gl) { /* display has opengl support */ - assert(dcl->con); - if (dcl->con->gl) { - fprintf(stderr, "can't register two opengl displays (%s, %s)\n", - dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name); + assert(con); + if (con->gl) { + error_report("The console already has an OpenGL context."); exit(1); } - dcl->con->gl =3D dcl; + con->gl =3D gl; +} + +static bool dpy_gl_compatible_with(QemuConsole *con, DisplayChangeListener= *dcl) +{ + if (!con->gl) { + return true; + } + + return con->gl->ops->compatible_dcl =3D=3D dcl->ops; } =20 void register_displaychangelistener(DisplayChangeListener *dcl) @@ -1480,8 +1487,7 @@ void register_displaychangelistener(DisplayChangeList= ener *dcl) =20 assert(!dcl->ds); =20 - if (dcl->con && dcl->con->gl && - dcl->con->gl !=3D dcl) { + if (dcl->con && !dpy_gl_compatible_with(dcl->con, dcl)) { error_report("Display %s is incompatible with the GL context", dcl->ops->dpy_name); exit(1); diff --git a/ui/egl-context.c b/ui/egl-context.c index 368ffa49d82f..eb5f520fc4da 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "ui/egl-context.h" =20 -QEMUGLContext qemu_egl_create_context(DisplayChangeListener *dcl, +QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { EGLContext ctx; @@ -24,12 +24,12 @@ QEMUGLContext qemu_egl_create_context(DisplayChangeList= ener *dcl, return ctx; } =20 -void qemu_egl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ct= x) +void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx) { eglDestroyContext(qemu_egl_display, ctx); } =20 -int qemu_egl_make_context_current(DisplayChangeListener *dcl, +int qemu_egl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { return eglMakeCurrent(qemu_egl_display, diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 08327c40c6ee..94082a9da951 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -38,12 +38,12 @@ static void egl_gfx_switch(DisplayChangeListener *dcl, edpy->ds =3D new_surface; } =20 -static QEMUGLContext egl_create_context(DisplayChangeListener *dcl, +static QEMUGLContext egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, qemu_egl_rn_ctx); - return qemu_egl_create_context(dcl, params); + return qemu_egl_create_context(dgc, params); } =20 static void egl_scanout_disable(DisplayChangeListener *dcl) @@ -157,10 +157,6 @@ static const DisplayChangeListenerOps egl_ops =3D { .dpy_gfx_update =3D egl_gfx_update, .dpy_gfx_switch =3D egl_gfx_switch, =20 - .dpy_gl_ctx_create =3D egl_create_context, - .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, - .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, - .dpy_gl_scanout_disable =3D egl_scanout_disable, .dpy_gl_scanout_texture =3D egl_scanout_texture, .dpy_gl_scanout_dmabuf =3D egl_scanout_dmabuf, @@ -170,6 +166,13 @@ static const DisplayChangeListenerOps egl_ops =3D { .dpy_gl_update =3D egl_scanout_flush, }; =20 +static const DisplayGLCtxOps eglctx_ops =3D { + .compatible_dcl =3D &egl_ops, + .dpy_gl_ctx_create =3D egl_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, +}; + static void early_egl_headless_init(DisplayOptions *opts) { display_opengl =3D 1; @@ -188,6 +191,8 @@ static void egl_headless_init(DisplayState *ds, Display= Options *opts) } =20 for (idx =3D 0;; idx++) { + DisplayGLCtx *ctx; + con =3D qemu_console_lookup_by_index(idx); if (!con || !qemu_console_is_graphic(con)) { break; @@ -197,7 +202,9 @@ static void egl_headless_init(DisplayState *ds, Display= Options *opts) edpy->dcl.con =3D con; edpy->dcl.ops =3D &egl_ops; edpy->gls =3D qemu_gl_init_shader(); - qemu_console_set_display_gl_ctx(con, &edpy->dcl); + ctx =3D g_new0(DisplayGLCtx, 1); + ctx->ops =3D &eglctx_ops; + qemu_console_set_display_gl_ctx(con, ctx); register_displaychangelistener(&edpy->dcl); } } diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index e891b61048a8..e3bd4bc27431 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -197,14 +197,14 @@ void gd_egl_switch(DisplayChangeListener *dcl, } } =20 -QEMUGLContext gd_egl_create_context(DisplayChangeListener *dcl, +QEMUGLContext gd_egl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); =20 eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, vc->gfx.ectx); - return qemu_egl_create_context(dcl, params); + return qemu_egl_create_context(dgc, params); } =20 void gd_egl_scanout_disable(DisplayChangeListener *dcl) @@ -360,10 +360,10 @@ void gtk_egl_init(DisplayGLMode mode) display_opengl =3D 1; } =20 -int gd_egl_make_current(DisplayChangeListener *dcl, +int gd_egl_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { - VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); =20 return eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, vc->gfx.esurface, ctx); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index f1c7636cba98..fc5a082eb846 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -170,10 +170,10 @@ void gd_gl_area_switch(DisplayChangeListener *dcl, } } =20 -QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, +QEMUGLContext gd_gl_area_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - VirtualConsole *vc =3D container_of(dcl, VirtualConsole, gfx.dcl); + VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); GdkWindow *window; GdkGLContext *ctx; GError *err =3D NULL; @@ -199,7 +199,7 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeLi= stener *dcl, return ctx; } =20 -void gd_gl_area_destroy_context(DisplayChangeListener *dcl, QEMUGLContext = ctx) +void gd_gl_area_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx) { /* FIXME */ } @@ -278,7 +278,7 @@ void gtk_gl_area_init(void) display_opengl =3D 1; } =20 -int gd_gl_area_make_current(DisplayChangeListener *dcl, +int gd_gl_area_make_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { gdk_gl_context_make_current(ctx); diff --git a/ui/gtk.c b/ui/gtk.c index 077d38145de8..6a1f65d51894 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -606,9 +606,6 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_mouse_set =3D gd_mouse_set, .dpy_cursor_define =3D gd_cursor_define, =20 - .dpy_gl_ctx_create =3D gd_gl_area_create_context, - .dpy_gl_ctx_destroy =3D gd_gl_area_destroy_context, - .dpy_gl_ctx_make_current =3D gd_gl_area_make_current, .dpy_gl_scanout_texture =3D gd_gl_area_scanout_texture, .dpy_gl_scanout_disable =3D gd_gl_area_scanout_disable, .dpy_gl_update =3D gd_gl_area_scanout_flush, @@ -617,8 +614,14 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = =3D { .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 -#ifdef CONFIG_X11 +static const DisplayGLCtxOps gl_area_ctx_ops =3D { + .compatible_dcl =3D &dcl_gl_area_ops, + .dpy_gl_ctx_create =3D gd_gl_area_create_context, + .dpy_gl_ctx_destroy =3D gd_gl_area_destroy_context, + .dpy_gl_ctx_make_current =3D gd_gl_area_make_current, +}; =20 +#ifdef CONFIG_X11 static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_name =3D "gtk-egl", .dpy_gfx_update =3D gd_egl_update, @@ -628,9 +631,6 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_mouse_set =3D gd_mouse_set, .dpy_cursor_define =3D gd_cursor_define, =20 - .dpy_gl_ctx_create =3D gd_egl_create_context, - .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, - .dpy_gl_ctx_make_current =3D gd_egl_make_current, .dpy_gl_scanout_disable =3D gd_egl_scanout_disable, .dpy_gl_scanout_texture =3D gd_egl_scanout_texture, .dpy_gl_scanout_dmabuf =3D gd_egl_scanout_dmabuf, @@ -641,6 +641,12 @@ static const DisplayChangeListenerOps dcl_egl_ops =3D { .dpy_has_dmabuf =3D gd_has_dmabuf, }; =20 +static const DisplayGLCtxOps egl_ctx_ops =3D { + .compatible_dcl =3D &dcl_egl_ops, + .dpy_gl_ctx_create =3D gd_egl_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D gd_egl_make_current, +}; #endif =20 #endif /* CONFIG_OPENGL */ @@ -2034,6 +2040,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, g_signal_connect(vc->gfx.drawing_area, "realize", G_CALLBACK(gl_area_realize), vc); vc->gfx.dcl.ops =3D &dcl_gl_area_ops; + vc->gfx.dgc.ops =3D &gl_area_ctx_ops; } else { #ifdef CONFIG_X11 vc->gfx.drawing_area =3D gtk_drawing_area_new(); @@ -2048,6 +2055,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, gtk_widget_set_double_buffered(vc->gfx.drawing_area, FALSE); #pragma GCC diagnostic pop vc->gfx.dcl.ops =3D &dcl_egl_ops; + vc->gfx.dgc.ops =3D &egl_ctx_ops; vc->gfx.has_dmabuf =3D qemu_egl_has_dmabuf(); #else abort(); @@ -2083,7 +2091,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, vc->gfx.dcl.con =3D con; =20 if (display_opengl) { - qemu_console_set_display_gl_ctx(con, &vc->gfx.dcl); + qemu_console_set_display_gl_ctx(con, &vc->gfx.dgc); } register_displaychangelistener(&vc->gfx.dcl); =20 diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 5b950fbbea2f..39cab8cde737 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -132,10 +132,10 @@ void sdl2_gl_redraw(struct sdl2_console *scon) } } =20 -QEMUGLContext sdl2_gl_create_context(DisplayChangeListener *dcl, +QEMUGLContext sdl2_gl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { - struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); + struct sdl2_console *scon =3D container_of(dgc, struct sdl2_console, d= gc); SDL_GLContext ctx; =20 assert(scon->opengl); @@ -167,17 +167,17 @@ QEMUGLContext sdl2_gl_create_context(DisplayChangeLis= tener *dcl, return (QEMUGLContext)ctx; } =20 -void sdl2_gl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx) +void sdl2_gl_destroy_context(DisplayGLCtx *dgc, QEMUGLContext ctx) { SDL_GLContext sdlctx =3D (SDL_GLContext)ctx; =20 SDL_GL_DeleteContext(sdlctx); } =20 -int sdl2_gl_make_context_current(DisplayChangeListener *dcl, +int sdl2_gl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { - struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); + struct sdl2_console *scon =3D container_of(dgc, struct sdl2_console, d= gc); SDL_GLContext sdlctx =3D (SDL_GLContext)ctx; =20 assert(scon->opengl); diff --git a/ui/sdl2.c b/ui/sdl2.c index bb186a381acd..0bd30504cfcc 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -778,13 +778,17 @@ static const DisplayChangeListenerOps dcl_gl_ops =3D { .dpy_mouse_set =3D sdl_mouse_warp, .dpy_cursor_define =3D sdl_mouse_define, =20 - .dpy_gl_ctx_create =3D sdl2_gl_create_context, - .dpy_gl_ctx_destroy =3D sdl2_gl_destroy_context, - .dpy_gl_ctx_make_current =3D sdl2_gl_make_context_current, .dpy_gl_scanout_disable =3D sdl2_gl_scanout_disable, .dpy_gl_scanout_texture =3D sdl2_gl_scanout_texture, .dpy_gl_update =3D sdl2_gl_scanout_flush, }; + +static const DisplayGLCtxOps gl_ctx_ops =3D { + .compatible_dcl =3D &dcl_gl_ops, + .dpy_gl_ctx_create =3D sdl2_gl_create_context, + .dpy_gl_ctx_destroy =3D sdl2_gl_destroy_context, + .dpy_gl_ctx_make_current =3D sdl2_gl_make_context_current, +}; #endif =20 static void sdl2_display_early_init(DisplayOptions *o) @@ -860,6 +864,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) #ifdef CONFIG_OPENGL sdl2_console[i].opengl =3D display_opengl; sdl2_console[i].dcl.ops =3D display_opengl ? &dcl_gl_ops : &dcl_2d= _ops; + sdl2_console[i].dgc.ops =3D display_opengl ? &gl_ctx_ops : NULL; #else sdl2_console[i].opengl =3D 0; sdl2_console[i].dcl.ops =3D &dcl_2d_ops; @@ -867,7 +872,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) sdl2_console[i].dcl.con =3D con; sdl2_console[i].kbd =3D qkbd_state_init(con); if (display_opengl) { - qemu_console_set_display_gl_ctx(con, &sdl2_console[i].dcl); + qemu_console_set_display_gl_ctx(con, &sdl2_console[i].dgc); } register_displaychangelistener(&sdl2_console[i].dcl); =20 diff --git a/ui/spice-display.c b/ui/spice-display.c index ec501f129f07..798e0f6167e7 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -908,12 +908,12 @@ static void spice_gl_switch(DisplayChangeListener *dc= l, } } =20 -static QEMUGLContext qemu_spice_gl_create_context(DisplayChangeListener *d= cl, +static QEMUGLContext qemu_spice_gl_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, qemu_egl_rn_ctx); - return qemu_egl_create_context(dcl, params); + return qemu_egl_create_context(dgc, params); } =20 static void qemu_spice_gl_scanout_disable(DisplayChangeListener *dcl) @@ -1105,10 +1105,6 @@ static const DisplayChangeListenerOps display_listen= er_gl_ops =3D { .dpy_mouse_set =3D display_mouse_set, .dpy_cursor_define =3D display_mouse_define, =20 - .dpy_gl_ctx_create =3D qemu_spice_gl_create_context, - .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, - .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, - .dpy_gl_scanout_disable =3D qemu_spice_gl_scanout_disable, .dpy_gl_scanout_texture =3D qemu_spice_gl_scanout_texture, .dpy_gl_scanout_dmabuf =3D qemu_spice_gl_scanout_dmabuf, @@ -1118,6 +1114,13 @@ static const DisplayChangeListenerOps display_listen= er_gl_ops =3D { .dpy_gl_update =3D qemu_spice_gl_update, }; =20 +static const DisplayGLCtxOps gl_ctx_ops =3D { + .compatible_dcl =3D &display_listener_gl_ops, + .dpy_gl_ctx_create =3D qemu_spice_gl_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, +}; + #endif /* HAVE_SPICE_GL */ =20 static void qemu_spice_display_init_one(QemuConsole *con) @@ -1130,6 +1133,7 @@ static void qemu_spice_display_init_one(QemuConsole *= con) #ifdef HAVE_SPICE_GL if (spice_opengl) { ssd->dcl.ops =3D &display_listener_gl_ops; + ssd->dgc.ops =3D &gl_ctx_ops; ssd->gl_unblock_bh =3D qemu_bh_new(qemu_spice_gl_unblock_bh, ssd); ssd->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, qemu_spice_gl_block_timer, ss= d); @@ -1156,7 +1160,7 @@ static void qemu_spice_display_init_one(QemuConsole *= con) qemu_spice_create_host_memslot(ssd); =20 if (spice_opengl) { - qemu_console_set_display_gl_ctx(con, &ssd->dcl); + qemu_console_set_display_gl_ctx(con, &ssd->dgc); } register_displaychangelistener(&ssd->dcl); } --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071541; cv=none; d=zohomail.com; s=zohoarc; b=VU38rPDVSwedAbH71H3s64WlL7wfHVlNEtY/qpuWoKO8q3Ub3Brn6bwdFHzU0d2mfbCugGEk0j8V5KqUxsL46kMZMSHtPmU67X8QHIXhiU+5iyazpaeDSRNSYhI4XKACiA3l0x+Tc4WD5ERiYXAfuEf3GFJXRta/b8S0AD2YExo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071541; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yZTKnnbpBds7/JO3O9qeODXIeEG4PnULWLhKLIpNrmw=; b=UJPXBVNSZL3BmUy63xs2A0beiNd3Mr2gzaPqpk43+TflVVrNwHfe+SC0Strgt0aGdDBbidJzTehVS7rjxxKYs63gAnvmoeoNwD+wY3CYVE6l6oCfNxxrb8FnwXlSYjcmqNHUFNMsrUVYeKGSHT32b3vb8oHbqnSaSsono76Ocpw= 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 1640071541182701.914729524874; Mon, 20 Dec 2021 23:25:41 -0800 (PST) Received: from localhost ([::1]:56478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZWm-0007BS-3o for importer@patchew.org; Tue, 21 Dec 2021 02:25:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZB2-0005zx-JE for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZB0-00026G-Fp for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-YtjZdW5FObGdOsXYkZNhtA-1; Tue, 21 Dec 2021 02:03:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E40B1006AA3; Tue, 21 Dec 2021 07:03:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE7767EA36; Tue, 21 Dec 2021 07:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070189; 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=yZTKnnbpBds7/JO3O9qeODXIeEG4PnULWLhKLIpNrmw=; b=S/jsOFusZJ/9PSXKrvxwrZ2zrJLIBwo9ofvc37gwSSvSReodOajGKaeHkiyG8nzKmLtDl2 GokYjsgEMGUx/GZwE/DUy3mQJ67/AJKDj4vBIXSER7mRfeJaKRQ9YozeyLBUkMFArp/ghi 6Z2zmkvSEDcBRSMzGFRbFeKdhVvPSy4= X-MC-Unique: YtjZdW5FObGdOsXYkZNhtA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 17/36] ui: move qemu_spice_fill_device_address to ui/util.c Date: Tue, 21 Dec 2021 10:58:36 +0400 Message-Id: <20211221065855.142578-18-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071542568100001 From: Marc-Andr=C3=A9 Lureau Other backends can use it. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 6 +++ include/ui/spice-display.h | 4 -- hw/display/qxl.c | 7 +++- ui/spice-core.c | 50 ------------------------- ui/spice-display.c | 5 ++- ui/util.c | 75 ++++++++++++++++++++++++++++++++++++++ ui/meson.build | 1 + 7 files changed, 92 insertions(+), 56 deletions(-) create mode 100644 ui/util.c diff --git a/include/ui/console.h b/include/ui/console.h index fe08b4dd040f..eefd7e4dc1f4 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -495,4 +495,10 @@ int index_from_key(const char *key, size_t key_length); int udmabuf_fd(void); #endif =20 +/* util.c */ +bool qemu_console_fill_device_address(QemuConsole *con, + char *device_address, + size_t size, + Error **errp); + #endif diff --git a/include/ui/spice-display.h b/include/ui/spice-display.h index a2fbf62c528e..e271e011da1a 100644 --- a/include/ui/spice-display.h +++ b/include/ui/spice-display.h @@ -184,8 +184,4 @@ void qemu_spice_display_start(void); void qemu_spice_display_stop(void); int qemu_spice_display_is_running(SimpleSpiceDisplay *ssd); =20 -bool qemu_spice_fill_device_address(QemuConsole *con, - char *device_address, - size_t size); - #endif diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 29c80b4289b7..e2d6e317da5d 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2171,12 +2171,17 @@ static void qxl_realize_common(PCIQXLDevice *qxl, E= rror **errp) } =20 #if SPICE_SERVER_VERSION >=3D 0x000e02 /* release 0.14.2 */ + Error *err =3D NULL; char device_address[256] =3D ""; - if (qemu_spice_fill_device_address(qxl->vga.con, device_address, 256))= { + if (qemu_console_fill_device_address(qxl->vga.con, + device_address, sizeof(device_add= ress), + &err)) { spice_qxl_set_device_info(&qxl->ssd.qxl, device_address, 0, qxl->max_outputs); + } else { + error_report_err(err); } #endif =20 diff --git a/ui/spice-core.c b/ui/spice-core.c index 31974b8d6c44..c3ac20ad4306 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -884,56 +884,6 @@ bool qemu_spice_have_display_interface(QemuConsole *co= n) return false; } =20 -/* - * Recursively (in reverse order) appends addresses of PCI devices as it m= oves - * up in the PCI hierarchy. - * - * @returns true on success, false when the buffer wasn't large enough - */ -static bool append_pci_address(char *buf, size_t buf_size, const PCIDevice= *pci) -{ - PCIBus *bus =3D pci_get_bus(pci); - /* - * equivalent to if (!pci_bus_is_root(bus)), but the function is not b= uilt - * with PCI_CONFIG=3Dn, avoid using an #ifdef by checking directly - */ - if (bus->parent_dev !=3D NULL) { - append_pci_address(buf, buf_size, bus->parent_dev); - } - - size_t len =3D strlen(buf); - ssize_t written =3D snprintf(buf + len, buf_size - len, "/%02x.%x", - PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn)); - - return written > 0 && written < buf_size - len; -} - -bool qemu_spice_fill_device_address(QemuConsole *con, - char *device_address, - size_t size) -{ - DeviceState *dev =3D DEVICE(object_property_get_link(OBJECT(con), - "device", - &error_abort)); - PCIDevice *pci =3D (PCIDevice *) object_dynamic_cast(OBJECT(dev), - TYPE_PCI_DEVICE); - - if (pci =3D=3D NULL) { - warn_report("Setting device address of a display device to SPICE: " - "Not a PCI device."); - return false; - } - - strncpy(device_address, "pci/0000", size); - if (!append_pci_address(device_address, size, pci)) { - warn_report("Setting device address of a display device to SPICE: " - "Too many PCI devices in the chain."); - return false; - } - - return true; -} - int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con) { if (g_slist_find(spice_consoles, con)) { diff --git a/ui/spice-display.c b/ui/spice-display.c index 798e0f6167e7..1043f47f9456 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1148,12 +1148,15 @@ static void qemu_spice_display_init_one(QemuConsole= *con) qemu_spice_add_display_interface(&ssd->qxl, con); =20 #if SPICE_SERVER_VERSION >=3D 0x000e02 /* release 0.14.2 */ + Error *err =3D NULL; char device_address[256] =3D ""; - if (qemu_spice_fill_device_address(con, device_address, 256)) { + if (qemu_console_fill_device_address(con, device_address, 256, &err)) { spice_qxl_set_device_info(&ssd->qxl, device_address, qemu_console_get_head(con), 1); + } else { + error_report_err(err); } #endif =20 diff --git a/ui/util.c b/ui/util.c new file mode 100644 index 000000000000..7e8fc1ea537a --- /dev/null +++ b/ui/util.c @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2021 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "qemu/osdep.h" + +#include "hw/pci/pci.h" +#include "hw/pci/pci_bus.h" +#include "qapi/error.h" +#include "ui/console.h" + +/* + * Recursively (in reverse order) appends addresses of PCI devices as it m= oves + * up in the PCI hierarchy. + * + * @returns true on success, false when the buffer wasn't large enough + */ +static bool append_pci_address(char *buf, size_t buf_size, const PCIDevice= *pci) +{ + PCIBus *bus =3D pci_get_bus(pci); + /* + * equivalent to if (!pci_bus_is_root(bus)), but the function is not b= uilt + * with PCI_CONFIG=3Dn, avoid using an #ifdef by checking directly + */ + if (bus->parent_dev !=3D NULL) { + append_pci_address(buf, buf_size, bus->parent_dev); + } + + size_t len =3D strlen(buf); + ssize_t written =3D snprintf(buf + len, buf_size - len, "/%02x.%x", + PCI_SLOT(pci->devfn), PCI_FUNC(pci->devfn)); + + return written > 0 && written < buf_size - len; +} + +bool qemu_console_fill_device_address(QemuConsole *con, + char *device_address, + size_t size, + Error **errp) +{ + ERRP_GUARD(); + DeviceState *dev =3D DEVICE(object_property_get_link(OBJECT(con), + "device", + &error_abort)); + PCIDevice *pci =3D (PCIDevice *) object_dynamic_cast(OBJECT(dev), + TYPE_PCI_DEVICE); + + if (pci =3D=3D NULL) { + error_setg(errp, "Setting device address of a display device: " + "Not a PCI device."); + return false; + } + + strncpy(device_address, "pci/0000", size); + if (!append_pci_address(device_address, size, pci)) { + error_setg(errp, "Setting device address of a display device: " + "Too many PCI devices in the chain."); + return false; + } + + return true; +} diff --git a/ui/meson.build b/ui/meson.build index ee8ef27714cd..a9df5b911ec8 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -12,6 +12,7 @@ softmmu_ss.add(files( 'kbd-state.c', 'keymaps.c', 'qemu-pixman.c', + 'util.c', )) softmmu_ss.add([spice_headers, files('spice-module.c')]) softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.c')) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072002; cv=none; d=zohomail.com; s=zohoarc; b=ltSUUFoIPnqGJU4SIwmNXwhvTSs91ih0IiZJqxf3hbDIp04w++aavpyaPvvXdZYRFF5QnIxTzrw2ZHxf4xECMFwdp3qaunRKKsawtDxvmGIF9aCHgl6RRNtqsvRaGaLg8BWUiRiTOXLUXqPSOMHisBDIgIrkoPb3tVIQg4cxsdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072002; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qMiNkCokrtNT9mUUH6x5x11OrQaJ0Ac5k+jaVR3jnpg=; b=BEBZQ5+n2wJ9uQym9E5xWtS7n6SmvMLmp7TSZd9LahRukMZzUyqeoDM7w6501EaFxuCtoifUBmL0lQsUb+Hrx61k01uP4mrjwUKBuP8wm8NWvNsnH4pYedmTvnBEthtnNVkjx/PQ6pu2CZk3LI0KGy9ulmjWFpEf77l/D5H6vz8= 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 1640072002619636.8234352831754; Mon, 20 Dec 2021 23:33:22 -0800 (PST) Received: from localhost ([::1]:36774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZeD-0004oJ-Gf for importer@patchew.org; Tue, 21 Dec 2021 02:33:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZBD-0006Hx-Ik for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZBA-00026R-3I for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-223-OUxumi5eO7eJK4R-9y00ug-1; Tue, 21 Dec 2021 02:03:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09DA51023F4D; Tue, 21 Dec 2021 07:03:17 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1A1138DFE; Tue, 21 Dec 2021 07:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070199; 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=qMiNkCokrtNT9mUUH6x5x11OrQaJ0Ac5k+jaVR3jnpg=; b=Sj8VbOXo1yJqKKHnZ+jqAKPlWymWIfmJPcoZGEnQ3kky9YLkiu/I4X7Fa+AMdp+MQzWMua u/XFKsRzjc4Y8eCMe/SyL/iCSFgCJGfmujqcC0WlfVf28lbnACJajOohxWN1NMdP8unKDH j5W1BcaL50J+pF12B/+WBElOThqyWFk= X-MC-Unique: OUxumi5eO7eJK4R-9y00ug-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 18/36] console: save current scanout details Date: Tue, 21 Dec 2021 10:58:37 +0400 Message-Id: <20211221065855.142578-19-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072004536100003 From: Marc-Andr=C3=A9 Lureau Add a new DisplayScanout structure to save the current scanout details. This allows to attach later UI backends and set the scanout. Introduce displaychangelistener_display_console() helper function to handle the dpy_gfx_switch/gl_scanout() & dpy_gfx_update() calls. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- include/ui/console.h | 27 +++++++ ui/console.c | 165 +++++++++++++++++++++++++++++-------------- 2 files changed, 138 insertions(+), 54 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index eefd7e4dc1f4..f590819880b5 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -108,6 +108,17 @@ struct QemuConsoleClass { #define QEMU_ALLOCATED_FLAG 0x01 #define QEMU_PLACEHOLDER_FLAG 0x02 =20 +typedef struct ScanoutTexture { + uint32_t backing_id; + bool backing_y_0_top; + uint32_t backing_width; + uint32_t backing_height; + uint32_t x; + uint32_t y; + uint32_t width; + uint32_t height; +} ScanoutTexture; + typedef struct DisplaySurface { pixman_format_code_t format; pixman_image_t *image; @@ -178,6 +189,22 @@ typedef struct QemuDmaBuf { bool draw_submitted; } QemuDmaBuf; =20 +enum display_scanout { + SCANOUT_NONE, + SCANOUT_SURFACE, + SCANOUT_TEXTURE, + SCANOUT_DMABUF, +}; + +typedef struct DisplayScanout { + enum display_scanout kind; + union { + /* DisplaySurface *surface; is kept in QemuConsole */ + ScanoutTexture texture; + QemuDmaBuf *dmabuf; + }; +} DisplayScanout; + typedef struct DisplayState DisplayState; typedef struct DisplayGLCtx DisplayGLCtx; =20 diff --git a/ui/console.c b/ui/console.c index 78583df92035..40eebb6d2cc2 100644 --- a/ui/console.c +++ b/ui/console.c @@ -77,6 +77,7 @@ struct QemuConsole { console_type_t console_type; DisplayState *ds; DisplaySurface *surface; + DisplayScanout scanout; int dcls; DisplayGLCtx *gl; int gl_block; @@ -146,6 +147,7 @@ static void dpy_refresh(DisplayState *s); static DisplayState *get_alloc_displaystate(void); static void text_console_update_cursor_timer(void); static void text_console_update_cursor(void *opaque); +static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl); =20 static void gui_update(void *opaque) { @@ -481,6 +483,8 @@ static void text_console_resize(QemuConsole *s) TextCell *cells, *c, *c1; int w1, x, y, last_width; =20 + assert(s->scanout.kind =3D=3D SCANOUT_SURFACE); + last_width =3D s->width; s->width =3D surface_width(s->surface) / FONT_WIDTH; s->height =3D surface_height(s->surface) / FONT_HEIGHT; @@ -1052,6 +1056,48 @@ static void console_putchar(QemuConsole *s, int ch) } } =20 +static void displaychangelistener_display_console(DisplayChangeListener *d= cl, + QemuConsole *con) +{ + static const char nodev[] =3D + "This VM has no graphic display device."; + static DisplaySurface *dummy; + + if (!con) { + if (!dcl->ops->dpy_gfx_switch) { + return; + } + if (!dummy) { + dummy =3D qemu_create_placeholder_surface(640, 480, nodev); + } + dcl->ops->dpy_gfx_switch(dcl, dummy); + return; + } + + if (con->scanout.kind =3D=3D SCANOUT_DMABUF && + displaychangelistener_has_dmabuf(dcl)) { + dcl->ops->dpy_gl_scanout_dmabuf(dcl, con->scanout.dmabuf); + } else if (con->scanout.kind =3D=3D SCANOUT_TEXTURE && + dcl->ops->dpy_gl_scanout_texture) { + dcl->ops->dpy_gl_scanout_texture(dcl, + con->scanout.texture.backing_id, + con->scanout.texture.backing_y_0_= top, + con->scanout.texture.backing_widt= h, + con->scanout.texture.backing_heig= ht, + con->scanout.texture.x, + con->scanout.texture.y, + con->scanout.texture.width, + con->scanout.texture.height); + } else if (con->scanout.kind =3D=3D SCANOUT_SURFACE && + dcl->ops->dpy_gfx_switch) { + dcl->ops->dpy_gfx_switch(dcl, con->surface); + } + + dcl->ops->dpy_gfx_update(dcl, 0, 0, + qemu_console_get_width(con, 0), + qemu_console_get_height(con, 0)); +} + void console_select(unsigned int index) { DisplayChangeListener *dcl; @@ -1068,13 +1114,7 @@ void console_select(unsigned int index) if (dcl->con !=3D NULL) { continue; } - if (dcl->ops->dpy_gfx_switch) { - dcl->ops->dpy_gfx_switch(dcl, s->surface); - } - } - if (s->surface) { - dpy_gfx_update(s, 0, 0, surface_width(s->surface), - surface_height(s->surface)); + displaychangelistener_display_console(dcl, s); } } if (ds->have_text) { @@ -1480,9 +1520,6 @@ static bool dpy_gl_compatible_with(QemuConsole *con, = DisplayChangeListener *dcl) =20 void register_displaychangelistener(DisplayChangeListener *dcl) { - static const char nodev[] =3D - "This VM has no graphic display device."; - static DisplaySurface *dummy; QemuConsole *con; =20 assert(!dcl->ds); @@ -1507,16 +1544,7 @@ void register_displaychangelistener(DisplayChangeLis= tener *dcl) } else { con =3D active_console; } - if (dcl->ops->dpy_gfx_switch) { - if (con) { - dcl->ops->dpy_gfx_switch(dcl, con->surface); - } else { - if (!dummy) { - dummy =3D qemu_create_placeholder_surface(640, 480, nodev); - } - dcl->ops->dpy_gfx_switch(dcl, dummy); - } - } + displaychangelistener_display_console(dcl, con); text_console_update_cursor(NULL); } =20 @@ -1597,13 +1625,9 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, = int w, int h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; - int width =3D w; - int height =3D h; + int width =3D qemu_console_get_width(con, x + w); + int height =3D qemu_console_get_height(con, y + h); =20 - if (con->surface) { - width =3D surface_width(con->surface); - height =3D surface_height(con->surface); - } x =3D MAX(x, 0); y =3D MAX(y, 0); x =3D MIN(x, width); @@ -1626,12 +1650,10 @@ void dpy_gfx_update(QemuConsole *con, int x, int y,= int w, int h) =20 void dpy_gfx_update_full(QemuConsole *con) { - if (!con->surface) { - return; - } - dpy_gfx_update(con, 0, 0, - surface_width(con->surface), - surface_height(con->surface)); + int w =3D qemu_console_get_width(con, 0); + int h =3D qemu_console_get_height(con, 0); + + dpy_gfx_update(con, 0, 0, w, h); } =20 void dpy_gfx_replace_surface(QemuConsole *con, @@ -1658,6 +1680,7 @@ void dpy_gfx_replace_surface(QemuConsole *con, =20 assert(old_surface !=3D surface); =20 + con->scanout.kind =3D SCANOUT_SURFACE; con->surface =3D surface; QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D (dcl->con ? dcl->con : active_console)) { @@ -1833,6 +1856,9 @@ void dpy_gl_scanout_disable(QemuConsole *con) DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 + if (con->scanout.kind !=3D SCANOUT_SURFACE) { + con->scanout.kind =3D SCANOUT_NONE; + } QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_disable(dcl); } @@ -1849,6 +1875,11 @@ void dpy_gl_scanout_texture(QemuConsole *con, DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 + con->scanout.kind =3D SCANOUT_TEXTURE; + con->scanout.texture =3D (ScanoutTexture) { + backing_id, backing_y_0_top, backing_width, backing_height, + x, y, width, height + }; QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_texture(dcl, backing_id, backing_y_0_top, @@ -1863,6 +1894,8 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 + con->scanout.kind =3D SCANOUT_DMABUF; + con->scanout.dmabuf =3D dmabuf; QLIST_FOREACH(dcl, &s->listeners, next) { dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf); } @@ -1989,10 +2022,8 @@ QemuConsole *graphic_console_init(DeviceState *dev, = uint32_t head, s =3D qemu_console_lookup_unused(); if (s) { trace_console_gfx_reuse(s->index); - if (s->surface) { - width =3D surface_width(s->surface); - height =3D surface_height(s->surface); - } + width =3D qemu_console_get_width(s, 0); + height =3D qemu_console_get_height(s, 0); } else { trace_console_gfx_new(); s =3D new_console(ds, GRAPHIC_CONSOLE, head); @@ -2021,13 +2052,8 @@ void graphic_console_close(QemuConsole *con) static const char unplugged[] =3D "Guest display has been unplugged"; DisplaySurface *surface; - int width =3D 640; - int height =3D 480; - - if (con->surface) { - width =3D surface_width(con->surface); - height =3D surface_height(con->surface); - } + int width =3D qemu_console_get_width(con, 640); + int height =3D qemu_console_get_height(con, 480); =20 trace_console_gfx_close(con->index); object_property_set_link(OBJECT(con), "device", NULL, &error_abort); @@ -2179,7 +2205,19 @@ int qemu_console_get_width(QemuConsole *con, int fal= lback) if (con =3D=3D NULL) { con =3D active_console; } - return con ? surface_width(con->surface) : fallback; + if (con =3D=3D NULL) { + return fallback; + } + switch (con->scanout.kind) { + case SCANOUT_DMABUF: + return con->scanout.dmabuf->width; + case SCANOUT_TEXTURE: + return con->scanout.texture.width; + case SCANOUT_SURFACE: + return surface_width(con->surface); + default: + return fallback; + } } =20 int qemu_console_get_height(QemuConsole *con, int fallback) @@ -2187,7 +2225,19 @@ int qemu_console_get_height(QemuConsole *con, int fa= llback) if (con =3D=3D NULL) { con =3D active_console; } - return con ? surface_height(con->surface) : fallback; + if (con =3D=3D NULL) { + return fallback; + } + switch (con->scanout.kind) { + case SCANOUT_DMABUF: + return con->scanout.dmabuf->height; + case SCANOUT_TEXTURE: + return con->scanout.texture.height; + case SCANOUT_SURFACE: + return surface_height(con->surface); + default: + return fallback; + } } =20 static void vc_chr_accept_input(Chardev *chr) @@ -2253,12 +2303,13 @@ static void text_console_do_init(Chardev *chr, Disp= layState *ds) s->total_height =3D DEFAULT_BACKSCROLL; s->x =3D 0; s->y =3D 0; - if (!s->surface) { - if (active_console && active_console->surface) { - g_width =3D surface_width(active_console->surface); - g_height =3D surface_height(active_console->surface); + if (s->scanout.kind !=3D SCANOUT_SURFACE) { + if (active_console && active_console->scanout.kind =3D=3D SCANOUT_= SURFACE) { + g_width =3D qemu_console_get_width(active_console, g_width); + g_height =3D qemu_console_get_height(active_console, g_height); } s->surface =3D qemu_create_displaysurface(g_width, g_height); + s->scanout.kind =3D SCANOUT_SURFACE; } =20 s->hw_ops =3D &text_console_ops; @@ -2317,6 +2368,7 @@ static void vc_chr_open(Chardev *chr, s =3D new_console(NULL, TEXT_CONSOLE, 0); } else { s =3D new_console(NULL, TEXT_CONSOLE_FIXED_SIZE, 0); + s->scanout.kind =3D SCANOUT_SURFACE; s->surface =3D qemu_create_displaysurface(width, height); } =20 @@ -2340,13 +2392,13 @@ static void vc_chr_open(Chardev *chr, =20 void qemu_console_resize(QemuConsole *s, int width, int height) { - DisplaySurface *surface; + DisplaySurface *surface =3D qemu_console_surface(s); =20 assert(s->console_type =3D=3D GRAPHIC_CONSOLE); =20 - if (s->surface && (s->surface->flags & QEMU_ALLOCATED_FLAG) && - pixman_image_get_width(s->surface->image) =3D=3D width && - pixman_image_get_height(s->surface->image) =3D=3D height) { + if (surface && (surface->flags & QEMU_ALLOCATED_FLAG) && + pixman_image_get_width(surface->image) =3D=3D width && + pixman_image_get_height(surface->image) =3D=3D height) { return; } =20 @@ -2356,7 +2408,12 @@ void qemu_console_resize(QemuConsole *s, int width, = int height) =20 DisplaySurface *qemu_console_surface(QemuConsole *console) { - return console->surface; + switch (console->scanout.kind) { + case SCANOUT_SURFACE: + return console->surface; + default: + return NULL; + } } =20 PixelFormat qemu_default_pixelformat(int bpp) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072679; cv=none; d=zohomail.com; s=zohoarc; b=DF5VIMgLq9QcZUR3RzxV/xu4+/XD/NxfBSQoWMtYPua46xX59J78TEYL+iQBG9s2VMs7xbFqvcrXmEXhtxvEeBf+2y1moCV4LjPjsledw+PulF4x6Ee6XAn7EiZC2Ix8+ld/LkZIS6nXARtrbTcl+e94HlKunKlJAAtgYAub/cw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072679; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wxI7enpms8x1wEW2qLMdd/TI1oYT7Wx6t357beToVE8=; b=gjwXRCHImMa8v6kRLKK2Y5tAg8CotzDlZk0smZY4uJkJ18iFcso5MuEMMtcCQtHj7lKDhDJd9/8Y4lJMZBAb9sV5yOkn2HrPFfB9m1zS8H7ChpFMvb3pQtq45oTO+o0beWi+Ryw13i0BaHo8pomg7IKkdaY8CGzpCh8fCnubWNQ= 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 1640072679930924.305032304541; Mon, 20 Dec 2021 23:44:39 -0800 (PST) Received: from localhost ([::1]:60940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZp8-0004x1-Su for importer@patchew.org; Tue, 21 Dec 2021 02:44:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZBg-0006ct-6a for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZBe-00028W-Ho for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:03:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-605-lP7B5GiIMn2ZTmARwwWjIA-1; Tue, 21 Dec 2021 02:03:49 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30D4A1853028; Tue, 21 Dec 2021 07:03:47 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB8D27EA39; Tue, 21 Dec 2021 07:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070230; 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=wxI7enpms8x1wEW2qLMdd/TI1oYT7Wx6t357beToVE8=; b=dZH7ao4NAUK6hb5AP2fIuamdWEAaw9K+WxHo4RbEyrQaD1Pnsmv9/QOfztvHkCUgP++ZhX hE5LhZeveeBa3q/0RngdjNzF0UIRpkRjqVnUtqh8k2cV2aWHlBJF6iA39mtH04ppJalzwa +2RU2bVWh6W8uHDCibVmfde78d0CfLo= X-MC-Unique: lP7B5GiIMn2ZTmARwwWjIA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 19/36] scripts: teach modinfo to skip non-C sources Date: Tue, 21 Dec 2021 10:58:38 +0400 Message-Id: <20211221065855.142578-20-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072680764100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- scripts/modinfo-collect.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py index 4acb188c3e89..61b90688c6dc 100755 --- a/scripts/modinfo-collect.py +++ b/scripts/modinfo-collect.py @@ -51,6 +51,9 @@ def main(args): with open('compile_commands.json') as f: compile_commands =3D json.load(f) for src in args: + if not src.endswith('.c'): + print("MODINFO_DEBUG skip %s" % src) + continue print("MODINFO_DEBUG src %s" % src) command =3D find_command(src, target, compile_commands) cmdline =3D process_command(src, command) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072915; cv=none; d=zohomail.com; s=zohoarc; b=D+0kOFwi2/0T63fug9YXY7GG3QSsSDoyiRMf65r29/p8X5pm2EcpfC8OgR3EeMuibWxtqwpNkc/fDANoVvOzniA+QBwrTjCSenB3yUGtFkTSXbTuezxlHe2+rRYB/gTd2GvhpRRHUnF8e2X00tODe9xlfhrpFFNV2HHHzN+cdXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072915; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aRILXhOIpdiTtyMy0stLTqiN3WJFSqWP8QCKwXfAz0E=; b=FQLk7GC6GDlwTC4BjvEABWe/DPnQkSx1S3v6xFJp3bViwAWTJNVK6R8z8JJXsxafy1k5S5qwVo9tuZQTmWSzByI/nmqnLDKLYaAFaieQ23DzECEeLPTmeEoaTRAcKGn75kiZyTGorZ6g5XNeTBaGCMrp2Iwl3kl6+rfM6Q3U9EY= 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 1640072915626576.3273349950932; Mon, 20 Dec 2021 23:48:35 -0800 (PST) Received: from localhost ([::1]:41192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZsw-0002UY-Bt for importer@patchew.org; Tue, 21 Dec 2021 02:48:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZC3-0006o9-UC for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:04:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZC0-00029A-F8 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:04:15 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-ZS63TXCmNmCRouv_Wp1M3w-1; Tue, 21 Dec 2021 02:04:08 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66D0A2F46; Tue, 21 Dec 2021 07:04:07 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAC75838E4; Tue, 21 Dec 2021 07:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070251; 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=aRILXhOIpdiTtyMy0stLTqiN3WJFSqWP8QCKwXfAz0E=; b=b5eYx4F2BI3740lmC/ESM/t75vmGo5l/U/EUX8HPnEOY2kH/kVeG2CL0tYihW0oqLopExO iyMUMRSm5Dy3qgETC3kw+/gdYO2eld8jF6MVerwVb9hhSB6oNA2Y0qam2/t+XVJNvXqMaL N+5+PxMCZwlt10T9Wn7UD+8BWhVrnyk= X-MC-Unique: ZS63TXCmNmCRouv_Wp1M3w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 20/36] docs/sphinx: add sphinx modules to include D-Bus documentation Date: Tue, 21 Dec 2021 10:58:39 +0400 Message-Id: <20211221065855.142578-21-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072915993100001 From: Marc-Andr=C3=A9 Lureau Add a new dbus-doc directive to import D-Bus interfaces documentation from the introspection XML. The comments annotations follow the gtkdoc/kerneldoc style, and should be formatted with reST. Note: I realize after the fact that I was implementing those modules with sphinx 4, and that we have much lower requirements. Instead of lowering the features and code (removing type annotations etc), let's have a warning in the documentation when the D-Bus modules can't be used, and point to the source XML file in that case. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- docs/conf.py | 8 + docs/sphinx/dbusdoc.py | 166 +++++++++++++++ docs/sphinx/dbusdomain.py | 406 +++++++++++++++++++++++++++++++++++++ docs/sphinx/dbusparser.py | 373 ++++++++++++++++++++++++++++++++++ docs/sphinx/fakedbusdoc.py | 25 +++ 5 files changed, 978 insertions(+) create mode 100644 docs/sphinx/dbusdoc.py create mode 100644 docs/sphinx/dbusdomain.py create mode 100644 docs/sphinx/dbusparser.py create mode 100644 docs/sphinx/fakedbusdoc.py diff --git a/docs/conf.py b/docs/conf.py index 763e7d243448..e79015975e6a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,6 +73,12 @@ # ones. extensions =3D ['kerneldoc', 'qmp_lexer', 'hxtool', 'depfile', 'qapidoc'] =20 +if sphinx.version_info[:3] > (4, 0, 0): + tags.add('sphinx4') + extensions +=3D ['dbusdoc'] +else: + extensions +=3D ['fakedbusdoc'] + # Add any paths that contain templates here, relative to this directory. templates_path =3D [os.path.join(qemu_docdir, '_templates')] =20 @@ -311,3 +317,5 @@ kerneldoc_srctree =3D os.path.join(qemu_docdir, '..') hxtool_srctree =3D os.path.join(qemu_docdir, '..') qapidoc_srctree =3D os.path.join(qemu_docdir, '..') +dbusdoc_srctree =3D os.path.join(qemu_docdir, '..') +dbus_index_common_prefix =3D ["org.qemu."] diff --git a/docs/sphinx/dbusdoc.py b/docs/sphinx/dbusdoc.py new file mode 100644 index 000000000000..be284ed08fd7 --- /dev/null +++ b/docs/sphinx/dbusdoc.py @@ -0,0 +1,166 @@ +# D-Bus XML documentation extension +# +# Copyright (C) 2021, Red Hat Inc. +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Author: Marc-Andr=C3=A9 Lureau +"""dbus-doc is a Sphinx extension that provides documentation from D-Bus X= ML.""" + +import os +import re +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + Iterator, + List, + Optional, + Sequence, + Set, + Tuple, + Type, + TypeVar, + Union, +) + +import sphinx +from docutils import nodes +from docutils.nodes import Element, Node +from docutils.parsers.rst import Directive, directives +from docutils.parsers.rst.states import RSTState +from docutils.statemachine import StringList, ViewList +from sphinx.application import Sphinx +from sphinx.errors import ExtensionError +from sphinx.util import logging +from sphinx.util.docstrings import prepare_docstring +from sphinx.util.docutils import SphinxDirective, switch_source_input +from sphinx.util.nodes import nested_parse_with_titles + +import dbusdomain +from dbusparser import parse_dbus_xml + +logger =3D logging.getLogger(__name__) + +__version__ =3D "1.0" + + +class DBusDoc: + def __init__(self, sphinx_directive, dbusfile): + self._cur_doc =3D None + self._sphinx_directive =3D sphinx_directive + self._dbusfile =3D dbusfile + self._top_node =3D nodes.section() + self.result =3D StringList() + self.indent =3D "" + + def add_line(self, line: str, *lineno: int) -> None: + """Append one line of generated reST to the output.""" + if line.strip(): # not a blank line + self.result.append(self.indent + line, self._dbusfile, *lineno) + else: + self.result.append("", self._dbusfile, *lineno) + + def add_method(self, method): + self.add_line(f".. dbus:method:: {method.name}") + self.add_line("") + self.indent +=3D " " + for arg in method.in_args: + self.add_line(f":arg {arg.signature} {arg.name}: {arg.doc_stri= ng}") + for arg in method.out_args: + self.add_line(f":ret {arg.signature} {arg.name}: {arg.doc_stri= ng}") + self.add_line("") + for line in prepare_docstring("\n" + method.doc_string): + self.add_line(line) + self.indent =3D self.indent[:-3] + + def add_signal(self, signal): + self.add_line(f".. dbus:signal:: {signal.name}") + self.add_line("") + self.indent +=3D " " + for arg in signal.args: + self.add_line(f":arg {arg.signature} {arg.name}: {arg.doc_stri= ng}") + self.add_line("") + for line in prepare_docstring("\n" + signal.doc_string): + self.add_line(line) + self.indent =3D self.indent[:-3] + + def add_property(self, prop): + self.add_line(f".. dbus:property:: {prop.name}") + self.indent +=3D " " + self.add_line(f":type: {prop.signature}") + access =3D {"read": "readonly", "write": "writeonly", "readwrite":= "readwrite"}[ + prop.access + ] + self.add_line(f":{access}:") + if prop.emits_changed_signal: + self.add_line(f":emits-changed: yes") + self.add_line("") + for line in prepare_docstring("\n" + prop.doc_string): + self.add_line(line) + self.indent =3D self.indent[:-3] + + def add_interface(self, iface): + self.add_line(f".. dbus:interface:: {iface.name}") + self.add_line("") + self.indent +=3D " " + for line in prepare_docstring("\n" + iface.doc_string): + self.add_line(line) + for method in iface.methods: + self.add_method(method) + for sig in iface.signals: + self.add_signal(sig) + for prop in iface.properties: + self.add_property(prop) + self.indent =3D self.indent[:-3] + + +def parse_generated_content(state: RSTState, content: StringList) -> List[= Node]: + """Parse a generated content by Documenter.""" + with switch_source_input(state, content): + node =3D nodes.paragraph() + node.document =3D state.document + state.nested_parse(content, 0, node) + + return node.children + + +class DBusDocDirective(SphinxDirective): + """Extract documentation from the specified D-Bus XML file""" + + has_content =3D True + required_arguments =3D 1 + optional_arguments =3D 0 + final_argument_whitespace =3D True + + def run(self): + reporter =3D self.state.document.reporter + + try: + source, lineno =3D reporter.get_source_and_line(self.lineno) = # type: ignore + except AttributeError: + source, lineno =3D (None, None) + + logger.debug("[dbusdoc] %s:%s: input:\n%s", source, lineno, self.b= lock_text) + + env =3D self.state.document.settings.env + dbusfile =3D env.config.qapidoc_srctree + "/" + self.arguments[0] + with open(dbusfile, "rb") as f: + xml_data =3D f.read() + xml =3D parse_dbus_xml(xml_data) + doc =3D DBusDoc(self, dbusfile) + for iface in xml: + doc.add_interface(iface) + + result =3D parse_generated_content(self.state, doc.result) + return result + + +def setup(app: Sphinx) -> Dict[str, Any]: + """Register dbus-doc directive with Sphinx""" + app.add_config_value("dbusdoc_srctree", None, "env") + app.add_directive("dbus-doc", DBusDocDirective) + dbusdomain.setup(app) + + return dict(version=3D__version__, parallel_read_safe=3DTrue, parallel= _write_safe=3DTrue) diff --git a/docs/sphinx/dbusdomain.py b/docs/sphinx/dbusdomain.py new file mode 100644 index 000000000000..2ea95af623d2 --- /dev/null +++ b/docs/sphinx/dbusdomain.py @@ -0,0 +1,406 @@ +# D-Bus sphinx domain extension +# +# Copyright (C) 2021, Red Hat Inc. +# +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Author: Marc-Andr=C3=A9 Lureau + +from typing import ( + Any, + Dict, + Iterable, + Iterator, + List, + NamedTuple, + Optional, + Tuple, + cast, +) + +from docutils import nodes +from docutils.nodes import Element, Node +from docutils.parsers.rst import directives +from sphinx import addnodes +from sphinx.addnodes import desc_signature, pending_xref +from sphinx.directives import ObjectDescription +from sphinx.domains import Domain, Index, IndexEntry, ObjType +from sphinx.locale import _ +from sphinx.roles import XRefRole +from sphinx.util import nodes as node_utils +from sphinx.util.docfields import Field, TypedField +from sphinx.util.typing import OptionSpec + + +class DBusDescription(ObjectDescription[str]): + """Base class for DBus objects""" + + option_spec: OptionSpec =3D ObjectDescription.option_spec.copy() + option_spec.update( + { + "deprecated": directives.flag, + } + ) + + def get_index_text(self, modname: str, name: str) -> str: + """Return the text for the index entry of the object.""" + raise NotImplementedError("must be implemented in subclasses") + + def add_target_and_index( + self, name: str, sig: str, signode: desc_signature + ) -> None: + ifacename =3D self.env.ref_context.get("dbus:interface") + node_id =3D name + if ifacename: + node_id =3D f"{ifacename}.{node_id}" + + signode["names"].append(name) + signode["ids"].append(node_id) + + if "noindexentry" not in self.options: + indextext =3D self.get_index_text(ifacename, name) + if indextext: + self.indexnode["entries"].append( + ("single", indextext, node_id, "", None) + ) + + domain =3D cast(DBusDomain, self.env.get_domain("dbus")) + domain.note_object(name, self.objtype, node_id, location=3Dsignode) + + +class DBusInterface(DBusDescription): + """ + Implementation of ``dbus:interface``. + """ + + def get_index_text(self, ifacename: str, name: str) -> str: + return ifacename + + def before_content(self) -> None: + self.env.ref_context["dbus:interface"] =3D self.arguments[0] + + def after_content(self) -> None: + self.env.ref_context.pop("dbus:interface") + + def handle_signature(self, sig: str, signode: desc_signature) -> str: + signode +=3D addnodes.desc_annotation("interface ", "interface ") + signode +=3D addnodes.desc_name(sig, sig) + return sig + + def run(self) -> List[Node]: + _, node =3D super().run() + name =3D self.arguments[0] + section =3D nodes.section(ids=3D[name + "-section"]) + section +=3D nodes.title(name, "%s interface" % name) + section +=3D node + return [self.indexnode, section] + + +class DBusMember(DBusDescription): + + signal =3D False + + +class DBusMethod(DBusMember): + """ + Implementation of ``dbus:method``. + """ + + option_spec: OptionSpec =3D DBusMember.option_spec.copy() + option_spec.update( + { + "noreply": directives.flag, + } + ) + + doc_field_types: List[Field] =3D [ + TypedField( + "arg", + label=3D_("Arguments"), + names=3D("arg",), + rolename=3D"arg", + typerolename=3DNone, + typenames=3D("argtype", "type"), + ), + TypedField( + "ret", + label=3D_("Returns"), + names=3D("ret",), + rolename=3D"ret", + typerolename=3DNone, + typenames=3D("rettype", "type"), + ), + ] + + def get_index_text(self, ifacename: str, name: str) -> str: + return _("%s() (%s method)") % (name, ifacename) + + def handle_signature(self, sig: str, signode: desc_signature) -> str: + params =3D addnodes.desc_parameterlist() + returns =3D addnodes.desc_parameterlist() + + contentnode =3D addnodes.desc_content() + self.state.nested_parse(self.content, self.content_offset, content= node) + for child in contentnode: + if isinstance(child, nodes.field_list): + for field in child: + ty, sg, name =3D field[0].astext().split(None, 2) + param =3D addnodes.desc_parameter() + param +=3D addnodes.desc_sig_keyword_type(sg, sg) + param +=3D addnodes.desc_sig_space() + param +=3D addnodes.desc_sig_name(name, name) + if ty =3D=3D "arg": + params +=3D param + elif ty =3D=3D "ret": + returns +=3D param + + anno =3D "signal " if self.signal else "method " + signode +=3D addnodes.desc_annotation(anno, anno) + signode +=3D addnodes.desc_name(sig, sig) + signode +=3D params + if not self.signal and "noreply" not in self.options: + ret =3D addnodes.desc_returns() + ret +=3D returns + signode +=3D ret + + return sig + + +class DBusSignal(DBusMethod): + """ + Implementation of ``dbus:signal``. + """ + + doc_field_types: List[Field] =3D [ + TypedField( + "arg", + label=3D_("Arguments"), + names=3D("arg",), + rolename=3D"arg", + typerolename=3DNone, + typenames=3D("argtype", "type"), + ), + ] + signal =3D True + + def get_index_text(self, ifacename: str, name: str) -> str: + return _("%s() (%s signal)") % (name, ifacename) + + +class DBusProperty(DBusMember): + """ + Implementation of ``dbus:property``. + """ + + option_spec: OptionSpec =3D DBusMember.option_spec.copy() + option_spec.update( + { + "type": directives.unchanged, + "readonly": directives.flag, + "writeonly": directives.flag, + "readwrite": directives.flag, + "emits-changed": directives.unchanged, + } + ) + + doc_field_types: List[Field] =3D [] + + def get_index_text(self, ifacename: str, name: str) -> str: + return _("%s (%s property)") % (name, ifacename) + + def transform_content(self, contentnode: addnodes.desc_content) -> Non= e: + fieldlist =3D nodes.field_list() + access =3D None + if "readonly" in self.options: + access =3D _("read-only") + if "writeonly" in self.options: + access =3D _("write-only") + if "readwrite" in self.options: + access =3D _("read & write") + if access: + content =3D nodes.Text(access) + fieldname =3D nodes.field_name("", _("Access")) + fieldbody =3D nodes.field_body("", nodes.paragraph("", "", con= tent)) + field =3D nodes.field("", fieldname, fieldbody) + fieldlist +=3D field + emits =3D self.options.get("emits-changed", None) + if emits: + content =3D nodes.Text(emits) + fieldname =3D nodes.field_name("", _("Emits Changed")) + fieldbody =3D nodes.field_body("", nodes.paragraph("", "", con= tent)) + field =3D nodes.field("", fieldname, fieldbody) + fieldlist +=3D field + if len(fieldlist) > 0: + contentnode.insert(0, fieldlist) + + def handle_signature(self, sig: str, signode: desc_signature) -> str: + contentnode =3D addnodes.desc_content() + self.state.nested_parse(self.content, self.content_offset, content= node) + ty =3D self.options.get("type") + + signode +=3D addnodes.desc_annotation("property ", "property ") + signode +=3D addnodes.desc_name(sig, sig) + signode +=3D addnodes.desc_sig_punctuation("", ":") + signode +=3D addnodes.desc_sig_keyword_type(ty, ty) + return sig + + def run(self) -> List[Node]: + self.name =3D "dbus:member" + return super().run() + + +class DBusXRef(XRefRole): + def process_link(self, env, refnode, has_explicit_title, title, target= ): + refnode["dbus:interface"] =3D env.ref_context.get("dbus:interface") + if not has_explicit_title: + title =3D title.lstrip(".") # only has a meaning for the targ= et + target =3D target.lstrip("~") # only has a meaning for the ti= tle + # if the first character is a tilde, don't display the module/= class + # parts of the contents + if title[0:1] =3D=3D "~": + title =3D title[1:] + dot =3D title.rfind(".") + if dot !=3D -1: + title =3D title[dot + 1 :] + # if the first character is a dot, search more specific namespaces= first + # else search builtins first + if target[0:1] =3D=3D ".": + target =3D target[1:] + refnode["refspecific"] =3D True + return title, target + + +class DBusIndex(Index): + """ + Index subclass to provide a D-Bus interfaces index. + """ + + name =3D "dbusindex" + localname =3D _("D-Bus Interfaces Index") + shortname =3D _("dbus") + + def generate( + self, docnames: Iterable[str] =3D None + ) -> Tuple[List[Tuple[str, List[IndexEntry]]], bool]: + content: Dict[str, List[IndexEntry]] =3D {} + # list of prefixes to ignore + ignores: List[str] =3D self.domain.env.config["dbus_index_common_p= refix"] + ignores =3D sorted(ignores, key=3Dlen, reverse=3DTrue) + + ifaces =3D sorted( + [ + x + for x in self.domain.data["objects"].items() + if x[1].objtype =3D=3D "interface" + ], + key=3Dlambda x: x[0].lower(), + ) + for name, (docname, node_id, _) in ifaces: + if docnames and docname not in docnames: + continue + + for ignore in ignores: + if name.startswith(ignore): + name =3D name[len(ignore) :] + stripped =3D ignore + break + else: + stripped =3D "" + + entries =3D content.setdefault(name[0].lower(), []) + entries.append(IndexEntry(stripped + name, 0, docname, node_id= , "", "", "")) + + # sort by first letter + sorted_content =3D sorted(content.items()) + + return sorted_content, False + + +class ObjectEntry(NamedTuple): + docname: str + node_id: str + objtype: str + + +class DBusDomain(Domain): + """ + Implementation of the D-Bus domain. + """ + + name =3D "dbus" + label =3D "D-Bus" + object_types: Dict[str, ObjType] =3D { + "interface": ObjType(_("interface"), "iface", "obj"), + "method": ObjType(_("method"), "meth", "obj"), + "signal": ObjType(_("signal"), "sig", "obj"), + "property": ObjType(_("property"), "attr", "_prop", "obj"), + } + directives =3D { + "interface": DBusInterface, + "method": DBusMethod, + "signal": DBusSignal, + "property": DBusProperty, + } + roles =3D { + "iface": DBusXRef(), + "meth": DBusXRef(), + "sig": DBusXRef(), + "prop": DBusXRef(), + } + initial_data: Dict[str, Dict[str, Tuple[Any]]] =3D { + "objects": {}, # fullname -> ObjectEntry + } + indices =3D [ + DBusIndex, + ] + + @property + def objects(self) -> Dict[str, ObjectEntry]: + return self.data.setdefault("objects", {}) # fullname -> ObjectEn= try + + def note_object( + self, name: str, objtype: str, node_id: str, location: Any =3D None + ) -> None: + self.objects[name] =3D ObjectEntry(self.env.docname, node_id, objt= ype) + + def clear_doc(self, docname: str) -> None: + for fullname, obj in list(self.objects.items()): + if obj.docname =3D=3D docname: + del self.objects[fullname] + + def find_obj(self, typ: str, name: str) -> Optional[Tuple[str, ObjectE= ntry]]: + # skip parens + if name[-2:] =3D=3D "()": + name =3D name[:-2] + if typ in ("meth", "sig", "prop"): + try: + ifacename, name =3D name.rsplit(".", 1) + except ValueError: + pass + return self.objects.get(name) + + def resolve_xref( + self, + env: "BuildEnvironment", + fromdocname: str, + builder: "Builder", + typ: str, + target: str, + node: pending_xref, + contnode: Element, + ) -> Optional[Element]: + """Resolve the pending_xref *node* with the given *typ* and *targe= t*.""" + objdef =3D self.find_obj(typ, target) + if objdef: + return node_utils.make_refnode( + builder, fromdocname, objdef.docname, objdef.node_id, cont= node + ) + + def get_objects(self) -> Iterator[Tuple[str, str, str, str, str, int]]: + for refname, obj in self.objects.items(): + yield (refname, refname, obj.objtype, obj.docname, obj.node_id= , 1) + + +def setup(app): + app.add_domain(DBusDomain) + app.add_config_value("dbus_index_common_prefix", [], "env") diff --git a/docs/sphinx/dbusparser.py b/docs/sphinx/dbusparser.py new file mode 100644 index 000000000000..024553eae7b5 --- /dev/null +++ b/docs/sphinx/dbusparser.py @@ -0,0 +1,373 @@ +# Based from "GDBus - GLib D-Bus Library": +# +# Copyright (C) 2008-2011 Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, see . +# +# Author: David Zeuthen + +import xml.parsers.expat + + +class Annotation: + def __init__(self, key, value): + self.key =3D key + self.value =3D value + self.annotations =3D [] + self.since =3D "" + + +class Arg: + def __init__(self, name, signature): + self.name =3D name + self.signature =3D signature + self.annotations =3D [] + self.doc_string =3D "" + self.since =3D "" + + +class Method: + def __init__(self, name, h_type_implies_unix_fd=3DTrue): + self.name =3D name + self.h_type_implies_unix_fd =3D h_type_implies_unix_fd + self.in_args =3D [] + self.out_args =3D [] + self.annotations =3D [] + self.doc_string =3D "" + self.since =3D "" + self.deprecated =3D False + self.unix_fd =3D False + + +class Signal: + def __init__(self, name): + self.name =3D name + self.args =3D [] + self.annotations =3D [] + self.doc_string =3D "" + self.since =3D "" + self.deprecated =3D False + + +class Property: + def __init__(self, name, signature, access): + self.name =3D name + self.signature =3D signature + self.access =3D access + self.annotations =3D [] + self.arg =3D Arg("value", self.signature) + self.arg.annotations =3D self.annotations + self.readable =3D False + self.writable =3D False + if self.access =3D=3D "readwrite": + self.readable =3D True + self.writable =3D True + elif self.access =3D=3D "read": + self.readable =3D True + elif self.access =3D=3D "write": + self.writable =3D True + else: + raise ValueError('Invalid access type "{}"'.format(self.access= )) + self.doc_string =3D "" + self.since =3D "" + self.deprecated =3D False + self.emits_changed_signal =3D True + + +class Interface: + def __init__(self, name): + self.name =3D name + self.methods =3D [] + self.signals =3D [] + self.properties =3D [] + self.annotations =3D [] + self.doc_string =3D "" + self.doc_string_brief =3D "" + self.since =3D "" + self.deprecated =3D False + + +class DBusXMLParser: + STATE_TOP =3D "top" + STATE_NODE =3D "node" + STATE_INTERFACE =3D "interface" + STATE_METHOD =3D "method" + STATE_SIGNAL =3D "signal" + STATE_PROPERTY =3D "property" + STATE_ARG =3D "arg" + STATE_ANNOTATION =3D "annotation" + STATE_IGNORED =3D "ignored" + + def __init__(self, xml_data, h_type_implies_unix_fd=3DTrue): + self._parser =3D xml.parsers.expat.ParserCreate() + self._parser.CommentHandler =3D self.handle_comment + self._parser.CharacterDataHandler =3D self.handle_char_data + self._parser.StartElementHandler =3D self.handle_start_element + self._parser.EndElementHandler =3D self.handle_end_element + + self.parsed_interfaces =3D [] + self._cur_object =3D None + + self.state =3D DBusXMLParser.STATE_TOP + self.state_stack =3D [] + self._cur_object =3D None + self._cur_object_stack =3D [] + + self.doc_comment_last_symbol =3D "" + + self._h_type_implies_unix_fd =3D h_type_implies_unix_fd + + self._parser.Parse(xml_data) + + COMMENT_STATE_BEGIN =3D "begin" + COMMENT_STATE_PARAMS =3D "params" + COMMENT_STATE_BODY =3D "body" + COMMENT_STATE_SKIP =3D "skip" + + def handle_comment(self, data): + comment_state =3D DBusXMLParser.COMMENT_STATE_BEGIN + lines =3D data.split("\n") + symbol =3D "" + body =3D "" + in_para =3D False + params =3D {} + for line in lines: + orig_line =3D line + line =3D line.lstrip() + if comment_state =3D=3D DBusXMLParser.COMMENT_STATE_BEGIN: + if len(line) > 0: + colon_index =3D line.find(": ") + if colon_index =3D=3D -1: + if line.endswith(":"): + symbol =3D line[0 : len(line) - 1] + comment_state =3D DBusXMLParser.COMMENT_STATE_= PARAMS + else: + comment_state =3D DBusXMLParser.COMMENT_STATE_= SKIP + else: + symbol =3D line[0:colon_index] + rest_of_line =3D line[colon_index + 2 :].strip() + if len(rest_of_line) > 0: + body +=3D rest_of_line + "\n" + comment_state =3D DBusXMLParser.COMMENT_STATE_PARA= MS + elif comment_state =3D=3D DBusXMLParser.COMMENT_STATE_PARAMS: + if line.startswith("@"): + colon_index =3D line.find(": ") + if colon_index =3D=3D -1: + comment_state =3D DBusXMLParser.COMMENT_STATE_BODY + if not in_para: + in_para =3D True + body +=3D orig_line + "\n" + else: + param =3D line[1:colon_index] + docs =3D line[colon_index + 2 :] + params[param] =3D docs + else: + comment_state =3D DBusXMLParser.COMMENT_STATE_BODY + if len(line) > 0: + if not in_para: + in_para =3D True + body +=3D orig_line + "\n" + elif comment_state =3D=3D DBusXMLParser.COMMENT_STATE_BODY: + if len(line) > 0: + if not in_para: + in_para =3D True + body +=3D orig_line + "\n" + else: + if in_para: + body +=3D "\n" + in_para =3D False + if in_para: + body +=3D "\n" + + if symbol !=3D "": + self.doc_comment_last_symbol =3D symbol + self.doc_comment_params =3D params + self.doc_comment_body =3D body + + def handle_char_data(self, data): + # print 'char_data=3D%s'%data + pass + + def handle_start_element(self, name, attrs): + old_state =3D self.state + old_cur_object =3D self._cur_object + if self.state =3D=3D DBusXMLParser.STATE_IGNORED: + self.state =3D DBusXMLParser.STATE_IGNORED + elif self.state =3D=3D DBusXMLParser.STATE_TOP: + if name =3D=3D DBusXMLParser.STATE_NODE: + self.state =3D DBusXMLParser.STATE_NODE + else: + self.state =3D DBusXMLParser.STATE_IGNORED + elif self.state =3D=3D DBusXMLParser.STATE_NODE: + if name =3D=3D DBusXMLParser.STATE_INTERFACE: + self.state =3D DBusXMLParser.STATE_INTERFACE + iface =3D Interface(attrs["name"]) + self._cur_object =3D iface + self.parsed_interfaces.append(iface) + elif name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + # assign docs, if any + if "name" in attrs and self.doc_comment_last_symbol =3D=3D att= rs["name"]: + self._cur_object.doc_string =3D self.doc_comment_body + if "short_description" in self.doc_comment_params: + short_description =3D self.doc_comment_params["short_d= escription"] + self._cur_object.doc_string_brief =3D short_description + if "since" in self.doc_comment_params: + self._cur_object.since =3D self.doc_comment_params["si= nce"].strip() + + elif self.state =3D=3D DBusXMLParser.STATE_INTERFACE: + if name =3D=3D DBusXMLParser.STATE_METHOD: + self.state =3D DBusXMLParser.STATE_METHOD + method =3D Method( + attrs["name"], h_type_implies_unix_fd=3Dself._h_type_i= mplies_unix_fd + ) + self._cur_object.methods.append(method) + self._cur_object =3D method + elif name =3D=3D DBusXMLParser.STATE_SIGNAL: + self.state =3D DBusXMLParser.STATE_SIGNAL + signal =3D Signal(attrs["name"]) + self._cur_object.signals.append(signal) + self._cur_object =3D signal + elif name =3D=3D DBusXMLParser.STATE_PROPERTY: + self.state =3D DBusXMLParser.STATE_PROPERTY + prop =3D Property(attrs["name"], attrs["type"], attrs["acc= ess"]) + self._cur_object.properties.append(prop) + self._cur_object =3D prop + elif name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + # assign docs, if any + if "name" in attrs and self.doc_comment_last_symbol =3D=3D att= rs["name"]: + self._cur_object.doc_string =3D self.doc_comment_body + if "since" in self.doc_comment_params: + self._cur_object.since =3D self.doc_comment_params["si= nce"].strip() + + elif self.state =3D=3D DBusXMLParser.STATE_METHOD: + if name =3D=3D DBusXMLParser.STATE_ARG: + self.state =3D DBusXMLParser.STATE_ARG + arg_name =3D None + if "name" in attrs: + arg_name =3D attrs["name"] + arg =3D Arg(arg_name, attrs["type"]) + direction =3D attrs.get("direction", "in") + if direction =3D=3D "in": + self._cur_object.in_args.append(arg) + elif direction =3D=3D "out": + self._cur_object.out_args.append(arg) + else: + raise ValueError('Invalid direction "{}"'.format(direc= tion)) + self._cur_object =3D arg + elif name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + # assign docs, if any + if self.doc_comment_last_symbol =3D=3D old_cur_object.name: + if "name" in attrs and attrs["name"] in self.doc_comment_p= arams: + doc_string =3D self.doc_comment_params[attrs["name"]] + if doc_string is not None: + self._cur_object.doc_string =3D doc_string + if "since" in self.doc_comment_params: + self._cur_object.since =3D self.doc_comment_params[ + "since" + ].strip() + + elif self.state =3D=3D DBusXMLParser.STATE_SIGNAL: + if name =3D=3D DBusXMLParser.STATE_ARG: + self.state =3D DBusXMLParser.STATE_ARG + arg_name =3D None + if "name" in attrs: + arg_name =3D attrs["name"] + arg =3D Arg(arg_name, attrs["type"]) + self._cur_object.args.append(arg) + self._cur_object =3D arg + elif name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + # assign docs, if any + if self.doc_comment_last_symbol =3D=3D old_cur_object.name: + if "name" in attrs and attrs["name"] in self.doc_comment_p= arams: + doc_string =3D self.doc_comment_params[attrs["name"]] + if doc_string is not None: + self._cur_object.doc_string =3D doc_string + if "since" in self.doc_comment_params: + self._cur_object.since =3D self.doc_comment_params[ + "since" + ].strip() + + elif self.state =3D=3D DBusXMLParser.STATE_PROPERTY: + if name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + elif self.state =3D=3D DBusXMLParser.STATE_ARG: + if name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + elif self.state =3D=3D DBusXMLParser.STATE_ANNOTATION: + if name =3D=3D DBusXMLParser.STATE_ANNOTATION: + self.state =3D DBusXMLParser.STATE_ANNOTATION + anno =3D Annotation(attrs["name"], attrs["value"]) + self._cur_object.annotations.append(anno) + self._cur_object =3D anno + else: + self.state =3D DBusXMLParser.STATE_IGNORED + + else: + raise ValueError( + 'Unhandled state "{}" while entering element with name "{}= "'.format( + self.state, name + ) + ) + + self.state_stack.append(old_state) + self._cur_object_stack.append(old_cur_object) + + def handle_end_element(self, name): + self.state =3D self.state_stack.pop() + self._cur_object =3D self._cur_object_stack.pop() + + +def parse_dbus_xml(xml_data): + parser =3D DBusXMLParser(xml_data, True) + return parser.parsed_interfaces diff --git a/docs/sphinx/fakedbusdoc.py b/docs/sphinx/fakedbusdoc.py new file mode 100644 index 000000000000..a680b257547f --- /dev/null +++ b/docs/sphinx/fakedbusdoc.py @@ -0,0 +1,25 @@ +# D-Bus XML documentation extension, compatibility gunk for +"""dbus-doc is a Sphinx extension that provides documentation from D-Bus X= ML.""" + +from sphinx.application import Sphinx +from sphinx.util.docutils import SphinxDirective +from typing import Any, Dict + + +class FakeDBusDocDirective(SphinxDirective): + has_content =3D True + required_arguments =3D 1 + + def run(self): + return [] + + +def setup(app: Sphinx) -> Dict[str, Any]: + """Register a fake dbus-doc directive with Sphinx""" + app.add_directive("dbus-doc", FakeDBusDocDirective) --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071844; cv=none; d=zohomail.com; s=zohoarc; b=bFQ4SyeykvOQFn9e679lxk67q8CALDlFPLaZRkVaR44KtvROPVrddY+M/xEFU1EEaH4MTTPurRvR81+svfFC5zjDW9P54itZry57Wdu5n/lvzKlX3KffyP7kJrdxEWCmQIMcJlJcs4eW8GNn/PYF3kzPTjSPxK3ldYq8YE5g6eE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071844; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W83hJczpdfh86fBAKy4JOQvlGl9mojfK61ERS47j030=; b=GmDdP+yGqH/r00VhJcsYqt5uRZDXK7wsdzLhw0C2zEu8Ljl6a85Ia9nlIXllBIbPiKVBkhfDZgnyeihOnyS0D3jAJ6cej6xchEyMghiEVbdO4rIWzFICxtBCjcXOffTEpYZ/OcsmYWROAF/ztRKwVySK7kSKUCrqOMGWgoGl8r4= 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 1640071844039867.9658268959702; Mon, 20 Dec 2021 23:30:44 -0800 (PST) Received: from localhost ([::1]:34080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZbe-0002nE-1H for importer@patchew.org; Tue, 21 Dec 2021 02:30:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZCU-00074z-0O for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:04:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52059) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZCS-0002B0-Cj for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:04:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-mGgpbS_RNyyxq4UCJfAczQ-1; Tue, 21 Dec 2021 02:04:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8CB61006AA6; Tue, 21 Dec 2021 07:04:35 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35B307EFD4; Tue, 21 Dec 2021 07:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070279; 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=W83hJczpdfh86fBAKy4JOQvlGl9mojfK61ERS47j030=; b=i1Ggu14Uq3i2935PZkAVMg9kprCHDTS73h+ewrewdfL/8zYNp/H+M1Zf2DtxZuQPStTvLm CBG8p9GhtjqRMdd8w5VYuPepxf2bMugosHGzidkkkn6sKCi9W0Abn7dvOGd3Bn8yJ9Iug8 mKE0reV9iPjsd59T4y/OgBKoeIZyD+w= X-MC-Unique: mGgpbS_RNyyxq4UCJfAczQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 21/36] backends: move dbus-vmstate1.xml to backends/ Date: Tue, 21 Dec 2021 10:58:40 +0400 Message-Id: <20211221065855.142578-22-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071844945100001 From: Marc-Andr=C3=A9 Lureau Although not used by the backend itself, use a common location for documentation and sharing purposes. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- {tests/qtest =3D> backends}/dbus-vmstate1.xml | 0 tests/qtest/meson.build | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {tests/qtest =3D> backends}/dbus-vmstate1.xml (100%) diff --git a/tests/qtest/dbus-vmstate1.xml b/backends/dbus-vmstate1.xml similarity index 100% rename from tests/qtest/dbus-vmstate1.xml rename to backends/dbus-vmstate1.xml diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ebeac59b3f95..913e987409d5 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -98,7 +98,7 @@ if dbus_daemon.found() and config_host.has_key('GDBUS_COD= EGEN') #qtests_i386 +=3D ['dbus-vmstate-test'] dbus_vmstate1 =3D custom_target('dbus-vmstate description', output: ['dbus-vmstate1.h', 'dbus-vmstate1= .c'], - input: files('dbus-vmstate1.xml'), + input: meson.source_root() / 'backends/dbu= s-vmstate1.xml', command: [config_host['GDBUS_CODEGEN'], '@INPUT@', '--interface-prefix', 'org.qemu', --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072354; cv=none; d=zohomail.com; s=zohoarc; b=mdHqTegJeCX3l/5wNAuRR0g0oho6iE+RuqnHIWx+qseAtpXgQ82APdA2nTvERo9qAjCrpCo7agAQ2ewnE8RaGEbFITpTn9npZLZCrRGUOdjp4wC2yMKP4iEUCzmt4iDNunC/2kKjs43oMS7b/Ja++dGNgYZFkk9b7JS2NOqE4Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072354; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vSG78TuWGCC1NmuFibw5NVJmoaUqphOLxLa+Ev+PXQA=; b=mjtPh+Y7I/yoNYcsCLPDddIkBbckAFcMIQd/knK9QkMvXwMynC9epVDbAQHFCEaQNU+D6vBp6n5loVg9XaKaGVZSOVOVYM92naZm/FyIHXh7nBvpOEX9CJ5HekLmqSjLkxMuuF7JCshcyoIkcOXiBrONpvi0GApPAyi8wPHA8iw= 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 1640072354377724.8266788936911; Mon, 20 Dec 2021 23:39:14 -0800 (PST) Received: from localhost ([::1]:45836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZjt-0002zE-9M for importer@patchew.org; Tue, 21 Dec 2021 02:39:13 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZD1-00088D-RF for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:05:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZCx-0002DB-Je for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:05:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-lb2ShXgCP_yPfWc4vUucdA-1; Tue, 21 Dec 2021 02:05:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC0C61F2DA; Tue, 21 Dec 2021 07:04:56 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 861C877456; Tue, 21 Dec 2021 07:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070310; 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=vSG78TuWGCC1NmuFibw5NVJmoaUqphOLxLa+Ev+PXQA=; b=TjseVMBNXa8w+1Zf+adaednx1Gai4CziPCPUvr3FALA4f+bzJcwVH/Tj2M14lcFxWZNlAD c13/uXMCnWYpKK1VyJOAMdGbpMuUgj64IQFg663yEwJa0zz8zzSuyVoH5MxpPfCKPwR3VK qcqOC8A1oOPERr9Ttm64x7ot0/qlML8= X-MC-Unique: lb2ShXgCP_yPfWc4vUucdA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 22/36] docs: move D-Bus VMState documentation to source XML Date: Tue, 21 Dec 2021 10:58:41 +0400 Message-Id: <20211221065855.142578-23-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072355007100001 From: Marc-Andr=C3=A9 Lureau Use the source XML document as single reference, importing its documentation via the dbus-doc directive. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- docs/interop/dbus-vmstate.rst | 52 ++++++----------------------------- backends/dbus-vmstate1.xml | 42 +++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/docs/interop/dbus-vmstate.rst b/docs/interop/dbus-vmstate.rst index 1d719c1c604f..5fb3f279e280 100644 --- a/docs/interop/dbus-vmstate.rst +++ b/docs/interop/dbus-vmstate.rst @@ -2,9 +2,6 @@ D-Bus VMState =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -Introduction -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - The QEMU dbus-vmstate object's aim is to migrate helpers' data running on a QEMU D-Bus bus. (refer to the :doc:`dbus` document for some recommendations on D-Bus usage) @@ -26,49 +23,16 @@ dbus-vmstate object can be configured with the expected= list of helpers by setting its ``id-list`` property, with a comma-separated ``Id`` list. =20 -Interface -=3D=3D=3D=3D=3D=3D=3D=3D=3D - -On object path ``/org/qemu/VMState1``, the following -``org.qemu.VMState1`` interface should be implemented: - -.. code:: xml - - - - - - - - - - - -"Id" property -------------- - -A string that identifies the helper uniquely. (maximum 256 bytes -including terminating NUL byte) - -.. note:: - - The helper ID namespace is a separate namespace. In particular, it is n= ot - related to QEMU "id" used in -object/-device objects. - -Load(in u8[] bytes) method --------------------------- - -The method called on destination with the state to restore. +.. only:: sphinx4 =20 -The helper may be initially started in a waiting state (with -an --incoming argument for example), and it may resume on success. + .. dbus-doc:: backends/dbus-vmstate1.xml =20 -An error may be returned to the caller. +.. only:: not sphinx4 =20 -Save(out u8[] bytes) method ---------------------------- + .. warning:: + Sphinx 4 is required to build D-Bus documentation. =20 -The method called on the source to get the current state to be -migrated. The helper should continue to run normally. + This is the content of ``backends/dbus-vmstate1.xml``: =20 -An error may be returned to the caller. + .. literalinclude:: ../../backends/dbus-vmstate1.xml + :language: xml diff --git a/backends/dbus-vmstate1.xml b/backends/dbus-vmstate1.xml index cc8563be4c92..601ee8dc7e4d 100644 --- a/backends/dbus-vmstate1.xml +++ b/backends/dbus-vmstate1.xml @@ -1,10 +1,50 @@ - + + + + + + + + --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640071799; cv=none; d=zohomail.com; s=zohoarc; b=mjDxYp4Lu3tTArTMYVrpi4TIr7SJCe2ta0b49FljZigntVLjziK5w3u5uJKR3dAqL7DmgK+A7i5Ul1mxyjbQlzj1DcH+ZR3MGd3DV8r5qV9lfsrySGH3q2/+r3jWWQEqBSIv+2j1y2cff1Qa3aMLE3GJfocly8pzfOZGpD5DcO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640071799; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4i695WYQfKfo7JWS1MpuRVcRVmXZfC3kjxOk40FWxpY=; b=Ul272IpGKUpGMJQmLC15gtUpFWngHNAPjPeSF0PNtQ1Bdyg0bjoWrqHR0WR/TA11UcvUnXio67HoScqndI6aAE/g4RSeBg3tXfahDc8C3/ItDDCcCM+iKMrimbHDJvP4NNVQfGr4TwRq6R2Vab6HnCE/FK7SKXdKT2ZaL6Wh23g= 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 1640071799474438.33513620766337; Mon, 20 Dec 2021 23:29:59 -0800 (PST) Received: from localhost ([::1]:33456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZaw-0002Nn-2l for importer@patchew.org; Tue, 21 Dec 2021 02:29:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZD8-0008Ck-Fp for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:05:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57018) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZD6-0002Dx-Sn for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:05:22 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-_dBvqSn0POaZiGLkLStm_A-1; Tue, 21 Dec 2021 02:05:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EB061853020; Tue, 21 Dec 2021 07:05:15 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8C5E7A426; Tue, 21 Dec 2021 07:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070320; 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=4i695WYQfKfo7JWS1MpuRVcRVmXZfC3kjxOk40FWxpY=; b=Sccd9dCETL+aiMsPKALch4wlNFUzITpzLVTowbWFizT2xLKKF1Z4PHuVayyGdjVNcp+tqH lFucOt/gWsXr2vYP71LDiN2tvS5S/6s6ayavf7TguxW8Zj50Ebx4Cp0TOyWlk+oJVNaifE XE9vemmpKCCleDicenoEsQQLqqv91hA= X-MC-Unique: _dBvqSn0POaZiGLkLStm_A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 23/36] docs: add dbus-display documentation Date: Tue, 21 Dec 2021 10:58:42 +0400 Message-Id: <20211221065855.142578-24-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640071800962100001 From: Marc-Andr=C3=A9 Lureau Wire up the dbus-display documentation. The interface and feature is implemented next. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- docs/interop/dbus-display.rst | 31 +++++++++++++++++++++++++++++++ docs/interop/dbus.rst | 2 ++ docs/interop/index.rst | 1 + ui/dbus-display1.xml | 0 4 files changed, 34 insertions(+) create mode 100644 docs/interop/dbus-display.rst create mode 100644 ui/dbus-display1.xml diff --git a/docs/interop/dbus-display.rst b/docs/interop/dbus-display.rst new file mode 100644 index 000000000000..8c6e8e0f5a82 --- /dev/null +++ b/docs/interop/dbus-display.rst @@ -0,0 +1,31 @@ +D-Bus display +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +QEMU can export the VM display through D-Bus (when started with ``-display +dbus``), to allow out-of-process UIs, remote protocol servers or other +interactive display usages. + +Various specialized D-Bus interfaces are available on different object pat= hs +under ``/org/qemu/Display1/``, depending on the VM configuration. + +QEMU also implements the standard interfaces, such as +`org.freedesktop.DBus.Introspectable +`_. + +.. contents:: + :local: + :depth: 1 + +.. only:: sphinx4 + + .. dbus-doc:: ui/dbus-display1.xml + +.. only:: not sphinx4 + + .. warning:: + Sphinx 4 is required to build D-Bus documentation. + + This is the content of ``ui/dbus-display1.xml``: + + .. literalinclude:: ../../ui/dbus-display1.xml + :language: xml diff --git a/docs/interop/dbus.rst b/docs/interop/dbus.rst index be596d3f418c..427debc9c504 100644 --- a/docs/interop/dbus.rst +++ b/docs/interop/dbus.rst @@ -108,3 +108,5 @@ QEMU Interfaces =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 :doc:`dbus-vmstate` + +:doc:`dbus-display` diff --git a/docs/interop/index.rst b/docs/interop/index.rst index 47b9ed82bbc0..c59bac983407 100644 --- a/docs/interop/index.rst +++ b/docs/interop/index.rst @@ -12,6 +12,7 @@ are useful for making QEMU interoperate with other softwa= re. bitmaps dbus dbus-vmstate + dbus-display live-block-operations pr-helper qemu-ga diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml new file mode 100644 index 000000000000..e69de29bb2d1 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072210; cv=none; d=zohomail.com; s=zohoarc; b=TUeeOaIHN4dkx90EpbBMk51gWzPUDtk3nLm74ogi8jaWnzGuiG631Y2LpCCuN/Cq5esgUzgVBDhdPhGdKjgXin7B9Ssy6e6rYxbMoFcFRA2KiHMXtWbqg0RGLKO747j7UBhy7zHNQ9LJVHIDr+sd1Xwr/Gz3DAPUtJrz1K2+l7Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072210; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UmhL4B1sw7EWYu23BvjQMASdSiQuAUqhG9SLwD6Mls0=; b=SS1O9QQBuUgulqYTZ43IYddPuQJMvQylui3cPFRuJx1twR5jB8/+LZGqQCKGzIwbkrIeYVFWOVPEYvVCKeABM8JzW+r+qKYgo6cQZQRNG1Ffu0zS3zqWqccUdgHsheVXCZPpNREzoxLop9MM2tP9Ca12RS6ILtA+m7rsS8B4rwE= 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 1640072210226825.50821458609; Mon, 20 Dec 2021 23:36:50 -0800 (PST) Received: from localhost ([::1]:41954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZhY-00007g-Os for importer@patchew.org; Tue, 21 Dec 2021 02:36:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZE2-00014Z-V3 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZE1-0002Lm-5k for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:18 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-49-F1ljuaf5OBObJygweWYwCw-1; Tue, 21 Dec 2021 02:06:13 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57637344B0; Tue, 21 Dec 2021 07:06:12 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F8A0838E9; Tue, 21 Dec 2021 07:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070376; 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=UmhL4B1sw7EWYu23BvjQMASdSiQuAUqhG9SLwD6Mls0=; b=AAqWDDzsnYXbMg1H4LPCGslZNJ7DfCDDcO9w/Py8BnchAORbZOdeCyLTTpe67jj/LjboQK alK7NDIRuwzR601gytLnrKYy96S8qN4knc7K2rLW/0YKFVcrmmXih5hYrGVws3ouqeCePJ l58PyUclQzRsknWDpe1syF9GlJNU41A= X-MC-Unique: F1ljuaf5OBObJygweWYwCw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 24/36] build-sys: set glib dependency version Date: Tue, 21 Dec 2021 10:58:43 +0400 Message-Id: <20211221065855.142578-25-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072211325100001 From: Marc-Andr=C3=A9 Lureau Further meson configuration tests are to be added based on the glib version. Also correct the version reporting in the config log. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- configure | 1 + meson.build | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 8ccfe51673eb..51eae49daf7d 100755 --- a/configure +++ b/configure @@ -3694,6 +3694,7 @@ echo "QEMU_CFLAGS=3D$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_CXXFLAGS=3D$QEMU_CXXFLAGS" >> $config_host_mak echo "GLIB_CFLAGS=3D$glib_cflags" >> $config_host_mak echo "GLIB_LIBS=3D$glib_libs" >> $config_host_mak +echo "GLIB_VERSION=3D$(pkg-config --modversion glib-2.0)" >> $config_host_= mak echo "QEMU_LDFLAGS=3D$QEMU_LDFLAGS" >> $config_host_mak echo "LD_I386_EMULATION=3D$ld_i386_emulation" >> $config_host_mak echo "EXESUF=3D$EXESUF" >> $config_host_mak diff --git a/meson.build b/meson.build index 1c70839bbf17..c37eb92ebeaa 100644 --- a/meson.build +++ b/meson.build @@ -404,14 +404,16 @@ endif add_project_arguments(config_host['GLIB_CFLAGS'].split(), native: false, language: ['c', 'cpp', 'objc']) glib =3D declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split= (), - link_args: config_host['GLIB_LIBS'].split()) + link_args: config_host['GLIB_LIBS'].split(), + version: config_host['GLIB_VERSION']) # override glib dep with the configure results (for subprojects) meson.override_dependency('glib-2.0', glib) =20 gio =3D not_found if 'CONFIG_GIO' in config_host gio =3D declare_dependency(compile_args: config_host['GIO_CFLAGS'].split= (), - link_args: config_host['GIO_LIBS'].split()) + link_args: config_host['GIO_LIBS'].split(), + version: config_host['GLIB_VERSION']) endif lttng =3D not_found if 'ust' in get_option('trace_backends') --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640073201; cv=none; d=zohomail.com; s=zohoarc; b=HGbATz4NTj1udLSjlj+ydT82dBLncBxR2/yW2B3b5CLouf7VjnQg3fi1u2t9GnZT8dZ7VmYzLmPG0cyzjKEwqeQEn6D2osTvmJcrfpJyLIzrJFdJUQSEQfSESmEeq8cixSWRmD/XJbF2hnQql6CvoF08sDo3BEGXrdwP1Gfndig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640073201; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L43UXHFl9AJKt0xZGOscmkcnvj9RZGQmyZoN8rAsbH4=; b=BY5PUsMGQ1TiBTB+LQGvcaoIdeTO28qgTt65xm65tsXSK0yqjyY7NWpBfQARuzgZqQgCg1V0NiSo9gpPVXqJOJ69Tu23245RyBAZBd+DodGxYzJqm+xmfZ4OzxG+c1RwHGVXcMnapR9E5xezc//JRwUhUkG6e5bvfd+pDZ0ZWw0= 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 1640073201357998.9559021033477; Mon, 20 Dec 2021 23:53:21 -0800 (PST) Received: from localhost ([::1]:49320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZxX-0008A5-O1 for importer@patchew.org; Tue, 21 Dec 2021 02:53:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEM-0001G1-T0 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57438) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEH-0002MM-Cz for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-170-a2HcscAUPLSCpPSl-wKGIA-1; Tue, 21 Dec 2021 02:06:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5C2FE1023F4E; Tue, 21 Dec 2021 07:06:26 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CCEC87953; Tue, 21 Dec 2021 07:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070392; 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=L43UXHFl9AJKt0xZGOscmkcnvj9RZGQmyZoN8rAsbH4=; b=Mnl/cIRRoFBtifq9IYwj6pye2Zd0GCQtBrnA6sVlLJRZt8MariZDNc7FYSOmhDfQG0zcOr D9X0XUO/HtXce0/eS75maMfyur+DfCVy2BYav2rICN5bYq3b1MyCtMfbdszBKql/JH2D+O hK5m1b1vrLDsLSTPB3P5YLbRYsJctVY= X-MC-Unique: a2HcscAUPLSCpPSl-wKGIA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 25/36] ui: add a D-Bus display backend Date: Tue, 21 Dec 2021 10:58:44 +0400 Message-Id: <20211221065855.142578-26-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640073202451100001 From: Marc-Andr=C3=A9 Lureau The "dbus" display backend exports the QEMU consoles and other UI-related interfaces over D-Bus. By default, the connection is established on the session bus, but you can specify a different bus with the "addr" option. The backend takes the "org.qemu" service name, while still allowing further instances to queue on the same name (so you can lookup all the available instances too). It accepts any number of clients at this point, although this is expected to evolve with options to restrict clients, or only accept p2p via fd passing. The interface is intentionally very close to the internal QEMU API, and can be introspected or interacted with busctl/dfeet etc: $ ./qemu-system-x86_64 -name MyVM -display dbus $ busctl --user introspect org.qemu /org/qemu/Display1/Console_0 org.qemu.Display1.Console interface - - - .RegisterListener method h - - .SetUIInfo method qqiiuu - - .DeviceAddress property s "pci/0000/01.0" emi= ts-change .Head property u 0 emi= ts-change .Height property u 480 emi= ts-change .Label property s "VGA" emi= ts-change .Type property s "Graphic" emi= ts-change .Width property u 640 emi= ts-change [...] See the interfaces XML source file and Sphinx docs for the generated API documentations. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- meson.build | 11 + qapi/ui.json | 27 +- include/qemu/dbus.h | 19 ++ ui/dbus.h | 83 ++++++ ui/dbus-console.c | 497 ++++++++++++++++++++++++++++++++++ ui/dbus-error.c | 48 ++++ ui/dbus-listener.c | 486 +++++++++++++++++++++++++++++++++ ui/dbus.c | 262 ++++++++++++++++++ meson_options.txt | 2 + qemu-options.hx | 15 + scripts/meson-buildoptions.sh | 3 + ui/dbus-display1.xml | 378 ++++++++++++++++++++++++++ ui/meson.build | 22 ++ ui/trace-events | 11 + 14 files changed, 1862 insertions(+), 2 deletions(-) create mode 100644 ui/dbus.h create mode 100644 ui/dbus-console.c create mode 100644 ui/dbus-error.c create mode 100644 ui/dbus-listener.c create mode 100644 ui/dbus.c diff --git a/meson.build b/meson.build index c37eb92ebeaa..73d4b241df1a 100644 --- a/meson.build +++ b/meson.build @@ -1397,6 +1397,15 @@ endif have_host_block_device =3D (targetos !=3D 'darwin' or cc.has_header('IOKit/storage/IOMedia.h')) =20 +dbus_display =3D false +if not get_option('dbus_display').disabled() + # FIXME enable_modules shouldn't be necessary, but: https://github.com/m= esonbuild/meson/issues/8333 + dbus_display =3D gio.version().version_compare('>=3D2.64') and config_ho= st.has_key('GDBUS_CODEGEN') and enable_modules + if get_option('dbus_display').enabled() and not dbus_display + error('Requirements missing to enable -display dbus (glib>=3D2.64 && -= -enable-modules)') + endif +endif + have_virtfs =3D (targetos =3D=3D 'linux' and have_system and libattr.found() and @@ -1506,6 +1515,7 @@ config_host_data.set('CONFIG_SPICE_PROTOCOL_MICRO', s= pice_protocol.version().spl endif config_host_data.set('CONFIG_SPICE', spice.found()) config_host_data.set('CONFIG_X11', x11.found()) +config_host_data.set('CONFIG_DBUS_DISPLAY', dbus_display) config_host_data.set('CONFIG_CFI', get_option('cfi')) config_host_data.set('CONFIG_SELINUX', selinux.found()) config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version(= ))) @@ -3229,6 +3239,7 @@ summary_info +=3D {'Trace backends': ','.join(get_= option('trace_backends'))} if 'simple' in get_option('trace_backends') summary_info +=3D {'Trace output file': get_option('trace_file') + '-'} endif +summary_info +=3D {'D-Bus display': dbus_display} summary_info +=3D {'QOM debugging': config_host.has_key('CONFIG_QOM_CA= ST_DEBUG')} summary_info +=3D {'vhost-kernel support': config_host.has_key('CONFIG_VHO= ST_KERNEL')} summary_info +=3D {'vhost-net support': config_host.has_key('CONFIG_VHOST_= NET')} diff --git a/qapi/ui.json b/qapi/ui.json index d7567ac86683..80855328b1d4 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1121,6 +1121,23 @@ { 'struct' : 'DisplayEGLHeadless', 'data' : { '*rendernode' : 'str' } } =20 +## +# @DisplayDBus: +# +# DBus display options. +# +# @addr: The D-Bus bus address (default to the session bus). +# +# @rendernode: Which DRM render node should be used. Default is the first +# available node on the host. +# +# Since: 7.0 +# +## +{ 'struct' : 'DisplayDBus', + 'data' : { '*rendernode' : 'str', + '*addr': 'str' } } + ## # @DisplayGLMode: # @@ -1186,6 +1203,8 @@ # application to connect to it. The server will redirect # the serial console and QEMU monitors. (Since 4.0) # +# @dbus: Start a D-Bus service for the display. (Since 7.0) +# # Since: 2.12 # ## @@ -1199,7 +1218,10 @@ 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, { 'name': 'curses', 'if': 'CONFIG_CURSES' }, { 'name': 'cocoa', 'if': 'CONFIG_COCOA' }, - { 'name': 'spice-app', 'if': 'CONFIG_SPICE'} ] } + { 'name': 'spice-app', 'if': 'CONFIG_SPICE' }, + { 'name': 'dbus', 'if': 'CONFIG_DBUS_DISPLAY' } + ] +} =20 ## # @DisplayOptions: @@ -1227,7 +1249,8 @@ 'gtk': { 'type': 'DisplayGTK', 'if': 'CONFIG_GTK' }, 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', - 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } } + 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, + 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' } } } =20 diff --git a/include/qemu/dbus.h b/include/qemu/dbus.h index 9d591f9ee4ad..c0cbb1ca44d3 100644 --- a/include/qemu/dbus.h +++ b/include/qemu/dbus.h @@ -12,6 +12,25 @@ =20 #include =20 +/* glib/gio 2.68 */ +#define DBUS_METHOD_INVOCATION_HANDLED TRUE +#define DBUS_METHOD_INVOCATION_UNHANDLED FALSE + +/* in msec */ +#define DBUS_DEFAULT_TIMEOUT 1000 + +#define DBUS_DISPLAY1_ROOT "/org/qemu/Display1" + +#define DBUS_DISPLAY_ERROR (dbus_display_error_quark()) +GQuark dbus_display_error_quark(void); + +typedef enum { + DBUS_DISPLAY_ERROR_FAILED, + DBUS_DISPLAY_ERROR_INVALID, + DBUS_DISPLAY_ERROR_UNSUPPORTED, + DBUS_DISPLAY_N_ERRORS, +} DBusDisplayError; + GStrv qemu_dbus_get_queued_owners(GDBusConnection *connection, const char *name, Error **errp); diff --git a/ui/dbus.h b/ui/dbus.h new file mode 100644 index 000000000000..d3c9598dd133 --- /dev/null +++ b/ui/dbus.h @@ -0,0 +1,83 @@ +/* + * QEMU DBus display + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#ifndef UI_DBUS_H_ +#define UI_DBUS_H_ + +#include "qemu/dbus.h" +#include "qom/object.h" +#include "ui/console.h" + +#include "dbus-display1.h" + +struct DBusDisplay { + Object parent; + + DisplayGLMode gl_mode; + char *dbus_addr; + DisplayGLCtx glctx; + + GDBusConnection *bus; + GDBusObjectManagerServer *server; + QemuDBusDisplay1VM *iface; + GPtrArray *consoles; +}; + +#define TYPE_DBUS_DISPLAY "dbus-display" +OBJECT_DECLARE_SIMPLE_TYPE(DBusDisplay, DBUS_DISPLAY) + +#define DBUS_DISPLAY_TYPE_CONSOLE dbus_display_console_get_type() +G_DECLARE_FINAL_TYPE(DBusDisplayConsole, + dbus_display_console, + DBUS_DISPLAY, + CONSOLE, + GDBusObjectSkeleton) + +DBusDisplayConsole * +dbus_display_console_new(DBusDisplay *display, QemuConsole *con); + +int +dbus_display_console_get_index(DBusDisplayConsole *ddc); + +#define DBUS_DISPLAY_TYPE_LISTENER dbus_display_listener_get_type() +G_DECLARE_FINAL_TYPE(DBusDisplayListener, + dbus_display_listener, + DBUS_DISPLAY, + LISTENER, + GObject) + +DBusDisplayListener * +dbus_display_listener_new(const char *bus_name, + GDBusConnection *conn, + DBusDisplayConsole *console); + +DBusDisplayConsole * +dbus_display_listener_get_console(DBusDisplayListener *ddl); + +const char * +dbus_display_listener_get_bus_name(DBusDisplayListener *ddl); + +extern const DisplayChangeListenerOps dbus_gl_dcl_ops; +extern const DisplayChangeListenerOps dbus_dcl_ops; + +#endif /* UI_DBUS_H_ */ diff --git a/ui/dbus-console.c b/ui/dbus-console.c new file mode 100644 index 000000000000..1ccf638c1061 --- /dev/null +++ b/ui/dbus-console.c @@ -0,0 +1,497 @@ +/* + * QEMU DBus display console + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "ui/input.h" +#include "ui/kbd-state.h" +#include "trace.h" + +#include + +#include "dbus.h" + +struct _DBusDisplayConsole { + GDBusObjectSkeleton parent_instance; + DisplayChangeListener dcl; + + DBusDisplay *display; + QemuConsole *con; + GHashTable *listeners; + QemuDBusDisplay1Console *iface; + + QemuDBusDisplay1Keyboard *iface_kbd; + QKbdState *kbd; + + QemuDBusDisplay1Mouse *iface_mouse; + gboolean last_set; + guint last_x; + guint last_y; + Notifier mouse_mode_notifier; +}; + +G_DEFINE_TYPE(DBusDisplayConsole, + dbus_display_console, + G_TYPE_DBUS_OBJECT_SKELETON) + +static void +dbus_display_console_set_size(DBusDisplayConsole *ddc, + uint32_t width, uint32_t height) +{ + g_object_set(ddc->iface, + "width", width, + "height", height, + NULL); +} + +static void +dbus_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + DBusDisplayConsole *ddc =3D container_of(dcl, DBusDisplayConsole, dcl); + + dbus_display_console_set_size(ddc, + surface_width(new_surface), + surface_height(new_surface)); +} + +static void +dbus_gfx_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ +} + +static void +dbus_gl_scanout_disable(DisplayChangeListener *dcl) +{ +} + +static void +dbus_gl_scanout_texture(DisplayChangeListener *dcl, + uint32_t tex_id, + bool backing_y_0_top, + uint32_t backing_width, + uint32_t backing_height, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + DBusDisplayConsole *ddc =3D container_of(dcl, DBusDisplayConsole, dcl); + + dbus_display_console_set_size(ddc, w, h); +} + +static void +dbus_gl_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + DBusDisplayConsole *ddc =3D container_of(dcl, DBusDisplayConsole, dcl); + + dbus_display_console_set_size(ddc, + dmabuf->width, + dmabuf->height); +} + +static void +dbus_gl_scanout_update(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ +} + +static const DisplayChangeListenerOps dbus_console_dcl_ops =3D { + .dpy_name =3D "dbus-console", + .dpy_gfx_switch =3D dbus_gfx_switch, + .dpy_gfx_update =3D dbus_gfx_update, + .dpy_gl_scanout_disable =3D dbus_gl_scanout_disable, + .dpy_gl_scanout_texture =3D dbus_gl_scanout_texture, + .dpy_gl_scanout_dmabuf =3D dbus_gl_scanout_dmabuf, + .dpy_gl_update =3D dbus_gl_scanout_update, +}; + +static void +dbus_display_console_init(DBusDisplayConsole *object) +{ + DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); + + ddc->listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, + NULL, g_object_unref); + ddc->dcl.ops =3D &dbus_console_dcl_ops; +} + +static void +dbus_display_console_dispose(GObject *object) +{ + DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); + + unregister_displaychangelistener(&ddc->dcl); + g_clear_object(&ddc->iface_kbd); + g_clear_object(&ddc->iface); + g_clear_pointer(&ddc->listeners, g_hash_table_unref); + g_clear_pointer(&ddc->kbd, qkbd_state_free); + + G_OBJECT_CLASS(dbus_display_console_parent_class)->dispose(object); +} + +static void +dbus_display_console_class_init(DBusDisplayConsoleClass *klass) +{ + GObjectClass *gobject_class =3D G_OBJECT_CLASS(klass); + + gobject_class->dispose =3D dbus_display_console_dispose; +} + +static void +listener_vanished_cb(DBusDisplayListener *listener) +{ + DBusDisplayConsole *ddc =3D dbus_display_listener_get_console(listener= ); + const char *name =3D dbus_display_listener_get_bus_name(listener); + + trace_dbus_listener_vanished(name); + + g_hash_table_remove(ddc->listeners, name); + qkbd_state_lift_all_keys(ddc->kbd); +} + +static gboolean +dbus_console_set_ui_info(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint16 arg_width_mm, + guint16 arg_height_mm, + gint arg_xoff, + gint arg_yoff, + guint arg_width, + guint arg_height) +{ + QemuUIInfo info =3D { + .width_mm =3D arg_width_mm, + .height_mm =3D arg_height_mm, + .xoff =3D arg_xoff, + .yoff =3D arg_yoff, + .width =3D arg_width, + .height =3D arg_height, + }; + + if (!dpy_ui_info_supported(ddc->con)) { + g_dbus_method_invocation_return_error(invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_UNSUPPORT= ED, + "SetUIInfo is not supported"= ); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + dpy_set_ui_info(ddc->con, &info, false); + qemu_dbus_display1_console_complete_set_uiinfo(ddc->iface, invocation); + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_console_register_listener(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + GUnixFDList *fd_list, + GVariant *arg_listener) +{ + const char *sender =3D g_dbus_method_invocation_get_sender(invocation); + GDBusConnection *listener_conn; + g_autoptr(GError) err =3D NULL; + g_autoptr(GSocket) socket =3D NULL; + g_autoptr(GSocketConnection) socket_conn =3D NULL; + g_autofree char *guid =3D g_dbus_generate_guid(); + DBusDisplayListener *listener; + int fd; + + if (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; + } + + fd =3D g_unix_fd_list_get(fd_list, g_variant_get_handle(arg_listener),= &err); + if (err) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Couldn't get peer fd: %s", err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + socket =3D g_socket_new_from_fd(fd, &err); + if (err) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Couldn't make a socket: %s", err->message); + close(fd); + return DBUS_METHOD_INVOCATION_HANDLED; + } + socket_conn =3D g_socket_connection_factory_create_connection(socket); + + qemu_dbus_display1_console_complete_register_listener( + ddc->iface, invocation, NULL); + + listener_conn =3D g_dbus_connection_new_sync( + G_IO_STREAM(socket_conn), + guid, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER, + NULL, NULL, &err); + if (err) { + error_report("Failed to setup peer connection: %s", err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + listener =3D dbus_display_listener_new(sender, listener_conn, ddc); + if (!listener) { + return DBUS_METHOD_INVOCATION_HANDLED; + } + + g_hash_table_insert(ddc->listeners, + (gpointer)dbus_display_listener_get_bus_name(liste= ner), + listener); + g_object_connect(listener_conn, + "swapped-signal::closed", listener_vanished_cb, liste= ner, + NULL); + + trace_dbus_registered_listener(sender); + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_kbd_press(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint arg_keycode) +{ + QKeyCode qcode =3D qemu_input_key_number_to_qcode(arg_keycode); + + trace_dbus_kbd_press(arg_keycode); + + qkbd_state_key_event(ddc->kbd, qcode, true); + + qemu_dbus_display1_keyboard_complete_press(ddc->iface_kbd, invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_kbd_release(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint arg_keycode) +{ + QKeyCode qcode =3D qemu_input_key_number_to_qcode(arg_keycode); + + trace_dbus_kbd_release(arg_keycode); + + qkbd_state_key_event(ddc->kbd, qcode, false); + + qemu_dbus_display1_keyboard_complete_release(ddc->iface_kbd, invocatio= n); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static void +dbus_kbd_qemu_leds_updated(void *data, int ledstate) +{ + DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(data); + + qemu_dbus_display1_keyboard_set_modifiers(ddc->iface_kbd, ledstate); +} + +static gboolean +dbus_mouse_rel_motion(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + int dx, int dy) +{ + trace_dbus_mouse_rel_motion(dx, dy); + + if (qemu_input_is_absolute()) { + g_dbus_method_invocation_return_error( + invocation, DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_INVALID, + "Mouse is not relative"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + qemu_input_queue_rel(ddc->con, INPUT_AXIS_X, dx); + qemu_input_queue_rel(ddc->con, INPUT_AXIS_Y, dy); + qemu_input_event_sync(); + + qemu_dbus_display1_mouse_complete_rel_motion(ddc->iface_mouse, + invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_mouse_set_pos(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint x, guint y) +{ + int width, height; + + trace_dbus_mouse_set_pos(x, y); + + if (!qemu_input_is_absolute()) { + g_dbus_method_invocation_return_error( + invocation, DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_INVALID, + "Mouse is not absolute"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + width =3D qemu_console_get_width(ddc->con, 0); + height =3D qemu_console_get_height(ddc->con, 0); + if (x >=3D width || y >=3D height) { + g_dbus_method_invocation_return_error( + invocation, DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_INVALID, + "Invalid mouse position"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + qemu_input_queue_abs(ddc->con, INPUT_AXIS_X, x, 0, width); + qemu_input_queue_abs(ddc->con, INPUT_AXIS_Y, y, 0, height); + qemu_input_event_sync(); + + qemu_dbus_display1_mouse_complete_set_abs_position(ddc->iface_mouse, + invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_mouse_press(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint button) +{ + trace_dbus_mouse_press(button); + + qemu_input_queue_btn(ddc->con, button, true); + qemu_input_event_sync(); + + qemu_dbus_display1_mouse_complete_press(ddc->iface_mouse, invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_mouse_release(DBusDisplayConsole *ddc, + GDBusMethodInvocation *invocation, + guint button) +{ + trace_dbus_mouse_release(button); + + qemu_input_queue_btn(ddc->con, button, false); + qemu_input_event_sync(); + + qemu_dbus_display1_mouse_complete_release(ddc->iface_mouse, invocation= ); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static void +dbus_mouse_mode_change(Notifier *notify, void *data) +{ + DBusDisplayConsole *ddc =3D + container_of(notify, DBusDisplayConsole, mouse_mode_notifier); + + g_object_set(ddc->iface_mouse, + "is-absolute", qemu_input_is_absolute(), + NULL); +} + +int dbus_display_console_get_index(DBusDisplayConsole *ddc) +{ + return qemu_console_get_index(ddc->con); +} + +DBusDisplayConsole * +dbus_display_console_new(DBusDisplay *display, QemuConsole *con) +{ + g_autofree char *path =3D NULL; + g_autofree char *label =3D NULL; + char device_addr[256] =3D ""; + DBusDisplayConsole *ddc; + int idx; + + assert(display); + assert(con); + + label =3D qemu_console_get_label(con); + idx =3D qemu_console_get_index(con); + path =3D g_strdup_printf(DBUS_DISPLAY1_ROOT "/Console_%d", idx); + ddc =3D g_object_new(DBUS_DISPLAY_TYPE_CONSOLE, + "g-object-path", path, + NULL); + ddc->display =3D display; + ddc->con =3D con; + /* handle errors, and skip non graphics? */ + qemu_console_fill_device_address( + con, device_addr, sizeof(device_addr), NULL); + + ddc->iface =3D qemu_dbus_display1_console_skeleton_new(); + g_object_set(ddc->iface, + "label", label, + "type", qemu_console_is_graphic(con) ? "Graphic" : "Text", + "head", qemu_console_get_head(con), + "width", qemu_console_get_width(con, 0), + "height", qemu_console_get_height(con, 0), + "device-address", device_addr, + NULL); + g_object_connect(ddc->iface, + "swapped-signal::handle-register-listener", + dbus_console_register_listener, ddc, + "swapped-signal::handle-set-uiinfo", + dbus_console_set_ui_info, ddc, + NULL); + g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc), + G_DBUS_INTERFACE_SKELETON(ddc->iface)); + + ddc->kbd =3D qkbd_state_init(con); + ddc->iface_kbd =3D qemu_dbus_display1_keyboard_skeleton_new(); + qemu_add_led_event_handler(dbus_kbd_qemu_leds_updated, ddc); + g_object_connect(ddc->iface_kbd, + "swapped-signal::handle-press", dbus_kbd_press, ddc, + "swapped-signal::handle-release", dbus_kbd_release, ddc, + NULL); + g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc), + G_DBUS_INTERFACE_SKELETON(ddc->iface_kbd)); + + ddc->iface_mouse =3D qemu_dbus_display1_mouse_skeleton_new(); + g_object_connect(ddc->iface_mouse, + "swapped-signal::handle-set-abs-position", dbus_mouse_set_pos, ddc, + "swapped-signal::handle-rel-motion", dbus_mouse_rel_motion, ddc, + "swapped-signal::handle-press", dbus_mouse_press, ddc, + "swapped-signal::handle-release", dbus_mouse_release, ddc, + NULL); + g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc), + G_DBUS_INTERFACE_SKELETON(ddc->iface_mouse)); + + register_displaychangelistener(&ddc->dcl); + ddc->mouse_mode_notifier.notify =3D dbus_mouse_mode_change; + qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); + + return ddc; +} diff --git a/ui/dbus-error.c b/ui/dbus-error.c new file mode 100644 index 000000000000..85a9194d57e8 --- /dev/null +++ b/ui/dbus-error.c @@ -0,0 +1,48 @@ +/* + * QEMU DBus display errors + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "dbus.h" + +static const GDBusErrorEntry dbus_display_error_entries[] =3D { + { DBUS_DISPLAY_ERROR_FAILED, "org.qemu.Display1.Error.Failed" }, + { DBUS_DISPLAY_ERROR_INVALID, "org.qemu.Display1.Error.Invalid" }, + { DBUS_DISPLAY_ERROR_UNSUPPORTED, "org.qemu.Display1.Error.Unsupported= " }, +}; + +G_STATIC_ASSERT(G_N_ELEMENTS(dbus_display_error_entries) =3D=3D + DBUS_DISPLAY_N_ERRORS); + +GQuark +dbus_display_error_quark(void) +{ + static gsize quark; + + g_dbus_error_register_error_domain( + "dbus-display-error-quark", + &quark, + dbus_display_error_entries, + G_N_ELEMENTS(dbus_display_error_entries)); + + return (GQuark)quark; +} diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c new file mode 100644 index 000000000000..20094fc18abe --- /dev/null +++ b/ui/dbus-listener.c @@ -0,0 +1,486 @@ +/* + * QEMU DBus display console + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" +#include "dbus.h" +#include + +#include "ui/shader.h" +#include "ui/egl-helpers.h" +#include "ui/egl-context.h" +#include "trace.h" + +struct _DBusDisplayListener { + GObject parent; + + char *bus_name; + DBusDisplayConsole *console; + GDBusConnection *conn; + + QemuDBusDisplay1Listener *proxy; + + DisplayChangeListener dcl; + DisplaySurface *ds; + QemuGLShader *gls; + int gl_updates; +}; + +G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT) + +static void dbus_update_gl_cb(GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + g_autoptr(GError) err =3D NULL; + DBusDisplayListener *ddl =3D user_data; + + if (!qemu_dbus_display1_listener_call_update_dmabuf_finish(ddl->proxy, + res, &err))= { + error_report("Failed to call update: %s", err->message); + } + + graphic_hw_gl_block(ddl->dcl.con, false); + g_object_unref(ddl); +} + +static void dbus_call_update_gl(DBusDisplayListener *ddl, + int x, int y, int w, int h) +{ + graphic_hw_gl_block(ddl->dcl.con, true); + glFlush(); + qemu_dbus_display1_listener_call_update_dmabuf(ddl->proxy, + x, y, w, h, + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT, NULL, + dbus_update_gl_cb, + g_object_ref(ddl)); +} + +static void dbus_scanout_disable(DisplayChangeListener *dcl) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + ddl->ds =3D NULL; + qemu_dbus_display1_listener_call_disable( + ddl->proxy, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static void dbus_scanout_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + g_autoptr(GError) err =3D NULL; + g_autoptr(GUnixFDList) fd_list =3D NULL; + + fd_list =3D g_unix_fd_list_new(); + if (g_unix_fd_list_append(fd_list, dmabuf->fd, &err) !=3D 0) { + error_report("Failed to setup dmabuf fdlist: %s", err->message); + return; + } + + qemu_dbus_display1_listener_call_scanout_dmabuf( + ddl->proxy, + g_variant_new_handle(0), + dmabuf->width, + dmabuf->height, + dmabuf->stride, + dmabuf->fourcc, + dmabuf->modifier, + dmabuf->y0_top, + G_DBUS_CALL_FLAGS_NONE, + -1, + fd_list, + NULL, NULL, NULL); +} + +static void dbus_scanout_texture(DisplayChangeListener *dcl, + uint32_t tex_id, + bool backing_y_0_top, + uint32_t backing_width, + uint32_t backing_height, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + QemuDmaBuf dmabuf =3D { + .width =3D backing_width, + .height =3D backing_height, + .y0_top =3D backing_y_0_top, + }; + + assert(tex_id); + dmabuf.fd =3D egl_get_fd_for_texture( + tex_id, (EGLint *)&dmabuf.stride, + (EGLint *)&dmabuf.fourcc, + &dmabuf.modifier); + if (dmabuf.fd < 0) { + error_report("%s: failed to get fd for texture", __func__); + return; + } + + dbus_scanout_dmabuf(dcl, &dmabuf); + close(dmabuf.fd); +} + +static void dbus_cursor_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf, bool have_hot, + uint32_t hot_x, uint32_t hot_y) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + DisplaySurface *ds; + GVariant *v_data =3D NULL; + egl_fb cursor_fb; + + if (!dmabuf) { + qemu_dbus_display1_listener_call_mouse_set( + ddl->proxy, 0, 0, false, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + return; + } + + egl_dmabuf_import_texture(dmabuf); + if (!dmabuf->texture) { + return; + } + egl_fb_setup_for_tex(&cursor_fb, dmabuf->width, dmabuf->height, + dmabuf->texture, false); + ds =3D qemu_create_displaysurface(dmabuf->width, dmabuf->height); + egl_fb_read(ds, &cursor_fb); + + v_data =3D g_variant_new_from_data( + G_VARIANT_TYPE("ay"), + surface_data(ds), + surface_width(ds) * surface_height(ds) * 4, + TRUE, + (GDestroyNotify)qemu_free_displaysurface, + ds); + qemu_dbus_display1_listener_call_cursor_define( + ddl->proxy, + surface_width(ds), + surface_height(ds), + hot_x, + hot_y, + v_data, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL, + NULL); +} + +static void dbus_cursor_position(DisplayChangeListener *dcl, + uint32_t pos_x, uint32_t pos_y) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + qemu_dbus_display1_listener_call_mouse_set( + ddl->proxy, pos_x, pos_y, true, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static void dbus_release_dmabuf(DisplayChangeListener *dcl, + QemuDmaBuf *dmabuf) +{ + dbus_scanout_disable(dcl); +} + +static void dbus_scanout_update(DisplayChangeListener *dcl, + uint32_t x, uint32_t y, + uint32_t w, uint32_t h) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + dbus_call_update_gl(ddl, x, y, w, h); +} + +static void dbus_gl_refresh(DisplayChangeListener *dcl) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + graphic_hw_update(dcl->con); + + if (!ddl->ds || qemu_console_is_gl_blocked(ddl->dcl.con)) { + return; + } + + if (ddl->gl_updates) { + dbus_call_update_gl(ddl, 0, 0, + surface_width(ddl->ds), surface_height(ddl->ds= )); + ddl->gl_updates =3D 0; + } +} + +static void dbus_refresh(DisplayChangeListener *dcl) +{ + graphic_hw_update(dcl->con); +} + +static void dbus_gl_gfx_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + if (ddl->ds) { + surface_gl_update_texture(ddl->gls, ddl->ds, x, y, w, h); + } + + ddl->gl_updates++; +} + +static void dbus_gfx_update(DisplayChangeListener *dcl, + int x, int y, int w, int h) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + pixman_image_t *img; + GVariant *v_data; + size_t stride; + + assert(ddl->ds); + stride =3D w * DIV_ROUND_UP(PIXMAN_FORMAT_BPP(surface_format(ddl->ds))= , 8); + + trace_dbus_update(x, y, w, h); + + /* make a copy, since gvariant only handles linear data */ + img =3D pixman_image_create_bits(surface_format(ddl->ds), + w, h, NULL, stride); + pixman_image_composite(PIXMAN_OP_SRC, ddl->ds->image, NULL, img, + x, y, 0, 0, 0, 0, w, h); + + v_data =3D g_variant_new_from_data( + G_VARIANT_TYPE("ay"), + pixman_image_get_data(img), + pixman_image_get_stride(img) * h, + TRUE, + (GDestroyNotify)pixman_image_unref, + img); + qemu_dbus_display1_listener_call_update(ddl->proxy, + x, y, w, h, pixman_image_get_stride(img), pixman_image_get_format(= img), + v_data, + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT, NULL, NULL, NULL); +} + +static void dbus_gl_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + if (ddl->ds) { + surface_gl_destroy_texture(ddl->gls, ddl->ds); + } + ddl->ds =3D new_surface; + if (ddl->ds) { + int width =3D surface_width(ddl->ds); + int height =3D surface_height(ddl->ds); + + surface_gl_create_texture(ddl->gls, ddl->ds); + /* TODO: lazy send dmabuf (there are unnecessary sent otherwise) */ + dbus_scanout_texture(&ddl->dcl, ddl->ds->texture, false, + width, height, 0, 0, width, height); + } +} + +static void dbus_gfx_switch(DisplayChangeListener *dcl, + struct DisplaySurface *new_surface) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + GVariant *v_data =3D NULL; + + ddl->ds =3D new_surface; + if (!ddl->ds) { + /* why not call disable instead? */ + return; + } + + v_data =3D g_variant_new_from_data( + G_VARIANT_TYPE("ay"), + surface_data(ddl->ds), + surface_stride(ddl->ds) * surface_height(ddl->ds), + TRUE, + (GDestroyNotify)pixman_image_unref, + pixman_image_ref(ddl->ds->image)); + qemu_dbus_display1_listener_call_scanout(ddl->proxy, + surface_width(ddl->ds), + surface_height(ddl->ds), + surface_stride(ddl->ds), + surface_format(ddl->ds), + v_data, + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT, NULL, NULL, NULL); +} + +static void dbus_mouse_set(DisplayChangeListener *dcl, + int x, int y, int on) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + + qemu_dbus_display1_listener_call_mouse_set( + ddl->proxy, x, y, on, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL= ); +} + +static void dbus_cursor_define(DisplayChangeListener *dcl, + QEMUCursor *c) +{ + DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); + GVariant *v_data =3D NULL; + + cursor_get(c); + v_data =3D g_variant_new_from_data( + G_VARIANT_TYPE("ay"), + c->data, + c->width * c->height * 4, + TRUE, + (GDestroyNotify)cursor_put, + c); + + qemu_dbus_display1_listener_call_cursor_define( + ddl->proxy, + c->width, + c->height, + c->hot_x, + c->hot_y, + v_data, + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL, + NULL); +} + +const DisplayChangeListenerOps dbus_gl_dcl_ops =3D { + .dpy_name =3D "dbus-gl", + .dpy_gfx_update =3D dbus_gl_gfx_update, + .dpy_gfx_switch =3D dbus_gl_gfx_switch, + .dpy_gfx_check_format =3D console_gl_check_format, + .dpy_refresh =3D dbus_gl_refresh, + .dpy_mouse_set =3D dbus_mouse_set, + .dpy_cursor_define =3D dbus_cursor_define, + + .dpy_gl_scanout_disable =3D dbus_scanout_disable, + .dpy_gl_scanout_texture =3D dbus_scanout_texture, + .dpy_gl_scanout_dmabuf =3D dbus_scanout_dmabuf, + .dpy_gl_cursor_dmabuf =3D dbus_cursor_dmabuf, + .dpy_gl_cursor_position =3D dbus_cursor_position, + .dpy_gl_release_dmabuf =3D dbus_release_dmabuf, + .dpy_gl_update =3D dbus_scanout_update, +}; + +const DisplayChangeListenerOps dbus_dcl_ops =3D { + .dpy_name =3D "dbus", + .dpy_gfx_update =3D dbus_gfx_update, + .dpy_gfx_switch =3D dbus_gfx_switch, + .dpy_refresh =3D dbus_refresh, + .dpy_mouse_set =3D dbus_mouse_set, + .dpy_cursor_define =3D dbus_cursor_define, +}; + +static void +dbus_display_listener_dispose(GObject *object) +{ + DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(object); + + unregister_displaychangelistener(&ddl->dcl); + g_clear_object(&ddl->conn); + g_clear_pointer(&ddl->bus_name, g_free); + g_clear_object(&ddl->proxy); + g_clear_pointer(&ddl->gls, qemu_gl_fini_shader); + + G_OBJECT_CLASS(dbus_display_listener_parent_class)->dispose(object); +} + +static void +dbus_display_listener_constructed(GObject *object) +{ + DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(object); + + if (display_opengl) { + ddl->gls =3D qemu_gl_init_shader(); + ddl->dcl.ops =3D &dbus_gl_dcl_ops; + } else { + ddl->dcl.ops =3D &dbus_dcl_ops; + } + + G_OBJECT_CLASS(dbus_display_listener_parent_class)->constructed(object= ); +} + +static void +dbus_display_listener_class_init(DBusDisplayListenerClass *klass) +{ + GObjectClass *object_class =3D G_OBJECT_CLASS(klass); + + object_class->dispose =3D dbus_display_listener_dispose; + object_class->constructed =3D dbus_display_listener_constructed; +} + +static void +dbus_display_listener_init(DBusDisplayListener *ddl) +{ +} + +const char * +dbus_display_listener_get_bus_name(DBusDisplayListener *ddl) +{ + return ddl->bus_name; +} + +DBusDisplayConsole * +dbus_display_listener_get_console(DBusDisplayListener *ddl) +{ + return ddl->console; +} + +DBusDisplayListener * +dbus_display_listener_new(const char *bus_name, + GDBusConnection *conn, + DBusDisplayConsole *console) +{ + DBusDisplayListener *ddl; + QemuConsole *con; + g_autoptr(GError) err =3D NULL; + + ddl =3D g_object_new(DBUS_DISPLAY_TYPE_LISTENER, NULL); + ddl->proxy =3D + qemu_dbus_display1_listener_proxy_new_sync(conn, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + "/org/qemu/Display1/Listener", + NULL, + &err); + if (!ddl->proxy) { + error_report("Failed to setup proxy: %s", err->message); + g_object_unref(conn); + g_object_unref(ddl); + return NULL; + } + + ddl->bus_name =3D g_strdup(bus_name); + ddl->conn =3D conn; + ddl->console =3D console; + + con =3D qemu_console_lookup_by_index(dbus_display_console_get_index(co= nsole)); + assert(con); + ddl->dcl.con =3D con; + register_displaychangelistener(&ddl->dcl); + + return ddl; +} diff --git a/ui/dbus.c b/ui/dbus.c new file mode 100644 index 000000000000..12da8ffe31e0 --- /dev/null +++ b/ui/dbus.c @@ -0,0 +1,262 @@ +/* + * QEMU DBus display + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qemu/dbus.h" +#include "qemu/option.h" +#include "qom/object_interfaces.h" +#include "sysemu/sysemu.h" +#include "ui/egl-helpers.h" +#include "ui/egl-context.h" +#include "qapi/error.h" +#include "trace.h" + +#include "dbus.h" + +static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc, + QEMUGLParams *params) +{ + eglMakeCurrent(qemu_egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, + qemu_egl_rn_ctx); + return qemu_egl_create_context(dgc, params); +} + +static const DisplayGLCtxOps dbus_gl_ops =3D { + .compatible_dcl =3D &dbus_gl_dcl_ops, + .dpy_gl_ctx_create =3D dbus_create_context, + .dpy_gl_ctx_destroy =3D qemu_egl_destroy_context, + .dpy_gl_ctx_make_current =3D qemu_egl_make_context_current, +}; + +static void +dbus_display_init(Object *o) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + g_autoptr(GDBusObjectSkeleton) vm =3D NULL; + + dd->glctx.ops =3D &dbus_gl_ops; + dd->iface =3D qemu_dbus_display1_vm_skeleton_new(); + dd->consoles =3D g_ptr_array_new_with_free_func(g_object_unref); + + dd->server =3D g_dbus_object_manager_server_new(DBUS_DISPLAY1_ROOT); + + vm =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_ROOT "/VM"); + g_dbus_object_skeleton_add_interface( + vm, G_DBUS_INTERFACE_SKELETON(dd->iface)); + g_dbus_object_manager_server_export(dd->server, vm); +} + +static void +dbus_display_finalize(Object *o) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + g_clear_object(&dd->server); + g_clear_pointer(&dd->consoles, g_ptr_array_unref); + g_clear_object(&dd->bus); + g_clear_object(&dd->iface); + g_free(dd->dbus_addr); +} + +static bool +dbus_display_add_console(DBusDisplay *dd, int idx, Error **errp) +{ + QemuConsole *con; + DBusDisplayConsole *dbus_console; + + con =3D qemu_console_lookup_by_index(idx); + assert(con); + + if (qemu_console_is_graphic(con) && + dd->gl_mode !=3D DISPLAYGL_MODE_OFF) { + qemu_console_set_display_gl_ctx(con, &dd->glctx); + } + + dbus_console =3D dbus_display_console_new(dd, con); + g_ptr_array_insert(dd->consoles, idx, dbus_console); + g_dbus_object_manager_server_export(dd->server, + G_DBUS_OBJECT_SKELETON(dbus_consol= e)); + return true; +} + +static void +dbus_display_complete(UserCreatable *uc, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(uc); + g_autoptr(GError) err =3D NULL; + g_autofree char *uuid =3D qemu_uuid_unparse_strdup(&qemu_uuid); + g_autoptr(GArray) consoles =3D NULL; + GVariant *console_ids; + int idx; + + if (!object_resolve_path_type("", TYPE_DBUS_DISPLAY, NULL)) { + error_setg(errp, "There is already an instance of %s", + TYPE_DBUS_DISPLAY); + return; + } + + if (dd->dbus_addr && *dd->dbus_addr) { + dd->bus =3D g_dbus_connection_new_for_address_sync(dd->dbus_addr, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | + G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, + NULL, NULL, &err); + } else { + dd->bus =3D g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err); + } + if (err) { + error_setg(errp, "failed to connect to DBus: %s", err->message); + return; + } + + + consoles =3D g_array_new(FALSE, FALSE, sizeof(guint32)); + for (idx =3D 0;; idx++) { + if (!qemu_console_lookup_by_index(idx)) { + break; + } + if (!dbus_display_add_console(dd, idx, errp)) { + return; + } + g_array_append_val(consoles, idx); + } + + console_ids =3D g_variant_new_from_data( + G_VARIANT_TYPE("au"), + consoles->data, consoles->len * sizeof(guint32), TRUE, + (GDestroyNotify)g_array_unref, consoles); + g_steal_pointer(&consoles); + g_object_set(dd->iface, + "name", qemu_name ?: "QEMU " QEMU_VERSION, + "uuid", uuid, + "console-ids", console_ids, + NULL); + + g_dbus_object_manager_server_set_connection(dd->server, dd->bus); + g_bus_own_name_on_connection(dd->bus, "org.qemu", + G_BUS_NAME_OWNER_FLAGS_NONE, + NULL, NULL, NULL, NULL); +} + +static char * +get_dbus_addr(Object *o, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + return g_strdup(dd->dbus_addr); +} + +static void +set_dbus_addr(Object *o, const char *str, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + g_free(dd->dbus_addr); + dd->dbus_addr =3D g_strdup(str); +} + +static int +get_gl_mode(Object *o, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + return dd->gl_mode; +} + +static void +set_gl_mode(Object *o, int val, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + dd->gl_mode =3D val; +} + +static void +dbus_display_class_init(ObjectClass *oc, void *data) +{ + UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(oc); + + ucc->complete =3D dbus_display_complete; + object_class_property_add_str(oc, "addr", get_dbus_addr, set_dbus_addr= ); + object_class_property_add_enum(oc, "gl-mode", + "DisplayGLMode", &DisplayGLMode_lookup, + get_gl_mode, set_gl_mode); +} + +static void +early_dbus_init(DisplayOptions *opts) +{ + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + + if (mode !=3D DISPLAYGL_MODE_OFF) { + if (egl_rendernode_init(opts->u.dbus.rendernode, mode) < 0) { + error_report("dbus: render node init failed"); + exit(1); + } + + display_opengl =3D 1; + } +} + +static void +dbus_init(DisplayState *ds, DisplayOptions *opts) +{ + DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; + + object_new_with_props(TYPE_DBUS_DISPLAY, + object_get_objects_root(), + "dbus-display", &error_fatal, + "addr", opts->u.dbus.addr ?: "", + "gl-mode", DisplayGLMode_str(mode), + NULL); +} + +static const TypeInfo dbus_display_info =3D { + .name =3D TYPE_DBUS_DISPLAY, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(DBusDisplay), + .instance_init =3D dbus_display_init, + .instance_finalize =3D dbus_display_finalize, + .class_init =3D dbus_display_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static QemuDisplay qemu_display_dbus =3D { + .type =3D DISPLAY_TYPE_DBUS, + .early_init =3D early_dbus_init, + .init =3D dbus_init, +}; + +static void register_dbus(void) +{ + type_register_static(&dbus_display_info); + qemu_display_register(&qemu_display_dbus); +} + +type_init(register_dbus); + +#ifdef CONFIG_OPENGL +module_dep("ui-opengl"); +#endif diff --git a/meson_options.txt b/meson_options.txt index 4114bfcaa474..921967eddbb9 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -66,6 +66,8 @@ option('cfi_debug', type: 'boolean', value: 'false', description: 'Verbose errors in case of CFI violation') option('multiprocess', type: 'feature', value: 'auto', description: 'Out of process device emulation support') +option('dbus_display', type: 'feature', value: 'auto', + description: '-display dbus support') =20 option('attr', type : 'feature', value : 'auto', description: 'attr/xattr support') diff --git a/qemu-options.hx b/qemu-options.hx index 489b58e15110..38983a919b12 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1862,6 +1862,10 @@ DEF("display", HAS_ARG, QEMU_OPTION_display, #endif #if defined(CONFIG_OPENGL) "-display egl-headless[,rendernode=3D]\n" +#endif +#if defined(CONFIG_DBUS_DISPLAY) + "-display dbus[,addr=3D]\n" + " [,gl=3Don|core|es|off][,rendernode=3D]\n" #endif "-display none\n" " select display backend type\n" @@ -1889,6 +1893,17 @@ SRST application. The Spice server will redirect the serial consoles and QEMU monitors. (Since 4.0) =20 + ``dbus`` + Export the display over D-Bus interfaces. (Since 7.0) + + The connection is registered with the "org.qemu" name (and queued = when + already owned). + + ``addr=3D`` : D-Bus bus address to connect to. + + ``gl=3Don|off|core|es`` : Use OpenGL for rendering (the D-interfac= e will + share framebuffers with DMABUF file descriptors). + ``sdl`` Display video output via SDL (usually in a separate graphics window; see the SDL documentation for other possibilities). diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index ae8f18edc2ed..50bd7bed4df8 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -33,6 +33,7 @@ meson_options_help() { printf "%s\n" ' coreaudio CoreAudio sound support' printf "%s\n" ' curl CURL block device driver' printf "%s\n" ' curses curses UI' + printf "%s\n" ' dbus-display -display dbus support' printf "%s\n" ' docs Documentations build support' printf "%s\n" ' dsound DirectSound sound support' printf "%s\n" ' fuse FUSE block device export' @@ -131,6 +132,8 @@ _meson_option_parse() { --disable-curl) printf "%s" -Dcurl=3Ddisabled ;; --enable-curses) printf "%s" -Dcurses=3Denabled ;; --disable-curses) printf "%s" -Dcurses=3Ddisabled ;; + --enable-dbus-display) printf "%s" -Ddbus_display=3Denabled ;; + --disable-dbus-display) printf "%s" -Ddbus_display=3Ddisabled ;; --enable-docs) printf "%s" -Ddocs=3Denabled ;; --disable-docs) printf "%s" -Ddocs=3Ddisabled ;; --enable-dsound) printf "%s" -Ddsound=3Denabled ;; diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index e69de29bb2d1..0f0ae92e4d57 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -0,0 +1,378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/meson.build b/ui/meson.build index a9df5b911ec8..6270aa768b6a 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -65,6 +65,28 @@ if config_host.has_key('CONFIG_OPENGL') and gbm.found() ui_modules +=3D {'egl-headless' : egl_headless_ss} endif =20 +if dbus_display + dbus_ss =3D ss.source_set() + dbus_display1 =3D custom_target('dbus-display gdbus-codegen', + output: ['dbus-display1.h', 'dbus-display1= .c'], + input: files('dbus-display1.xml'), + command: [config_host['GDBUS_CODEGEN'], + '@INPUT@', + '--glib-min-required', '2.64', + '--output-directory', meson.curr= ent_build_dir(), + '--interface-prefix', 'org.qemu.= ', + '--c-namespace', 'QemuDBus', + '--generate-c-code', '@BASENAME@= ']) + dbus_ss.add(when: [gio, pixman, opengl, 'CONFIG_GIO'], + if_true: [files( + 'dbus-console.c', + 'dbus-error.c', + 'dbus-listener.c', + 'dbus.c', + ), dbus_display1]) + ui_modules +=3D {'dbus' : dbus_ss} +endif + if gtk.found() softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c')) =20 diff --git a/ui/trace-events b/ui/trace-events index e832c3e3659d..b1ae30159a53 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -136,3 +136,14 @@ vdagent_peer_cap(const char *name) "cap %s" vdagent_cb_grab_selection(const char *name) "selection %s" vdagent_cb_grab_type(const char *name) "type %s" vdagent_cb_serial_discard(uint32_t current, uint32_t received) "current=3D= %u, received=3D%u" + +# dbus.c +dbus_registered_listener(const char *bus_name) "peer %s" +dbus_listener_vanished(const char *bus_name) "peer %s" +dbus_kbd_press(unsigned int keycode) "keycode %u" +dbus_kbd_release(unsigned int keycode) "keycode %u" +dbus_mouse_press(unsigned int button) "button %u" +dbus_mouse_release(unsigned int button) "button %u" +dbus_mouse_set_pos(unsigned int x, unsigned int y) "x=3D%u, y=3D%u" +dbus_mouse_rel_motion(int dx, int dy) "dx=3D%d, dy=3D%d" +dbus_update(int x, int y, int w, int h) "x=3D%d, y=3D%d, w=3D%d, h=3D%d" --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072457; cv=none; d=zohomail.com; s=zohoarc; b=NoJBQsU3S8+s3pOeGY34EvDfexFtnDA///uBE9J+4SuMRT2zs9YRGZaC+dsyJSZ8OSOZNjW5n/tamLnnVibPuDIWMiJ0EMi+ihk2alJ5DkXHhNXT3pz6Lb7qkilN3AkY6/r0l+aj0a0xRAYT9MqXQIHLHBd+BdcbnkrUzic6A+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IHM1osYo3oJvMNI6G05bmm0qANxq+mU1JiUaImCEw8U=; b=E5cyAtl3UMGhxpPnWPG8xz7kE5ULoMZJaIs1UtRA7lz1rNZx5Zri537BS3IYaYyOLVO2+TLJpgqaE4hfIkF9qeQDebFu81USTprhKyJVPgXdC8myGykRxIxVi2goaUWup+w9uNL44kzmwszAmSMdNEjHb21KtXPtXcFa5zbcM8M= 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 1640072457865536.2531503734093; Mon, 20 Dec 2021 23:40:57 -0800 (PST) Received: from localhost ([::1]:50536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZlY-0006K4-EB for importer@patchew.org; Tue, 21 Dec 2021 02:40:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEW-0001S2-FG for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39115) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZET-0002Qs-Uq for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-zD4elxu7Pp6MtVR8DjtirA-1; Tue, 21 Dec 2021 02:06:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7DC3B1853020; Tue, 21 Dec 2021 07:06:40 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6E1CA7EA32; Tue, 21 Dec 2021 07:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070404; 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=IHM1osYo3oJvMNI6G05bmm0qANxq+mU1JiUaImCEw8U=; b=VTMb80UKNo43UcQ3XZrJr/+26Gg1hMgrZoONymjI4ZvCLbv8v3/65OJs+Y0uBY3rQ4TkCu 7OAy3SGlTzjgqa85Hs+Um9BU+e++tJCR6ERs3xN7RDvr4uRU8P9WaJQ6tSeuvEfNLSdCDh dfzXOsoKfb+TyRhlbjjT1guQKgCpJ4g= X-MC-Unique: zD4elxu7Pp6MtVR8DjtirA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 26/36] ui/dbus: add p2p=on/off option Date: Tue, 21 Dec 2021 10:58:45 +0400 Message-Id: <20211221065855.142578-27-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072458688100001 From: Marc-Andr=C3=A9 Lureau Add an option to use direct connections instead of via the bus. Clients are accepted with QMP add_client. This allows to provide the D-Bus display without a bus. It also simplifies the testing setup (some CI have issues to setup a D-Bus bus in a container). Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- qapi/misc.json | 4 +- qapi/ui.json | 6 ++- include/qemu/cutils.h | 5 ++ include/ui/dbus-display.h | 17 ++++++ include/ui/dbus-module.h | 11 ++++ ui/dbus.h | 2 + monitor/qmp-cmds.c | 13 +++++ ui/dbus-console.c | 2 +- ui/dbus-listener.c | 2 +- ui/dbus-module.c | 35 ++++++++++++ ui/dbus.c | 109 ++++++++++++++++++++++++++++++++++++-- qemu-options.hx | 6 ++- ui/meson.build | 3 ++ 13 files changed, 203 insertions(+), 12 deletions(-) create mode 100644 include/ui/dbus-display.h create mode 100644 include/ui/dbus-module.h create mode 100644 ui/dbus-module.c diff --git a/qapi/misc.json b/qapi/misc.json index 358548abe1ad..e8054f415b21 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -14,8 +14,8 @@ # Allow client connections for VNC, Spice and socket based # character devices to be passed in to QEMU via SCM_RIGHTS. # -# @protocol: protocol name. Valid names are "vnc", "spice" or the -# name of a character device (eg. from -chardev id=3DXXXX) +# @protocol: protocol name. Valid names are "vnc", "spice", "@dbus-display= " or +# the name of a character device (eg. from -chardev id=3DXXXX) # # @fdname: file descriptor name previously passed via 'getfd' command # diff --git a/qapi/ui.json b/qapi/ui.json index 80855328b1d4..d435e9472264 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1131,12 +1131,16 @@ # @rendernode: Which DRM render node should be used. Default is the first # available node on the host. # +# @p2p: Whether to use peer-to-peer connections (accepted through +# ``add_client``). +# # Since: 7.0 # ## { 'struct' : 'DisplayDBus', 'data' : { '*rendernode' : 'str', - '*addr': 'str' } } + '*addr': 'str', + '*p2p': 'bool' } } =20 ## # @DisplayGLMode: diff --git a/include/qemu/cutils.h b/include/qemu/cutils.h index 986ed8e15f41..320543950c4c 100644 --- a/include/qemu/cutils.h +++ b/include/qemu/cutils.h @@ -209,4 +209,9 @@ int qemu_pstrcmp0(const char **str1, const char **str2); */ char *get_relocated_path(const char *dir); =20 +static inline const char *yes_no(bool b) +{ + return b ? "yes" : "no"; +} + #endif diff --git a/include/ui/dbus-display.h b/include/ui/dbus-display.h new file mode 100644 index 000000000000..88f153c2371d --- /dev/null +++ b/include/ui/dbus-display.h @@ -0,0 +1,17 @@ +#ifndef DBUS_DISPLAY_H_ +#define DBUS_DISPLAY_H_ + +#include "qapi/error.h" +#include "ui/dbus-module.h" + +static inline bool qemu_using_dbus_display(Error **errp) +{ + if (!using_dbus_display) { + error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, + "D-Bus display is not in use"); + return false; + } + return true; +} + +#endif /* DBUS_DISPLAY_H_ */ diff --git a/include/ui/dbus-module.h b/include/ui/dbus-module.h new file mode 100644 index 000000000000..ace4a17a5c25 --- /dev/null +++ b/include/ui/dbus-module.h @@ -0,0 +1,11 @@ +#ifndef DBUS_MODULE_H_ +#define DBUS_MODULE_H_ + +struct QemuDBusDisplayOps { + bool (*add_client)(int csock, Error **errp); +}; + +extern int using_dbus_display; +extern struct QemuDBusDisplayOps qemu_dbus_display; + +#endif /* DBUS_MODULE_H_*/ diff --git a/ui/dbus.h b/ui/dbus.h index d3c9598dd133..4698d324632e 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -34,6 +34,7 @@ struct DBusDisplay { Object parent; =20 DisplayGLMode gl_mode; + bool p2p; char *dbus_addr; DisplayGLCtx glctx; =20 @@ -41,6 +42,7 @@ struct DBusDisplay { GDBusObjectManagerServer *server; QemuDBusDisplay1VM *iface; GPtrArray *consoles; + GCancellable *add_client_cancellable; }; =20 #define TYPE_DBUS_DISPLAY "dbus-display" diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 343353e27a7a..14e3beeaafcf 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -24,6 +24,7 @@ #include "chardev/char.h" #include "ui/qemu-spice.h" #include "ui/console.h" +#include "ui/dbus-display.h" #include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "sysemu/runstate-action.h" @@ -285,6 +286,18 @@ void qmp_add_client(const char *protocol, const char *= fdname, skipauth =3D has_skipauth ? skipauth : false; vnc_display_add_client(NULL, fd, skipauth); return; +#endif +#ifdef CONFIG_DBUS_DISPLAY + } else if (strcmp(protocol, "@dbus-display") =3D=3D 0) { + if (!qemu_using_dbus_display(errp)) { + close(fd); + return; + } + if (!qemu_dbus_display.add_client(fd, errp)) { + close(fd); + return; + } + return; #endif } else if ((s =3D qemu_chr_find(protocol)) !=3D NULL) { if (qemu_chr_add_client(s, fd) < 0) { diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 1ccf638c1061..e062f721d761 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -219,7 +219,7 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, DBusDisplayListener *listener; int fd; =20 - if (g_hash_table_contains(ddc->listeners, sender)) { + if (sender && g_hash_table_contains(ddc->listeners, sender)) { g_dbus_method_invocation_return_error( invocation, DBUS_DISPLAY_ERROR, diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 20094fc18abe..81c119b13a2c 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -440,7 +440,7 @@ dbus_display_listener_init(DBusDisplayListener *ddl) const char * dbus_display_listener_get_bus_name(DBusDisplayListener *ddl) { - return ddl->bus_name; + return ddl->bus_name ?: "p2p"; } =20 DBusDisplayConsole * diff --git a/ui/dbus-module.c b/ui/dbus-module.c new file mode 100644 index 000000000000..c8771fe48c7d --- /dev/null +++ b/ui/dbus-module.c @@ -0,0 +1,35 @@ +/* + * D-Bus module support. + * + * Copyright (C) 2021 Red Hat, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "ui/dbus-module.h" + +int using_dbus_display; + +static bool +qemu_dbus_display_add_client(int csock, Error **errp) +{ + error_setg(errp, "D-Bus display isn't enabled"); + return false; +} + +struct QemuDBusDisplayOps qemu_dbus_display =3D { + .add_client =3D qemu_dbus_display_add_client, +}; diff --git a/ui/dbus.c b/ui/dbus.c index 12da8ffe31e0..847a66782116 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -22,10 +22,12 @@ * THE SOFTWARE. */ #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qemu/dbus.h" #include "qemu/option.h" #include "qom/object_interfaces.h" #include "sysemu/sysemu.h" +#include "ui/dbus-module.h" #include "ui/egl-helpers.h" #include "ui/egl-context.h" #include "qapi/error.h" @@ -33,6 +35,8 @@ =20 #include "dbus.h" =20 +static DBusDisplay *dbus_display; + static QEMUGLContext dbus_create_context(DisplayGLCtx *dgc, QEMUGLParams *params) { @@ -73,9 +77,14 @@ dbus_display_finalize(Object *o) =20 g_clear_object(&dd->server); g_clear_pointer(&dd->consoles, g_ptr_array_unref); + if (dd->add_client_cancellable) { + g_cancellable_cancel(dd->add_client_cancellable); + } + g_clear_object(&dd->add_client_cancellable); g_clear_object(&dd->bus); g_clear_object(&dd->iface); g_free(dd->dbus_addr); + dbus_display =3D NULL; } =20 static bool @@ -115,7 +124,10 @@ dbus_display_complete(UserCreatable *uc, Error **errp) return; } =20 - if (dd->dbus_addr && *dd->dbus_addr) { + if (dd->p2p) { + /* wait for dbus_display_add_client() */ + dbus_display =3D dd; + } else if (dd->dbus_addr && *dd->dbus_addr) { dd->bus =3D g_dbus_connection_new_for_address_sync(dd->dbus_addr, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, @@ -151,10 +163,85 @@ dbus_display_complete(UserCreatable *uc, Error **errp) "console-ids", console_ids, NULL); =20 - g_dbus_object_manager_server_set_connection(dd->server, dd->bus); - g_bus_own_name_on_connection(dd->bus, "org.qemu", - G_BUS_NAME_OWNER_FLAGS_NONE, - NULL, NULL, NULL, NULL); + if (dd->bus) { + g_dbus_object_manager_server_set_connection(dd->server, dd->bus); + g_bus_own_name_on_connection(dd->bus, "org.qemu", + G_BUS_NAME_OWNER_FLAGS_NONE, + NULL, NULL, NULL, NULL); + } +} + +static void +dbus_display_add_client_ready(GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GDBusConnection) conn =3D NULL; + + g_clear_object(&dbus_display->add_client_cancellable); + + conn =3D g_dbus_connection_new_finish(res, &err); + if (!conn) { + error_printf("Failed to accept D-Bus client: %s", err->message); + } + + g_dbus_object_manager_server_set_connection(dbus_display->server, conn= ); +} + + +static bool +dbus_display_add_client(int csock, Error **errp) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GSocket) socket =3D NULL; + g_autoptr(GSocketConnection) conn =3D NULL; + g_autofree char *guid =3D g_dbus_generate_guid(); + + if (!dbus_display) { + error_setg(errp, "p2p connections not accepted in bus mode"); + return false; + } + + if (dbus_display->add_client_cancellable) { + g_cancellable_cancel(dbus_display->add_client_cancellable); + } + + socket =3D g_socket_new_from_fd(csock, &err); + if (!socket) { + error_setg(errp, "Failed to setup D-Bus socket: %s", err->message); + return false; + } + + conn =3D g_socket_connection_factory_create_connection(socket); + + dbus_display->add_client_cancellable =3D g_cancellable_new(); + + g_dbus_connection_new(G_IO_STREAM(conn), + guid, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER, + NULL, + dbus_display->add_client_cancellable, + dbus_display_add_client_ready, + NULL); + + return true; +} + +static bool +get_dbus_p2p(Object *o, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + return dd->p2p; +} + +static void +set_dbus_p2p(Object *o, bool p2p, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + dd->p2p =3D p2p; } =20 static char * @@ -196,6 +283,7 @@ dbus_display_class_init(ObjectClass *oc, void *data) UserCreatableClass *ucc =3D USER_CREATABLE_CLASS(oc); =20 ucc->complete =3D dbus_display_complete; + object_class_property_add_bool(oc, "p2p", get_dbus_p2p, set_dbus_p2p); object_class_property_add_str(oc, "addr", get_dbus_addr, set_dbus_addr= ); object_class_property_add_enum(oc, "gl-mode", "DisplayGLMode", &DisplayGLMode_lookup, @@ -222,11 +310,19 @@ dbus_init(DisplayState *ds, DisplayOptions *opts) { DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; =20 + if (opts->u.dbus.addr && opts->u.dbus.p2p) { + error_report("dbus: can't accept both addr=3DX and p2p=3Dyes optio= ns"); + exit(1); + } + + using_dbus_display =3D 1; + object_new_with_props(TYPE_DBUS_DISPLAY, object_get_objects_root(), "dbus-display", &error_fatal, "addr", opts->u.dbus.addr ?: "", "gl-mode", DisplayGLMode_str(mode), + "p2p", yes_no(opts->u.dbus.p2p), NULL); } =20 @@ -251,6 +347,9 @@ static QemuDisplay qemu_display_dbus =3D { =20 static void register_dbus(void) { + qemu_dbus_display =3D (struct QemuDBusDisplayOps) { + .add_client =3D dbus_display_add_client, + }; type_register_static(&dbus_display_info); qemu_display_register(&qemu_display_dbus); } diff --git a/qemu-options.hx b/qemu-options.hx index 38983a919b12..977e0873a12c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1901,8 +1901,10 @@ SRST =20 ``addr=3D`` : D-Bus bus address to connect to. =20 - ``gl=3Don|off|core|es`` : Use OpenGL for rendering (the D-interfac= e will - share framebuffers with DMABUF file descriptors). + ``p2p=3Dyes|no`` : Use peer-to-peer connection, accepted via QMP `= `add_client``. + + ``gl=3Don|off|core|es`` : Use OpenGL for rendering (the D-Bus inte= rface + will share framebuffers with DMABUF file descriptors). =20 ``sdl`` Display video output via SDL (usually in a separate graphics diff --git a/ui/meson.build b/ui/meson.build index 6270aa768b6a..80f21704ada6 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -14,6 +14,9 @@ softmmu_ss.add(files( 'qemu-pixman.c', 'util.c', )) +if dbus_display + softmmu_ss.add(files('dbus-module.c')) +endif softmmu_ss.add([spice_headers, files('spice-module.c')]) softmmu_ss.add(when: spice_protocol, if_true: files('vdagent.c')) =20 --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072234; cv=none; d=zohomail.com; s=zohoarc; b=DvtRlQIHBj4sGMqF60NQAaHjU4VbdYExsuiIsKbpoDr3WrLuiXZRRSPG+0iTtKiNGuGTQ9ydrAxTLlhNjdrcbIwGQMG8+MqttdvSscOzCQcy3hM+OqP2siLJGzMk5Keb9XwBM+/uDKrPYUuMFLZ+Bagw7q71JVoYbmWdwEgS+ic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072234; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rfp9+UqiAP0EZ917IhNkGUo0n5NEeCrIQK7EF5hcVeQ=; b=XchAw21zJ2iju/uIhYWOeVtYUylRLjFsjYvYFAq7z12hvEA4PS4zYO6OI6lxnWvPSEdZQMFs+xOQwk3EMlHgq8NdLYDLxgvVRVwxu5JfOVcRRmpVjT9FZgCOYMh6Pi2TFNgy+G2cK1XprVHTdzUO+yqjc4FTF+OS3YrDNrcqvBI= 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 1640072234221630.3810809326371; Mon, 20 Dec 2021 23:37:14 -0800 (PST) Received: from localhost ([::1]:42706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZhw-0000ey-TX for importer@patchew.org; Tue, 21 Dec 2021 02:37:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEc-0001aL-Mj for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEb-0002TW-6Z for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:06:54 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-TGXtbBFyPva3pPCbmSEFxg-1; Tue, 21 Dec 2021 02:06:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2CFF1006AA3; Tue, 21 Dec 2021 07:06:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6BF17A423; Tue, 21 Dec 2021 07:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070412; 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=rfp9+UqiAP0EZ917IhNkGUo0n5NEeCrIQK7EF5hcVeQ=; b=JyZntYtVHbOZcH3DJqm4TrWpg967UWTltkpwDlRBWfGn7WgFLTA9yg6KJONc7p/IpMlQYA llIU2/DOXZj6Ao3UfmJT9qf1adzln9UFf11HACtPzXm42r45k3bg4dKlgICCsYfksy/iIM ihvVvvBNYns555jLHvGqci8sKPx1KR0= X-MC-Unique: TGXtbBFyPva3pPCbmSEFxg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 27/36] tests/qtests: add qtest_qmp_add_client() Date: Tue, 21 Dec 2021 10:58:46 +0400 Message-Id: <20211221065855.142578-28-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072235970100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- tests/qtest/libqos/libqtest.h | 10 ++++++++++ tests/qtest/libqtest.c | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h index dff6b31cf0ec..a6d38d7ef7fb 100644 --- a/tests/qtest/libqos/libqtest.h +++ b/tests/qtest/libqos/libqtest.h @@ -744,6 +744,16 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const= char *drv, void qtest_qmp_device_add(QTestState *qts, const char *driver, const char = *id, const char *fmt, ...) GCC_FMT_ATTR(4, 5); =20 +/** + * qtest_qmp_add_client: + * @qts: QTestState instance to operate on + * @protocol: the protocol to add to + * @fd: the client file-descriptor + * + * Call QMP ``getfd`` followed by ``add_client`` with the given @fd. + */ +void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); + /** * qtest_qmp_device_del: * @qts: QTestState instance to operate on diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 65ed9496850f..a68326caae98 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1453,6 +1453,25 @@ void qtest_qmp_device_add(QTestState *qts, const cha= r *driver, const char *id, qobject_unref(args); } =20 +void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd) +{ + QDict *resp; + + resp =3D qtest_qmp_fds(qts, &fd, 1, "{'execute': 'getfd'," + "'arguments': {'fdname': 'fdname'}}"); + g_assert(resp); + g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events = */ + g_assert(!qdict_haskey(resp, "error")); + qobject_unref(resp); + + resp =3D qtest_qmp( + qts, "{'execute': 'add_client'," + "'arguments': {'protocol': %s, 'fdname': 'fdname'}}", protocol); + g_assert(resp); + g_assert(!qdict_haskey(resp, "event")); /* We don't expect any events = */ + g_assert(!qdict_haskey(resp, "error")); + qobject_unref(resp); +} =20 /* * Generic hot-unplugging test via the device_del QMP command. --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640073469; cv=none; d=zohomail.com; s=zohoarc; b=HqOGaDrvB9q0YdXXJ0d7rDX9d61J00JFJxZyps7D/CNrv7BHjsGnibJVe9EFTmlMLsWnWzrhp4xgne1snPh5QURoEDUgaiDmcJ6Cq0RE9Omx2Cx584vxtHgNzFax9yy/8sxjPbbRM0CGALcs7jt6QXvuAZnrALGRK2bZKlbASdg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640073469; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Od6lCCUOGkAPzq9jfcCfkBnwxs1xDBQI7592Jvxm+Co=; b=HWIixZQb2XMATHiRsREzgpVkKNPQyobSHAgenkfPlIQfeCjwHuh3E02DbhHjOoLTncpiaIPH3sMDvE6pnmO8ifZEX5a4VVEOC6xn9yb8n0V1Pm8D45Ulz2uy2Qf8CLNqm2AqJO91v9VZTQ/LObJBsJUSWztlzvAgi4057+/3XrU= 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 1640073469920137.67218696976295; Mon, 20 Dec 2021 23:57:49 -0800 (PST) Received: from localhost ([::1]:58208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mza1q-00062P-KC for importer@patchew.org; Tue, 21 Dec 2021 02:57:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEo-0001go-Jc for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:07:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31258) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZEm-0002Tx-LW for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:07:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-xbxpD_fuOU6wZvhbCYtqrw-1; Tue, 21 Dec 2021 02:07:01 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8968F344AF; Tue, 21 Dec 2021 07:06:58 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9A2D7EDAD; Tue, 21 Dec 2021 07:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070424; 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=Od6lCCUOGkAPzq9jfcCfkBnwxs1xDBQI7592Jvxm+Co=; b=Ne/hCt3PfLPr0n7zgPNqW/YDTcakPw+L6OnhtIR2Vd5LmkFlnzjoRul7VCeHpVbNo9Y4e+ NrF+aXXbB7x6iwZzzIugxfXiyNg0fUvzEgscFfMckvLc1USOXYmgpkifQXSHUKeRfslamr +oiyUOv9XfusEZ52NP3+SbvXvgW7j0E= X-MC-Unique: xbxpD_fuOU6wZvhbCYtqrw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 28/36] tests: start dbus-display-test Date: Tue, 21 Dec 2021 10:58:47 +0400 Message-Id: <20211221065855.142578-29-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640073470633100001 From: Marc-Andr=C3=A9 Lureau Cover basic display interface usage. More cases to be added to cover disconnections, multiple connections, corner cases. At this point, they would be better written in Rust or Python though. The proxy also covers reading the properties, since they are automatically loaded at creation. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- tests/qtest/dbus-display-test.c | 257 ++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 8 + 2 files changed, 265 insertions(+) create mode 100644 tests/qtest/dbus-display-test.c diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-tes= t.c new file mode 100644 index 000000000000..43c77aff045c --- /dev/null +++ b/tests/qtest/dbus-display-test.c @@ -0,0 +1,257 @@ +#include "qemu/osdep.h" +#include "qemu/dbus.h" +#include +#include +#include "libqos/libqtest.h" +#include "qemu-common.h" +#include "dbus-display1.h" + +static GDBusConnection* +test_dbus_p2p_from_fd(int fd) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GSocket) socket =3D NULL; + g_autoptr(GSocketConnection) socketc =3D NULL; + GDBusConnection *conn; + + socket =3D g_socket_new_from_fd(fd, &err); + g_assert_no_error(err); + + socketc =3D g_socket_connection_factory_create_connection(socket); + g_assert(socketc !=3D NULL); + + conn =3D g_dbus_connection_new_sync( + G_IO_STREAM(socketc), NULL, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | + G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING, + NULL, NULL, &err); + g_assert_no_error(err); + + return conn; +} + +static void +test_setup(QTestState **qts, GDBusConnection **conn) +{ + int pair[2]; + + *qts =3D qtest_init("-display dbus,p2p=3Dyes -name dbus-test"); + + g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), =3D=3D, 0); + + qtest_qmp_add_client(*qts, "@dbus-display", pair[1]); + + *conn =3D test_dbus_p2p_from_fd(pair[0]); + g_dbus_connection_start_message_processing(*conn); +} + +static void +test_dbus_display_vm(void) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GDBusConnection) conn =3D NULL; + g_autoptr(QemuDBusDisplay1VMProxy) vm =3D NULL; + QTestState *qts =3D NULL; + + test_setup(&qts, &conn); + + vm =3D QEMU_DBUS_DISPLAY1_VM_PROXY( + qemu_dbus_display1_vm_proxy_new_sync( + conn, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + DBUS_DISPLAY1_ROOT "/VM", + NULL, + &err)); + g_assert_no_error(err); + + g_assert_cmpstr( + qemu_dbus_display1_vm_get_name(QEMU_DBUS_DISPLAY1_VM(vm)), + =3D=3D, + "dbus-test"); + qtest_quit(qts); +} + +typedef struct TestDBusConsoleRegister { + GMainLoop *loop; + GThread *thread; + GDBusConnection *listener_conn; + GDBusObjectManagerServer *server; +} TestDBusConsoleRegister; + +static gboolean listener_handle_scanout( + QemuDBusDisplay1Listener *object, + GDBusMethodInvocation *invocation, + guint arg_width, + guint arg_height, + guint arg_stride, + guint arg_pixman_format, + GVariant *arg_data, + TestDBusConsoleRegister *test) +{ + g_main_loop_quit(test->loop); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static void +test_dbus_console_setup_listener(TestDBusConsoleRegister *test) +{ + g_autoptr(GDBusObjectSkeleton) listener =3D NULL; + g_autoptr(QemuDBusDisplay1ListenerSkeleton) iface =3D NULL; + + test->server =3D g_dbus_object_manager_server_new(DBUS_DISPLAY1_ROOT); + listener =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_ROOT "/Listener"= ); + iface =3D QEMU_DBUS_DISPLAY1_LISTENER_SKELETON( + qemu_dbus_display1_listener_skeleton_new()); + g_object_connect(iface, + "signal::handle-scanout", listener_handle_scanout, te= st, + NULL); + g_dbus_object_skeleton_add_interface(listener, + G_DBUS_INTERFACE_SKELETON(iface)); + g_dbus_object_manager_server_export(test->server, listener); + g_dbus_object_manager_server_set_connection(test->server, + test->listener_conn); + + g_dbus_connection_start_message_processing(test->listener_conn); +} + +static void +test_dbus_console_registered(GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + TestDBusConsoleRegister *test =3D user_data; + g_autoptr(GError) err =3D NULL; + + qemu_dbus_display1_console_call_register_listener_finish( + QEMU_DBUS_DISPLAY1_CONSOLE(source_object), + NULL, res, &err); + g_assert_no_error(err); + + test->listener_conn =3D g_thread_join(test->thread); + test_dbus_console_setup_listener(test); +} + +static gpointer +test_dbus_p2p_server_setup_thread(gpointer data) +{ + return test_dbus_p2p_from_fd(GPOINTER_TO_INT(data)); +} + +static void +test_dbus_display_console(void) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GDBusConnection) conn =3D NULL; + g_autoptr(QemuDBusDisplay1ConsoleProxy) console =3D NULL; + g_autoptr(GUnixFDList) fd_list =3D NULL; + g_autoptr(GMainLoop) loop =3D NULL; + QTestState *qts =3D NULL; + int pair[2], idx; + TestDBusConsoleRegister test; + + test_setup(&qts, &conn); + + g_assert_cmpint(socketpair(AF_UNIX, SOCK_STREAM, 0, pair), =3D=3D, 0); + fd_list =3D g_unix_fd_list_new(); + idx =3D g_unix_fd_list_append(fd_list, pair[1], NULL); + + console =3D QEMU_DBUS_DISPLAY1_CONSOLE_PROXY( + qemu_dbus_display1_console_proxy_new_sync( + conn, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "/org/qemu/Display1/Console_0", + NULL, + &err)); + g_assert_no_error(err); + + test.loop =3D loop =3D g_main_loop_new(NULL, FALSE); + test.thread =3D g_thread_new(NULL, test_dbus_p2p_server_setup_thread, + GINT_TO_POINTER(pair[0])); + + qemu_dbus_display1_console_call_register_listener( + QEMU_DBUS_DISPLAY1_CONSOLE(console), + g_variant_new_handle(idx), + G_DBUS_CALL_FLAGS_NONE, + -1, + fd_list, + NULL, + test_dbus_console_registered, + &test); + + g_main_loop_run(loop); + + g_clear_object(&test.server); + g_clear_object(&test.listener_conn); + qtest_quit(qts); +} + +static void +test_dbus_display_keyboard(void) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(GDBusConnection) conn =3D NULL; + g_autoptr(QemuDBusDisplay1KeyboardProxy) keyboard =3D NULL; + QTestState *qts =3D NULL; + + test_setup(&qts, &conn); + + keyboard =3D QEMU_DBUS_DISPLAY1_KEYBOARD_PROXY( + qemu_dbus_display1_keyboard_proxy_new_sync( + conn, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + "/org/qemu/Display1/Console_0", + NULL, + &err)); + g_assert_no_error(err); + + + g_assert_cmpint(qtest_inb(qts, 0x64) & 0x1, =3D=3D, 0); + g_assert_cmpint(qtest_inb(qts, 0x60), =3D=3D, 0); + + qemu_dbus_display1_keyboard_call_press_sync( + QEMU_DBUS_DISPLAY1_KEYBOARD(keyboard), + 0x1C, /* qnum enter */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &err); + g_assert_no_error(err); + + /* may be should wait for interrupt? */ + g_assert_cmpint(qtest_inb(qts, 0x64) & 0x1, =3D=3D, 1); + g_assert_cmpint(qtest_inb(qts, 0x60), =3D=3D, 0x5A); /* scan code 2 en= ter */ + + qemu_dbus_display1_keyboard_call_release_sync( + QEMU_DBUS_DISPLAY1_KEYBOARD(keyboard), + 0x1C, /* qnum enter */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &err); + g_assert_no_error(err); + + g_assert_cmpint(qtest_inb(qts, 0x64) & 0x1, =3D=3D, 1); + g_assert_cmpint(qtest_inb(qts, 0x60), =3D=3D, 0xF0); /* scan code 2 re= lease */ + g_assert_cmpint(qtest_inb(qts, 0x60), =3D=3D, 0x5A); /* scan code 2 en= ter */ + + g_assert_cmpint(qemu_dbus_display1_keyboard_get_modifiers( + QEMU_DBUS_DISPLAY1_KEYBOARD(keyboard)), =3D=3D, 0); + + qtest_quit(qts); +} + +int +main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + qtest_add_func("/dbus-display/vm", test_dbus_display_vm); + qtest_add_func("/dbus-display/console", test_dbus_display_console); + qtest_add_func("/dbus-display/keyboard", test_dbus_display_keyboard); + + return g_test_run(); +} diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 913e987409d5..1b2bde666037 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -92,6 +92,10 @@ qtests_i386 =3D \ 'test-x86-cpuid-compat', 'numa-test'] =20 +if dbus_display + qtests_i386 +=3D ['dbus-display-test'] +endif + dbus_daemon =3D find_program('dbus-daemon', required: false) if dbus_daemon.found() and config_host.has_key('GDBUS_CODEGEN') # Temporarily disabled due to Patchew failures: @@ -265,6 +269,10 @@ qtests =3D { 'vmgenid-test': files('boot-sector.c', 'acpi-utils.c'), } =20 +if dbus_display +qtests +=3D {'dbus-display-test': [dbus_display1, gio]} +endif + qtest_executables =3D {} foreach dir : target_dirs if not dir.endswith('-softmmu') --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072664; cv=none; d=zohomail.com; s=zohoarc; b=mKQa4BIUBYC5nCSjrrvnST/Ol+ZvgQb2UdTJ/M/ILOoCDWUmgk2o3sGJ7xZsPEuILVCsnAYFoOyYTwqkYTGYlXew56w4hrdQacVYJY5FJlwJH6V5oInYhWSG+NIa1zhhrItMXRDWj1i7NmEMvBturAqamH2ZRoAneZN5upS1aI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072664; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uZmHqPJwF3GSSjNUX5ebugjGeisqMy1vI7MNbYpokPw=; b=Y7N/a1mpOFTF+Z4QAyI6jEo+djcu8PMlnmcWAL8EhWVHvmjp/SFCn4A+UiGCDnJbI4Z/mQquwxbibjP3ttYelGChwR+6cDIy9y9HPOAsnmInKOSAI43fZgTU00dKGHuuTRDnNsb2WTGwpFrvrauYfKeDofmXmwPEzIKdTJcR4C8= 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 1640072664353981.1794964519503; Mon, 20 Dec 2021 23:44:24 -0800 (PST) Received: from localhost ([::1]:59284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZot-0003r3-4U for importer@patchew.org; Tue, 21 Dec 2021 02:44:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZFI-0002S0-O4 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:07:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:25983) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZFF-0002Ub-9q for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:07:36 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-65-Ybsm6vWLPCyKzOr4D5FHIQ-1; Tue, 21 Dec 2021 02:07:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71EC48042E2; Tue, 21 Dec 2021 07:07:29 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69A79105B20B; Tue, 21 Dec 2021 07:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070452; 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=uZmHqPJwF3GSSjNUX5ebugjGeisqMy1vI7MNbYpokPw=; b=b08Jk3+Ex3GJoMbuunpT9BCZkLyJitK6i9DaWi4E0BgErtF3aFxOGQizVDW0/5okWdvWSm D9RkQ74L1b7Gxhe9ujEt9uCjj4x663C5nHxsaBm+Vi9MSM6eIzUrlo8CuAVqQNIxqcnViQ o1oKbtJwxlhngvBnaDdyHdOxEQIMH1w= X-MC-Unique: Ybsm6vWLPCyKzOr4D5FHIQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 29/36] audio: add "dbus" audio backend Date: Tue, 21 Dec 2021 10:58:48 +0400 Message-Id: <20211221065855.142578-30-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072664764100001 From: Marc-Andr=C3=A9 Lureau Add a new -audio backend that accepts D-Bus clients/listeners to handle playback & recording, to be exported via the -display dbus. Example usage: -audiodev dbus,in.mixing-engine=3Doff,out.mixing-engine=3Doff,id=3Ddbus -display dbus,audiodev=3Ddbus Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- qapi/audio.json | 3 +- qapi/ui.json | 5 +- audio/audio_int.h | 7 + audio/audio_template.h | 2 + ui/dbus.h | 1 + audio/audio.c | 1 + audio/dbusaudio.c | 654 +++++++++++++++++++++++++++++++++++++++++ ui/dbus.c | 35 +++ audio/meson.build | 6 + audio/trace-events | 5 + qemu-options.hx | 3 + ui/dbus-display1.xml | 211 +++++++++++++ 12 files changed, 931 insertions(+), 2 deletions(-) create mode 100644 audio/dbusaudio.c diff --git a/qapi/audio.json b/qapi/audio.json index 9cba0df8a4e9..693e327c6b6a 100644 --- a/qapi/audio.json +++ b/qapi/audio.json @@ -386,7 +386,7 @@ # Since: 4.0 ## { 'enum': 'AudiodevDriver', - 'data': [ 'none', 'alsa', 'coreaudio', 'dsound', 'jack', 'oss', 'pa', + 'data': [ 'none', 'alsa', 'coreaudio', 'dbus', 'dsound', 'jack', 'oss', = 'pa', 'sdl', 'spice', 'wav' ] } =20 ## @@ -412,6 +412,7 @@ 'none': 'AudiodevGenericOptions', 'alsa': 'AudiodevAlsaOptions', 'coreaudio': 'AudiodevCoreaudioOptions', + 'dbus': 'AudiodevGenericOptions', 'dsound': 'AudiodevDsoundOptions', 'jack': 'AudiodevJackOptions', 'oss': 'AudiodevOssOptions', diff --git a/qapi/ui.json b/qapi/ui.json index d435e9472264..2b4371da3777 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1134,13 +1134,16 @@ # @p2p: Whether to use peer-to-peer connections (accepted through # ``add_client``). # +# @audiodev: Use the specified DBus audiodev to export audio. +# # Since: 7.0 # ## { 'struct' : 'DisplayDBus', 'data' : { '*rendernode' : 'str', '*addr': 'str', - '*p2p': 'bool' } } + '*p2p': 'bool', + '*audiodev': 'str' } } =20 ## # @DisplayGLMode: diff --git a/audio/audio_int.h b/audio/audio_int.h index 6d685e24a388..428a091d05e5 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -31,6 +31,10 @@ #endif #include "mixeng.h" =20 +#ifdef CONFIG_GIO +#include +#endif + struct audio_pcm_ops; =20 struct audio_callback { @@ -140,6 +144,9 @@ struct audio_driver { const char *descr; void *(*init) (Audiodev *); void (*fini) (void *); +#ifdef CONFIG_GIO + void (*set_dbus_server) (AudioState *s, GDBusObjectManagerServer *mana= ger); +#endif struct audio_pcm_ops *pcm_ops; int can_be_default; int max_voices_out; diff --git a/audio/audio_template.h b/audio/audio_template.h index c6714946aaed..d2d348638b8c 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -327,6 +327,8 @@ AudiodevPerDirectionOptions *glue(audio_get_pdo_, TYPE)= (Audiodev *dev) case AUDIODEV_DRIVER_COREAUDIO: return qapi_AudiodevCoreaudioPerDirectionOptions_base( dev->u.coreaudio.TYPE); + case AUDIODEV_DRIVER_DBUS: + return dev->u.dbus.TYPE; case AUDIODEV_DRIVER_DSOUND: return dev->u.dsound.TYPE; case AUDIODEV_DRIVER_JACK: diff --git a/ui/dbus.h b/ui/dbus.h index 4698d324632e..ca1f0f4ab94f 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -36,6 +36,7 @@ struct DBusDisplay { DisplayGLMode gl_mode; bool p2p; char *dbus_addr; + char *audiodev; DisplayGLCtx glctx; =20 GDBusConnection *bus; diff --git a/audio/audio.c b/audio/audio.c index 54a153c0ef07..dc28685d226d 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -2000,6 +2000,7 @@ void audio_create_pdos(Audiodev *dev) CASE(NONE, none, ); CASE(ALSA, alsa, Alsa); CASE(COREAUDIO, coreaudio, Coreaudio); + CASE(DBUS, dbus, ); CASE(DSOUND, dsound, ); CASE(JACK, jack, Jack); CASE(OSS, oss, Oss); diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c new file mode 100644 index 000000000000..f178b47deec1 --- /dev/null +++ b/audio/dbusaudio.c @@ -0,0 +1,654 @@ +/* + * QEMU DBus audio + * + * Copyright (c) 2021 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu/error-report.h" +#include "qemu/host-utils.h" +#include "qemu/module.h" +#include "qemu/timer.h" +#include "qemu/dbus.h" + +#include +#include "ui/dbus-display1.h" + +#define AUDIO_CAP "dbus" +#include "audio.h" +#include "audio_int.h" +#include "trace.h" + +#define DBUS_DISPLAY1_AUDIO_PATH DBUS_DISPLAY1_ROOT "/Audio" + +#define DBUS_AUDIO_NSAMPLES 1024 /* could be configured? */ + +typedef struct DBusAudio { + GDBusObjectManagerServer *server; + GDBusObjectSkeleton *audio; + QemuDBusDisplay1Audio *iface; + GHashTable *out_listeners; + GHashTable *in_listeners; +} DBusAudio; + +typedef struct DBusVoiceOut { + HWVoiceOut hw; + bool enabled; + RateCtl rate; + + void *buf; + size_t buf_pos; + size_t buf_size; + + bool has_volume; + Volume volume; +} DBusVoiceOut; + +typedef struct DBusVoiceIn { + HWVoiceIn hw; + bool enabled; + RateCtl rate; + + bool has_volume; + Volume volume; +} DBusVoiceIn; + +static void *dbus_get_buffer_out(HWVoiceOut *hw, size_t *size) +{ + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + + if (!vo->buf) { + vo->buf_size =3D hw->samples * hw->info.bytes_per_frame; + vo->buf =3D g_malloc(vo->buf_size); + vo->buf_pos =3D 0; + } + + *size =3D MIN(vo->buf_size - vo->buf_pos, *size); + *size =3D audio_rate_get_bytes(&hw->info, &vo->rate, *size); + + return vo->buf + vo->buf_pos; + +} + +static size_t dbus_put_buffer_out(HWVoiceOut *hw, void *buf, size_t size) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioOutListener *listener =3D NULL; + g_autoptr(GBytes) bytes =3D NULL; + g_autoptr(GVariant) v_data =3D NULL; + + assert(buf =3D=3D vo->buf + vo->buf_pos && vo->buf_pos + size <=3D vo-= >buf_size); + vo->buf_pos +=3D size; + + trace_dbus_audio_put_buffer_out(size); + + if (vo->buf_pos < vo->buf_size) { + return size; + } + + bytes =3D g_bytes_new_take(g_steal_pointer(&vo->buf), vo->buf_size); + v_data =3D g_variant_new_from_bytes(G_VARIANT_TYPE("ay"), bytes, TRUE); + g_variant_ref_sink(v_data); + + g_hash_table_iter_init(&iter, da->out_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + qemu_dbus_display1_audio_out_listener_call_write( + listener, + (uintptr_t)hw, + v_data, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + + return size; +} + +#ifdef HOST_WORDS_BIGENDIAN +#define AUDIO_HOST_BE TRUE +#else +#define AUDIO_HOST_BE FALSE +#endif + +static void +dbus_init_out_listener(QemuDBusDisplay1AudioOutListener *listener, + HWVoiceOut *hw) +{ + qemu_dbus_display1_audio_out_listener_call_init( + listener, + (uintptr_t)hw, + hw->info.bits, + hw->info.is_signed, + hw->info.is_float, + hw->info.freq, + hw->info.nchannels, + hw->info.bytes_per_frame, + hw->info.bytes_per_second, + hw->info.swap_endianness ? !AUDIO_HOST_BE : AUDIO_HOST_BE, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static int +dbus_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioOutListener *listener =3D NULL; + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D DBUS_AUDIO_NSAMPLES; + audio_rate_start(&vo->rate); + + g_hash_table_iter_init(&iter, da->out_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + dbus_init_out_listener(listener, hw); + } + return 0; +} + +static void +dbus_fini_out(HWVoiceOut *hw) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioOutListener *listener =3D NULL; + + g_hash_table_iter_init(&iter, da->out_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + qemu_dbus_display1_audio_out_listener_call_fini( + listener, + (uintptr_t)hw, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + + g_clear_pointer(&vo->buf, g_free); +} + +static void +dbus_enable_out(HWVoiceOut *hw, bool enable) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioOutListener *listener =3D NULL; + + vo->enabled =3D enable; + if (enable) { + audio_rate_start(&vo->rate); + } + + g_hash_table_iter_init(&iter, da->out_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + qemu_dbus_display1_audio_out_listener_call_set_enabled( + listener, (uintptr_t)hw, enable, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } +} + +static void +dbus_volume_out_listener(HWVoiceOut *hw, + QemuDBusDisplay1AudioOutListener *listener) +{ + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + Volume *vol =3D &vo->volume; + g_autoptr(GBytes) bytes =3D NULL; + GVariant *v_vol =3D NULL; + + if (!vo->has_volume) { + return; + } + + assert(vol->channels < sizeof(vol->vol)); + bytes =3D g_bytes_new(vol->vol, vol->channels); + v_vol =3D g_variant_new_from_bytes(G_VARIANT_TYPE("ay"), bytes, TRUE); + qemu_dbus_display1_audio_out_listener_call_set_volume( + listener, (uintptr_t)hw, vol->mute, v_vol, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static void +dbus_volume_out(HWVoiceOut *hw, Volume *vol) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioOutListener *listener =3D NULL; + + vo->has_volume =3D true; + vo->volume =3D *vol; + + g_hash_table_iter_init(&iter, da->out_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + dbus_volume_out_listener(hw, listener); + } +} + +static void +dbus_init_in_listener(QemuDBusDisplay1AudioInListener *listener, HWVoiceIn= *hw) +{ + qemu_dbus_display1_audio_in_listener_call_init( + listener, + (uintptr_t)hw, + hw->info.bits, + hw->info.is_signed, + hw->info.is_float, + hw->info.freq, + hw->info.nchannels, + hw->info.bytes_per_frame, + hw->info.bytes_per_second, + hw->info.swap_endianness ? !AUDIO_HOST_BE : AUDIO_HOST_BE, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static int +dbus_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioInListener *listener =3D NULL; + + audio_pcm_init_info(&hw->info, as); + hw->samples =3D DBUS_AUDIO_NSAMPLES; + audio_rate_start(&vo->rate); + + g_hash_table_iter_init(&iter, da->in_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + dbus_init_in_listener(listener, hw); + } + return 0; +} + +static void +dbus_fini_in(HWVoiceIn *hw) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + GHashTableIter iter; + QemuDBusDisplay1AudioInListener *listener =3D NULL; + + g_hash_table_iter_init(&iter, da->in_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + qemu_dbus_display1_audio_in_listener_call_fini( + listener, + (uintptr_t)hw, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } +} + +static void +dbus_volume_in_listener(HWVoiceIn *hw, + QemuDBusDisplay1AudioInListener *listener) +{ + DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); + Volume *vol =3D &vo->volume; + g_autoptr(GBytes) bytes =3D NULL; + GVariant *v_vol =3D NULL; + + if (!vo->has_volume) { + return; + } + + assert(vol->channels < sizeof(vol->vol)); + bytes =3D g_bytes_new(vol->vol, vol->channels); + v_vol =3D g_variant_new_from_bytes(G_VARIANT_TYPE("ay"), bytes, TRUE); + qemu_dbus_display1_audio_in_listener_call_set_volume( + listener, (uintptr_t)hw, vol->mute, v_vol, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); +} + +static void +dbus_volume_in(HWVoiceIn *hw, Volume *vol) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioInListener *listener =3D NULL; + + vo->has_volume =3D true; + vo->volume =3D *vol; + + g_hash_table_iter_init(&iter, da->in_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + dbus_volume_in_listener(hw, listener); + } +} + +static size_t +dbus_read(HWVoiceIn *hw, void *buf, size_t size) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + /* DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); */ + GHashTableIter iter; + QemuDBusDisplay1AudioInListener *listener =3D NULL; + + trace_dbus_audio_read(size); + + /* size =3D audio_rate_get_bytes(&hw->info, &vo->rate, size); */ + + g_hash_table_iter_init(&iter, da->in_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + g_autoptr(GVariant) v_data =3D NULL; + const char *data; + gsize n =3D 0; + + if (qemu_dbus_display1_audio_in_listener_call_read_sync( + listener, + (uintptr_t)hw, + size, + G_DBUS_CALL_FLAGS_NONE, -1, + &v_data, NULL, NULL)) { + data =3D g_variant_get_fixed_array(v_data, &n, 1); + g_warn_if_fail(n <=3D size); + size =3D MIN(n, size); + memcpy(buf, data, size); + break; + } + } + + return size; +} + +static void +dbus_enable_in(HWVoiceIn *hw, bool enable) +{ + DBusAudio *da =3D (DBusAudio *)hw->s->drv_opaque; + DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); + GHashTableIter iter; + QemuDBusDisplay1AudioInListener *listener =3D NULL; + + vo->enabled =3D enable; + if (enable) { + audio_rate_start(&vo->rate); + } + + g_hash_table_iter_init(&iter, da->in_listeners); + while (g_hash_table_iter_next(&iter, NULL, (void **)&listener)) { + qemu_dbus_display1_audio_in_listener_call_set_enabled( + listener, (uintptr_t)hw, enable, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } +} + +static void * +dbus_audio_init(Audiodev *dev) +{ + DBusAudio *da =3D g_new0(DBusAudio, 1); + + da->out_listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_object_unref); + da->in_listeners =3D g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_object_unref); + return da; +} + +static void +dbus_audio_fini(void *opaque) +{ + DBusAudio *da =3D opaque; + + if (da->server) { + g_dbus_object_manager_server_unexport(da->server, + DBUS_DISPLAY1_AUDIO_PATH); + } + g_clear_object(&da->audio); + g_clear_object(&da->iface); + g_clear_pointer(&da->in_listeners, g_hash_table_unref); + g_clear_pointer(&da->out_listeners, g_hash_table_unref); + g_clear_object(&da->server); + g_free(da); +} + +static void +listener_out_vanished_cb(GDBusConnection *connection, + gboolean remote_peer_vanished, + GError *error, + DBusAudio *da) +{ + char *name =3D g_object_get_data(G_OBJECT(connection), "name"); + + g_hash_table_remove(da->out_listeners, name); +} + +static void +listener_in_vanished_cb(GDBusConnection *connection, + gboolean remote_peer_vanished, + GError *error, + DBusAudio *da) +{ + char *name =3D g_object_get_data(G_OBJECT(connection), "name"); + + g_hash_table_remove(da->in_listeners, name); +} + +static gboolean +dbus_audio_register_listener(AudioState *s, + GDBusMethodInvocation *invocation, + GUnixFDList *fd_list, + GVariant *arg_listener, + bool out) +{ + DBusAudio *da =3D s->drv_opaque; + const char *sender =3D g_dbus_method_invocation_get_sender(invocation); + g_autoptr(GDBusConnection) listener_conn =3D NULL; + g_autoptr(GError) err =3D NULL; + g_autoptr(GSocket) socket =3D NULL; + g_autoptr(GSocketConnection) socket_conn =3D NULL; + g_autofree char *guid =3D g_dbus_generate_guid(); + GHashTable *listeners =3D out ? da->out_listeners : da->in_listeners; + GObject *listener; + int fd; + + trace_dbus_audio_register(sender, out ? "out" : "in"); + + if (g_hash_table_contains(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; + } + + fd =3D g_unix_fd_list_get(fd_list, g_variant_get_handle(arg_listener),= &err); + if (err) { + g_dbus_method_invocation_return_error(invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Couldn't get peer fd: %s", + err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + socket =3D g_socket_new_from_fd(fd, &err); + if (err) { + g_dbus_method_invocation_return_error(invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Couldn't make a socket: %s", + err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + socket_conn =3D g_socket_connection_factory_create_connection(socket); + if (out) { + qemu_dbus_display1_audio_complete_register_out_listener( + da->iface, invocation, NULL); + } else { + qemu_dbus_display1_audio_complete_register_in_listener( + da->iface, invocation, NULL); + } + + listener_conn =3D + g_dbus_connection_new_sync( + G_IO_STREAM(socket_conn), + guid, + G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER, + NULL, NULL, &err); + if (err) { + error_report("Failed to setup peer connection: %s", err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + listener =3D out ? + G_OBJECT(qemu_dbus_display1_audio_out_listener_proxy_new_sync( + listener_conn, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + "/org/qemu/Display1/AudioOutListener", + NULL, + &err)) : + G_OBJECT(qemu_dbus_display1_audio_in_listener_proxy_new_sync( + listener_conn, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + "/org/qemu/Display1/AudioInListener", + NULL, + &err)); + if (!listener) { + error_report("Failed to setup proxy: %s", err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (out) { + HWVoiceOut *hw; + + QLIST_FOREACH(hw, &s->hw_head_out, entries) { + DBusVoiceOut *vo =3D container_of(hw, DBusVoiceOut, hw); + QemuDBusDisplay1AudioOutListener *l =3D + QEMU_DBUS_DISPLAY1_AUDIO_OUT_LISTENER(listener); + + dbus_init_out_listener(l, hw); + qemu_dbus_display1_audio_out_listener_call_set_enabled( + l, (uintptr_t)hw, vo->enabled, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + } else { + HWVoiceIn *hw; + + QLIST_FOREACH(hw, &s->hw_head_in, entries) { + DBusVoiceIn *vo =3D container_of(hw, DBusVoiceIn, hw); + QemuDBusDisplay1AudioInListener *l =3D + QEMU_DBUS_DISPLAY1_AUDIO_IN_LISTENER(listener); + + dbus_init_in_listener( + QEMU_DBUS_DISPLAY1_AUDIO_IN_LISTENER(listener), hw); + qemu_dbus_display1_audio_in_listener_call_set_enabled( + l, (uintptr_t)hw, vo->enabled, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + } + + g_object_set_data_full(G_OBJECT(listener_conn), "name", + g_strdup(sender), g_free); + g_hash_table_insert(listeners, g_strdup(sender), listener); + g_object_connect(listener_conn, + "signal::closed", + out ? listener_out_vanished_cb : listener_in_vanished= _cb, + da, + NULL); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_audio_register_out_listener(AudioState *s, + GDBusMethodInvocation *invocation, + GUnixFDList *fd_list, + GVariant *arg_listener) +{ + return dbus_audio_register_listener(s, invocation, + fd_list, arg_listener, true); + +} + +static gboolean +dbus_audio_register_in_listener(AudioState *s, + GDBusMethodInvocation *invocation, + GUnixFDList *fd_list, + GVariant *arg_listener) +{ + return dbus_audio_register_listener(s, invocation, + fd_list, arg_listener, false); +} + +static void +dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server) +{ + DBusAudio *da =3D s->drv_opaque; + + g_assert(da); + g_assert(!da->server); + + da->server =3D g_object_ref(server); + + da->audio =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_AUDIO_PATH); + da->iface =3D qemu_dbus_display1_audio_skeleton_new(); + g_object_connect(da->iface, + "swapped-signal::handle-register-in-listener", + dbus_audio_register_in_listener, s, + "swapped-signal::handle-register-out-listener", + dbus_audio_register_out_listener, s, + NULL); + + g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(da->audio), + G_DBUS_INTERFACE_SKELETON(da->ifa= ce)); + g_dbus_object_manager_server_export(da->server, da->audio); +} + +static struct audio_pcm_ops dbus_pcm_ops =3D { + .init_out =3D dbus_init_out, + .fini_out =3D dbus_fini_out, + .write =3D audio_generic_write, + .get_buffer_out =3D dbus_get_buffer_out, + .put_buffer_out =3D dbus_put_buffer_out, + .enable_out =3D dbus_enable_out, + .volume_out =3D dbus_volume_out, + + .init_in =3D dbus_init_in, + .fini_in =3D dbus_fini_in, + .read =3D dbus_read, + .run_buffer_in =3D audio_generic_run_buffer_in, + .enable_in =3D dbus_enable_in, + .volume_in =3D dbus_volume_in, +}; + +static struct audio_driver dbus_audio_driver =3D { + .name =3D "dbus", + .descr =3D "Timer based audio exposed with DBus interface", + .init =3D dbus_audio_init, + .fini =3D dbus_audio_fini, + .set_dbus_server =3D dbus_audio_set_server, + .pcm_ops =3D &dbus_pcm_ops, + .can_be_default =3D 1, + .max_voices_out =3D INT_MAX, + .max_voices_in =3D INT_MAX, + .voice_size_out =3D sizeof(DBusVoiceOut), + .voice_size_in =3D sizeof(DBusVoiceIn) +}; + +static void register_audio_dbus(void) +{ + audio_driver_register(&dbus_audio_driver); +} +type_init(register_audio_dbus); + +module_dep("ui-dbus") diff --git a/ui/dbus.c b/ui/dbus.c index 847a66782116..d24f704d4662 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -30,6 +30,8 @@ #include "ui/dbus-module.h" #include "ui/egl-helpers.h" #include "ui/egl-context.h" +#include "audio/audio.h" +#include "audio/audio_int.h" #include "qapi/error.h" #include "trace.h" =20 @@ -84,6 +86,7 @@ dbus_display_finalize(Object *o) g_clear_object(&dd->bus); g_clear_object(&dd->iface); g_free(dd->dbus_addr); + g_free(dd->audiodev); dbus_display =3D NULL; } =20 @@ -140,6 +143,19 @@ dbus_display_complete(UserCreatable *uc, Error **errp) return; } =20 + if (dd->audiodev && *dd->audiodev) { + AudioState *audio_state =3D audio_state_by_name(dd->audiodev); + if (!audio_state) { + error_setg(errp, "Audiodev '%s' not found", dd->audiodev); + return; + } + if (!g_str_equal(audio_state->drv->name, "dbus")) { + error_setg(errp, "Audiodev '%s' is not compatible with DBus", + dd->audiodev); + return; + } + audio_state->drv->set_dbus_server(audio_state, dd->server); + } =20 consoles =3D g_array_new(FALSE, FALSE, sizeof(guint32)); for (idx =3D 0;; idx++) { @@ -261,6 +277,23 @@ set_dbus_addr(Object *o, const char *str, Error **errp) dd->dbus_addr =3D g_strdup(str); } =20 +static char * +get_audiodev(Object *o, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + return g_strdup(dd->audiodev); +} + +static void +set_audiodev(Object *o, const char *str, Error **errp) +{ + DBusDisplay *dd =3D DBUS_DISPLAY(o); + + g_free(dd->audiodev); + dd->audiodev =3D g_strdup(str); +} + static int get_gl_mode(Object *o, Error **errp) { @@ -285,6 +318,7 @@ dbus_display_class_init(ObjectClass *oc, void *data) ucc->complete =3D dbus_display_complete; object_class_property_add_bool(oc, "p2p", get_dbus_p2p, set_dbus_p2p); object_class_property_add_str(oc, "addr", get_dbus_addr, set_dbus_addr= ); + object_class_property_add_str(oc, "audiodev", get_audiodev, set_audiod= ev); object_class_property_add_enum(oc, "gl-mode", "DisplayGLMode", &DisplayGLMode_lookup, get_gl_mode, set_gl_mode); @@ -321,6 +355,7 @@ dbus_init(DisplayState *ds, DisplayOptions *opts) object_get_objects_root(), "dbus-display", &error_fatal, "addr", opts->u.dbus.addr ?: "", + "audiodev", opts->u.dbus.audiodev ?: "", "gl-mode", DisplayGLMode_str(mode), "p2p", yes_no(opts->u.dbus.p2p), NULL); diff --git a/audio/meson.build b/audio/meson.build index 462533bb8c22..0ac3791d0bd1 100644 --- a/audio/meson.build +++ b/audio/meson.build @@ -26,4 +26,10 @@ foreach m : [ endif endforeach =20 +if dbus_display + module_ss =3D ss.source_set() + module_ss.add(when: gio, if_true: files('dbusaudio.c')) + audio_modules +=3D {'dbus': module_ss} +endif + modules +=3D {'audio': audio_modules} diff --git a/audio/trace-events b/audio/trace-events index 957c92337bee..e1ab643add39 100644 --- a/audio/trace-events +++ b/audio/trace-events @@ -13,6 +13,11 @@ alsa_resume_out(void) "Resuming suspended output stream" # ossaudio.c oss_version(int version) "OSS version =3D 0x%x" =20 +# dbusaudio.c +dbus_audio_register(const char *s, const char *dir) "sender =3D %s, dir = =3D %s" +dbus_audio_put_buffer_out(size_t len) "len =3D %zu" +dbus_audio_read(size_t len) "len =3D %zu" + # audio.c audio_timer_start(int interval) "interval %d ms" audio_timer_stop(void) "" diff --git a/qemu-options.hx b/qemu-options.hx index 977e0873a12c..7d4751094783 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -659,6 +659,9 @@ DEF("audiodev", HAS_ARG, QEMU_OPTION_audiodev, #endif #ifdef CONFIG_SPICE "-audiodev spice,id=3Did[,prop[=3Dvalue][,...]]\n" +#endif +#ifdef CONFIG_DBUS_DISPLAY + "-audiodev dbus,id=3Did[,prop[=3Dvalue][,...]]\n" #endif "-audiodev wav,id=3Did[,prop[=3Dvalue][,...]]\n" " path=3D path of wav file to record\n", diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index 0f0ae92e4d57..aff645220c88 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -375,4 +375,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072507; cv=none; d=zohomail.com; s=zohoarc; b=GeUaK/1Dwwcg6ez+8FYlL5rOfzMLga95IH2d8nPKIOulUBOFeUSnhSdJRWA8NBQVduQABJy+xl/HwRnaclJl8SAYnQLk4dWFl+oFZqTjAILDECnre7DXIfec38B3NGwT6epL5UVWRrnLz/aVsGIpZ5lC01gm3Sg6JRBJflPYkdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072507; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5hiUfx+gBCUbUp8y/68Tfn2aLA/jeDrE7SScd4mmGms=; b=H5Vvp+hkHBk68iQ6b4NDpZl36dETvGxhwRPuZySZl4xBD6sBHPwVhfLW7vU7qTaByvKmhxcoDND3d0xubQgPqqCMyQLpCkSyslGowSkDVO4y9J9c9kP+NuxWgSF7JvQU5b7B4sHQu7M0GYPh7b5a8EmavqQR3J2kylH7rKLYUjc= 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 164007250755053.07923722372391; Mon, 20 Dec 2021 23:41:47 -0800 (PST) Received: from localhost ([::1]:51140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZmM-0006io-9N for importer@patchew.org; Tue, 21 Dec 2021 02:41:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZFg-0002oO-JP for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:08:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZFc-0002Wd-SR for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:07:59 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-135-UyBT3bfuOX-P4wl-Xm3bWg-1; Tue, 21 Dec 2021 02:07:42 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A00681006AA6; Tue, 21 Dec 2021 07:07:41 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8143E87945; Tue, 21 Dec 2021 07:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070469; 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=5hiUfx+gBCUbUp8y/68Tfn2aLA/jeDrE7SScd4mmGms=; b=ZtTR68bRcGlB5PJQmp7ntVsPHA0F+05/VHv0wmC9TkH3ABCt2eYYOkVCQ482NL5WObIKe0 XsAirbo3h+rlZs7S3/IZVx88f4wvO6FZ/24uBzo/KiUTaN7+5YDiypuFf8rkLq/xFV9FwI sSn4e/Zo3WRptG4qu9JlaB2+eaejxjE= X-MC-Unique: UyBT3bfuOX-P4wl-Xm3bWg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 30/36] ui/dbus: add clipboard interface Date: Tue, 21 Dec 2021 10:58:49 +0400 Message-Id: <20211221065855.142578-31-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072507821100001 From: Marc-Andr=C3=A9 Lureau Expose the clipboard API over D-Bus. See the interface documentation for further details. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/dbus.h | 14 ++ ui/dbus-clipboard.c | 457 +++++++++++++++++++++++++++++++++++++++++++ ui/dbus.c | 7 + ui/dbus-display1.xml | 97 +++++++++ ui/meson.build | 1 + ui/trace-events | 3 + 6 files changed, 579 insertions(+) create mode 100644 ui/dbus-clipboard.c diff --git a/ui/dbus.h b/ui/dbus.h index ca1f0f4ab94f..3e89eafcab6e 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -27,9 +27,16 @@ #include "qemu/dbus.h" #include "qom/object.h" #include "ui/console.h" +#include "ui/clipboard.h" =20 #include "dbus-display1.h" =20 +typedef struct DBusClipboardRequest { + GDBusMethodInvocation *invocation; + QemuClipboardType type; + guint timeout_id; +} DBusClipboardRequest; + struct DBusDisplay { Object parent; =20 @@ -44,6 +51,11 @@ struct DBusDisplay { QemuDBusDisplay1VM *iface; GPtrArray *consoles; GCancellable *add_client_cancellable; + + QemuClipboardPeer clipboard_peer; + QemuDBusDisplay1Clipboard *clipboard; + QemuDBusDisplay1Clipboard *clipboard_proxy; + DBusClipboardRequest clipboard_request[QEMU_CLIPBOARD_SELECTION__COUNT= ]; }; =20 #define TYPE_DBUS_DISPLAY "dbus-display" @@ -83,4 +95,6 @@ dbus_display_listener_get_bus_name(DBusDisplayListener *d= dl); extern const DisplayChangeListenerOps dbus_gl_dcl_ops; extern const DisplayChangeListenerOps dbus_dcl_ops; =20 +void dbus_clipboard_init(DBusDisplay *dpy); + #endif /* UI_DBUS_H_ */ diff --git a/ui/dbus-clipboard.c b/ui/dbus-clipboard.c new file mode 100644 index 000000000000..5843d26cd2cb --- /dev/null +++ b/ui/dbus-clipboard.c @@ -0,0 +1,457 @@ +/* + * QEMU DBus display + * + * Copyright (c) 2021 Marc-Andr=C3=A9 Lureau + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ +#include "qemu/osdep.h" +#include "qemu/dbus.h" +#include "qemu/main-loop.h" +#include "qom/object_interfaces.h" +#include "sysemu/sysemu.h" +#include "qapi/error.h" +#include "trace.h" + +#include "dbus.h" + +#define MIME_TEXT_PLAIN_UTF8 "text/plain;charset=3Dutf-8" + +static void +dbus_clipboard_complete_request( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation, + QemuClipboardInfo *info, + QemuClipboardType type) +{ + GVariant *v_data =3D g_variant_new_from_data( + G_VARIANT_TYPE("ay"), + info->types[type].data, + info->types[type].size, + TRUE, + (GDestroyNotify)qemu_clipboard_info_unref, + qemu_clipboard_info_ref(info)); + + qemu_dbus_display1_clipboard_complete_request( + dpy->clipboard, invocation, + MIME_TEXT_PLAIN_UTF8, v_data); +} + +static void +dbus_clipboard_update_info(DBusDisplay *dpy, QemuClipboardInfo *info) +{ + bool self_update =3D info->owner =3D=3D &dpy->clipboard_peer; + const char *mime[QEMU_CLIPBOARD_TYPE__COUNT + 1] =3D { 0, }; + DBusClipboardRequest *req; + int i =3D 0; + + if (info->owner =3D=3D NULL) { + if (dpy->clipboard_proxy) { + qemu_dbus_display1_clipboard_call_release( + dpy->clipboard_proxy, + info->selection, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + return; + } + + if (self_update || !info->has_serial) { + return; + } + + req =3D &dpy->clipboard_request[info->selection]; + if (req->invocation && info->types[req->type].data) { + dbus_clipboard_complete_request(dpy, req->invocation, info, req->t= ype); + g_clear_object(&req->invocation); + g_source_remove(req->timeout_id); + req->timeout_id =3D 0; + return; + } + + if (info->types[QEMU_CLIPBOARD_TYPE_TEXT].available) { + mime[i++] =3D MIME_TEXT_PLAIN_UTF8; + } + + if (i > 0) { + if (dpy->clipboard_proxy) { + qemu_dbus_display1_clipboard_call_grab( + dpy->clipboard_proxy, + info->selection, + info->serial, + mime, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + } + } +} + +static void +dbus_clipboard_reset_serial(DBusDisplay *dpy) +{ + if (dpy->clipboard_proxy) { + qemu_dbus_display1_clipboard_call_register( + dpy->clipboard_proxy, + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, NULL, NULL); + } +} + +static void +dbus_clipboard_notify(Notifier *notifier, void *data) +{ + DBusDisplay *dpy =3D + container_of(notifier, DBusDisplay, clipboard_peer.notifier); + QemuClipboardNotify *notify =3D data; + + switch (notify->type) { + case QEMU_CLIPBOARD_UPDATE_INFO: + dbus_clipboard_update_info(dpy, notify->info); + return; + case QEMU_CLIPBOARD_RESET_SERIAL: + dbus_clipboard_reset_serial(dpy); + return; + } +} + +static void +dbus_clipboard_qemu_request(QemuClipboardInfo *info, + QemuClipboardType type) +{ + DBusDisplay *dpy =3D container_of(info->owner, DBusDisplay, clipboard_= peer); + g_autofree char *mime =3D NULL; + g_autoptr(GVariant) v_data =3D NULL; + g_autoptr(GError) err =3D NULL; + const char *data =3D NULL; + const char *mimes[] =3D { MIME_TEXT_PLAIN_UTF8, NULL }; + size_t n; + + if (type !=3D QEMU_CLIPBOARD_TYPE_TEXT) { + /* unsupported atm */ + return; + } + + if (dpy->clipboard_proxy) { + if (!qemu_dbus_display1_clipboard_call_request_sync( + dpy->clipboard_proxy, + info->selection, + mimes, + G_DBUS_CALL_FLAGS_NONE, -1, &mime, &v_data, NULL, &err)) { + error_report("Failed to request clipboard: %s", err->message); + return; + } + + if (g_strcmp0(mime, MIME_TEXT_PLAIN_UTF8)) { + error_report("Unsupported returned MIME: %s", mime); + return; + } + + data =3D g_variant_get_fixed_array(v_data, &n, 1); + qemu_clipboard_set_data(&dpy->clipboard_peer, info, type, + n, data, true); + } +} + +static void +dbus_clipboard_request_cancelled(DBusClipboardRequest *req) +{ + if (!req->invocation) { + return; + } + + g_dbus_method_invocation_return_error( + req->invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Cancelled clipboard request"); + + g_clear_object(&req->invocation); + g_source_remove(req->timeout_id); + req->timeout_id =3D 0; +} + +static void +dbus_clipboard_unregister_proxy(DBusDisplay *dpy) +{ + const char *name =3D NULL; + int i; + + for (i =3D 0; i < G_N_ELEMENTS(dpy->clipboard_request); ++i) { + dbus_clipboard_request_cancelled(&dpy->clipboard_request[i]); + } + + if (!dpy->clipboard_proxy) { + return; + } + + name =3D g_dbus_proxy_get_name(G_DBUS_PROXY(dpy->clipboard_proxy)); + trace_dbus_clipboard_unregister(name); + g_clear_object(&dpy->clipboard_proxy); +} + +static void +dbus_on_clipboard_proxy_name_owner_changed( + DBusDisplay *dpy, + GObject *object, + GParamSpec *pspec) +{ + dbus_clipboard_unregister_proxy(dpy); +} + +static gboolean +dbus_clipboard_register( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation) +{ + g_autoptr(GError) err =3D NULL; + const char *name =3D NULL; + + if (dpy->clipboard_proxy) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Clipboard peer already registered!"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + dpy->clipboard_proxy =3D + qemu_dbus_display1_clipboard_proxy_new_sync( + g_dbus_method_invocation_get_connection(invocation), + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + g_dbus_method_invocation_get_sender(invocation), + "/org/qemu/Display1/Clipboard", + NULL, + &err); + if (!dpy->clipboard_proxy) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Failed to setup proxy: %s", err->message); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + name =3D g_dbus_proxy_get_name(G_DBUS_PROXY(dpy->clipboard_proxy)); + trace_dbus_clipboard_register(name); + + g_object_connect(dpy->clipboard_proxy, + "swapped-signal::notify::g-name-owner", + dbus_on_clipboard_proxy_name_owner_changed, dpy, + NULL); + qemu_clipboard_reset_serial(); + + qemu_dbus_display1_clipboard_complete_register(dpy->clipboard, invocat= ion); + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_clipboard_check_caller(DBusDisplay *dpy, GDBusMethodInvocation *invoc= ation) +{ + if (!dpy->clipboard_proxy || + g_strcmp0(g_dbus_proxy_get_name(G_DBUS_PROXY(dpy->clipboard_proxy)= ), + g_dbus_method_invocation_get_sender(invocation))) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Unregistered caller"); + return FALSE; + } + + return TRUE; +} + +static gboolean +dbus_clipboard_unregister( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation) +{ + if (!dbus_clipboard_check_caller(dpy, invocation)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } + + dbus_clipboard_unregister_proxy(dpy); + + qemu_dbus_display1_clipboard_complete_unregister( + dpy->clipboard, invocation); + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_clipboard_grab( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation, + gint arg_selection, + guint arg_serial, + const gchar *const *arg_mimes) +{ + QemuClipboardSelection s =3D arg_selection; + g_autoptr(QemuClipboardInfo) info =3D NULL; + + if (!dbus_clipboard_check_caller(dpy, invocation)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (s >=3D QEMU_CLIPBOARD_SELECTION__COUNT) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Invalid clipboard selection: %d", arg_selection); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + info =3D qemu_clipboard_info_new(&dpy->clipboard_peer, s); + if (g_strv_contains(arg_mimes, MIME_TEXT_PLAIN_UTF8)) { + info->types[QEMU_CLIPBOARD_TYPE_TEXT].available =3D true; + } + info->serial =3D arg_serial; + info->has_serial =3D true; + if (qemu_clipboard_check_serial(info, true)) { + qemu_clipboard_update(info); + } else { + trace_dbus_clipboard_grab_failed(); + } + + qemu_dbus_display1_clipboard_complete_grab(dpy->clipboard, invocation); + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_clipboard_release( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation, + gint arg_selection) +{ + if (!dbus_clipboard_check_caller(dpy, invocation)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } + + qemu_clipboard_peer_release(&dpy->clipboard_peer, arg_selection); + + qemu_dbus_display1_clipboard_complete_release(dpy->clipboard, invocati= on); + return DBUS_METHOD_INVOCATION_HANDLED; +} + +static gboolean +dbus_clipboard_request_timeout(gpointer user_data) +{ + dbus_clipboard_request_cancelled(user_data); + return G_SOURCE_REMOVE; +} + +static gboolean +dbus_clipboard_request( + DBusDisplay *dpy, + GDBusMethodInvocation *invocation, + gint arg_selection, + const gchar *const *arg_mimes) +{ + QemuClipboardSelection s =3D arg_selection; + QemuClipboardType type =3D QEMU_CLIPBOARD_TYPE_TEXT; + QemuClipboardInfo *info =3D NULL; + + if (!dbus_clipboard_check_caller(dpy, invocation)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (s >=3D QEMU_CLIPBOARD_SELECTION__COUNT) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Invalid clipboard selection: %d", arg_selection); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (dpy->clipboard_request[s].invocation) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Pending request"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + info =3D qemu_clipboard_info(s); + if (!info || !info->owner || info->owner =3D=3D &dpy->clipboard_peer) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Empty clipboard"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (!g_strv_contains(arg_mimes, MIME_TEXT_PLAIN_UTF8) || + !info->types[type].available) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Unhandled MIME types requested"); + return DBUS_METHOD_INVOCATION_HANDLED; + } + + if (info->types[type].data) { + dbus_clipboard_complete_request(dpy, invocation, info, type); + } else { + qemu_clipboard_request(info, type); + + dpy->clipboard_request[s].invocation =3D g_object_ref(invocation); + dpy->clipboard_request[s].type =3D type; + dpy->clipboard_request[s].timeout_id =3D + g_timeout_add_seconds(5, dbus_clipboard_request_timeout, + &dpy->clipboard_request[s]); + } + + return DBUS_METHOD_INVOCATION_HANDLED; +} + +void +dbus_clipboard_init(DBusDisplay *dpy) +{ + g_autoptr(GDBusObjectSkeleton) clipboard =3D NULL; + + assert(!dpy->clipboard); + + clipboard =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_ROOT "/Clipboar= d"); + dpy->clipboard =3D qemu_dbus_display1_clipboard_skeleton_new(); + g_object_connect(dpy->clipboard, + "swapped-signal::handle-register", + dbus_clipboard_register, dpy, + "swapped-signal::handle-unregister", + dbus_clipboard_unregister, dpy, + "swapped-signal::handle-grab", + dbus_clipboard_grab, dpy, + "swapped-signal::handle-release", + dbus_clipboard_release, dpy, + "swapped-signal::handle-request", + dbus_clipboard_request, dpy, + NULL); + + g_dbus_object_skeleton_add_interface( + G_DBUS_OBJECT_SKELETON(clipboard), + G_DBUS_INTERFACE_SKELETON(dpy->clipboard)); + g_dbus_object_manager_server_export(dpy->server, clipboard); + dpy->clipboard_peer.name =3D "dbus"; + dpy->clipboard_peer.notifier.notify =3D dbus_clipboard_notify; + dpy->clipboard_peer.request =3D dbus_clipboard_qemu_request; + qemu_clipboard_peer_register(&dpy->clipboard_peer); +} diff --git a/ui/dbus.c b/ui/dbus.c index d24f704d4662..4f0bc293aaa0 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" #include "qemu/dbus.h" +#include "qemu/main-loop.h" #include "qemu/option.h" #include "qom/object_interfaces.h" #include "sysemu/sysemu.h" @@ -70,6 +71,8 @@ dbus_display_init(Object *o) g_dbus_object_skeleton_add_interface( vm, G_DBUS_INTERFACE_SKELETON(dd->iface)); g_dbus_object_manager_server_export(dd->server, vm); + + dbus_clipboard_init(dd); } =20 static void @@ -77,6 +80,9 @@ dbus_display_finalize(Object *o) { DBusDisplay *dd =3D DBUS_DISPLAY(o); =20 + qemu_clipboard_peer_unregister(&dd->clipboard_peer); + g_clear_object(&dd->clipboard); + g_clear_object(&dd->server); g_clear_pointer(&dd->consoles, g_ptr_array_unref); if (dd->add_client_cancellable) { @@ -294,6 +300,7 @@ set_audiodev(Object *o, const char *str, Error **errp) dd->audiodev =3D g_strdup(str); } =20 + static int get_gl_mode(Object *o, Error **errp) { diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index aff645220c88..767562ad1ea3 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -376,6 +376,103 @@ =20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ui/meson.build b/ui/meson.build index 8982ab63c4df..64286ba1503a 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -82,6 +82,7 @@ if dbus_display '--generate-c-code', '@BASENAME@= ']) dbus_ss.add(when: [gio, pixman, opengl, 'CONFIG_GIO'], if_true: [files( + 'dbus-chardev.c', 'dbus-clipboard.c', 'dbus-console.c', 'dbus-error.c', --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072666; cv=none; d=zohomail.com; s=zohoarc; b=QLAXppGeOKRZiGUrVSkY+qyp+ZYZjNk4bB9Ylxlb6N5Cfzytrs8omVPb7fPUWwQFknvS/z4mVTkidREa7meaAZvEIfUJGEhqPihbzJVwIIf8FXHu3GNJU7WPQz+glCXnwXpIPKbOO++xpGu9T/04LeusrGbJ4ngnoHhtA7TfvVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072666; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/I9K6kD8hofZ3E5tucSZC0k9jpSA/jYzjNFhe+WbYHs=; b=Y7XzqhC+aKu93nowOD+QgmYRbr12cgdpE6mfGe/yV+R7MCxR71A5aErA83nUCBrWyT7p5dpl8el1+40hCBZzuJ2PNXftG6JZNopM0o7SG6FXwqXY1afNjJgczKOInQYa46n8CiMtTnd3m4Mjw7/sLjRVVdvSLLFeX4g0vn+UuRM= 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 1640072666755542.072371751691; Mon, 20 Dec 2021 23:44:26 -0800 (PST) Received: from localhost ([::1]:59680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZov-000476-NE for importer@patchew.org; Tue, 21 Dec 2021 02:44:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZGU-0003Fg-Uo for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:08:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZGT-0002aE-EM for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:08:50 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-479-qAv62ITnNd284zSF3DRgeA-1; Tue, 21 Dec 2021 02:08:45 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70D8A802C92; Tue, 21 Dec 2021 07:08:44 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 273C37ED9D; Tue, 21 Dec 2021 07:08:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070528; 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=/I9K6kD8hofZ3E5tucSZC0k9jpSA/jYzjNFhe+WbYHs=; b=DHd8N6CxHfAvRjSlb2i0tne1nPFEmmdOllRH9udGeTU9P8Xah7nCYk5O98dDBybFLvnxgG xVM5/fkB8SKxIO44tzti6YeatTTP+i5xNmufzsCnJ9aO0dzY8EtKkjkBzn1r8VrOIeGADV 7Sm0Lp79fbcp2Qa4Jaa/XvCnXPhHyjg= X-MC-Unique: qAv62ITnNd284zSF3DRgeA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 35/36] ui/dbus: register D-Bus VC handler Date: Tue, 21 Dec 2021 10:58:54 +0400 Message-Id: <20211221065855.142578-36-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072667165100001 From: Marc-Andr=C3=A9 Lureau Export the default consoles over the D-Bus chardev. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- ui/dbus.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/ui/dbus.c b/ui/dbus.c index 41f1716f255a..b2c1c9fb522c 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -357,6 +357,57 @@ dbus_display_class_init(ObjectClass *oc, void *data) get_gl_mode, set_gl_mode); } =20 +#define TYPE_CHARDEV_VC "chardev-vc" + +typedef struct DBusVCClass { + DBusChardevClass parent_class; + + void (*parent_parse)(QemuOpts *opts, ChardevBackend *b, Error **errp); +} DBusVCClass; + +DECLARE_CLASS_CHECKERS(DBusVCClass, DBUS_VC, + TYPE_CHARDEV_VC) + +static void +dbus_vc_parse(QemuOpts *opts, ChardevBackend *backend, + Error **errp) +{ + DBusVCClass *klass =3D DBUS_VC_CLASS(object_class_by_name(TYPE_CHARDEV= _VC)); + const char *name =3D qemu_opt_get(opts, "name"); + const char *id =3D qemu_opts_id(opts); + + if (name =3D=3D NULL) { + if (g_str_has_prefix(id, "compat_monitor")) { + name =3D "org.qemu.monitor.hmp.0"; + } else if (g_str_has_prefix(id, "serial")) { + name =3D "org.qemu.console.serial.0"; + } else { + name =3D ""; + } + if (!qemu_opt_set(opts, "name", name, errp)) { + return; + } + } + + klass->parent_parse(opts, backend, errp); +} + +static void +dbus_vc_class_init(ObjectClass *oc, void *data) +{ + DBusVCClass *klass =3D DBUS_VC_CLASS(oc); + ChardevClass *cc =3D CHARDEV_CLASS(oc); + + klass->parent_parse =3D cc->parse; + cc->parse =3D dbus_vc_parse; +} + +static const TypeInfo dbus_vc_type_info =3D { + .name =3D TYPE_CHARDEV_VC, + .parent =3D TYPE_CHARDEV_DBUS, + .class_init =3D dbus_vc_class_init, +}; + static void early_dbus_init(DisplayOptions *opts) { @@ -370,6 +421,8 @@ early_dbus_init(DisplayOptions *opts) =20 display_opengl =3D 1; } + + type_register(&dbus_vc_type_info); } =20 static void --=20 2.34.1.8.g35151cf07204 From nobody Sat Feb 7 05:37:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640072787; cv=none; d=zohomail.com; s=zohoarc; b=cHkPMWYmFoF3eRf+BSkUzaljTFgTykhuXKPmo8EhxzkY4sBC5Eg9qt6ZtAcsqnXakc9s60jHsgb50UqElgRe+2zgq1MSDo60WWs2vJbs8Copb8yFQ/KPYScoQYZLD1kFMi4MNksmkjUNBPuYY35WrCYAtv6Z5J4oyLb5qyacLyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640072787; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g9GuePvfcQNUX4Ocvb+3skfoRvEJi1UaU0Qp/d2hX+Q=; b=RyWWYqcWJZIoer07kmd9h4VVoDkIvMmP0Zrt/1SfN4tzDbvC8zJ/AvnMMhPjNcDLFIc2A2uJ77jZvAXQWtzg/HvKKIs5ZefrIFR+mL0ABMMxmQKeWkgt/yY7WwIFdONjL/y+xFoiRcquhU3d4R4U3ZSBVcv2nzGAuTSLCf0R+S0= 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 1640072787147591.514902362489; Mon, 20 Dec 2021 23:46:27 -0800 (PST) Received: from localhost ([::1]:34846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzZqs-0006Ry-4B for importer@patchew.org; Tue, 21 Dec 2021 02:46:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZGa-0003Md-Q3 for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:08:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZGZ-0002bE-FO for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:08:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-277-dzPFKmk6PsyG1fSnMffbKQ-1; Tue, 21 Dec 2021 02:08:53 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4893B1006AA6; Tue, 21 Dec 2021 07:08:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F03F77451; Tue, 21 Dec 2021 07:08:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640070535; 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=g9GuePvfcQNUX4Ocvb+3skfoRvEJi1UaU0Qp/d2hX+Q=; b=QZBhFrTAVU837X3fFNEb0XhXXgtdXUql5zxRYy3jn6CjzdLN6sxEJps6DCzek+WVHPXg0y C/ZL+cBHsnD1da2rigoH4E9YnYMCZTE/jGwpUp7HynngIhbmqZZvZd7uQ4DVeP++h6en8B Xkg1tNfp8KBYMB0OAv4IOyiMKRiaV6Y= X-MC-Unique: dzPFKmk6PsyG1fSnMffbKQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Subject: [PULL v2 36/36] MAINTAINERS: update D-Bus section Date: Tue, 21 Dec 2021 10:58:55 +0400 Message-Id: <20211221065855.142578-37-marcandre.lureau@redhat.com> In-Reply-To: <20211221065855.142578-1-marcandre.lureau@redhat.com> References: <20211221065855.142578-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: peter.maydell@linaro.org, richard.henderson@linaro.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640072789354100001 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Gerd Hoffmann --- MAINTAINERS | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1de6ce6e44eb..dc4b6f7c1e06 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2873,11 +2873,15 @@ D-Bus M: Marc-Andr=C3=A9 Lureau S: Maintained F: backends/dbus-vmstate.c -F: tests/dbus-vmstate* +F: ui/dbus* +F: audio/dbus* F: util/dbus.c +F: include/ui/dbus* F: include/qemu/dbus.h -F: docs/interop/dbus.rst -F: docs/interop/dbus-vmstate.rst +F: docs/interop/dbus* +F: docs/sphinx/dbus* +F: docs/sphinx/fakedbusdoc.py +F: tests/qtest/dbus* =20 Seccomp M: Eduardo Otubo --=20 2.34.1.8.g35151cf07204