VirtualBox

Changeset 86877 in vbox


Ignore:
Timestamp:
Nov 12, 2020 6:32:51 PM (4 years ago)
Author:
vboxsync
Message:

Additions/VBoxDRMClient: Removed code duplication between VBoxClient / VBoxService by refactoring the VBoxDRMClient routines into VbglR3. Also improved error checking here and there, added @todos. bugref:9637

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLib.h

    r86876 r86877  
    812812VBGLR3DECL(int)     VbglR3WriteCoreDump(void);
    813813
     814/** @}  */
     815
     816/** @name DRM client handling
     817 * @{ */
     818VBGLR3DECL(bool)    VbglR3DRMClientIsNeeded(void);
     819VBGLR3DECL(bool)    VbglR3DRMClientIsRunning(void);
     820VBGLR3DECL(int)     VbglR3DRMClientStart(void);
    814821/** @}  */
    815822
  • trunk/src/VBox/Additions/common/VBoxGuest/lib/Makefile.kmk

    r83655 r86877  
    122122        VBoxGuestR3LibCpuHotPlug.cpp \
    123123        VBoxGuestR3LibCredentials.cpp \
     124        VBoxGuestR3LibDRMClient.cpp \
    124125        VBoxGuestR3LibEvent.cpp \
    125126        VBoxGuestR3LibGuestUser.cpp \
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp

    r86876 r86877  
    894894}
    895895
    896 #ifdef VBOX_WITH_VBOXSERVICE_DRMRESIZE
    897 /**
    898  * Check for a guest property and start VBoxDRMClient if it exists.
    899  *
    900  */
    901 static void startDRMResize(void)
    902 {
    903     uint32_t uGuestPropSvcClientID;
    904     int rc = VbglR3GuestPropConnect(&uGuestPropSvcClientID);
    905     if (RT_SUCCESS(rc))
    906     {
    907         rc = VbglR3GuestPropExist(uGuestPropSvcClientID, "/VirtualBox/GuestAdd/DRMResize");
    908         if (RT_SUCCESS(rc))
    909         {
    910             RTMsgInfo("Starting DRM resize service");
    911             char szDRMClientPath[RTPATH_MAX];
    912             RTPathExecDir(szDRMClientPath, RTPATH_MAX);
    913             RTPathStripSuffix(szDRMClientPath);
    914             RTPathAppend(szDRMClientPath, RTPATH_MAX, "VBoxDRMClient");
    915             const char *apszArgs[1] = { NULL };
    916             rc = RTProcCreate("VBoxDRMClient", apszArgs, RTENV_DEFAULT,
    917                               RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SEARCH_PATH, NULL);
    918             if (rc == -1)
    919                 RTMsgError("Could not start DRM resize service");
    920         }
    921     }
    922 }
    923 #endif /* VBOX_WITH_VBOXSERVICE_DRMRESIZE */
    924896
    925897int main(int argc, char **argv)
     
    11881160
    11891161#ifdef VBOX_WITH_VBOXSERVICE_DRMRESIZE
    1190     startDRMResize();
     1162        if (VbglR3DRMClientIsNeeded())
     1163    {
     1164        rc = VbglR3DRMClientStart();
     1165        if (RT_FAILURE(rc))
     1166            VGSvcError("Starting DRM resizing client failed with %Rrc\n", rc);
     1167    }
    11911168#endif /* VBOX_WITH_VBOXSERVICE_DRMRESIZE */
    11921169
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp

    r86876 r86877  
    670670    const char *pSessionType;
    671671
    672     if (pDisplayType != NULL) {
     672    if (pDisplayType != NULL)
    673673        return true;
    674     }
    675     pSessionType = getenv("XDG_SESSION_TYPE");
    676     if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland"))) {
     674
     675    pSessionType = getenv("XDG_SESSION_TYPE"); /** @todo r=andy Use RTEnv API. */
     676    if ((pSessionType != NULL) && (RTStrIStartsWith(pSessionType, "wayland")))
    677677        return true;
    678     }
    679     return false;
    680 }
    681 
    682 /**
    683  * We start VBoxDRMClient from VBoxService in case  some guest property is set.
    684  * We check the same guest property here and dont start this service in case
    685  * it (guest property) is set.
    686  */
    687 static bool checkDRMClient(void)
    688 {
    689     bool fStartClient = false;
    690 
    691     uint32_t idClient;
    692     int rc = VbglR3GuestPropConnect(&idClient);
    693     if (RT_SUCCESS(rc))
    694     {
    695         fStartClient = VbglR3GuestPropExist(idClient, "/VirtualBox/GuestAdd/DRMResize" /*pszPropName*/);
    696         VbglR3GuestPropDisconnect(idClient);
    697     }
    698 
    699     return fStartClient;
    700 }
    701 
    702 static bool startDRMClient(void)
    703 {
    704     char* argv[] = {NULL};
    705     char* env[] = {NULL};
    706     char szDRMClientPath[RTPATH_MAX];
    707     RTPathExecDir(szDRMClientPath, RTPATH_MAX);
    708     RTPathAppend(szDRMClientPath, RTPATH_MAX, "VBoxDRMClient");
    709     VBClLogInfo("Starting DRM client.\n");
    710     int rc = execve(szDRMClientPath, argv, env);
    711     if (rc == -1)
    712         VBClLogFatalError("execve for '%s' returns the following error %d: %s\n", szDRMClientPath, errno, strerror(errno));
    713     /* This is reached only when execve fails. */
     678
    714679    return false;
    715680}
     
    723688     * So for 32-bit GAs we use our DRM client. */
    724689#if ARCH_BITS == 32
    725     /* igore rc */ startDRMClient();
    726     return VERR_NOT_AVAILABLE;
     690    int rc = VbglR3DRMClientStart();
     691    if (RT_FAILURE(rc))
     692        VBClLogError("Starting DRM resizing client (32-bit) failed with %Rrc\n", rc);
     693    return VERR_NOT_AVAILABLE; /** @todo r=andy Why ignoring rc here? */
    727694#endif
    728695
    729696    /* If DRM client is already running don't start this service. */
    730     if (checkDRMClient())
    731     {
    732         VBClLogFatalError("DRM resizing is already running. Exiting this service\n");
     697    if (VbglR3DRMClientIsRunning())
     698    {
     699        VBClLogInfo("DRM resizing is already running. Exiting this service\n");
    733700        return VERR_NOT_AVAILABLE;
    734701    }
     702
    735703    if (isXwayland())
    736         return startDRMClient();
     704    {
     705        int rc = VbglR3DRMClientStart();
     706        if (RT_FAILURE(rc))
     707            VBClLogError("Starting DRM resizing client failed with %Rrc\n", rc);
     708        return rc;
     709    }
    737710
    738711    x11Connect();
     712
    739713    if (x11Context.pDisplay == NULL)
    740         return false;
     714        return VERR_NOT_AVAILABLE;
     715
    741716    /* don't start the monitoring thread if related randr functionality is not available. */
    742717    if (x11Context.fMonitorInfoAvailable)
     718    {
    743719        if (RT_FAILURE(startX11MonitorThread()))
    744             return false;
    745     return true;
     720            return VERR_NOT_AVAILABLE;
     721    }
     722
     723    return VINF_SUCCESS;
    746724}
    747725
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette