From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686052889; cv=none; d=zohomail.com; s=zohoarc; b=dcx/5cCwQH14UWleQ/h1JGgRgS421AIeqxyeTuD0DzB90clngCF4Ci4dG/0jn6506BgxRpzdNCXbHuDuBQE9PKVG03ZJiAviUXm/O21xUrDG24qNuO6W8iEQWAquIzavuNLwS5188of+RExnZAZ72oavmtSkpOt0O6uIDkImWOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686052889; 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=fREygsgNwI2Tm+JkeLXrtqpNbNlMTEYFpIoh3ScT0qE=; b=MgcDeqTBlDJnonj+s+JJICuUOoO9x7K9wpPnK/m2dwO33jhmNke/LmUO/GFH4ssQKL8dnbtUOIqP3RuREBDoDJbWu9fjBkLHveiQHbl9Q2f3O1xU03ra7ZASYijxLSBSpyJdtiATZkBBvRBe5elKYIuolJxnH2DjNonRG316Di8= 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 168605288976515.624779205275217; Tue, 6 Jun 2023 05:01:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VJK-00006E-Nv; Tue, 06 Jun 2023 07:57:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJJ-00005o-0N for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJE-0005fO-9A for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:12 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-393-iZYogJEDPASNozZSG3dFkQ-1; Tue, 06 Jun 2023 07:57:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB3C23C0CEEF for ; Tue, 6 Jun 2023 11:57:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D56A40CFD46; Tue, 6 Jun 2023 11:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052627; 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=fREygsgNwI2Tm+JkeLXrtqpNbNlMTEYFpIoh3ScT0qE=; b=Crbc0LozS+tPoA4d9JBupHvJbK6tm+6sUvEeZlb42L823JQQAgKnol5fj4/5v/Poc32lnM UhP5n8I3WULy3LFP3IJwREHIbRN500R8yJfF+fN9ByJ3WUCZrqT7+/4aQc2mKof4ROhmyl H6NQz3P2QXuU9OUl/V44mdSyJ7RzB00= X-MC-Unique: iZYogJEDPASNozZSG3dFkQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 01/21] ui/egl: export qemu_egl_get_error_string() Date: Tue, 6 Jun 2023 15:56:38 +0400 Message-Id: <20230606115658.677673-2-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686052904666100001 From: Marc-Andr=C3=A9 Lureau It will be used from other units. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/egl-helpers.h | 2 ++ ui/egl-helpers.c | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 53d953ddf4..2cf6633ad2 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -67,4 +67,6 @@ bool qemu_egl_has_dmabuf(void); =20 bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp); =20 +const char *qemu_egl_get_error_string(void); + #endif /* EGL_HELPERS_H */ diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 4203163ace..3c94b3f216 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -28,8 +28,7 @@ DisplayGLMode qemu_egl_mode; =20 /* ------------------------------------------------------------------ */ =20 -#if defined(CONFIG_X11) || defined(CONFIG_GBM) -static const char *egl_get_error_string(void) +const char *qemu_egl_get_error_string(void) { EGLint error =3D eglGetError(); =20 @@ -68,7 +67,6 @@ static const char *egl_get_error_string(void) return "Unknown EGL error"; } } -#endif =20 static void egl_fb_delete_texture(egl_fb *fb) { @@ -482,20 +480,20 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, =20 qemu_egl_display =3D qemu_egl_get_display(dpy, platform); if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { - error_report("egl: eglGetDisplay failed: %s", egl_get_error_string= ()); + error_report("egl: eglGetDisplay failed: %s", qemu_egl_get_error_s= tring()); return -1; } =20 b =3D eglInitialize(qemu_egl_display, &major, &minor); if (b =3D=3D EGL_FALSE) { - error_report("egl: eglInitialize failed: %s", egl_get_error_string= ()); + error_report("egl: eglInitialize failed: %s", qemu_egl_get_error_s= tring()); return -1; } =20 b =3D eglBindAPI(gles ? EGL_OPENGL_ES_API : EGL_OPENGL_API); if (b =3D=3D EGL_FALSE) { error_report("egl: eglBindAPI failed (%s mode): %s", - gles ? "gles" : "core", egl_get_error_string()); + gles ? "gles" : "core", qemu_egl_get_error_string()); return -1; } =20 @@ -504,7 +502,7 @@ static int qemu_egl_init_dpy(EGLNativeDisplayType dpy, &qemu_egl_config, 1, &n); if (b =3D=3D EGL_FALSE || n !=3D 1) { error_report("egl: eglChooseConfig failed (%s mode): %s", - gles ? "gles" : "core", egl_get_error_string()); + gles ? "gles" : "core", qemu_egl_get_error_string()); return -1; } =20 --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686053065; cv=none; d=zohomail.com; s=zohoarc; b=MRR9N8E9D8PqokVe56yOKoiULkyXTXfnEs1MrYP72TfqN3cp1OI63IlTo+yqnHAbrqIvt0IrScuP7gCVSc8lpw/Jwo+ChDisi/STf+Nz4j5FezDGrxn61gsB2puI5dSMSMD1hsFnua/2iJl5uU/SI/FabZDeUX5JNUtfH9ypvK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686053065; 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=m0bCb//3S1YWVtZD/CuiOvQZEwkrfi94l77q2yPHDB0=; b=QYznEJMJz+h/WkMQ2eJYF1lDCaYB6OWOFi866i2cuYj8ODpQwHxI5+9Mhyt0y5CwN3wOM2LSh92IE+/rWY0G2CAMCa1+oxLG8F3OMfdqCWl4BeY331TGsjabcU8hFT02z6NceyZxPZoCh5x2xJXdYJncbDSm7vD2YxF8mbIOVhc= 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 1686053065038619.0709823679442; Tue, 6 Jun 2023 05:04:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VJM-00006c-CW; Tue, 06 Jun 2023 07:57:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJL-00006O-Be for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJI-0005fo-GI for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:15 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-657-70nkkhxYOQSa6d1CusygRg-1; Tue, 06 Jun 2023 07:57:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFA8F282CCA7 for ; Tue, 6 Jun 2023 11:57:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34F942166B25; Tue, 6 Jun 2023 11:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052631; 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=m0bCb//3S1YWVtZD/CuiOvQZEwkrfi94l77q2yPHDB0=; b=cVlK4r+6AwR0uoREmdkJz0kreqZ8iptw7wbLlN06ZPzn348wcL5zapsx4vjZVNy8HRmAV3 4Rs1k6B2AjHA1aYcjbVHmB1aO0uOj1MCEE4sgfVlO1JbDOC6yNIQ+QlFnE/2zpYa2Co6wb He6eQWquFOYsL/pVefaRDadm8Oy9yns= X-MC-Unique: 70nkkhxYOQSa6d1CusygRg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 02/21] ui/egl: fix make_context_current() callback return value Date: Tue, 6 Jun 2023 15:56:39 +0400 Message-Id: <20230606115658.677673-3-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686053067592100005 From: Marc-Andr=C3=A9 Lureau eglMakeCurrent() returns 1/EGL_TRUE on success. This is not what the callback expects, where 0 indicates success. While at it, print the EGL error to ease debugging. As with virgl_renderer_callbacks, the return value is now checked since version >=3D 4: https://gitlab.freedesktop.org/virgl/virglrenderer/-/commit/7f09e6bf0c6ceea= 6727bd0049781256a28cab0e5 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/egl-context.c | 10 ++++++++-- ui/gtk-egl.c | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ui/egl-context.c b/ui/egl-context.c index eb5f520fc4..9e0df466f3 100644 --- a/ui/egl-context.c +++ b/ui/egl-context.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "ui/egl-context.h" =20 QEMUGLContext qemu_egl_create_context(DisplayGLCtx *dgc, @@ -32,6 +33,11 @@ void qemu_egl_destroy_context(DisplayGLCtx *dgc, QEMUGLC= ontext ctx) int qemu_egl_make_context_current(DisplayGLCtx *dgc, QEMUGLContext ctx) { - return eglMakeCurrent(qemu_egl_display, - EGL_NO_SURFACE, EGL_NO_SURFACE, ctx); + if (!eglMakeCurrent(qemu_egl_display, + EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) { + error_report("egl: eglMakeCurrent failed: %s", qemu_egl_get_error_= string()); + return -1; + } + + return 0; } diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 19130041bc..f8b5901ce9 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -368,6 +368,11 @@ int gd_egl_make_current(DisplayGLCtx *dgc, { VirtualConsole *vc =3D container_of(dgc, VirtualConsole, gfx.dgc); =20 - return eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, - vc->gfx.esurface, ctx); + if (!eglMakeCurrent(qemu_egl_display, vc->gfx.esurface, + vc->gfx.esurface, ctx)) { + error_report("egl: eglMakeCurrent failed: %s", qemu_egl_get_error_= string()); + return -1; + } + + return 0; } --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686052683; cv=none; d=zohomail.com; s=zohoarc; b=l7sMIQOLKdBX7fa/WpfHvMiFYTQ8sP9PVJryB2+cEjAp0YmpQ5zHNSNiPcUZAvcBe1LsObLkO5+4xbkV/K7uCw6L1Z6XJyrsVly7x+8byoSgfJeI2FsyCAvtp6b+el5+VI8oqdFhcS3JUzUFdceVGNqMAmAzYlsQa5jQrNSYP4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686052683; 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=QDwg2cFQzvvccTpQ1pyTSM2hPkpUNWjnPtpP00nmGz8=; b=OBjemyKHv2qnVGRK6G6EPK2BLwf66gxUdWQkTtE5noyh8sQRXd6eJvX0f+Oouo52QVZ2CjPy34xO1QjIAAdTPdR2gAkLQgTzPw7wJVJwoMpPdPV3PW1HTmsF7AAjcwuGJsy0MkqI5lURzpKtKGpL1qQe8Fv6xEZegtdpOjSDQrI= 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 168605268342225.519207134690987; Tue, 6 Jun 2023 04:58:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VJS-00007s-N6; Tue, 06 Jun 2023 07:57:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJQ-00007F-Cr for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJO-0005gy-1D for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:20 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-J3H5oavsMEmP9-ZKfMTRGg-1; Tue, 06 Jun 2023 07:57:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1E9FA1C068E7 for ; Tue, 6 Jun 2023 11:57:14 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE8E27AE4; Tue, 6 Jun 2023 11:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052637; 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=QDwg2cFQzvvccTpQ1pyTSM2hPkpUNWjnPtpP00nmGz8=; b=VeslC3sNrzz7ThHVztZhAyF0STkZ35Kex3eOYrEi1HTkrdTd3+UhP0grOwfTZll6JiCixH C74SkElpC992jlN7vFCzHqy4vyBLA0/rTEuuJZYWsx/KPU/DZ9REK4JnGtos8p8O4qeIaJ M5pE/1yYA9V0mV88jbZtTwoaMSYQe20= X-MC-Unique: J3H5oavsMEmP9-ZKfMTRGg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 03/21] ui/dbus: compile without gio/gunixfdlist.h Date: Tue, 6 Jun 2023 15:56:40 +0400 Message-Id: <20230606115658.677673-4-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686052685187100007 From: Marc-Andr=C3=A9 Lureau D-Bus on windows doesn't support fd-passing. Let's isolate the fdlist-related code as a first step, before adding Windows support, using another mechanism. Signed-off-by: Marc-Andr=C3=A9 Lureau --- audio/dbusaudio.c | 7 +++++++ ui/dbus-chardev.c | 6 ++++++ ui/dbus-console.c | 8 ++++++++ ui/dbus-listener.c | 2 ++ 4 files changed, 23 insertions(+) diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index fece74f78c..de59467d9e 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -29,7 +29,10 @@ #include "qemu/timer.h" #include "qemu/dbus.h" =20 +#ifdef G_OS_UNIX #include +#endif + #include "ui/dbus-display1.h" =20 #define AUDIO_CAP "dbus" @@ -419,6 +422,7 @@ dbus_audio_fini(void *opaque) g_free(da); } =20 +#ifdef G_OS_UNIX static void listener_out_vanished_cb(GDBusConnection *connection, gboolean remote_peer_vanished, @@ -591,6 +595,7 @@ dbus_audio_register_in_listener(AudioState *s, return dbus_audio_register_listener(s, invocation, fd_list, arg_listener, false); } +#endif =20 static void dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, boo= l p2p) @@ -605,12 +610,14 @@ dbus_audio_set_server(AudioState *s, GDBusObjectManag= erServer *server, bool p2p) =20 da->audio =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_AUDIO_PATH); da->iface =3D qemu_dbus_display1_audio_skeleton_new(); +#ifdef G_OS_UNIX 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); +#endif =20 g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(da->audio), G_DBUS_INTERFACE_SKELETON(da->ifa= ce)); diff --git a/ui/dbus-chardev.c b/ui/dbus-chardev.c index 940ef937cd..7154d81a9a 100644 --- a/ui/dbus-chardev.c +++ b/ui/dbus-chardev.c @@ -27,7 +27,9 @@ #include "qemu/config-file.h" #include "qemu/option.h" =20 +#ifdef G_OS_UNIX #include +#endif =20 #include "dbus.h" =20 @@ -108,6 +110,7 @@ dbus_chardev_init(DBusDisplay *dpy) dbus_display_chardev_foreach, dpy); } =20 +#ifdef G_OS_UNIX static gboolean dbus_chr_register( DBusChardev *dc, @@ -145,6 +148,7 @@ dbus_chr_register( qemu_dbus_display1_chardev_complete_register(object, invocation, NULL); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 static gboolean dbus_chr_send_break( @@ -175,8 +179,10 @@ dbus_chr_open(Chardev *chr, ChardevBackend *backend, dc->iface =3D qemu_dbus_display1_chardev_skeleton_new(); g_object_set(dc->iface, "name", backend->u.dbus.data->name, NULL); g_object_connect(dc->iface, +#ifdef G_OS_UNIX "swapped-signal::handle-register", dbus_chr_register, dc, +#endif "swapped-signal::handle-send-break", dbus_chr_send_break, dc, NULL); diff --git a/ui/dbus-console.c b/ui/dbus-console.c index f77bc49d2e..fd50fd3200 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -28,7 +28,9 @@ #include "ui/kbd-state.h" #include "trace.h" =20 +#ifdef G_OS_UNIX #include +#endif =20 #include "dbus.h" =20 @@ -160,6 +162,7 @@ dbus_display_console_class_init(DBusDisplayConsoleClass= *klass) gobject_class->dispose =3D dbus_display_console_dispose; } =20 +#ifdef G_OS_UNIX static void listener_vanished_cb(DBusDisplayListener *listener) { @@ -171,6 +174,7 @@ listener_vanished_cb(DBusDisplayListener *listener) g_hash_table_remove(ddc->listeners, name); qkbd_state_lift_all_keys(ddc->kbd); } +#endif =20 static gboolean dbus_console_set_ui_info(DBusDisplayConsole *ddc, @@ -204,6 +208,7 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 +#ifdef G_OS_UNIX static gboolean dbus_console_register_listener(DBusDisplayConsole *ddc, GDBusMethodInvocation *invocation, @@ -279,6 +284,7 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, trace_dbus_registered_listener(sender); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 static gboolean dbus_kbd_press(DBusDisplayConsole *ddc, @@ -467,8 +473,10 @@ dbus_display_console_new(DBusDisplay *display, QemuCon= sole *con) "device-address", device_addr, NULL); g_object_connect(ddc->iface, +#ifdef G_OS_UNIX "swapped-signal::handle-register-listener", dbus_console_register_listener, ddc, +#endif "swapped-signal::handle-set-uiinfo", dbus_console_set_ui_info, ddc, NULL); diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 23034eebf9..41597a0078 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -25,7 +25,9 @@ #include "qemu/error-report.h" #include "sysemu/sysemu.h" #include "dbus.h" +#ifdef G_OS_UNIX #include +#endif =20 #ifdef CONFIG_OPENGL #include "ui/shader.h" --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686052743; cv=none; d=zohomail.com; s=zohoarc; b=RUr0oH4zEWegQVQtuRSKzXqQSIESy2pnVKYvUzK3wciy5fbBSLB3Yi0lBzlsPLYZhej5uYJHzHmNMFychFCtVMMHnUJOIzq+g3/WcbpE3q2Ny0i4kUOOBX6xzATiqx02ehW2YnIRqBg2KO32+KmSZEnnrR0vf5m77D0kCaEUbEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686052743; 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=Xs7NCRO1NxyKtJ4YtgpLzRcmg5STsaVsT+hkKMwIY5w=; b=VWup2vfKVCQZzezpqROtrKWGJNqJpFGCtjt0I8Eralxsq0Zz+ROSAgZjKH+VgHdboc+Qy1EyPNl3qCbdulpuyURLY2jGFoiePx6Ru2AcQbztg6Gp+R/VKPWyEv/sPsnjqe1YkcVZlL9g1OuaaS0ZNIhMxtGBrTtvqdtZ7NBNj6o= 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 1686052743710896.8446443581432; Tue, 6 Jun 2023 04:59:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VJV-00008b-DP; Tue, 06 Jun 2023 07:57:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJT-00007v-Fx for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJQ-0005j5-V1 for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:23 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-84-QvoJ_1oiNo-3NU1Ih0ikCA-1; Tue, 06 Jun 2023 07:57:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADA0C185A78B for ; Tue, 6 Jun 2023 11:57:18 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3096140CFD47; Tue, 6 Jun 2023 11:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052640; 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=Xs7NCRO1NxyKtJ4YtgpLzRcmg5STsaVsT+hkKMwIY5w=; b=KJjaB33novGL2AlnYMF4iaFLAgkNs50Z0F5dGcCyZEEwMsxEVpnZ8Ur5u1iPFMg4Bl/UpG ZPo4pRj1YAvcPPIpq/cV1IxlUar6kueaMvPbxVT2Xv7kXnMLDFJgXH+uE16y5Qxt4qvbFI xMx2lLdXmhUOjnsGIJVWpmN3xNFMcf8= X-MC-Unique: QvoJ_1oiNo-3NU1Ih0ikCA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , John Snow , Cleber Rosa Subject: [PATCH 04/21] scripts: add a XML preprocessor script Date: Tue, 6 Jun 2023 15:56:41 +0400 Message-Id: <20230606115658.677673-5-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686052744406100002 From: Marc-Andr=C3=A9 Lureau gdbus-codegen doesn't support conditions or pre-processing. Rather than duplicating D-Bus interfaces for win32 adaptation, let's have a preprocess step, so we can have platform-specific interfaces. The python script is based on https://github.com/peitaosu/XML-Preprocessor, with bug fixes, some testing and replacing lxml dependency with the built-in xml module. This preprocessing syntax style is not very common, but is similar to the one provided by WiX (https://wixtoolset.org/docs/v3/overview/preprocess= or/) or wixl, that we adopted in QEMU for packaging the guest agent. Signed-off-by: Marc-Andr=C3=A9 Lureau --- MAINTAINERS | 1 + scripts/meson.build | 2 + scripts/xml-preprocess-test.py | 136 +++++++++++++++ scripts/xml-preprocess.py | 293 +++++++++++++++++++++++++++++++++ 4 files changed, 432 insertions(+) create mode 100644 scripts/xml-preprocess-test.py create mode 100755 scripts/xml-preprocess.py diff --git a/MAINTAINERS b/MAINTAINERS index 55668d6336..0119488583 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3194,6 +3194,7 @@ F: docs/interop/dbus* F: docs/sphinx/dbus* F: docs/sphinx/fakedbusdoc.py F: tests/qtest/dbus* +F: scripts/xml-preprocess* =20 Seccomp M: Daniel P. Berrange diff --git a/scripts/meson.build b/scripts/meson.build index 1c89e10a76..532277f5a2 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -1,3 +1,5 @@ if stap.found() install_data('qemu-trace-stap', install_dir: get_option('bindir')) endif + +test('xml-preprocess', files('xml-preprocess-test.py'), suite: ['unit']) diff --git a/scripts/xml-preprocess-test.py b/scripts/xml-preprocess-test.py new file mode 100644 index 0000000000..dd92579969 --- /dev/null +++ b/scripts/xml-preprocess-test.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2023 Red Hat, Inc. +# +# SPDX-License-Identifier: MIT +"""Unit tests for xml-preprocess""" + +import contextlib +import importlib +import os +import platform +import subprocess +import tempfile +import unittest +from io import StringIO + +xmlpp =3D importlib.import_module("xml-preprocess") + + +class TestXmlPreprocess(unittest.TestCase): + """Tests for xml-preprocess.Preprocessor""" + + def test_preprocess_xml(self): + with tempfile.NamedTemporaryFile(mode=3D"w", delete=3DFalse) as te= mp_file: + temp_file.write("") + temp_file_name =3D temp_file.name + result =3D xmlpp.preprocess_xml(temp_file_name) + self.assertEqual(result, "") + os.remove(temp_file_name) + + def test_save_xml(self): + with tempfile.NamedTemporaryFile(mode=3D"w", delete=3DFalse) as te= mp_file: + temp_file_name =3D temp_file.name + xmlpp.save_xml("", temp_file_name) + self.assertTrue(os.path.isfile(temp_file_name)) + os.remove(temp_file_name) + + def test_include(self): + with tempfile.NamedTemporaryFile(mode=3D"w", delete=3DFalse) as in= c_file: + inc_file.write("Content from included file") + inc_file_name =3D inc_file.name + xml_str =3D f"" + expected =3D "Content from included file" + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + os.remove(inc_file_name) + self.assertRaises(FileNotFoundError, xpp.preprocess, xml_str) + + def test_envvar(self): + os.environ["TEST_ENV_VAR"] =3D "TestValue" + xml_str =3D "$(env.TEST_ENV_VAR)" + expected =3D "TestValue" + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + self.assertRaises(KeyError, xpp.preprocess, "$(env.UNKNOWN)") + + def test_sys_var(self): + xml_str =3D "$(sys.ARCH)" + expected =3D f"{platform.architecture()[0]}" + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + self.assertRaises(KeyError, xpp.preprocess, "$(sys.UNKNOWN)") + + def test_cus_var(self): + xml_str =3D "$(var.USER)" + expected =3D "" + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + xml_str =3D "$(var.USER)" + expected =3D "FOO" + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + + def test_error_warning(self): + xml_str =3D "" + expected =3D "" + xpp =3D xmlpp.Preprocessor() + out =3D StringIO() + with contextlib.redirect_stdout(out): + result =3D xpp.preprocess(xml_str) + self.assertEqual(result, expected) + self.assertEqual(out.getvalue(), "[Warning]: test warn\n") + self.assertRaises(RuntimeError, xpp.preprocess, "") + + def test_cmd(self): + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess('= ') + self.assertEqual(result, "hello world") + self.assertRaises( + subprocess.CalledProcessError, + xpp.preprocess, '' + ) + + def test_foreach(self): + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess( + '$(var.x)' + ) + self.assertEqual(result, "abc") + + def test_if_elseif(self): + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess('ok') + self.assertEqual(result, "ok") + result =3D xpp.preprocess('ok') + self.assertEqual(result, "") + result =3D xpp.preprocess('okko<= /root>') + self.assertEqual(result, "ok") + result =3D xpp.preprocess('okko= ') + self.assertEqual(result, "ko") + result =3D xpp.preprocess( + 'okok2ko' + ) + self.assertEqual(result, "ok2") + result =3D xpp.preprocess( + 'okokko' + ) + self.assertEqual(result, "ko") + + def test_ifdef(self): + xpp =3D xmlpp.Preprocessor() + result =3D xpp.preprocess('okko') + self.assertEqual(result, "ko") + result =3D xpp.preprocess( + 'okko' + ) + self.assertEqual(result, "ok") + + +if __name__ =3D=3D "__main__": + unittest.main() diff --git a/scripts/xml-preprocess.py b/scripts/xml-preprocess.py new file mode 100755 index 0000000000..57f1d28912 --- /dev/null +++ b/scripts/xml-preprocess.py @@ -0,0 +1,293 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2017-2019 Tony Su +# Copyright (c) 2023 Red Hat, Inc. +# +# SPDX-License-Identifier: MIT +# +# Adapted from https://github.com/peitaosu/XML-Preprocessor +# +"""This is a XML Preprocessor which can be used to process your XML file b= efore +you use it, to process conditional statements, variables, iteration +statements, error/warning, execute command, etc. + +## XML Schema + +### Include Files +``` + +``` + +### Variables +``` +$(env.EnvironmentVariable) + +$(sys.SystemVariable) + +$(var.CustomVariable) +``` + +### Conditional Statements +``` + + + + + + + + + + + +``` + +### Iteration Statements +``` + + $(var.VARNAME) + +``` + +### Errors and Warnings +``` + + + +``` + +### Commands +``` + +``` +""" + +import os +import platform +import re +import subprocess +import sys +from typing import Optional +from xml.dom import minidom + + +class Preprocessor(): + """This class holds the XML preprocessing state""" + + def __init__(self): + self.sys_vars =3D { + "ARCH": platform.architecture()[0], + "SOURCE": os.path.abspath(__file__), + "CURRENT": os.getcwd(), + } + self.cus_vars =3D {} + + def _pp_include(self, xml_str: str) -> str: + include_regex =3D r"(<\?include([\w\s\\/.:_-]+)\s*\?>)" + matches =3D re.findall(include_regex, xml_str) + for group_inc, group_xml in matches: + inc_file_path =3D group_xml.strip() + with open(inc_file_path, "r", encoding=3D"utf-8") as inc_file: + inc_file_content =3D inc_file.read() + xml_str =3D xml_str.replace(group_inc, inc_file_content) + return xml_str + + def _pp_env_var(self, xml_str: str) -> str: + envvar_regex =3D r"(\$\(env\.(\w+)\))" + matches =3D re.findall(envvar_regex, xml_str) + for group_env, group_var in matches: + xml_str =3D xml_str.replace(group_env, os.environ[group_var]) + return xml_str + + def _pp_sys_var(self, xml_str: str) -> str: + sysvar_regex =3D r"(\$\(sys\.(\w+)\))" + matches =3D re.findall(sysvar_regex, xml_str) + for group_sys, group_var in matches: + xml_str =3D xml_str.replace(group_sys, self.sys_vars[group_var= ]) + return xml_str + + def _pp_cus_var(self, xml_str: str) -> str: + define_regex =3D r"(<\?define\s*(\w+)\s*=3D\s*([\w\s\"]+)\s*\?>)" + matches =3D re.findall(define_regex, xml_str) + for group_def, group_name, group_var in matches: + group_name =3D group_name.strip() + group_var =3D group_var.strip().strip("\"") + self.cus_vars[group_name] =3D group_var + xml_str =3D xml_str.replace(group_def, "") + cusvar_regex =3D r"(\$\(var\.(\w+)\))" + matches =3D re.findall(cusvar_regex, xml_str) + for group_cus, group_var in matches: + xml_str =3D xml_str.replace( + group_cus, + self.cus_vars.get(group_var, "") + ) + return xml_str + + def _pp_foreach(self, xml_str: str) -> str: + foreach_regex =3D r"(<\?foreach\s+(\w+)\s+in\s+([\w;]+)\s*\?>(.*)<= \?endforeach\?>)" + matches =3D re.findall(foreach_regex, xml_str) + for group_for, group_name, group_vars, group_text in matches: + group_texts =3D "" + for var in group_vars.split(";"): + self.cus_vars[group_name] =3D var + group_texts +=3D self._pp_cus_var(group_text) + xml_str =3D xml_str.replace(group_for, group_texts) + return xml_str + + def _pp_error_warning(self, xml_str: str) -> str: + error_regex =3D r"<\?error\s*\"([^\"]+)\"\s*\?>" + matches =3D re.findall(error_regex, xml_str) + for group_var in matches: + raise RuntimeError("[Error]: " + group_var) + warning_regex =3D r"(<\?warning\s*\"([^\"]+)\"\s*\?>)" + matches =3D re.findall(warning_regex, xml_str) + for group_wrn, group_var in matches: + print("[Warning]: " + group_var) + xml_str =3D xml_str.replace(group_wrn, "") + return xml_str + + def _pp_if_eval(self, xml_str: str) -> str: + ifelif_regex =3D ( + r"(<\?(if|elseif)\s*([^\"\s=3D<>!]+)\s*([!=3D<>]+)\s*\"*([^\"= =3D<>!]+)\"*\s*\?>)" + ) + matches =3D re.findall(ifelif_regex, xml_str) + for ifelif, tag, left, operator, right in matches: + if "<" in operator or ">" in operator: + result =3D eval(f"{left} {operator} {right}") + else: + result =3D eval(f'"{left}" {operator} "{right}"') + xml_str =3D xml_str.replace(ifelif, f"") + return xml_str + + def _pp_ifdef_ifndef(self, xml_str: str) -> str: + ifndef_regex =3D r"(<\?(ifdef|ifndef)\s*([\w]+)\s*\?>)" + matches =3D re.findall(ifndef_regex, xml_str) + for group_ifndef, group_tag, group_var in matches: + if group_tag =3D=3D "ifdef": + result =3D group_var in self.cus_vars + else: + result =3D group_var not in self.cus_vars + xml_str =3D xml_str.replace(group_ifndef, f"") + return xml_str + + def _pp_if_elseif(self, xml_str: str) -> str: + if_elif_else_regex =3D ( + r"(<\?if\s(True|False)\?>" + r"(.*?)" + r"<\?elseif\s(True|False)\?>" + r"(.*?)" + r"<\?else\?>" + r"(.*?)" + r"<\?endif\?>)" + ) + if_else_regex =3D ( + r"(<\?if\s(True|False)\?>" + r"(.*?)" + r"<\?else\?>" + r"(.*?)" + r"<\?endif\?>)" + ) + if_regex =3D r"(<\?if\s(True|False)\?>(.*?)<\?endif\?>)" + matches =3D re.findall(if_elif_else_regex, xml_str, re.DOTALL) + for (group_full, group_if, group_if_elif, group_elif, + group_elif_else, group_else) in matches: + result =3D "" + if group_if =3D=3D "True": + result =3D group_if_elif + elif group_elif =3D=3D "True": + result =3D group_elif_else + else: + result =3D group_else + xml_str =3D xml_str.replace(group_full, result) + matches =3D re.findall(if_else_regex, xml_str, re.DOTALL) + for group_full, group_if, group_if_else, group_else in matches: + result =3D "" + if group_if =3D=3D "True": + result =3D group_if_else + else: + result =3D group_else + xml_str =3D xml_str.replace(group_full, result) + matches =3D re.findall(if_regex, xml_str, re.DOTALL) + for group_full, group_if, group_text in matches: + result =3D "" + if group_if =3D=3D "True": + result =3D group_text + xml_str =3D xml_str.replace(group_full, result) + return xml_str + + def _pp_command(self, xml_str: str) -> str: + cmd_regex =3D r"(<\?cmd\s*\"([^\"]+)\"\s*\?>)" + matches =3D re.findall(cmd_regex, xml_str) + for group_cmd, group_exec in matches: + output =3D subprocess.check_output( + group_exec, shell=3DTrue, + text=3DTrue, stderr=3Dsubprocess.STDOUT + ) + xml_str =3D xml_str.replace(group_cmd, output) + return xml_str + + def _pp_blanks(self, xml_str: str) -> str: + right_blank_regex =3D r">[\n\s\t\r]*" + left_blank_regex =3D r"[\n\s\t\r]*<" + xml_str =3D re.sub(right_blank_regex, ">", xml_str) + xml_str =3D re.sub(left_blank_regex, "<", xml_str) + return xml_str + + def preprocess(self, xml_str: str) -> str: + fns =3D [ + self._pp_blanks, + self._pp_include, + self._pp_foreach, + self._pp_env_var, + self._pp_sys_var, + self._pp_cus_var, + self._pp_if_eval, + self._pp_ifdef_ifndef, + self._pp_if_elseif, + self._pp_command, + self._pp_error_warning, + ] + + while True: + changed =3D False + for func in fns: + out_xml =3D func(xml_str) + if not changed and out_xml !=3D xml_str: + changed =3D True + xml_str =3D out_xml + if not changed: + break + + return xml_str + + +def preprocess_xml(path: str) -> str: + with open(path, "r", encoding=3D"utf-8") as original_file: + input_xml =3D original_file.read() + + proc =3D Preprocessor() + return proc.preprocess(input_xml) + + +def save_xml(xml_str: str, path: Optional[str]): + xml =3D minidom.parseString(xml_str) + with open(path, "w", encoding=3D"utf-8") if path else sys.stdout as ou= tput_file: + output_file.write(xml.toprettyxml()) + + +def main(): + if len(sys.argv) < 2: + print("Usage: xml-preprocessor input.xml [output.xml]") + sys.exit(1) + + output_file =3D None + if len(sys.argv) =3D=3D 3: + output_file =3D sys.argv[2] + + input_file =3D sys.argv[1] + output_xml =3D preprocess_xml(input_file) + save_xml(output_xml, output_file) + + +if __name__ =3D=3D "__main__": + main() --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686052743; cv=none; d=zohomail.com; s=zohoarc; b=RskixnOVSDga6i68WsVeH+TMi/Mgkcijj/hYV3PLFjRkiVVghbdkIuinJoOO/r0BIa3FDVHGKtmJYRfCNbq+f6WLPSO2JUj76ahYQn9WYdBiqRu7pNtdwtmS2mycx5jMUxmnYUn2v3PjlNjhSoGjsN4Uk8zbIIon2xOF+7n37sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686052743; 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=CZek60IdUXVopL0fOifxwaQzKtonox4OSfDDLjj9SuE=; b=bF3cuDMoy9MCQq0/L4FoW2JkLy9+MvU00XkJj2F8hkhrVOMeLpgCBXBBCm2WWlV6uFJm7wM3d1UDNkK8qkyuPT0VLsCwejm8yRgy5ylxf8J1t9qbARj6LZ/GwBpBYjdNsG/yMqeeMdhgE6L73bMdb6e8VCj4qY8rx56WieBS6Yg= 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 168605274334386.66859273498142; Tue, 6 Jun 2023 04:59:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VJZ-00009C-FF; Tue, 06 Jun 2023 07:57:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJX-00008i-C7 for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VJV-0005jl-2V for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:57:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-6VWqlNOjPyWp5EYwKfQJEg-1; Tue, 06 Jun 2023 07:57:23 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FFF285A5A8; Tue, 6 Jun 2023 11:57:23 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6845340CFD47; Tue, 6 Jun 2023 11:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052644; 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=CZek60IdUXVopL0fOifxwaQzKtonox4OSfDDLjj9SuE=; b=XFVdG8OeYQkK8Rb439AOmDfNsbY2lrTzzmus9j48vwYIhUUbbiWmSJ98X4p4MuERtZv0w/ 7r4km/gwSDQxQQ8yMow/j82ldbBCZo/jSy7dU6UN02VbJIlu1B/kfNw7vdpMY2uOZqMWzd yEFgOLso0h1CQebBdxAlu/84A1KWDf4= X-MC-Unique: 6VWqlNOjPyWp5EYwKfQJEg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 05/21] ui/dbus: win32 support Date: Tue, 6 Jun 2023 15:56:42 +0400 Message-Id: <20230606115658.677673-6-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686052744421100004 From: Marc-Andr=C3=A9 Lureau D-Bus doesn't support fd-passing on Windows (AF_UNIX doesn't have SCM_RIGHTS yet, but there are other means to share objects. I have proposed various solutions upstream, but none seem fitting enough atm). To make the "-display dbus" work on Windows, implement an alternative D-Bus interface where all the 'h' (FDs) arguments are replaced with 'ay' (WSASocketW data), and sockets are passed to the other end via WSADuplicateSocket(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- meson.build | 4 +-- ui/dbus.h | 6 +++++ audio/dbusaudio.c | 44 +++++++++++++++++++++++++++------ ui/dbus-chardev.c | 22 +++++++++++++---- ui/dbus-console.c | 59 ++++++++++++++++++++++++++++++++++++++------ ui/dbus-display1.xml | 28 +++++++++++++++++++++ ui/meson.build | 9 ++++++- 7 files changed, 149 insertions(+), 23 deletions(-) diff --git a/meson.build b/meson.build index a61d3e9b06..ce7138a69f 100644 --- a/meson.build +++ b/meson.build @@ -838,6 +838,8 @@ if gdbus_codegen.found() and get_option('cfi') gdbus_codegen_error =3D '@0@ uses gdbus-codegen, which does not support = control flow integrity' endif =20 +xml_pp =3D find_program('scripts/xml-preprocess.py') + lttng =3D not_found if 'ust' in get_option('trace_backends') lttng =3D dependency('lttng-ust', required: true, version: '>=3D 2.1', @@ -2008,8 +2010,6 @@ dbus_display =3D get_option('dbus_display') \ error_message: '-display dbus requires glib>=3D2.64') \ .require(gdbus_codegen.found(), error_message: gdbus_codegen_error.format('-display dbus')) \ - .require(targetos !=3D 'windows', - error_message: '-display dbus is not available on Windows') \ .allowed() =20 have_virtfs =3D get_option('virtfs') \ diff --git a/ui/dbus.h b/ui/dbus.h index 9c149e7b41..1e8c24a48e 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -62,6 +62,12 @@ struct DBusDisplay { Notifier notifier; }; =20 +#ifdef WIN32 +bool +dbus_win32_import_socket(GDBusMethodInvocation *invocation, + GVariant *arg_listener, int *socket); +#endif + #define TYPE_DBUS_DISPLAY "dbus-display" OBJECT_DECLARE_SIMPLE_TYPE(DBusDisplay, DBUS_DISPLAY) =20 diff --git a/audio/dbusaudio.c b/audio/dbusaudio.c index de59467d9e..7a11fbfb42 100644 --- a/audio/dbusaudio.c +++ b/audio/dbusaudio.c @@ -33,6 +33,7 @@ #include #endif =20 +#include "ui/dbus.h" #include "ui/dbus-display1.h" =20 #define AUDIO_CAP "dbus" @@ -422,7 +423,6 @@ dbus_audio_fini(void *opaque) g_free(da); } =20 -#ifdef G_OS_UNIX static void listener_out_vanished_cb(GDBusConnection *connection, gboolean remote_peer_vanished, @@ -448,7 +448,9 @@ listener_in_vanished_cb(GDBusConnection *connection, static gboolean dbus_audio_register_listener(AudioState *s, GDBusMethodInvocation *invocation, +#ifdef G_OS_UNIX GUnixFDList *fd_list, +#endif GVariant *arg_listener, bool out) { @@ -475,6 +477,11 @@ dbus_audio_register_listener(AudioState *s, return DBUS_METHOD_INVOCATION_HANDLED; } =20 +#ifdef G_OS_WIN32 + if (!dbus_win32_import_socket(invocation, arg_listener, &fd)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } +#else 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, @@ -484,6 +491,7 @@ dbus_audio_register_listener(AudioState *s, err->message); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 socket =3D g_socket_new_from_fd(fd, &err); if (err) { @@ -492,15 +500,28 @@ dbus_audio_register_listener(AudioState *s, DBUS_DISPLAY_ERROR_FAILED, "Couldn't make a socket: %s", err->message); +#ifdef G_OS_WIN32 + closesocket(fd); +#else + close(fd); +#endif 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); + da->iface, invocation +#ifdef G_OS_UNIX + , NULL +#endif + ); } else { qemu_dbus_display1_audio_complete_register_in_listener( - da->iface, invocation, NULL); + da->iface, invocation +#ifdef G_OS_UNIX + , NULL +#endif + ); } =20 listener_conn =3D @@ -578,24 +599,33 @@ dbus_audio_register_listener(AudioState *s, static gboolean dbus_audio_register_out_listener(AudioState *s, GDBusMethodInvocation *invocation, +#ifdef G_OS_UNIX GUnixFDList *fd_list, +#endif GVariant *arg_listener) { return dbus_audio_register_listener(s, invocation, - fd_list, arg_listener, true); +#ifdef G_OS_UNIX + fd_list, +#endif + arg_listener, true); =20 } =20 static gboolean dbus_audio_register_in_listener(AudioState *s, GDBusMethodInvocation *invocation, +#ifdef G_OS_UNIX GUnixFDList *fd_list, +#endif GVariant *arg_listener) { return dbus_audio_register_listener(s, invocation, - fd_list, arg_listener, false); -} +#ifdef G_OS_UNIX + fd_list, #endif + arg_listener, false); +} =20 static void dbus_audio_set_server(AudioState *s, GDBusObjectManagerServer *server, boo= l p2p) @@ -610,14 +640,12 @@ dbus_audio_set_server(AudioState *s, GDBusObjectManag= erServer *server, bool p2p) =20 da->audio =3D g_dbus_object_skeleton_new(DBUS_DISPLAY1_AUDIO_PATH); da->iface =3D qemu_dbus_display1_audio_skeleton_new(); -#ifdef G_OS_UNIX 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); -#endif =20 g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(da->audio), G_DBUS_INTERFACE_SKELETON(da->ifa= ce)); diff --git a/ui/dbus-chardev.c b/ui/dbus-chardev.c index 7154d81a9a..1d3a7122a1 100644 --- a/ui/dbus-chardev.c +++ b/ui/dbus-chardev.c @@ -110,18 +110,24 @@ dbus_chardev_init(DBusDisplay *dpy) dbus_display_chardev_foreach, dpy); } =20 -#ifdef G_OS_UNIX static gboolean dbus_chr_register( DBusChardev *dc, GDBusMethodInvocation *invocation, +#ifdef G_OS_UNIX GUnixFDList *fd_list, +#endif GVariant *arg_stream, QemuDBusDisplay1Chardev *object) { g_autoptr(GError) err =3D NULL; int fd; =20 +#ifdef G_OS_WIN32 + if (!dbus_win32_import_socket(invocation, arg_stream, &fd)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } +#else fd =3D g_unix_fd_list_get(fd_list, g_variant_get_handle(arg_stream), &= err); if (err) { g_dbus_method_invocation_return_error( @@ -131,13 +137,18 @@ dbus_chr_register( "Couldn't get peer FD: %s", err->message); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 if (qemu_chr_add_client(CHARDEV(dc), fd) < 0) { g_dbus_method_invocation_return_error(invocation, DBUS_DISPLAY_ERROR, DBUS_DISPLAY_ERROR_FAILED, "Couldn't register FD!"); +#ifdef G_OS_WIN32 + closesocket(fd); +#else close(fd); +#endif return DBUS_METHOD_INVOCATION_HANDLED; } =20 @@ -145,10 +156,13 @@ dbus_chr_register( "owner", g_dbus_method_invocation_get_sender(invocation), NULL); =20 - qemu_dbus_display1_chardev_complete_register(object, invocation, NULL); + qemu_dbus_display1_chardev_complete_register(object, invocation +#ifndef G_OS_WIN32 + , NULL +#endif + ); return DBUS_METHOD_INVOCATION_HANDLED; } -#endif =20 static gboolean dbus_chr_send_break( @@ -179,10 +193,8 @@ dbus_chr_open(Chardev *chr, ChardevBackend *backend, dc->iface =3D qemu_dbus_display1_chardev_skeleton_new(); g_object_set(dc->iface, "name", backend->u.dbus.data->name, NULL); g_object_connect(dc->iface, -#ifdef G_OS_UNIX "swapped-signal::handle-register", dbus_chr_register, dc, -#endif "swapped-signal::handle-send-break", dbus_chr_send_break, dc, NULL); diff --git a/ui/dbus-console.c b/ui/dbus-console.c index fd50fd3200..f0a060dc81 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -162,7 +162,6 @@ dbus_display_console_class_init(DBusDisplayConsoleClass= *klass) gobject_class->dispose =3D dbus_display_console_dispose; } =20 -#ifdef G_OS_UNIX static void listener_vanished_cb(DBusDisplayListener *listener) { @@ -174,7 +173,6 @@ listener_vanished_cb(DBusDisplayListener *listener) g_hash_table_remove(ddc->listeners, name); qkbd_state_lift_all_keys(ddc->kbd); } -#endif =20 static gboolean dbus_console_set_ui_info(DBusDisplayConsole *ddc, @@ -208,11 +206,47 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 -#ifdef G_OS_UNIX +#ifdef G_OS_WIN32 +bool +dbus_win32_import_socket(GDBusMethodInvocation *invocation, + GVariant *arg_listener, int *socket) +{ + gsize n; + WSAPROTOCOL_INFOW *info =3D (void *)g_variant_get_fixed_array(arg_list= ener, &n, 1); + + if (!info || n !=3D sizeof(*info)) { + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Failed to get socket infos"); + return false; + } + + *socket =3D WSASocketW(FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + FROM_PROTOCOL_INFO, + info, 0, 0); + if (*socket =3D=3D INVALID_SOCKET) { + g_autofree gchar *emsg =3D g_win32_error_message(WSAGetLastError()= ); + g_dbus_method_invocation_return_error( + invocation, + DBUS_DISPLAY_ERROR, + DBUS_DISPLAY_ERROR_FAILED, + "Couldn't create socket: %s", emsg); + return false; + } + + return true; +} +#endif + static gboolean dbus_console_register_listener(DBusDisplayConsole *ddc, GDBusMethodInvocation *invocation, +#ifdef G_OS_UNIX GUnixFDList *fd_list, +#endif GVariant *arg_listener) { const char *sender =3D g_dbus_method_invocation_get_sender(invocation); @@ -234,6 +268,11 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 +#ifdef G_OS_WIN32 + if (!dbus_win32_import_socket(invocation, arg_listener, &fd)) { + return DBUS_METHOD_INVOCATION_HANDLED; + } +#else fd =3D g_unix_fd_list_get(fd_list, g_variant_get_handle(arg_listener),= &err); if (err) { g_dbus_method_invocation_return_error( @@ -243,6 +282,7 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, "Couldn't get peer fd: %s", err->message); return DBUS_METHOD_INVOCATION_HANDLED; } +#endif =20 socket =3D g_socket_new_from_fd(fd, &err); if (err) { @@ -251,13 +291,21 @@ dbus_console_register_listener(DBusDisplayConsole *dd= c, DBUS_DISPLAY_ERROR, DBUS_DISPLAY_ERROR_FAILED, "Couldn't make a socket: %s", err->message); +#ifdef G_OS_WIN32 + closesocket(fd); +#else close(fd); +#endif return DBUS_METHOD_INVOCATION_HANDLED; } socket_conn =3D g_socket_connection_factory_create_connection(socket); =20 qemu_dbus_display1_console_complete_register_listener( - ddc->iface, invocation, NULL); + ddc->iface, invocation +#ifdef G_OS_UNIX + , NULL +#endif + ); =20 listener_conn =3D g_dbus_connection_new_sync( G_IO_STREAM(socket_conn), @@ -284,7 +332,6 @@ dbus_console_register_listener(DBusDisplayConsole *ddc, trace_dbus_registered_listener(sender); return DBUS_METHOD_INVOCATION_HANDLED; } -#endif =20 static gboolean dbus_kbd_press(DBusDisplayConsole *ddc, @@ -473,10 +520,8 @@ dbus_display_console_new(DBusDisplay *display, QemuCon= sole *con) "device-address", device_addr, NULL); g_object_connect(ddc->iface, -#ifdef G_OS_UNIX "swapped-signal::handle-register-listener", dbus_console_register_listener, ddc, -#endif "swapped-signal::handle-set-uiinfo", dbus_console_set_ui_info, ddc, NULL); diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index c3b2293376..80eae363f0 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -56,7 +56,13 @@ :dbus:iface:`org.qemu.Display1.Listener` interface. --> + + + + + + =20 + + + + + + + =20 + + + + + + =20 @@ -719,7 +741,13 @@ The current handler, if any, will be replaced. --> + + + + + + =20 + + + =20 + + + =20 @@ -170,7 +199,8 @@ + =20 + =20 + =20 + =20 + =20 + + + --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686053077; cv=none; d=zohomail.com; s=zohoarc; b=bzaDrRgEeNOgVVthW6JKkJJlyAHaVx4zWLK1x97QKPC+0WeXcZi7DjnPAdJXpqhz7B1hXMh1wOZ0GHhcAIpngbwgXu8yj6iLHTWEhRtqyILcNDg0uCWBqmYwu9r7TikjHLgWBtk58l7oTtM3lXxLHStznnnGbRz9VKFrChSGRxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686053077; 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=sqJsNl4Ar54jPG3d2clpVdVLe4x6TN6Wzg67MJF4rOc=; b=db/0Trib++g4L6p8J+hZNaFuaZCSa7yvigpmaY3pr6idqsmVPv62GlgVOkZbv0qYPwtk8wTX71oZJ1ISE7Md9jyMCkzXAZ+u8fP2vhMlOigWkAkLRc+aj9fk1l+6mzFMEF/Xc32r2uvXh+Pl+YAgD/wZacph4lgd4Ak55XwlzVE= 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 1686053077055797.3221890564307; Tue, 6 Jun 2023 05:04:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VP7-00087P-1M; Tue, 06 Jun 2023 08:03:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VP4-00083W-RS for qemu-devel@nongnu.org; Tue, 06 Jun 2023 08:03:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VP2-0007G6-It for qemu-devel@nongnu.org; Tue, 06 Jun 2023 08:03:10 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-295-nIsYckiZNSWBMP3u7lpMpQ-1; Tue, 06 Jun 2023 08:03:04 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 25A93802355; Tue, 6 Jun 2023 11:57:57 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBA4E140E958; Tue, 6 Jun 2023 11:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052987; 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=sqJsNl4Ar54jPG3d2clpVdVLe4x6TN6Wzg67MJF4rOc=; b=Rr8k5rZCRwnAKGAV+27HS+huxE/T1JtDRHftnPllIiIZhQqD5cXdNn/OT1uXvco6xqT1qY dftpYSFW+SXZHkRwd06JsY3YrK284KqqUzkicLve3xR9/pwA38yMZSsN3CCWo/JmPvax7M sVqG9FsNvhpFQJHNOJS4Ife8JEnVwas= X-MC-Unique: nIsYckiZNSWBMP3u7lpMpQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Stefan Weil Subject: [PATCH 09/21] console/win32: allocate shareable display surface Date: Tue, 6 Jun 2023 15:56:46 +0400 Message-Id: <20230606115658.677673-10-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686053079827100011 From: Marc-Andr=C3=A9 Lureau Introduce qemu_win32_map_alloc() and qemu_win32_map_free() to allocate shared memory mapping. The handle can be used to share the mapping with another process. Teach qemu_create_displaysurface() to allocate shared memory. Following patches will introduce other places for shared memory allocation. Other patches for -display dbus will share the memory when possible with the client, to avoid expensive memory copy between the processes. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/os-win32.h | 3 ++ include/ui/console.h | 8 ++++++ ui/console.c | 59 ++++++++++++++++++++++++++++++++++----- ui/qemu-pixman.c | 1 + util/oslib-win32.c | 33 ++++++++++++++++++++++ ui/trace-events | 2 +- util/trace-events | 4 +++ 7 files changed, 102 insertions(+), 8 deletions(-) diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h index 65f6c9ea57..91aa0d7ec0 100644 --- a/include/sysemu/os-win32.h +++ b/include/sysemu/os-win32.h @@ -263,6 +263,9 @@ EXCEPTION_DISPOSITION win32_close_exception_handler(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); =20 +void *qemu_win32_map_alloc(size_t size, HANDLE *h, Error **errp); +void qemu_win32_map_free(void *ptr, HANDLE h, Error **errp); + #ifdef __cplusplus } #endif diff --git a/include/ui/console.h b/include/ui/console.h index ae5ec466c1..0fd2692110 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -128,6 +128,10 @@ typedef struct DisplaySurface { GLenum gltype; GLuint texture; #endif +#ifdef WIN32 + HANDLE handle; + uint32_t handle_offset; +#endif } DisplaySurface; =20 typedef struct QemuUIInfo { @@ -314,6 +318,10 @@ DisplaySurface *qemu_create_displaysurface_from(int wi= dth, int height, DisplaySurface *qemu_create_displaysurface_pixman(pixman_image_t *image); DisplaySurface *qemu_create_placeholder_surface(int w, int h, const char *msg); +#ifdef WIN32 +void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, + HANDLE h, uint32_t offset); +#endif PixelFormat qemu_default_pixelformat(int bpp); =20 DisplaySurface *qemu_create_displaysurface(int width, int height); diff --git a/ui/console.c b/ui/console.c index e173731e20..2b53c64ef0 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1513,18 +1513,59 @@ static QemuConsole *new_console(DisplayState *ds, c= onsole_type_t console_type, return s; } =20 +#ifdef WIN32 +void qemu_displaysurface_win32_set_handle(DisplaySurface *surface, + HANDLE h, uint32_t offset) +{ + assert(!surface->handle); + + surface->handle =3D h; + surface->handle_offset =3D offset; +} + +static void +win32_pixman_image_destroy(pixman_image_t *image, void *data) +{ + DisplaySurface *surface =3D data; + + if (!surface->handle) { + return; + } + + assert(surface->handle_offset =3D=3D 0); + + qemu_win32_map_free( + pixman_image_get_data(surface->image), + surface->handle, + &error_warn + ); +} +#endif + DisplaySurface *qemu_create_displaysurface(int width, int height) { - DisplaySurface *surface =3D g_new0(DisplaySurface, 1); + DisplaySurface *surface; + void *bits =3D NULL; +#ifdef WIN32 + HANDLE handle =3D NULL; +#endif =20 - trace_displaysurface_create(surface, width, height); - surface->format =3D PIXMAN_x8r8g8b8; - surface->image =3D pixman_image_create_bits(surface->format, - width, height, - NULL, width * 4); - assert(surface->image !=3D NULL); + trace_displaysurface_create(width, height); + +#ifdef WIN32 + bits =3D qemu_win32_map_alloc(width * height * 4, &handle, &error_abor= t); +#endif + + surface =3D qemu_create_displaysurface_from( + width, height, + PIXMAN_x8r8g8b8, + width * 4, bits + ); surface->flags =3D QEMU_ALLOCATED_FLAG; =20 +#ifdef WIN32 + qemu_displaysurface_win32_set_handle(surface, handle, 0); +#endif return surface; } =20 @@ -1540,6 +1581,10 @@ DisplaySurface *qemu_create_displaysurface_from(int = width, int height, width, height, (void *)data, linesize); assert(surface->image !=3D NULL); +#ifdef WIN32 + pixman_image_set_destroy_function(surface->image, + win32_pixman_image_destroy, surface); +#endif =20 return surface; } diff --git a/ui/qemu-pixman.c b/ui/qemu-pixman.c index 3ab7e2e958..e4f024a85e 100644 --- a/ui/qemu-pixman.c +++ b/ui/qemu-pixman.c @@ -6,6 +6,7 @@ #include "qemu/osdep.h" #include "ui/console.h" #include "standard-headers/drm/drm_fourcc.h" +#include "trace.h" =20 PixelFormat qemu_pixelformat_from_pixman(pixman_format_code_t format) { diff --git a/util/oslib-win32.c b/util/oslib-win32.c index fafbab80b4..429542face 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -835,3 +835,36 @@ int qemu_msync(void *addr, size_t length, int fd) */ return qemu_fdatasync(fd); } + +void *qemu_win32_map_alloc(size_t size, HANDLE *h, Error **errp) +{ + void *bits; + + trace_win32_map_alloc(size); + + *h =3D CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, + size, NULL); + if (*h =3D=3D NULL) { + error_setg_win32(errp, GetLastError(), "Failed to CreateFileMappin= g"); + return NULL; + } + + bits =3D MapViewOfFile(*h, FILE_MAP_ALL_ACCESS, 0, 0, size); + if (bits =3D=3D NULL) { + error_setg_win32(errp, GetLastError(), "Failed to MapViewOfFile"); + CloseHandle(*h); + return NULL; + } + + return bits; +} + +void qemu_win32_map_free(void *ptr, HANDLE h, Error **errp) +{ + trace_win32_map_free(ptr, h); + + if (UnmapViewOfFile(ptr) =3D=3D 0) { + error_setg_win32(errp, GetLastError(), "Failed to UnmapViewOfFile"= ); + } + CloseHandle(h); +} diff --git a/ui/trace-events b/ui/trace-events index 6747361745..712c4b2273 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -9,7 +9,7 @@ console_putchar_unhandled(int ch) "unhandled escape charact= er '%c'" console_txt_new(int w, int h) "%dx%d" console_select(int nr) "%d" console_refresh(int interval) "interval %d ms" -displaysurface_create(void *display_surface, int w, int h) "surface=3D%p, = %dx%d" +displaysurface_create(int w, int h) "%dx%d" displaysurface_create_from(void *display_surface, int w, int h, uint32_t f= ormat) "surface=3D%p, %dx%d, format 0x%x" displaysurface_create_pixman(void *display_surface) "surface=3D%p" displaysurface_free(void *display_surface) "surface=3D%p" diff --git a/util/trace-events b/util/trace-events index 3f7e766683..49a4962e18 100644 --- a/util/trace-events +++ b/util/trace-events @@ -52,6 +52,10 @@ qemu_anon_ram_alloc(size_t size, void *ptr) "size %zu pt= r %p" qemu_vfree(void *ptr) "ptr %p" qemu_anon_ram_free(void *ptr, size_t size) "ptr %p size %zu" =20 +# oslib-win32.c +win32_map_alloc(size_t size) "size:%zd" +win32_map_free(void *ptr, void *h) "ptr:%p handle:%p" + # hbitmap.c hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned = long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx" hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uin= t64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64 --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686052813; cv=none; d=zohomail.com; s=zohoarc; b=kmiNhbhZ7liVQAXteNqTMOliTTe2cHp5NfmpNkMrXNT4/ZtZli0B0dxLqDBpimMp/csGOy7dRBaQQkh8UXkSx6tMmuK1JaVYmVioLDi8jbDwZHJqOxAsUTgC2YFcFOUYK6dmua1ADdwR4t51RyGpaPjMjXJcEEbZHsrpXbLJUvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686052813; 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=yCTtOHm+boLKGqy2hpJrZtD7WOOuQ5iAw0JYdvrtBUs=; b=EQCh5GAMe9wrpnUcgJFc1FpMG+rcJvfBPIYPmQQ6cAk25aH0hlDoWcar6AaAV4RQZ9R327YQ5eF0gVoeZoY5p+CkX57SBU2Qe6wqE/5LfB7OXVCIL+MPt3cEz9LcL6tppam46wOlDx//54TEpCHZ0NbBfYZBI/nEsXtwJY/hnv0= 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 168605281312426.261466839227523; Tue, 6 Jun 2023 05:00:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VKC-0000X4-Hl; Tue, 06 Jun 2023 07:58:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VK9-0000Qn-9U for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VK7-0005u5-Lw for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:05 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-2FYZTvPEN5elEivkTdHPpw-1; Tue, 06 Jun 2023 07:58:01 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CA73185A79B for ; Tue, 6 Jun 2023 11:58:01 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BF62492B00; Tue, 6 Jun 2023 11:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052683; 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=yCTtOHm+boLKGqy2hpJrZtD7WOOuQ5iAw0JYdvrtBUs=; b=cgmKaPUc6MQl6P4fF8+IXIprua4Mvp8Zhkd48sn/P0iMQRobBWeab/fxD1f3KKDUAkQTtM pHIe/EEmO6rr5ua++YmTxRIX/Rig7n+jAg1lnWpTWAAZzgF38QZDGc215QcAgz1yu/ba+Y /a7Q38564OmgXyU+Rp4rpS2ArkntXzo= X-MC-Unique: 2FYZTvPEN5elEivkTdHPpw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" Subject: [PATCH 10/21] virtio-gpu/win32: allocate shareable 2d resources/images Date: Tue, 6 Jun 2023 15:56:47 +0400 Message-Id: <20230606115658.677673-11-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686052815859100003 From: Marc-Andr=C3=A9 Lureau Allocate pixman bits for scanouts with qemu_win32_map_alloc() so we can set a shareable handle on the associated display surface. Note: when bits are provided to pixman_image_create_bits(), you must also g= ive the rowstride (the argument is ignored when bits is NULL) Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/virtio/virtio-gpu.h | 3 +++ hw/display/virtio-gpu.c | 46 +++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2e28507efe..7a5f8056ea 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -48,6 +48,9 @@ struct virtio_gpu_simple_resource { unsigned int iov_cnt; uint32_t scanout_bitmask; pixman_image_t *image; +#ifdef WIN32 + HANDLE handle; +#endif uint64_t hostmem; =20 uint64_t blob_size; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 66cddd94d9..2871563c40 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -258,6 +258,16 @@ static uint32_t calc_image_hostmem(pixman_format_code_= t pformat, return height * stride; } =20 +#ifdef WIN32 +static void +win32_pixman_image_destroy(pixman_image_t *image, void *data) +{ + HANDLE handle =3D data; + + qemu_win32_map_free(pixman_image_get_data(image), handle, &error_warn); +} +#endif + static void virtio_gpu_resource_create_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *= cmd) { @@ -304,12 +314,27 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *= g, =20 res->hostmem =3D calc_image_hostmem(pformat, c2d.width, c2d.height); if (res->hostmem + g->hostmem < g->conf_max_hostmem) { + void *bits =3D NULL; +#ifdef WIN32 + bits =3D qemu_win32_map_alloc(res->hostmem, &res->handle, &error_w= arn); + if (!bits) { + goto end; + } +#endif res->image =3D pixman_image_create_bits(pformat, c2d.width, c2d.height, - NULL, 0); + bits, res->hostmem / c2d.hei= ght); +#ifdef WIN32 + if (res->image) { + pixman_image_set_destroy_function(res->image, win32_pixman_ima= ge_destroy, res->handle); + } +#endif } =20 +#ifdef WIN32 +end: +#endif if (!res->image) { qemu_log_mask(LOG_GUEST_ERROR, "%s: resource creation failed %d %d %d\n", @@ -666,6 +691,9 @@ static void virtio_gpu_do_set_scanout(VirtIOGPU *g, *error =3D VIRTIO_GPU_RESP_ERR_UNSPEC; return; } +#ifdef WIN32 + qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, fb-= >offset); +#endif =20 pixman_image_unref(rect); dpy_gfx_replace_surface(g->parent_obj.scanout[scanout_id].con, @@ -1209,6 +1237,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; + void *bits =3D NULL; int i; =20 g->hostmem =3D 0; @@ -1233,15 +1262,23 @@ static int virtio_gpu_load(QEMUFile *f, void *opaqu= e, size_t size, g_free(res); return -EINVAL; } + + res->hostmem =3D calc_image_hostmem(pformat, res->width, res->heig= ht); +#ifdef WIN32 + bits =3D qemu_win32_map_alloc(res->hostmem, &res->handle, &error_w= arn); + if (!bits) { + g_free(res); + return -EINVAL; + } +#endif res->image =3D pixman_image_create_bits(pformat, res->width, res->height, - NULL, 0); + bits, res->hostmem / res->he= ight); if (!res->image) { g_free(res); return -EINVAL; } =20 - res->hostmem =3D calc_image_hostmem(pformat, res->width, res->heig= ht); =20 res->addrs =3D g_new(uint64_t, res->iov_cnt); res->iov =3D g_new(struct iovec, res->iov_cnt); @@ -1302,6 +1339,9 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, if (!scanout->ds) { return -EINVAL; } +#ifdef WIN32 + qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0); +#endif =20 dpy_gfx_replace_surface(scanout->con, scanout->ds); dpy_gfx_update_full(scanout->con); --=20 2.40.1 From nobody Sat May 18 03:46:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1686053077; cv=none; d=zohomail.com; s=zohoarc; b=NI0yWFHlVx+80UtJTDCMJQXVuTiJbObtj56RHbE1824X7790hSuFS73pSfao9+RcFa8eJRAFwLT2djaMnmda+wi9VL3J0N4XijUyrdw7/C2zFYMBe8L61z8fxHv/eqD3qePkxSuukzqOJ/W3mTXoHa0xFAk1XskJB4dfUTd9b5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686053077; 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=cqhnRZ1s3SdpV7aTMr4ERQcbo6TaWDNElf/vaSj/Au8=; b=mTS+6Kj1H2W9DPdnr/Tiy0GOWAkRgH/mKqioWwCP7YTrMnXrk5ZWvv9lO4cPkYkv0C5ADlBMG8BkWAGVQLSNxU67HNp/34xSAqVdpBX5Sxi2QExFSrXi2kUIgzeiAAm9YRbkgu+WvKLiyko1SF1N50knzRALtdihs2qywT+ESTY= 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 168605307688036.710596691277715; Tue, 6 Jun 2023 05:04:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6VKW-00019R-En; Tue, 06 Jun 2023 07:58:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VKI-0000aY-CY for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6VKD-0005ua-NS for qemu-devel@nongnu.org; Tue, 06 Jun 2023 07:58:11 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-rk6dnsZENyC6u4JtFTJ-GQ-1; Tue, 06 Jun 2023 07:58:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E0F63850540 for ; Tue, 6 Jun 2023 11:58:06 +0000 (UTC) Received: from localhost (unknown [10.39.208.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06C1A9E8B; Tue, 6 Jun 2023 11:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686052688; 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=cqhnRZ1s3SdpV7aTMr4ERQcbo6TaWDNElf/vaSj/Au8=; b=FC25TPbelCpGx/f6AN7tTMG0/OHu64YdL0CTirAyEl07Tf+WghtyirGhN+SPqc0k6bCQU8 pMptv8Ir2SuFhBfDOi+t3GgLU8+67AgUFmvMyO6iWipq6T8Jbpt2L0vAP9DbJHaR260rgl OFlo7Ce+EgGCR4tQ05Mr941FioKDw+8= X-MC-Unique: rk6dnsZENyC6u4JtFTJ-GQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 11/21] ui/dbus: use shared memory when possible on win32 Date: Tue, 6 Jun 2023 15:56:48 +0400 Message-Id: <20230606115658.677673-12-marcandre.lureau@redhat.com> In-Reply-To: <20230606115658.677673-1-marcandre.lureau@redhat.com> References: <20230606115658.677673-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1686053079647100009 From: Marc-Andr=C3=A9 Lureau When the display surface has an associated HANDLE, we can duplicate it to the client process and let it map the memory to avoid expensive copies. Introduce two new win32-specific methods ScanoutMap and UpdateMap. The first is used to inform the listener about the a shared map availability, and the second for display updates. Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus-listener.c | 165 ++++++++++++++++++++++++++++++++++++++++++- ui/dbus-display1.xml | 48 ++++++++++++- 2 files changed, 208 insertions(+), 5 deletions(-) diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index 41597a0078..f6b1cd11be 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -48,6 +48,14 @@ struct _DBusDisplayListener { DisplayChangeListener dcl; DisplaySurface *ds; int gl_updates; + + bool ds_mapped; + bool can_share_map; + +#ifdef WIN32 + QemuDBusDisplay1ListenerWin32Map *map_proxy; + HANDLE peer_process; +#endif }; =20 G_DEFINE_TYPE(DBusDisplayListener, dbus_display_listener, G_TYPE_OBJECT) @@ -119,7 +127,61 @@ static void dbus_scanout_dmabuf(DisplayChangeListener = *dcl, fd_list, NULL, NULL, NULL); } +#endif /* OPENGL & GBM */ + +#ifdef WIN32 +static bool dbus_scanout_map(DBusDisplayListener *ddl) +{ + g_autoptr(GError) err =3D NULL; + BOOL success; + HANDLE target_handle; + + if (ddl->ds_mapped) { + return true; + } + + if (!ddl->can_share_map || !ddl->ds->handle) { + return false; + } + + success =3D DuplicateHandle( + GetCurrentProcess(), + ddl->ds->handle, + ddl->peer_process, + &target_handle, + FILE_MAP_READ | SECTION_QUERY, + FALSE, 0); + if (!success) { + g_autofree char *msg =3D g_win32_error_message(GetLastError()); + g_debug("Failed to DuplicateHandle: %s", msg); + ddl->can_share_map =3D false; + return false; + } + + if (!qemu_dbus_display1_listener_win32_map_call_scanout_map_sync( + ddl->map_proxy, + GPOINTER_TO_UINT(target_handle), + ddl->ds->handle_offset, + surface_width(ddl->ds), + surface_height(ddl->ds), + surface_stride(ddl->ds), + surface_format(ddl->ds), + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT, + NULL, + &err)) { + g_debug("Failed to call ScanoutMap: %s", err->message); + ddl->can_share_map =3D false; + return false; + } + + ddl->ds_mapped =3D true; + + return true; +} +#endif =20 +#if defined(CONFIG_OPENGL) && defined(CONFIG_GBM) static void dbus_scanout_texture(DisplayChangeListener *dcl, uint32_t tex_id, bool backing_y_0_top, @@ -239,7 +301,7 @@ static void dbus_gl_refresh(DisplayChangeListener *dcl) ddl->gl_updates =3D 0; } } -#endif +#endif /* OPENGL & GBM */ =20 static void dbus_refresh(DisplayChangeListener *dcl) { @@ -265,10 +327,20 @@ static void dbus_gfx_update(DisplayChangeListener *dc= l, size_t stride; =20 assert(ddl->ds); - stride =3D w * DIV_ROUND_UP(PIXMAN_FORMAT_BPP(surface_format(ddl->ds))= , 8); =20 trace_dbus_update(x, y, w, h); =20 +#ifdef WIN32 + if (dbus_scanout_map(ddl)) { + qemu_dbus_display1_listener_win32_map_call_update_map( + ddl->map_proxy, + x, y, w, h, + G_DBUS_CALL_FLAGS_NONE, + DBUS_DEFAULT_TIMEOUT, NULL, NULL, NULL); + return; + } +#endif + if (x =3D=3D 0 && y =3D=3D 0 && w =3D=3D surface_width(ddl->ds) && h = =3D=3D surface_height(ddl->ds)) { v_data =3D g_variant_new_from_data( G_VARIANT_TYPE("ay"), @@ -290,6 +362,7 @@ static void dbus_gfx_update(DisplayChangeListener *dcl, } =20 /* make a copy, since gvariant only handles linear data */ + stride =3D w * DIV_ROUND_UP(PIXMAN_FORMAT_BPP(surface_format(ddl->ds))= , 8); 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, @@ -333,6 +406,9 @@ static void dbus_gfx_switch(DisplayChangeListener *dcl, DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 ddl->ds =3D new_surface; +#ifdef WIN32 + ddl->ds_mapped =3D false; +#endif if (!ddl->ds) { /* why not call disable instead? */ return; @@ -414,6 +490,10 @@ dbus_display_listener_dispose(GObject *object) g_clear_object(&ddl->conn); g_clear_pointer(&ddl->bus_name, g_free); g_clear_object(&ddl->proxy); +#ifdef WIN32 + g_clear_object(&ddl->map_proxy); + g_clear_pointer(&ddl->peer_process, CloseHandle); +#endif =20 G_OBJECT_CLASS(dbus_display_listener_parent_class)->dispose(object); } @@ -459,6 +539,85 @@ dbus_display_listener_get_console(DBusDisplayListener = *ddl) return ddl->console; } =20 +#ifdef WIN32 +static bool +dbus_display_listener_implements(DBusDisplayListener *ddl, const char *ifa= ce) +{ + QemuDBusDisplay1Listener *l =3D QEMU_DBUS_DISPLAY1_LISTENER(ddl->proxy= ); + bool implements; + + implements =3D g_strv_contains(qemu_dbus_display1_listener_get_interfa= ces(l), iface); + if (!implements) { + g_debug("Display listener does not implement: `%s`", iface); + } + + return implements; +} +#endif + +static void +dbus_display_listener_setup_shared_map(DBusDisplayListener *ddl) +{ +#ifdef WIN32 + g_autoptr(GError) err =3D NULL; + GDBusConnection *conn; + GIOStream *stream; + GSocket *sock; + g_autoptr(GCredentials) creds =3D NULL; + DWORD *pid; + + if (!dbus_display_listener_implements(ddl, "org.qemu.Display1.Listener= .Win32.Map")) { + return; + } + + conn =3D g_dbus_proxy_get_connection(G_DBUS_PROXY(ddl->proxy)); + stream =3D g_dbus_connection_get_stream(conn); + + if (!G_IS_UNIX_CONNECTION(stream)) { + return; + } + + sock =3D g_socket_connection_get_socket(G_SOCKET_CONNECTION(stream)); + creds =3D g_socket_get_credentials(sock, &err); + + if (!creds) { + g_debug("Failed to get peer credentials: %s", err->message); + return; + } + + pid =3D g_credentials_get_native(creds, G_CREDENTIALS_TYPE_WIN32_PID); + + if (pid =3D=3D NULL) { + g_debug("Failed to get peer PID"); + return; + } + + ddl->peer_process =3D OpenProcess( + PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION, + false, *pid); + + if (!ddl->peer_process) { + g_autofree char *msg =3D g_win32_error_message(GetLastError()); + g_debug("Failed to OpenProcess: %s", msg); + return; + } + + ddl->map_proxy =3D + qemu_dbus_display1_listener_win32_map_proxy_new_sync(conn, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + "/org/qemu/Display1/Listener", + NULL, + &err); + if (!ddl->map_proxy) { + g_debug("Failed to setup win32 map proxy: %s", err->message); + return; + } + + ddl->can_share_map =3D true; +#endif +} + DBusDisplayListener * dbus_display_listener_new(const char *bus_name, GDBusConnection *conn, @@ -487,6 +646,8 @@ dbus_display_listener_new(const char *bus_name, ddl->conn =3D conn; ddl->console =3D console; =20 + dbus_display_listener_setup_shared_map(ddl); + con =3D qemu_console_lookup_by_index(dbus_display_console_get_index(co= nsole)); assert(con); ddl->dcl.con =3D con; diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index 2c4acce593..2aba36fee0 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -329,9 +329,7 @@ =20 - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +