From nobody Mon Apr 29 12:15:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487597189924988.4526634078634; Mon, 20 Feb 2017 05:26:29 -0800 (PST) Received: from localhost ([::1]:38502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfnz1-0000c7-KN for importer@patchew.org; Mon, 20 Feb 2017 08:26:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfnxD-0007iC-4v for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfnx8-0007lL-Lk for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35174) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cfnx8-0007l3-Cv for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:30 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 90C09C04B31F for ; Mon, 20 Feb 2017 13:24:30 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1KDOTAv013628; Mon, 20 Feb 2017 08:24:29 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id DCADA80E57; Mon, 20 Feb 2017 14:24:27 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 20 Feb 2017 14:24:24 +0100 Message-Id: <1487597065-27023-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1487597065-27023-1-git-send-email-kraxel@redhat.com> References: <1487597065-27023-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 20 Feb 2017 13:24:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/2] spice: allow to specify drm rendernode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau When multiple GPU are available, picking the first one isn't always the best choice. Learn to specify a device rendernode. Signed-off-by: Marc-Andr=C3=A9 Lureau Message-id: 20170212112118.16044-1-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- include/ui/egl-helpers.h | 3 +-- qemu-options.hx | 6 +++++- ui/egl-helpers.c | 10 +++++++--- ui/spice-core.c | 5 ++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 03fcf4b..88a13e8 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -14,8 +14,7 @@ extern int qemu_egl_rn_fd; extern struct gbm_device *qemu_egl_rn_gbm_dev; extern EGLContext qemu_egl_rn_ctx; =20 -int qemu_egl_rendernode_open(void); -int egl_rendernode_init(void); +int egl_rendernode_init(const char *rendernode); int egl_get_fd_for_texture(uint32_t tex_id, EGLint *stride, EGLint *fourcc= ); =20 #endif diff --git a/qemu-options.hx b/qemu-options.hx index 5633d39..809b2b0 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1066,7 +1066,7 @@ DEF("spice", HAS_ARG, QEMU_OPTION_spice, " [,streaming-video=3D[off|all|filter]][,disable-copy-paste]\n" " [,disable-agent-file-xfer][,agent-mouse=3D[on|off]]\n" " [,playback-compression=3D[on|off]][,seamless-migration=3D[on|o= ff]]\n" - " [,gl=3D[on|off]]\n" + " [,gl=3D[on|off]][,rendernode=3D]\n" " enable spice\n" " at least one of {port, tls-port} is mandatory\n", QEMU_ARCH_ALL) @@ -1161,6 +1161,10 @@ Enable/disable spice seamless migration. Default is = off. @item gl=3D[on|off] Enable/disable OpenGL context. Default is off. =20 +@item rendernode=3D +DRM render node for OpenGL rendering. If not specified, it will pick +the first available. (Since 2.9) + @end table ETEXI =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index cd24568..417462b 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -44,13 +44,17 @@ int qemu_egl_rn_fd; struct gbm_device *qemu_egl_rn_gbm_dev; EGLContext qemu_egl_rn_ctx; =20 -int qemu_egl_rendernode_open(void) +static int qemu_egl_rendernode_open(const char *rendernode) { DIR *dir; struct dirent *e; int r, fd; char *p; =20 + if (rendernode) { + return open(rendernode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK= ); + } + dir =3D opendir("/dev/dri"); if (!dir) { return -1; @@ -85,11 +89,11 @@ int qemu_egl_rendernode_open(void) return fd; } =20 -int egl_rendernode_init(void) +int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd =3D -1; =20 - qemu_egl_rn_fd =3D qemu_egl_rendernode_open(); + qemu_egl_rn_fd =3D qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd =3D=3D -1) { error_report("egl: no drm render node available"); goto err; diff --git a/ui/spice-core.c b/ui/spice-core.c index 1452e77..39ccab7 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -501,6 +501,9 @@ static QemuOptsList qemu_spice_opts =3D { },{ .name =3D "gl", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "rendernode", + .type =3D QEMU_OPT_STRING, #endif }, { /* end of list */ } @@ -833,7 +836,7 @@ void qemu_spice_init(void) "incompatible with -spice port/tls-port"); exit(1); } - if (egl_rendernode_init() !=3D 0) { + if (egl_rendernode_init(qemu_opt_get(opts, "rendernode")) !=3D 0) { error_report("Failed to initialize EGL render node for SPICE G= L"); exit(1); } --=20 1.8.3.1 From nobody Mon Apr 29 12:15:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487597653663625.2356048594402; Mon, 20 Feb 2017 05:34:13 -0800 (PST) Received: from localhost ([::1]:38559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfo6V-0007eg-FX for importer@patchew.org; Mon, 20 Feb 2017 08:34:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cfnxD-0007i9-4M for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cfnx8-0007lU-Rw for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cfnx8-0007l6-M4 for qemu-devel@nongnu.org; Mon, 20 Feb 2017 08:24:30 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D894AC05681A for ; Mon, 20 Feb 2017 13:24:30 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1KDOTq5021609; Mon, 20 Feb 2017 08:24:30 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 7D2F680E82; Mon, 20 Feb 2017 14:24:28 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 20 Feb 2017 14:24:25 +0100 Message-Id: <1487597065-27023-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1487597065-27023-1-git-send-email-kraxel@redhat.com> References: <1487597065-27023-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 20 Feb 2017 13:24:30 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/2] egl-helpers: Support newer MESA versions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Frediano Ziglio Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Frediano Ziglio According to https://www.khronos.org/registry/EGL/extensions/MESA/EGL_MESA_platform_gbm.= txt if MESA_platform_gbm is supported display should be initialized from a GBM handle using eglGetPlatformDisplayEXT. Signed-off-by: Frediano Ziglio Message-id: 20170220095055.4234-1-fziglio@redhat.com Signed-off-by: Gerd Hoffmann --- ui/egl-helpers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index 417462b..584dd1b 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -223,7 +223,11 @@ int qemu_egl_init_dpy(EGLNativeDisplayType dpy, bool g= les, bool debug) } =20 egl_dbg("eglGetDisplay (dpy %p) ...\n", dpy); +#ifdef EGL_MESA_platform_gbm + qemu_egl_display =3D eglGetPlatformDisplayEXT(EGL_PLATFORM_GBM_MESA, d= py, NULL); +#else qemu_egl_display =3D eglGetDisplay(dpy); +#endif if (qemu_egl_display =3D=3D EGL_NO_DISPLAY) { error_report("egl: eglGetDisplay failed"); return -1; --=20 1.8.3.1