VirtualBox

Changeset 75876 in vbox for trunk


Ignore:
Timestamp:
Dec 2, 2018 5:27:34 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127080
Message:

GuestControl: Some more cleanups. bugref:9313

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r75875 r75876  
    106106 * Structure for holding a buffered host command which has
    107107 * not been processed yet.
     108 *
     109 * @todo r=bird: It would be nice if we could decide on _one_ term for what the
     110 *       host passes to the guest.  We currently have:
     111 *          - The enum is called eHostFn, implying it's a function
     112 *          - The guest retrieves messages, if the eGuestFn enum is anything to
     113 *            go by: GUEST_MSG_GET, GUEST_MSG_CANCEL, GUEST_MSG_XXX
     114 *          - Here it's called a host command.
     115 *          - But this HostCommand structure has a mMsgType rather than command
     116 *            number/enum value, impliying it's a message.
    108117 */
    109118typedef struct HostCommand
     
    368377    }
    369378
    370     int Assign(const ClientRequest *pConnection)
    371     {
    372         AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
     379    int Assign(const ClientRequest *pReq)
     380    {
     381        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    373382
    374383        int rc;
     
    378387        /* Does the current host command need more parameter space which
    379388         * the client does not provide yet? */
    380         if (mParmCount > pConnection->mNumParms)
     389        if (mParmCount > pReq->mNumParms)
    381390        {
    382391            LogFlowThisFunc(("[Cmd %RU32] Requires %RU32 parms, only got %RU32 from client\n",
    383                              mMsgType, mParmCount, pConnection->mNumParms));
     392                             mMsgType, mParmCount, pReq->mNumParms));
    384393            /*
    385394             * So this call apparently failed because the guest wanted to peek
     
    391400        else
    392401        {
    393             rc = CopyTo(pConnection->mParms, pConnection->mNumParms);
     402            rc = CopyTo(pReq->mParms, pReq->mNumParms);
    394403
    395404            /*
     
    408417    }
    409418
    410     int Peek(const ClientRequest *pConnection)
    411     {
    412         AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
     419    int Peek(const ClientRequest *pReq)
     420    {
     421        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    413422
    414423        LogFlowThisFunc(("[Cmd %RU32] mParmCount=%RU32, mpParms=%p\n", mMsgType, mParmCount, mpParms));
    415424
    416         if (pConnection->mNumParms >= 2)
    417         {
    418             HGCMSvcSetU32(&pConnection->mParms[0], mMsgType);   /* Message ID */
    419             HGCMSvcSetU32(&pConnection->mParms[1], mParmCount); /* Required parameters for message */
     425        if (pReq->mNumParms >= 2)
     426        {
     427            HGCMSvcSetU32(&pReq->mParms[0], mMsgType);   /* Message ID */
     428            HGCMSvcSetU32(&pReq->mParms[1], mParmCount); /* Required parameters for message */
    420429        }
    421430        else
    422431            LogFlowThisFunc(("Warning: Client has not (yet) submitted enough parameters (%RU32, must be at least 2) to at least peak for the next message\n",
    423                              pConnection->mNumParms));
     432                             pReq->mNumParms));
    424433
    425434        /*
     
    655664     * @note Only used by GUEST_MSG_WAIT scenarios.
    656665     */
    657     int OldRun(ClientRequest const *pConnection, HostCommand *pHostCmd)
    658     {
    659         AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
     666    int OldRun(ClientRequest const *pReq, HostCommand *pHostCmd)
     667    {
     668        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    660669        AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER);
    661670        Assert(RTListNodeIsFirst(&m_HostCmdList, &pHostCmd->m_ListEntry));
    662671
    663         LogFlowFunc(("[Client %RU32] pConnection=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n",
    664                       m_idClient, pConnection, mHostCmdRc, mHostCmdTries, mPeekCount));
    665 
    666         int rc = mHostCmdRc = OldSendReply(pConnection, pHostCmd);
     672        LogFlowFunc(("[Client %RU32] pReq=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n",
     673                      m_idClient, pReq, mHostCmdRc, mHostCmdTries, mPeekCount));
     674
     675        int rc = mHostCmdRc = OldSendReply(pReq, pHostCmd);
    667676
    668677        LogFlowThisFunc(("[Client %RU32] Processing command %RU32 ended with rc=%Rrc\n", m_idClient, pHostCmd->mMsgType, mHostCmdRc));
     
    717726     * @note Only used by GUEST_MSG_WAIT scenarios.
    718727     */
    719     int OldRunCurrent(const ClientRequest *pConnection)
    720     {
    721         AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
     728    int OldRunCurrent(const ClientRequest *pReq)
     729    {
     730        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    722731
    723732        /*
     
    731740                /* Go to sleep. */
    732741                ASSERT_GUEST_RETURN(m_enmIsPending == 0, VERR_WRONG_ORDER);
    733                 m_PendingReq = *pConnection;
     742                m_PendingReq = *pReq;
    734743                m_enmIsPending  = GUEST_MSG_WAIT;
    735744                LogFlowFunc(("[Client %RU32] Is now in pending mode\n", m_idClient));
     
    739748            /* Wait was cancelled. */
    740749            m_fPendingCancel = false;
    741             if (pConnection->mNumParms > 0)
    742                 HGCMSvcSetU32(&pConnection->mParms[0], HOST_CANCEL_PENDING_WAITS);
    743             if (pConnection->mNumParms > 1)
    744                 HGCMSvcSetU32(&pConnection->mParms[1], 0);
    745             return pConnection->mNumParms == 2 ? VINF_SUCCESS : VERR_TRY_AGAIN;
     750            if (pReq->mNumParms > 0)
     751                HGCMSvcSetU32(&pReq->mParms[0], HOST_CANCEL_PENDING_WAITS);
     752            if (pReq->mNumParms > 1)
     753                HGCMSvcSetU32(&pReq->mParms[1], 0);
     754            return pReq->mNumParms == 2 ? VINF_SUCCESS : VERR_TRY_AGAIN;
    746755        }
    747756
     
    749758         * Return first host command.
    750759         */
    751         return OldRun(pConnection, pFirstCmd);
     760        return OldRun(pReq, pFirstCmd);
    752761    }
    753762
     
    756765     * @note Only used for GUEST_MSG_WAIT.
    757766     */
    758     int OldSendReply(ClientRequest const *pConnection,
    759                      HostCommand            *pHostCmd)
    760     {
    761         AssertPtrReturn(pConnection, VERR_INVALID_POINTER);
     767    int OldSendReply(ClientRequest const *pReq,
     768                     HostCommand         *pHostCmd)
     769    {
     770        AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    762771        AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER);
    763772
     
    771780        {
    772781            Assert(m_enmIsPending == GUEST_MSG_WAIT);
    773             rc = pHostCmd->Peek(pConnection);
     782            rc = pHostCmd->Peek(pReq);
    774783            mPeekCount++;
    775784        }
     
    781790            if (!mPeekCount)
    782791            {
    783                 rc = pHostCmd->Peek(pConnection);
     792                rc = pHostCmd->Peek(pReq);
    784793                mPeekCount++;
    785794            }
     
    788797                /* Try assigning the host command to the client and store the
    789798                 * result code for later use. */
    790                 rc = pHostCmd->Assign(pConnection);
     799                rc = pHostCmd->Assign(pReq);
    791800                if (RT_FAILURE(rc)) /* If something failed, let the client peek (again). */
    792801                {
    793                     rc = pHostCmd->Peek(pConnection);
     802                    rc = pHostCmd->Peek(pReq);
    794803                    mPeekCount++;
    795804                }
     
    805814         * the pending call with the result we just got. */
    806815        AssertPtr(m_pSvcHelpers);
    807         int rc2 = m_pSvcHelpers->pfnCallComplete(pConnection->mHandle, rc);
     816        int rc2 = m_pSvcHelpers->pfnCallComplete(pReq->mHandle, rc);
    808817
    809818        /* Rollback in case the guest cancelled the call. */
     
    814823        }
    815824
    816         LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, pConnection=%p)\n",
    817                          m_idClient, pHostCmd->mMsgType, rc, mPeekCount, pConnection));
     825        LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, pReq=%p)\n",
     826                         m_idClient, pHostCmd->mMsgType, rc, mPeekCount, pReq));
    818827        return rc;
    819828    }
     
    822831} ClientState;
    823832typedef std::map< uint32_t, ClientState *> ClientStateMap;
    824 typedef std::map< uint32_t, ClientState *>::iterator ClientStateMapIter;
    825 typedef std::map< uint32_t, ClientState *>::const_iterator ClientStateMapIterConst;
    826833
    827834/**
     
    12171224     * Wait for the host to queue a message for this client.
    12181225     */
    1219     ASSERT_GUEST_MSG_RETURN(pClient->m_enmIsPending == 0, ("Already pending! (idClient=%RU32)\n", pClient->m_idClient), 
     1226    ASSERT_GUEST_MSG_RETURN(pClient->m_enmIsPending == 0, ("Already pending! (idClient=%RU32)\n", pClient->m_idClient),
    12201227                            VERR_RESOURCE_BUSY);
    1221     pClient->m_PendingReq.mHandle    = hCall;
    1222     pClient->m_PendingReq.mNumParms  = cParms;
    1223     pClient->m_PendingReq.mParms     = paParms;
    1224     pClient->m_enmIsPending             = GUEST_MSG_PEEK_WAIT;
     1228    pClient->m_PendingReq.mHandle   = hCall;
     1229    pClient->m_PendingReq.mNumParms = cParms;
     1230    pClient->m_PendingReq.mParms    = paParms;
     1231    pClient->m_enmIsPending         = GUEST_MSG_PEEK_WAIT;
    12251232    LogFlowFunc(("[Client %RU32] Is now in pending mode...\n", pClient->m_idClient));
    12261233    return VINF_HGCM_ASYNC_EXECUTE;
     
    18221829        ASSERT_GUEST_LOGREL_MSG_RETURN(idSession > 0, ("idSession=%u (%#x)\n", idSession, uValue), VERR_OUT_OF_RANGE);
    18231830
    1824         for (ClientStateMapIter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
     1831        for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
    18251832            ASSERT_GUEST_LOGREL_MSG_RETURN(It->second->m_idSession != idSession,
    18261833                                           ("idSession=%u uValue=%#x idClient=%u; conflicting with client %u\n",
     
    21382145                rc = VWRN_NOT_FOUND;
    21392146                uint32_t const idSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->m_idContext);
    2140                 for (ClientStateMapIter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
     2147                for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)
    21412148                {
    21422149                    ClientState *pClient = It->second;
Note: See TracChangeset for help on using the changeset viewer.

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