From 7b5255083b7965b427052b5a0b911e51556139ca Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 12 Feb 2017 15:21:18 +0400 Subject: spice: allow to specify drm rendernode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Lureau Message-id: 20170212112118.16044-1-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- ui/egl-helpers.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ui/egl-helpers.c') 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; -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; + if (rendernode) { + return open(rendernode, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); + } + dir = opendir("/dev/dri"); if (!dir) { return -1; @@ -85,11 +89,11 @@ int qemu_egl_rendernode_open(void) return fd; } -int egl_rendernode_init(void) +int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd = -1; - qemu_egl_rn_fd = qemu_egl_rendernode_open(); + qemu_egl_rn_fd = qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd == -1) { error_report("egl: no drm render node available"); goto err; -- cgit v1.2.3