VirtualBox

Changeset 54522 in vbox


Ignore:
Timestamp:
Feb 26, 2015 1:39:47 AM (10 years ago)
Author:
vboxsync
Message:

VBoxGuest.cpp: todo wrt unnecessary session walking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r54239 r54522  
    6767static DECLCALLBACK(int) VBoxGuestHGCMAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User);
    6868#endif
    69 
    70 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags);
     69static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask,
     70                                           uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags);
     71static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
    7172
    7273#define VBOXGUEST_ACQUIRE_STYLE_EVENTS (VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST | VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
     
    135136 * @param   fMask       The new mask.
    136137 */
    137 static int vboxGuestSetFilterMask(VMMDevCtlGuestFilterMask *pReq,
    138                                   uint32_t fMask)
     138static int vboxGuestSetFilterMask(VMMDevCtlGuestFilterMask *pReq, uint32_t fMask)
    139139{
    140140    int rc;
     
    158158 * @param   fMask       The new mask.
    159159 */
    160 static int vboxGuestSetCapabilities(VMMDevReqGuestCapabilities2 *pReq,
    161                                     uint32_t fMask)
     160static int vboxGuestSetCapabilities(VMMDevReqGuestCapabilities2 *pReq, uint32_t fMask)
    162161{
    163162    int rc;
     
    197196/** Host flags to be updated by a given invocation of the
    198197 * vboxGuestUpdateHostFlags() method. */
     198/** @todo r=bird: Use RT_BIT_32 for the bits, preferably replace enum with
     199 *        \#define. */
    199200enum
    200201{
     
    218219    int rc = VINF_SUCCESS;
    219220
     221/** @todo r=bird: Please just do the global bit counting thing.  This code
     222 * gives me the [performances] creeps.  */
    220223    RTListForEach(&pDevExt->SessionList, pIterator, VBOXGUESTSESSION, ListNode)
    221224    {
     
    245248
    246249
    247 /** Check which host flags in a given category are being asserted by some guest
     250/**
     251 * Calls the host and set the filter mask, capabilities and/or mouse status.
     252 *
     253 * Check which host flags in a given category are being asserted by some guest
    248254 * session and assert exactly those on the host which are being asserted by one
    249255 * or more sessions.  pCallingSession is purely for sanity checking and can be
    250256 * NULL.
     257 *
    251258 * @note Takes the session spin-lock.
    252259 */
    253260static int vboxGuestUpdateHostFlags(PVBOXGUESTDEVEXT pDevExt,
    254261                                    PVBOXGUESTSESSION pSession,
    255                                     unsigned enmFlags)
     262                                    unsigned fFlags)
    256263{
    257264    int rc;
     
    259266    VMMDevReqGuestCapabilities2 *pCapabilitiesReq = NULL;
    260267    VMMDevReqMouseStatus        *pStatusReq = NULL;
    261     uint32_t fFilterMask = 0, fCapabilities = 0, fMouseStatus = 0;
     268    uint32_t                     fFilterMask = 0;
     269    uint32_t                     fCapabilities = 0;
     270    uint32_t                     fMouseStatus = 0;
    262271
    263272    rc = VbglGRAlloc((VMMDevRequestHeader **)&pFilterReq, sizeof(*pFilterReq),
     
    270279        rc = VbglGRAlloc((VMMDevRequestHeader **)&pStatusReq,
    271280                         sizeof(*pStatusReq), VMMDevReq_SetMouseStatus);
    272     RTSpinlockAcquire(pDevExt->SessionSpinlock);
    273281    if (RT_SUCCESS(rc))
     282    {
     283        RTSpinlockAcquire(pDevExt->SessionSpinlock);
    274284        rc = vboxGuestGetHostFlagsFromSessions(pDevExt, pSession, &fFilterMask,
    275285                                               &fCapabilities, &fMouseStatus);
    276     if (RT_SUCCESS(rc))
    277     {
    278         fFilterMask |= pDevExt->fFixedEvents;
    279         /* Since VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR is inverted in the session
    280          * capabilities we invert it again before sending it to the host. */
    281         fMouseStatus ^= VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR;
    282         if (enmFlags & HostFlags_FilterMask)
    283             vboxGuestSetFilterMask(pFilterReq, fFilterMask);
    284         fCapabilities |= pDevExt->u32GuestCaps;
    285         if (enmFlags & HostFlags_Capabilities)
    286             vboxGuestSetCapabilities(pCapabilitiesReq, fCapabilities);
    287         if (enmFlags & HostFlags_MouseStatus)
    288             vboxGuestSetMouseStatus(pStatusReq, fMouseStatus);
    289     }
    290     RTSpinlockRelease(pDevExt->SessionSpinlock);
     286        if (RT_SUCCESS(rc))
     287        {
     288            fFilterMask |= pDevExt->fFixedEvents;
     289            /* Since VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR is inverted in the session
     290             * capabilities we invert it again before sending it to the host. */
     291            fMouseStatus ^= VMMDEV_MOUSE_GUEST_NEEDS_HOST_CURSOR;
     292            if (fFlags & HostFlags_FilterMask)
     293                vboxGuestSetFilterMask(pFilterReq, fFilterMask);
     294            fCapabilities |= pDevExt->u32GuestCaps;
     295            if (fFlags & HostFlags_Capabilities)
     296                vboxGuestSetCapabilities(pCapabilitiesReq, fCapabilities);
     297            if (fFlags & HostFlags_MouseStatus)
     298                vboxGuestSetMouseStatus(pStatusReq, fMouseStatus);
     299        }
     300        RTSpinlockRelease(pDevExt->SessionSpinlock);
     301    }
    291302    if (pFilterReq)
    292303        VbglGRFree(&pFilterReq->header);
     
    299310
    300311
     312/** @todo r=bird: WTF did someone add code before the globals? */
    301313/*******************************************************************************
    302314*   Global Variables                                                           *
     
    13331345}
    13341346
    1335 static int VBoxGuestCommonIOCtl_CancelAllWaitEvents(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession);
    13361347
    13371348/**
     
    13431354void VBoxGuestCloseSession(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession)
    13441355{
    1345     unsigned i; NOREF(i);
     1356#ifdef VBOX_WITH_HGCM
     1357    unsigned i;
     1358#endif
    13461359    LogFlow(("VBoxGuestCloseSession: pSession=%p proc=%RTproc (%d) r0proc=%p\n",
    13471360             pSession, pSession->Process, (int)pSession->Process, (uintptr_t)pSession->R0Process)); /** @todo %RTr0proc */
     
    13731386    RTMemFree(pSession);
    13741387    /* Update the host flags (mouse status etc) not to reflect this session. */
    1375     vboxGuestUpdateHostFlags(pDevExt, NULL, HostFlags_All
     1388    vboxGuestUpdateHostFlags(pDevExt, NULL,
     1389                               HostFlags_All
    13761390#ifdef RT_OS_WINDOWS
    1377                 & (~HostFlags_MouseStatus)
     1391                             & ~HostFlags_MouseStatus
    13781392#endif
    1379             );
     1393                             );
    13801394}
    13811395
     
    20812095
    20822096
    2083 static int VBoxGuestCommonIOCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt,
    2084                                               PVBOXGUESTSESSION pSession,
     2097static int VBoxGuestCommonIOCtl_CtlFilterMask(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
    20852098                                              VBoxGuestFilterMaskInfo *pInfo)
    20862099{
     
    20982111
    20992112
    2100 static int VBoxGuestCommonIOCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt,
    2101                                             PVBOXGUESTSESSION pSession,
    2102                                             VBoxGuestSetCapabilitiesInfo *pInfo)
     2113static int VBoxGuestCommonIOCtl_SetCapabilities(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
     2114                                                VBoxGuestSetCapabilitiesInfo *pInfo)
    21032115{
    21042116    int rc;
    21052117
    2106     if (  (pInfo->u32OrMask | pInfo->u32NotMask)
    2107         & ~VMMDEV_GUEST_CAPABILITIES_MASK)
     2118    if ((pInfo->u32OrMask | pInfo->u32NotMask) & ~VMMDEV_GUEST_CAPABILITIES_MASK)
    21082119        return VERR_INVALID_PARAMETER;
    21092120    RTSpinlockAcquire(pDevExt->SessionSpinlock);
     
    21262137 * @param   fFeatures           New bitmap of enabled features.
    21272138 */
    2128 static int vboxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt,
    2129                                                PVBOXGUESTSESSION pSession,
    2130                                                uint32_t fFeatures)
     2139static int vboxGuestCommonIOCtl_SetMouseStatus(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fFeatures)
    21312140{
    21322141    int rc;
     
    22482257                                                true /* fInterruptible */,
    22492258                                                u32User /* cMillies */ );
    2250 
    22512259}
    22522260
     
    26892697 * VBOXGUESTCAPSACQUIRE_FLAGS_CONFIG_ACQUIRE_MODE, also try to acquire those
    26902698 * capabilities for the current session and release those in @a fNotFlag. */
    2691 static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession, uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags)
     2699static int VBoxGuestCommonGuestCapsAcquire(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
     2700                                           uint32_t fOrMask, uint32_t fNotMask, VBOXGUESTCAPSACQUIRE_FLAGS enmFlags)
    26922701{
    26932702    uint32_t fSetCaps = 0;
     
    27772786         * this is generally bad since e.g. failure to release the caps may result in other sessions not being able to use it
    27782787         * so we are not trying to restore the caps back to their values before the VBoxGuestCommonGuestCapsAcquire call,
    2779          * but just pretend everithing is OK.
    2780          * @todo: better failure handling mechanism? */
     2788         * but just pretend everithing is OK. */
     2789        /** @todo better failure handling mechanism? */
    27812790    }
    27822791
     
    29742983
    29752984            case VBOXGUEST_IOCTL_CTL_FILTER_MASK:
    2976                 CHECKRET_MIN_SIZE("CTL_FILTER_MASK",
    2977                                   sizeof(VBoxGuestFilterMaskInfo));
    2978                 rc = VBoxGuestCommonIOCtl_CtlFilterMask(pDevExt, pSession,
    2979                                              (VBoxGuestFilterMaskInfo *)pvData);
     2985                CHECKRET_MIN_SIZE("CTL_FILTER_MASK", sizeof(VBoxGuestFilterMaskInfo));
     2986                rc = VBoxGuestCommonIOCtl_CtlFilterMask(pDevExt, pSession, (VBoxGuestFilterMaskInfo *)pvData);
    29802987                break;
    29812988
     
    29943001# endif
    29953002                CHECKRET_MIN_SIZE("HGCM_DISCONNECT", sizeof(VBoxGuestHGCMDisconnectInfo));
    2996                 rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData, pcbDataReturned);
     3003                rc = VBoxGuestCommonIOCtl_HGCMDisconnect(pDevExt, pSession, (VBoxGuestHGCMDisconnectInfo *)pvData,
     3004                                                         pcbDataReturned);
    29973005                break;
    29983006#endif /* VBOX_WITH_HGCM */
     
    30003008            case VBOXGUEST_IOCTL_CHECK_BALLOON:
    30013009                CHECKRET_MIN_SIZE("CHECK_MEMORY_BALLOON", sizeof(VBoxGuestCheckBalloonInfo));
    3002                 rc = VBoxGuestCommonIOCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData, pcbDataReturned);
     3010                rc = VBoxGuestCommonIOCtl_CheckMemoryBalloon(pDevExt, pSession, (VBoxGuestCheckBalloonInfo *)pvData,
     3011                                                             pcbDataReturned);
    30033012                break;
    30043013
    30053014            case VBOXGUEST_IOCTL_CHANGE_BALLOON:
    30063015                CHECKRET_MIN_SIZE("CHANGE_MEMORY_BALLOON", sizeof(VBoxGuestChangeBalloonInfo));
    3007                 rc = VBoxGuestCommonIOCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData, pcbDataReturned);
     3016                rc = VBoxGuestCommonIOCtl_ChangeMemoryBalloon(pDevExt, pSession, (VBoxGuestChangeBalloonInfo *)pvData,
     3017                                                              pcbDataReturned);
    30083018                break;
    30093019
     
    30153025            case VBOXGUEST_IOCTL_SET_MOUSE_STATUS:
    30163026                CHECKRET_SIZE("SET_MOUSE_STATUS", sizeof(uint32_t));
    3017                 rc = vboxGuestCommonIOCtl_SetMouseStatus(pDevExt, pSession,
    3018                                                          *(uint32_t *)pvData);
     3027                rc = vboxGuestCommonIOCtl_SetMouseStatus(pDevExt, pSession, *(uint32_t *)pvData);
    30193028                break;
    30203029
     
    30333042
    30343043            case VBOXGUEST_IOCTL_SET_GUEST_CAPABILITIES:
    3035                 CHECKRET_MIN_SIZE("SET_GUEST_CAPABILITIES",
    3036                                   sizeof(VBoxGuestSetCapabilitiesInfo));
    3037                 rc = VBoxGuestCommonIOCtl_SetCapabilities(pDevExt, pSession,
    3038                                         (VBoxGuestSetCapabilitiesInfo *)pvData);
     3044                CHECKRET_MIN_SIZE("SET_GUEST_CAPABILITIES", sizeof(VBoxGuestSetCapabilitiesInfo));
     3045                rc = VBoxGuestCommonIOCtl_SetCapabilities(pDevExt, pSession, (VBoxGuestSetCapabilitiesInfo *)pvData);
    30393046                break;
    30403047
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