- Timestamp:
- Dec 2, 2018 5:27:34 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 127080
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r75875 r75876 106 106 * Structure for holding a buffered host command which has 107 107 * 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. 108 117 */ 109 118 typedef struct HostCommand … … 368 377 } 369 378 370 int Assign(const ClientRequest *p Connection)371 { 372 AssertPtrReturn(p Connection, VERR_INVALID_POINTER);379 int Assign(const ClientRequest *pReq) 380 { 381 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 373 382 374 383 int rc; … … 378 387 /* Does the current host command need more parameter space which 379 388 * the client does not provide yet? */ 380 if (mParmCount > p Connection->mNumParms)389 if (mParmCount > pReq->mNumParms) 381 390 { 382 391 LogFlowThisFunc(("[Cmd %RU32] Requires %RU32 parms, only got %RU32 from client\n", 383 mMsgType, mParmCount, p Connection->mNumParms));392 mMsgType, mParmCount, pReq->mNumParms)); 384 393 /* 385 394 * So this call apparently failed because the guest wanted to peek … … 391 400 else 392 401 { 393 rc = CopyTo(p Connection->mParms, pConnection->mNumParms);402 rc = CopyTo(pReq->mParms, pReq->mNumParms); 394 403 395 404 /* … … 408 417 } 409 418 410 int Peek(const ClientRequest *p Connection)411 { 412 AssertPtrReturn(p Connection, VERR_INVALID_POINTER);419 int Peek(const ClientRequest *pReq) 420 { 421 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 413 422 414 423 LogFlowThisFunc(("[Cmd %RU32] mParmCount=%RU32, mpParms=%p\n", mMsgType, mParmCount, mpParms)); 415 424 416 if (p Connection->mNumParms >= 2)417 { 418 HGCMSvcSetU32(&p Connection->mParms[0], mMsgType); /* Message ID */419 HGCMSvcSetU32(&p Connection->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 */ 420 429 } 421 430 else 422 431 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 p Connection->mNumParms));432 pReq->mNumParms)); 424 433 425 434 /* … … 655 664 * @note Only used by GUEST_MSG_WAIT scenarios. 656 665 */ 657 int OldRun(ClientRequest const *p Connection, HostCommand *pHostCmd)658 { 659 AssertPtrReturn(p Connection, VERR_INVALID_POINTER);666 int OldRun(ClientRequest const *pReq, HostCommand *pHostCmd) 667 { 668 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 660 669 AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER); 661 670 Assert(RTListNodeIsFirst(&m_HostCmdList, &pHostCmd->m_ListEntry)); 662 671 663 LogFlowFunc(("[Client %RU32] p Connection=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n",664 m_idClient, p Connection, mHostCmdRc, mHostCmdTries, mPeekCount));665 666 int rc = mHostCmdRc = OldSendReply(p Connection, 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); 667 676 668 677 LogFlowThisFunc(("[Client %RU32] Processing command %RU32 ended with rc=%Rrc\n", m_idClient, pHostCmd->mMsgType, mHostCmdRc)); … … 717 726 * @note Only used by GUEST_MSG_WAIT scenarios. 718 727 */ 719 int OldRunCurrent(const ClientRequest *p Connection)720 { 721 AssertPtrReturn(p Connection, VERR_INVALID_POINTER);728 int OldRunCurrent(const ClientRequest *pReq) 729 { 730 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 722 731 723 732 /* … … 731 740 /* Go to sleep. */ 732 741 ASSERT_GUEST_RETURN(m_enmIsPending == 0, VERR_WRONG_ORDER); 733 m_PendingReq = *p Connection;742 m_PendingReq = *pReq; 734 743 m_enmIsPending = GUEST_MSG_WAIT; 735 744 LogFlowFunc(("[Client %RU32] Is now in pending mode\n", m_idClient)); … … 739 748 /* Wait was cancelled. */ 740 749 m_fPendingCancel = false; 741 if (p Connection->mNumParms > 0)742 HGCMSvcSetU32(&p Connection->mParms[0], HOST_CANCEL_PENDING_WAITS);743 if (p Connection->mNumParms > 1)744 HGCMSvcSetU32(&p Connection->mParms[1], 0);745 return p Connection->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; 746 755 } 747 756 … … 749 758 * Return first host command. 750 759 */ 751 return OldRun(p Connection, pFirstCmd);760 return OldRun(pReq, pFirstCmd); 752 761 } 753 762 … … 756 765 * @note Only used for GUEST_MSG_WAIT. 757 766 */ 758 int OldSendReply(ClientRequest const *p Connection,759 HostCommand 760 { 761 AssertPtrReturn(p Connection, VERR_INVALID_POINTER);767 int OldSendReply(ClientRequest const *pReq, 768 HostCommand *pHostCmd) 769 { 770 AssertPtrReturn(pReq, VERR_INVALID_POINTER); 762 771 AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER); 763 772 … … 771 780 { 772 781 Assert(m_enmIsPending == GUEST_MSG_WAIT); 773 rc = pHostCmd->Peek(p Connection);782 rc = pHostCmd->Peek(pReq); 774 783 mPeekCount++; 775 784 } … … 781 790 if (!mPeekCount) 782 791 { 783 rc = pHostCmd->Peek(p Connection);792 rc = pHostCmd->Peek(pReq); 784 793 mPeekCount++; 785 794 } … … 788 797 /* Try assigning the host command to the client and store the 789 798 * result code for later use. */ 790 rc = pHostCmd->Assign(p Connection);799 rc = pHostCmd->Assign(pReq); 791 800 if (RT_FAILURE(rc)) /* If something failed, let the client peek (again). */ 792 801 { 793 rc = pHostCmd->Peek(p Connection);802 rc = pHostCmd->Peek(pReq); 794 803 mPeekCount++; 795 804 } … … 805 814 * the pending call with the result we just got. */ 806 815 AssertPtr(m_pSvcHelpers); 807 int rc2 = m_pSvcHelpers->pfnCallComplete(p Connection->mHandle, rc);816 int rc2 = m_pSvcHelpers->pfnCallComplete(pReq->mHandle, rc); 808 817 809 818 /* Rollback in case the guest cancelled the call. */ … … 814 823 } 815 824 816 LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, p Connection=%p)\n",817 m_idClient, pHostCmd->mMsgType, rc, mPeekCount, p Connection));825 LogFlowThisFunc(("[Client %RU32] Command %RU32 ended with %Rrc (mPeekCount=%RU32, pReq=%p)\n", 826 m_idClient, pHostCmd->mMsgType, rc, mPeekCount, pReq)); 818 827 return rc; 819 828 } … … 822 831 } ClientState; 823 832 typedef 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;826 833 827 834 /** … … 1217 1224 * Wait for the host to queue a message for this client. 1218 1225 */ 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), 1220 1227 VERR_RESOURCE_BUSY); 1221 pClient->m_PendingReq.mHandle 1222 pClient->m_PendingReq.mNumParms 1223 pClient->m_PendingReq.mParms 1224 pClient->m_enmIsPending 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; 1225 1232 LogFlowFunc(("[Client %RU32] Is now in pending mode...\n", pClient->m_idClient)); 1226 1233 return VINF_HGCM_ASYNC_EXECUTE; … … 1822 1829 ASSERT_GUEST_LOGREL_MSG_RETURN(idSession > 0, ("idSession=%u (%#x)\n", idSession, uValue), VERR_OUT_OF_RANGE); 1823 1830 1824 for (ClientStateMap Iter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)1831 for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It) 1825 1832 ASSERT_GUEST_LOGREL_MSG_RETURN(It->second->m_idSession != idSession, 1826 1833 ("idSession=%u uValue=%#x idClient=%u; conflicting with client %u\n", … … 2138 2145 rc = VWRN_NOT_FOUND; 2139 2146 uint32_t const idSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->m_idContext); 2140 for (ClientStateMap Iter It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It)2147 for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It) 2141 2148 { 2142 2149 ClientState *pClient = It->second;
Note:
See TracChangeset
for help on using the changeset viewer.