Index: /trunk/include/VBox/VBoxGuestLib.h
===================================================================
--- /trunk/include/VBox/VBoxGuestLib.h	(revision 86876)
+++ /trunk/include/VBox/VBoxGuestLib.h	(revision 86877)
@@ -812,4 +812,11 @@
 VBGLR3DECL(int)     VbglR3WriteCoreDump(void);
 
+/** @}  */
+
+/** @name DRM client handling
+ * @{ */
+VBGLR3DECL(bool)    VbglR3DRMClientIsNeeded(void);
+VBGLR3DECL(bool)    VbglR3DRMClientIsRunning(void);
+VBGLR3DECL(int)     VbglR3DRMClientStart(void);
 /** @}  */
 
Index: /trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk	(revision 86876)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk	(revision 86877)
@@ -122,4 +122,5 @@
 	VBoxGuestR3LibCpuHotPlug.cpp \
 	VBoxGuestR3LibCredentials.cpp \
+	VBoxGuestR3LibDRMClient.cpp \
 	VBoxGuestR3LibEvent.cpp \
 	VBoxGuestR3LibGuestUser.cpp \
Index: /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDRMClient.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDRMClient.cpp	(revision 86877)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDRMClient.cpp	(revision 86877)
@@ -0,0 +1,99 @@
+/* $Id$ */
+/** @file
+ * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, DRM client handling.
+ */
+
+/*
+ * Copyright (C) 2020 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * The contents of this file may alternatively be used under the terms
+ * of the Common Development and Distribution License Version 1.0
+ * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
+ * VirtualBox OSE distribution, in which case the provisions of the
+ * CDDL are applicable instead of those of the GPL.
+ *
+ * You may elect to license modified versions of this file under the
+ * terms and conditions of either the GPL or the CDDL or both.
+ */
+
+
+/*********************************************************************************************************************************
+*   Header Files                                                                                                                 *
+*********************************************************************************************************************************/
+#include "VBoxGuestR3LibInternal.h"
+
+#include <iprt/env.h>
+#include <iprt/path.h>
+#include <iprt/process.h>
+
+/** Defines the DRM client executable (image). */
+#define VBOX_DRMCLIENT_EXECUTABLE        "VBoxDRMClient"
+/** Defines the guest property that defines if the DRM resizing client needs to be active or not. */
+#define VBOX_DRMCLIENT_GUEST_PROP_RESIZE "/VirtualBox/GuestAdd/DRMResize"
+
+/**
+ * Returns if the DRM resizing client is needed.
+ * This is achieved by querying existence of a guest property.
+ *
+ * @returns \c true if the DRM resizing client is needed, \c false if not.
+ */
+VBGLR3DECL(bool) VbglR3DRMClientIsNeeded(void)
+{
+    bool fStartClient = false;
+
+#ifdef VBOX_WITH_GUEST_PROPS
+    uint32_t idClient;
+    int rc = VbglR3GuestPropConnect(&idClient);
+    if (RT_SUCCESS(rc))
+    {
+        fStartClient = VbglR3GuestPropExist(idClient, VBOX_DRMCLIENT_GUEST_PROP_RESIZE /*pszPropName*/);
+        VbglR3GuestPropDisconnect(idClient);
+    }
+#endif
+
+    return fStartClient;
+}
+
+/**
+ * Returns if the DRM resizing client already is running.
+ * This is achieved by querying existence of a guest property.
+ *
+ * @returns \c true if the DRM resizing client is running, \c false if not.
+ */
+VBGLR3DECL(bool) VbglR3DRMClientIsRunning(void)
+{
+    return VbglR3DRMClientIsNeeded();
+}
+
+/**
+ * Starts (executes) the DRM resizing client process ("VBoxDRMClient").
+ *
+ * @returns VBox status code.
+ */
+VBGLR3DECL(int) VbglR3DRMClientStart(void)
+{
+    char szDRMClientPath[RTPATH_MAX];
+    int rc = RTPathExecDir(szDRMClientPath, RTPATH_MAX);
+    if (RT_SUCCESS(rc))
+    {
+        RTPathStripSuffix(szDRMClientPath);
+        rc = RTPathAppend(szDRMClientPath, RTPATH_MAX, VBOX_DRMCLIENT_EXECUTABLE);
+        if (RT_SUCCESS(rc))
+        {
+            const char *apszArgs[1] = { NULL }; /** @todo r=andy Pass path + process name as argv0? */
+            rc = RTProcCreate(VBOX_DRMCLIENT_EXECUTABLE, apszArgs, RTENV_DEFAULT,
+                              RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SEARCH_PATH, NULL);
+        }
+   }
+
+   return rc;
+}
+
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp	(revision 86876)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp	(revision 86877)
@@ -894,32 +894,4 @@
 }
 
-#ifdef VBOX_WITH_VBOXSERVICE_DRMRESIZE
-/**
- * Check for a guest property and start VBoxDRMClient if it exists.
- *
- */
-static void startDRMResize(void)
-{
-    uint32_t uGuestPropSvcClientID;
-    int rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
-    if (RT_SUCCESS(rc))
-    {
-        rc = VbglR3GuestPropExist(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/DRMResize");
-        if (RT_SUCCESS(rc))
-        {
-            RTMsgInfo("Starting DRM resize service");
-            char szDRMClientPath[RTPATH_MAX];
-            RTPathExecDir(szDRMClientPath, RTPATH_MAX);
-            RTPathStripSuffix(szDRMClientPath);
-            RTPathAppend(szDRMClientPath, RTPATH_MAX, "VBoxDRMClient");
-            const char *apszArgs[1] = { NULL };
-            rc = RTProcCreate("VBoxDRMClient", apszArgs, RTENV_DEFAULT,
-                              RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SEARCH_PATH, NULL);
-            if (rc == -1)
-                RTMsgError("Could not start DRM resize service");
-        }
-    }
-}
-#endif /* VBOX_WITH_VBOXSERVICE_DRMRESIZE */
 
 int main(int argc, char **argv)
@@ -1188,5 +1160,10 @@
 
 #ifdef VBOX_WITH_VBOXSERVICE_DRMRESIZE
-    startDRMResize();
+	if (VbglR3DRMClientIsNeeded())
+    {
+        rc = VbglR3DRMClientStart();
+        if (RT_FAILURE(rc))
+            VGSvcError("Starting DRM resizing client failed with %Rrc\n", rc);
+    }
 #endif /* VBOX_WITH_VBOXSERVICE_DRMRESIZE */
 
Index: /trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp
===================================================================
--- /trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp	(revision 86876)
+++ /trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp	(revision 86877)
@@ -670,46 +670,11 @@
     const char *pSessionType;
 
-    if (pDisplayType != NULL) {
+    if (pDisplayType != NULL)
         return true;
-    }
-    pSessionType = getenv("XDG_SESSION_TYPE");
-    if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland"))) {
+
+    pSessionType = getenv("XDG_SESSION_TYPE"); /** @todo r=andy Use RTEnv API. */
+    if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland")))
         return true;
-    }
-    return false;
-}
-
-/**
- * We start VBoxDRMClient from VBoxService in case  some guest property is set.
- * We check the same guest property here and dont start this service in case
- * it (guest property) is set.
- */
-static bool checkDRMClient(void)
-{
-    bool fStartClient = false;
-
-    uint32_t idClient;
-    int rc = VbglR3GuestPropConnect(&idClient);
-    if (RT_SUCCESS(rc))
-    {
-        fStartClient = VbglR3GuestPropExist(idClient, "/VirtualBox/GuestAdd/DRMResize" /*pszPropName*/);
-        VbglR3GuestPropDisconnect(idClient);
-    }
-
-    return fStartClient;
-}
-
-static bool startDRMClient(void)
-{
-    char* argv[] = {NULL};
-    char* env[] = {NULL};
-    char szDRMClientPath[RTPATH_MAX];
-    RTPathExecDir(szDRMClientPath, RTPATH_MAX);
-    RTPathAppend(szDRMClientPath, RTPATH_MAX, "VBoxDRMClient");
-    VBClLogInfo("Starting DRM client.\n");
-    int rc = execve(szDRMClientPath, argv, env);
-    if (rc == -1)
-        VBClLogFatalError("execve for '%s' returns the following error %d: %s\n", szDRMClientPath, errno, strerror(errno));
-    /* This is reached only when execve fails. */
+
     return false;
 }
@@ -723,25 +688,38 @@
      * So for 32-bit GAs we use our DRM client. */
 #if ARCH_BITS == 32
-    /* igore rc */ startDRMClient();
-    return VERR_NOT_AVAILABLE;
+    int rc = VbglR3DRMClientStart();
+    if (RT_FAILURE(rc))
+        VBClLogError("Starting DRM resizing client (32-bit) failed with %Rrc\n", rc);
+    return VERR_NOT_AVAILABLE; /** @todo r=andy Why ignoring rc here? */
 #endif
 
     /* If DRM client is already running don't start this service. */
-    if (checkDRMClient())
-    {
-        VBClLogFatalError("DRM resizing is already running. Exiting this service\n");
+    if (VbglR3DRMClientIsRunning())
+    {
+        VBClLogInfo("DRM resizing is already running. Exiting this service\n");
         return VERR_NOT_AVAILABLE;
     }
+
     if (isXwayland())
-        return startDRMClient();
+    {
+        int rc = VbglR3DRMClientStart();
+        if (RT_FAILURE(rc))
+            VBClLogError("Starting DRM resizing client failed with %Rrc\n", rc);
+        return rc;
+    }
 
     x11Connect();
+
     if (x11Context.pDisplay == NULL)
-        return false;
+        return VERR_NOT_AVAILABLE;
+
     /* don't start the monitoring thread if related randr functionality is not available. */
     if (x11Context.fMonitorInfoAvailable)
+    {
         if (RT_FAILURE(startX11MonitorThread()))
-            return false;
-    return true;
+            return VERR_NOT_AVAILABLE;
+    }
+
+    return VINF_SUCCESS;
 }
 
