From nobody Sat Apr 27 03:16:03 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 1486898555933471.4254305919644; Sun, 12 Feb 2017 03:22:35 -0800 (PST) Received: from localhost ([::1]:51540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccsEk-00068h-GT for importer@patchew.org; Sun, 12 Feb 2017 06:22:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccsDi-0005bb-1Z for qemu-devel@nongnu.org; Sun, 12 Feb 2017 06:21:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccsDe-0007Fl-TG for qemu-devel@nongnu.org; Sun, 12 Feb 2017 06:21:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50074) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ccsDe-0007De-Kw for qemu-devel@nongnu.org; Sun, 12 Feb 2017 06:21:26 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 DD27361B91 for ; Sun, 12 Feb 2017 11:21:25 +0000 (UTC) Received: from localhost (ovpn-116-64.phx2.redhat.com [10.3.116.64]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1CBLNVI024633; Sun, 12 Feb 2017 06:21:24 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Sun, 12 Feb 2017 15:21:18 +0400 Message-Id: <20170212112118.16044-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 12 Feb 2017 11:21:25 +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] [PATCH] 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?= , kraxel@redhat.com 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" 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 --- include/ui/egl-helpers.h | 3 +-- ui/egl-helpers.c | 10 +++++++--- ui/spice-core.c | 5 ++++- qemu-options.hx | 6 +++++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index 03fcf4bba2..88a13e827b 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/ui/egl-helpers.c b/ui/egl-helpers.c index cd24568a5e..417462b76d 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 1452e77fd1..39ccab7561 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); } diff --git a/qemu-options.hx b/qemu-options.hx index ac036b4cbd..b64087d934 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 --=20 2.11.0.295.gd7dffce1c.dirty