[Pkg-virtualbox-commits] [virtualbox] 01/17: Try to use Vbox provided GL.so and EGL.so libraries
Gianfranco Costamagna
locutusofborg at moszumanska.debian.org
Tue Aug 23 16:42:49 UTC 2016
This is an automated email from the git hooks/post-receive script.
locutusofborg pushed a commit to branch master
in repository virtualbox.
commit 9b4eb6f74ca9bb1a289f2786585d4df606f78e1d
Author: Gianfranco Costamagna <costamagnagianfranco at yahoo.it>
Date: Fri Jul 15 11:38:32 2016 +0200
Try to use Vbox provided GL.so and EGL.so libraries
---
debian/changelog | 7 +-
debian/patches/gl-fix.patch | 206 +++++++++++++++++++++
debian/patches/series | 1 +
debian/virtualbox-guest-x11.dirs | 1 +
debian/virtualbox-guest-x11.files/00vboxvideo.conf | 1 +
debian/virtualbox-guest-x11.install | 4 +
debian/virtualbox-guest-x11.links | 4 +
debian/virtualbox-guest-x11.postinst | 17 ++
debian/virtualbox-guest-x11.prerm | 16 ++
9 files changed, 255 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8547cf6..219b1b0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,11 @@
-virtualbox (5.1.0-dfsg-1) experimental; urgency=medium
+virtualbox (5.1.0-dfsg-1) UNRELEASED; urgency=medium
* New upstream major release, patch refresh.
- * Update to qt5
+ * Update dependencies to qt5
* Regenerate manpages
+ * Major rewrite of the guest-additions GL library handling
+ * Backport upstream patch for non-root Xorg guest run
+ LP: #1599775
-- Gianfranco Costamagna <locutusofborg at debian.org> Mon, 30 May 2016 12:30:24 +0200
diff --git a/debian/patches/gl-fix.patch b/debian/patches/gl-fix.patch
new file mode 100644
index 0000000..7ccb75e
--- /dev/null
+++ b/debian/patches/gl-fix.patch
@@ -0,0 +1,206 @@
+Index: src/VBox/Additions/common/crOpenGL/egl.c
+===================================================================
+--- a/src/VBox/Additions/common/crOpenGL/egl.c
++++ b/src/VBox/Additions/common/crOpenGL/egl.c
+@@ -21,8 +21,5 @@
+ *******************************************************************************/
+ #include <iprt/cdefs.h>
+-#include <iprt/initterm.h>
+-#include <iprt/mem.h>
+-#include <iprt/once.h>
+-#include <iprt/thread.h>
++#include <iprt/types.h>
+
+ #include <EGL/egl.h>
+@@ -30,5 +27,11 @@
+ #include <X11/Xlib.h>
+
++#include <dlfcn.h>
++#include <pthread.h>
++#include <stdio.h>
+ #include <stdlib.h>
++
++#define EGL_ASSERT(expr) \
++ if (!(expr)) { printf("Assertion failed: %s\n", #expr); exit(1); }
+
+ /*******************************************************************************
+@@ -72,14 +75,12 @@
+ *******************************************************************************/
+
+-static RTTLS g_tls = NIL_RTTLS;
+-static RTONCE g_tlsOnce = RTONCE_INITIALIZER;
+-static Display *g_pDefaultDisplay = NULL;
+-static RTONCE g_defaultDisplayOnce = RTONCE_INITIALIZER;
+-
+-static DECLCALLBACK(int32_t) tlsInitOnce(void *pv)
+-{
+- NOREF(pv);
+- g_tls = RTTlsAlloc();
+- return VINF_SUCCESS;
++static pthread_key_t g_tls;
++static pthread_once_t g_tlsOnce = PTHREAD_ONCE_INIT;
++static Display *g_pDefaultDisplay = NULL;
++static pthread_once_t g_defaultDisplayOnce = PTHREAD_ONCE_INIT;
++
++static void tlsInitOnce(void)
++{
++ pthread_key_create(&g_tls, NULL);
+ }
+
+@@ -88,9 +89,9 @@
+ struct VBEGLTLS *pTls;
+
+- RTOnce(&g_tlsOnce, tlsInitOnce, NULL);
+- pTls = (struct VBEGLTLS *)RTTlsGet(g_tls);
++ pthread_once(&g_tlsOnce, tlsInitOnce);
++ pTls = (struct VBEGLTLS *)pthread_getspecific(g_tls);
+ if (RT_LIKELY(pTls))
+ return pTls;
+- pTls = (struct VBEGLTLS *)RTMemAlloc(sizeof(*pTls));
++ pTls = (struct VBEGLTLS *)malloc(sizeof(*pTls));
+ if (!VALID_PTR(pTls))
+ return NULL;
+@@ -101,13 +102,13 @@
+ pTls->hCurrentDraw = EGL_NO_SURFACE;
+ pTls->hCurrentRead = EGL_NO_SURFACE;
+- RTTlsSet(g_tls, pTls);
+- return pTls;
+-}
+-
+-static DECLCALLBACK(int32_t) defaultDisplayInitOnce(void *pv)
+-{
+- NOREF(pv);
++ if (pthread_setspecific(g_tls, pTls) == 0)
++ return pTls;
++ free(pTls);
++ return NULL;
++}
++
++static void defaultDisplayInitOnce(void)
++{
+ g_pDefaultDisplay = XOpenDisplay(NULL);
+- return VINF_SUCCESS;
+ }
+
+@@ -131,15 +132,24 @@
+ }
+
++static EGLBoolean testValidDisplay(EGLNativeDisplayType hDisplay)
++{
++ if (hDisplay == EGL_DEFAULT_DISPLAY)
++ return EGL_TRUE;
++ if ((void *)hDisplay == NULL)
++ return EGL_FALSE;
++ /* This is the test that Mesa uses to see if this is a GBM "display". Not
++ * very pretty, but since no one can afford to break Mesa it should be
++ * safe. Obviously we can't support GBM for now. */
++ if (*(void **)hDisplay == dlsym(NULL, "gbm_create_device"))
++ return EGL_FALSE;
++ return EGL_TRUE;
++}
++
+ DECLEXPORT(EGLDisplay) eglGetDisplay(EGLNativeDisplayType hDisplay)
+ {
+ Display *pDisplay;
+ int rc, cError, cEvent, cMajor, cMinor;
+- /* Prevent working from inside the X server by requiring a valid DISPLAY. */
+- char *pszDisplay = getenv("DISPLAY");
+-
+- if (!pszDisplay || !*pszDisplay)
+- return EGL_NO_DISPLAY;
+- rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE);
+- if (RT_FAILURE(rc))
++
++ if (!testValidDisplay(hDisplay))
+ return EGL_NO_DISPLAY;
+ if (!clearEGLError()) /* Set up our tls. */
+@@ -149,5 +159,5 @@
+ else
+ {
+- RTOnce(&g_defaultDisplayOnce, defaultDisplayInitOnce, NULL);
++ pthread_once(&g_defaultDisplayOnce, defaultDisplayInitOnce);
+ pDisplay = g_pDefaultDisplay;
+ }
+@@ -170,8 +180,5 @@
+ DECLEXPORT(EGLBoolean) eglInitialize (EGLDisplay hDisplay, EGLint *pcMajor, EGLint *pcMinor)
+ {
+- /* Prevent working from inside the X server by requiring a valid DISPLAY. */
+- char *pszDisplay = getenv("DISPLAY");
+-
+- if (!pszDisplay || !*pszDisplay)
++ if (hDisplay == EGL_NO_DISPLAY)
+ return EGL_FALSE;
+ if (!VALID_PTR(hDisplay))
+@@ -222,5 +229,6 @@
+ return setEGLError(EGL_BAD_PARAMETER);
+ paFBConfigs = glXGetFBConfigs(pDisplay, DefaultScreen(pDisplay), &caFBConfigs);
+- AssertPtrReturn(paFBConfigs, setEGLError(EGL_BAD_PARAMETER));
++ if (!VALID_PTR(paFBConfigs))
++ return setEGLError(EGL_BAD_PARAMETER);
+ if (caFBConfigs > caConfigs)
+ caFBConfigs = caConfigs;
+@@ -426,5 +434,5 @@
+ {
+ aAttribList[cAttribs] = None;
+- AssertRelease(cAttribs < RT_ELEMENTS(aAttribList));
++ EGL_ASSERT(cAttribs < RT_ELEMENTS(aAttribList));
+ if (!(cRenderableType & EGL_OPENGL_BIT))
+ return setEGLError(EGL_BAD_ACCESS);
+@@ -559,5 +567,5 @@
+ return EGL_NO_SURFACE;
+ }
+- AssertRelease(hGLXWindow < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
++ EGL_ASSERT(hGLXWindow < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
+ clearEGLError();
+ return (EGLSurface)(hGLXWindow | VBEGL_WINDOW_SURFACE);
+@@ -627,5 +635,5 @@
+ paAttributes += 2;
+ }
+- AssertRelease(cIndex < RT_ELEMENTS(aAttributes) - 1);
++ EGL_ASSERT(cIndex < RT_ELEMENTS(aAttributes) - 1);
+ aAttributes[cIndex + 1] = None;
+ hPbuffer = glXCreatePbuffer(pDisplay, (GLXFBConfig)config, aAttributes);
+@@ -635,5 +643,5 @@
+ return EGL_NO_SURFACE;
+ }
+- AssertRelease(hPbuffer < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
++ EGL_ASSERT(hPbuffer < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
+ clearEGLError();
+ return (EGLSurface)(hPbuffer | VBEGL_PBUFFER_SURFACE);
+@@ -671,5 +679,5 @@
+ return EGL_NO_SURFACE;
+ }
+- AssertRelease(hGLXPixmap < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
++ EGL_ASSERT(hGLXPixmap < VBEGL_WINDOW_SURFACE); /* Greater than the maximum XID. */
+ clearEGLError();
+ return (EGLSurface)(hGLXPixmap | VBEGL_PIXMAP_SURFACE);
+@@ -741,9 +749,4 @@
+ DECLEXPORT(EGLBoolean) eglBindAPI(EGLenum enmApi)
+ {
+- /* Prevent working from inside the X server by requiring a valid DISPLAY. */
+- char *pszDisplay = getenv("DISPLAY");
+-
+- if (!pszDisplay || !*pszDisplay)
+- return EGL_FALSE;
+ return enmApi == EGL_OPENGL_API ? clearEGLError() : setEGLError(EGL_BAD_PARAMETER);
+ }
+@@ -842,6 +845,7 @@
+ DECLEXPORT(EGLDisplay) eglGetCurrentDisplay(void)
+ {
+- struct VBEGLTLS *pTls = getTls();
+-
++ struct VBEGLTLS *pTls;
++
++ pTls = getTls();
+ if (!VALID_PTR(pTls))
+ return EGL_NO_DISPLAY;
+@@ -947,6 +951,7 @@
+ if (!(pTls))
+ return EGL_TRUE;
+- RTMemFree(pTls);
+- RTTlsSet(g_tls, NULL);
++ free(pTls);
++ /* Can this fail with ENOMEM? */
++ pthread_setspecific(g_tls, NULL);
+ return EGL_TRUE;
+ }
diff --git a/debian/patches/series b/debian/patches/series
index 5b32c83..2f6ae80 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -14,3 +14,4 @@
32-disable-guest-version-check.patch
35-libvdeplug-soname.patch
36-fix-vnc-version-string.patch
+gl-fix.patch
diff --git a/debian/virtualbox-guest-x11.dirs b/debian/virtualbox-guest-x11.dirs
new file mode 100644
index 0000000..0369ff7
--- /dev/null
+++ b/debian/virtualbox-guest-x11.dirs
@@ -0,0 +1 @@
+/usr/lib/virtualbox/additions
diff --git a/debian/virtualbox-guest-x11.files/00vboxvideo.conf b/debian/virtualbox-guest-x11.files/00vboxvideo.conf
new file mode 100644
index 0000000..0369ff7
--- /dev/null
+++ b/debian/virtualbox-guest-x11.files/00vboxvideo.conf
@@ -0,0 +1 @@
+/usr/lib/virtualbox/additions
diff --git a/debian/virtualbox-guest-x11.install b/debian/virtualbox-guest-x11.install
index 3b7aa74..04db04c 100644
--- a/debian/virtualbox-guest-x11.install
+++ b/debian/virtualbox-guest-x11.install
@@ -3,3 +3,7 @@ src/VBox/Additions/x11/Installer/x11config.pl /usr/share/virtualbox
src/VBox/Additions/x11/Installer/98vboxadd-xclient /etc/X11/Xsession.d
out/bin/additions/VBoxOGL*.so /usr/lib
out/bin/additions/VBoxEGL*.so /usr/lib
+out/bin/additions/VBoxOGL*.so /usr/lib/virtualbox/additions
+out/bin/additions/VBoxEGL*.so /usr/lib/virtualbox/additions
+
+debian/virtualbox-guest-x11.files/00vboxvideo.conf /usr/lib/virtualbox/additions
diff --git a/debian/virtualbox-guest-x11.links b/debian/virtualbox-guest-x11.links
new file mode 100644
index 0000000..282e9ac
--- /dev/null
+++ b/debian/virtualbox-guest-x11.links
@@ -0,0 +1,4 @@
+/usr/lib/virtualbox/additions/VBoxOGL.so /usr/lib/virtualbox/additions/libGL.so.1
+/usr/lib/virtualbox/additions/VBoxOGL.so /usr/lib/virtualbox/additions/libGL.so
+/usr/lib/virtualbox/additions/VBoxEGL.so /usr/lib/virtualbox/additions/libEGL.so.1
+/usr/lib/virtualbox/additions/VBoxEGL.so /usr/lib/virtualbox/additions/libEGL.so
diff --git a/debian/virtualbox-guest-x11.postinst b/debian/virtualbox-guest-x11.postinst
index 748d03a..2e3bcff 100644
--- a/debian/virtualbox-guest-x11.postinst
+++ b/debian/virtualbox-guest-x11.postinst
@@ -2,7 +2,24 @@
set -e
+ARCH=`dpkg --print-architecture`
+
if [ "$1" = "configure" ]; then
+
+ if [ "$ARCH" = "amd64" ]; then
+ update-alternatives --force \
+ --install /etc/ld.so.conf.d/x86_64-linux-gnu_GL.conf x86_64-linux-gnu_gl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf 8605
+
+ update-alternatives --force \
+ --install /etc/ld.so.conf.d/x86_64-linux-gnu_EGL.conf x86_64-linux-gnu_egl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf 8605
+ else
+ update-alternatives --force \
+ --install /etc/ld.so.conf.d/i386-linux-gnu_GL.conf i386-linux-gnu_gl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf 8605
+
+ update-alternatives --force \
+ --install /etc/ld.so.conf.d/i386-linux-gnu_EGL.conf i386-linux-gnu_egl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf 8605
+ fi
+
ldconfig
fi
diff --git a/debian/virtualbox-guest-x11.prerm b/debian/virtualbox-guest-x11.prerm
new file mode 100644
index 0000000..d1ec441
--- /dev/null
+++ b/debian/virtualbox-guest-x11.prerm
@@ -0,0 +1,16 @@
+#!/bin/sh
+set -e
+
+ARCH=`dpkg --print-architecture`
+
+case "$1" in
+ remove)
+ update-alternatives --remove x86_64-linux-gnu_gl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf
+ update-alternatives --remove x86_64-linux-gnu_egl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf
+ update-alternatives --remove i386-linux-gnu_gl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf
+ update-alternatives --remove i386-linux-gnu_egl_conf /usr/lib/virtualbox/additions/00vboxvideo.conf
+ ldconfig
+ ;;
+
+esac
+##DEBHELPER##
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-virtualbox/virtualbox.git
More information about the Pkg-virtualbox-commits
mailing list