VirtualBox

Changeset 96885 in vbox


Ignore:
Timestamp:
Sep 26, 2022 7:09:42 PM (2 years ago)
Author:
vboxsync
Message:

Additions: X11: DRM Client: Monitor guest properties in a bit more efficient way, bugref:10134.

Once monitoring guest property change, there is no reason to re-ask host to re-read
guest property value if host already issued notification about the property.
Flag fWasDeleted will also tell if property was removed. This commit also makes a room
to monitor more than one guest property which related to VBoxDRMClient.

Location:
trunk
Files:
2 edited

Legend:

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

    r96407 r96885  
    826826/** @name DRM client handling
    827827 * @{ */
     828/** Guest property names pattern which is used by Guest Additions DRM services. */
     829# define VBGLR3DRMPROPPTR           "/VirtualBox/GuestAdd/DRM*"
    828830/** Guest property that defines if the DRM IPC server access should be restricted to a specific user group. */
    829831# define VBGLR3DRMIPCPROPRESTRICT   "/VirtualBox/GuestAdd/DRMIpcRestricted"
  • trunk/src/VBox/Additions/x11/VBoxClient/display-drm.cpp

    r96407 r96885  
    10851085 *
    10861086 * @param   hIpcServer  IPC server handle.
    1087  */
    1088 static void vbDrmSetIpcServerAccessPermissions(RTLOCALIPCSERVER hIpcServer)
     1087 * @param   fRestrict   Whether to restrict access to socket or not.
     1088 */
     1089static void vbDrmSetIpcServerAccessPermissions(RTLOCALIPCSERVER hIpcServer, bool fRestrict)
    10891090{
    10901091    int rc;
    10911092
    1092     ASMAtomicWriteBool(&g_fDrmIpcRestricted, VbglR3DrmRestrictedIpcAccessIsNeeded());
    1093 
    1094     if (g_fDrmIpcRestricted)
     1093    if (fRestrict)
    10951094    {
    10961095        struct group *pGrp;
     
    11191118            VBClLogError("unable to grant IPC server socket access to all users, rc=%Rrc\n", rc);
    11201119    }
     1120
     1121    /* Set flag for the thread which serves incomming IPC connections. */
     1122    ASMAtomicWriteBool(&g_fDrmIpcRestricted, fRestrict);
    11211123}
    11221124
     
    11381140        do
    11391141        {
    1140             /* Buffer should be big enough to fit guest property data layout: Name\0Value\0Flags\0. */
     1142            /* Buffer should be big enough to fit guest property data layout: Name\0Value\0Flags\0fWasDeleted\0. */
    11411143            static char achBuf[GUEST_PROP_MAX_NAME_LEN];
     1144            char *pszName = NULL;
     1145            char *pszValue = NULL;
     1146            char *pszFlags = NULL;
     1147            bool fWasDeleted = false;
    11421148            uint64_t u64Timestamp = 0;
    11431149
    1144             rc = VbglR3GuestPropWait(idClient, VBGLR3DRMIPCPROPRESTRICT, achBuf, sizeof(achBuf), u64Timestamp,
    1145                                      VBOX_DRMIPC_RX_TIMEOUT_MS, NULL, NULL, &u64Timestamp, NULL, NULL, NULL);
     1150            rc = VbglR3GuestPropWait(idClient, VBGLR3DRMPROPPTR, achBuf, sizeof(achBuf), u64Timestamp,
     1151                                     VBOX_DRMIPC_RX_TIMEOUT_MS, &pszName, &pszValue, &u64Timestamp,
     1152                                     &pszFlags, NULL, &fWasDeleted);
    11461153            if (RT_SUCCESS(rc))
    1147                 vbDrmSetIpcServerAccessPermissions(hIpcServer);
    1148             else if (   rc != VERR_TIMEOUT
     1154            {
     1155                uint32_t fFlags = 0;
     1156
     1157                VBClLogVerbose(1, "guest property change: name: %s, val: %s, flags: %s, fWasDeleted: %RTbool\n",
     1158                               pszName, pszValue, pszFlags, fWasDeleted);
     1159
     1160                if (RT_SUCCESS(GuestPropValidateFlags(pszFlags, &fFlags)))
     1161                {
     1162                    if (RTStrNCmp(pszName, VBGLR3DRMIPCPROPRESTRICT, GUEST_PROP_MAX_NAME_LEN) == 0)
     1163                    {
     1164                        /* Enforce restricted socket access until guest property exist and READ-ONLY for the guest. */
     1165                        vbDrmSetIpcServerAccessPermissions(hIpcServer, !fWasDeleted && fFlags & GUEST_PROP_F_RDONLYGUEST);
     1166                    }
     1167
     1168                } else
     1169                    VBClLogError("guest property change: name: %s, val: %s, flags: %s, fWasDeleted: %RTbool: bad flags\n",
     1170                                 pszName, pszValue, pszFlags, fWasDeleted);
     1171
     1172            } else if (   rc != VERR_TIMEOUT
    11491173                     && rc != VERR_INTERRUPTED)
    11501174            {
     
    12841308
    12851309    /* Set IPC server socket access permissions according to VM configuration. */
    1286     vbDrmSetIpcServerAccessPermissions(hIpcServer);
     1310    vbDrmSetIpcServerAccessPermissions(hIpcServer, VbglR3DrmRestrictedIpcAccessIsNeeded());
    12871311
    12881312    /* Attempt to start DRM resize task. */
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