VirtualBox

Changeset 29867 in vbox


Ignore:
Timestamp:
May 28, 2010 3:09:23 PM (15 years ago)
Author:
vboxsync
Message:

r=bird: todos

Location:
trunk/src/VBox
Files:
2 edited

Legend:

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

    r29797 r29867  
    2828 *           new host commands to perform. There can be multiple clients connected
    2929 *           to a service. A client is represented by its HGCM client ID.
    30  * - Context ID: A (almost) unique ID automatically generated on the host (Main API) 
     30 * - Context ID: A (almost) unique ID automatically generated on the host (Main API)
    3131 *               to not only distinguish clients but individual requests. Because
    3232 *               the host does not know anything about connected clients it needs
    3333 *               an indicator which it can refer to later. This context ID gets
    34  *               internally bound by the service to a client which actually processes 
     34 *               internally bound by the service to a client which actually processes
    3535 *               the command in order to have a relationship between client<->context ID(s).
    3636 *
    3737 * The host can trigger commands which get buffered by the service (with full HGCM
    38  * parameter info). As soon as a client connects (or is ready to do some new work) 
    39  * it gets a buffered host command to process it. This command then will be immediately 
     38 * parameter info). As soon as a client connects (or is ready to do some new work)
     39 * it gets a buffered host command to process it. This command then will be immediately
    4040 * removed from the command list. If there are ready clients but no new commands to be
    4141 * processed, these clients will be set into a deferred state (that is being blocked
    4242 * to return until a new command is available).
    4343 *
    44  * If a client needs to inform the host that something happend, it can send a 
     44 * If a client needs to inform the host that something happend, it can send a
    4545 * message to a low level HGCM callback registered in Main. This callback contains
    46  * the actual data as well as the context ID to let the host do the next necessary 
     46 * the actual data as well as the context ID to let the host do the next necessary
    4747 * steps for this context. This context ID makes it possible to wait for an event
    4848 * inside the host's Main API function (like starting a process on the guest and
    4949 * wait for getting its PID returned by the client) as well as cancelling blocking
    50  * host calls in order the client terminated/crashed (HGCM detects disconnected 
     50 * host calls in order the client terminated/crashed (HGCM detects disconnected
    5151 * clients and reports it to this service's callback).
    5252 */
     
    8080/**
    8181 * Structure for holding all clients with their
    82  * generated host contexts. This is necessary for 
     82 * generated host contexts. This is necessary for
    8383 * mainting the relationship between a client and its context IDs.
    8484 */
     
    135135    GuestCall() : mClientID(0), mHandle(0), mParms(NULL), mNumParms(0) {}
    136136    /** The normal contructor. */
    137     GuestCall(uint32_t aClientID, VBOXHGCMCALLHANDLE aHandle, 
     137    GuestCall(uint32_t aClientID, VBOXHGCMCALLHANDLE aHandle,
    138138              VBOXHGCMSVCPARM aParms[], uint32_t cParms)
    139139              : mClientID(aClientID), mHandle(aHandle), mParms(aParms), mNumParms(cParms) {}
     
    475475    AssertPtr(pCmd);
    476476    int rc;
    477  
     477
    478478    /* Sufficient parameter space? */
    479479    if (pCmd->mParmBuf.uParmCount > cParms)
     
    481481        paParms[0].setUInt32(pCmd->mParmBuf.uMsg);       /* Message ID */
    482482        paParms[1].setUInt32(pCmd->mParmBuf.uParmCount); /* Required parameters for message */
    483        
     483
    484484        /*
    485485        * So this call apparently failed because the guest wanted to peek
     
    500500 * defer the guest call until we have something from the host.
    501501 */
    502 int Service::retrieveNextHostCmd(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, 
     502int Service::retrieveNextHostCmd(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle,
    503503                                 uint32_t cParms, VBOXHGCMSVCPARM paParms[])
    504504{
    505505    int rc = VINF_SUCCESS;
    506506
    507     /* 
     507    /*
    508508     * Lookup client in our list so that we can assign the context ID of
    509509     * a command to that client.
     
    547547              * later reference & cleanup). */
    548548             Assert(curCmd.mContextID > 0);
     549             /// @todo r=bird: check if already in the list.
    549550             it->mContextList.push_back(curCmd.mContextID);
    550551
     
    568569    {
    569570        if (it->mClientID == u32ClientID)
    570         {       
     571        {
    571572            if (it->mNumParms >= 2)
    572573            {
    573574                it->mParms[0].setUInt32(GETHOSTMSG_EXEC_HOST_CANCEL_WAIT); /* Message ID. */
    574575                it->mParms[1].setUInt32(0);                                /* Required parameters for message. */
    575             }             
     576            }
    576577            if (mpHelpers)
    577                 mpHelpers->pfnCallComplete(it->mHandle, rc);     
     578                mpHelpers->pfnCallComplete(it->mHandle, rc);
    578579            it = mClientList.erase(it);
    579580        }
     
    636637        && newCmd.mParmBuf.uParmCount > 0)
    637638    {
    638         /* 
     639        /*
    639640         * Assume that the context ID *always* is the first parameter,
    640641         * assign the context ID to the command.
     
    651652        {
    652653            GuestCall guest = mClientList.front();
    653             rc = sendHostCmdToGuest(&newCmd, 
     654            rc = sendHostCmdToGuest(&newCmd,
    654655                                    guest.mHandle, guest.mNumParms, guest.mParms);
    655656
     
    657658            AssertPtr(mpHelpers);
    658659            mpHelpers->pfnCallComplete(guest.mHandle, rc);
    659             mClientList.pop_front();                       
    660            
     660            mClientList.pop_front();
     661
    661662            /* If we got VERR_TOO_MUCH_DATA we buffer the host command in the next block
    662              * and return success to the host. */           
     663             * and return success to the host. */
    663664            if (rc == VERR_TOO_MUCH_DATA)
    664665            {
     
    675676        if (!fProcessed)
    676677        {
    677             mHostCmds.push_back(newCmd);   
     678            mHostCmds.push_back(newCmd);
    678679#if 0
    679680            /* Limit list size by deleting oldest element. */
  • trunk/src/VBox/Main/GuestImpl.cpp

    r29807 r29867  
    599599            /* Not found, add to list. */
    600600            GuestProcess p;
    601             p.mPID = pCBData->u32PID;           
     601            p.mPID = pCBData->u32PID;
    602602            p.mStatus = pCBData->u32Status;
    603603            p.mExitCode = pCBData->u32Flags; /* Contains exit code. */
    604604            p.mFlags = 0;
    605            
     605
    606606            mGuestProcessList.push_back(p);
    607607        }
     
    747747        if (SUCCEEDED(it->pProgress->COMGETTER(Canceled)(&fCancelled)) && !fCancelled)
    748748            it->pProgress->Cancel();
    749         /* 
    750          * Do *not NULL pProgress here, because waiting function like executeProcess() 
    751          * will still rely on this object for checking whether they have to give up! 
     749        /*
     750         * Do *not NULL pProgress here, because waiting function like executeProcess()
     751         * will still rely on this object for checking whether they have to give up!
    752752         */
    753753    }
     
    777777    {
    778778        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     779        /// @todo r=bird: check if already in the list and find another one.
    779780        mCallbackList.push_back(context);
    780781        nCallbacks = mCallbackList.size();
    781     }   
     782    }
    782783
    783784#if 0
     
    803804                                   ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress)
    804805{
     806/** @todo r=bird: Eventually we should clean up all the timeout parameters
     807 *        in the API and have the same way of specifying infinite waits!  */
    805808#ifndef VBOX_WITH_GUEST_CONTROL
    806809    ReturnComNotImplemented();
     
    860863            for (unsigned i = 0; RT_SUCCESS(vrc) && i < uNumArgs; i++)
    861864            {
     865                /// @todo r=bird: RTUtf16ToUtf8().
    862866                int cbLen = RTStrAPrintf(&papszArgv[i], "%s", Utf8Str(args[i]).raw());
    863867                if (cbLen < 0)
     
    901905                    PCALLBACKDATAEXECSTATUS pData = (PCALLBACKDATAEXECSTATUS)RTMemAlloc(sizeof(CALLBACKDATAEXECSTATUS));
    902906                    AssertReturn(pData, VBOX_E_IPRT_ERROR);
    903                     uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_START, 
     907                    uContextID = addCtrlCallbackContext(VBOXGUESTCTRLCALLBACKTYPE_EXEC_START,
    904908                                                        pData, sizeof(CALLBACKDATAEXECSTATUS), progress);
    905909                    Assert(uContextID > 0);
     
    921925                    VMMDev *vmmDev;
    922926                    {
    923                         /* Make sure mParent is valid, so set the read lock while using. 
     927                        /* Make sure mParent is valid, so set the read lock while using.
    924928                         * Do not keep this lock while doing the actual call, because in the meanwhile
    925929                         * another thread could request a write lock which would be a bad idea ... */
    926930                        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    927    
     931
    928932                        /* Forward the information to the VMM device. */
    929933                        AssertPtr(mParent);
     
    973977                        /* Check for manual stop. */
    974978                        if (!it->pProgress.isNull())
    975                         {                           
     979                        {
    976980                            rc = it->pProgress->COMGETTER(Canceled)(&fCanceled);
    977981                            if (FAILED(rc)) throw rc;
    978982                            if (fCanceled)
    979                                 break; /* Client wants to abort. */
     983                                break; /* HGCM/guest wants to abort because of status change. */
     984
    980985                        }
     986                        /// @todo r=bird: two operation progress object and wait first operation.
     987                        /// IProgress::WaitForOperationCompletion.
    981988                        RTThreadSleep(cMsWait);
    982989                    }
     
    986993                if (!fCanceled)
    987994                {
    988                     AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 
     995                    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    989996
    990997                    PCALLBACKDATAEXECSTATUS pData = (PCALLBACKDATAEXECSTATUS)it->pvData;
     
    10011008                                *aPID = pData->u32PID;
    10021009                                break;
    1003    
     1010
    10041011                            /* In any other case the process either already
    10051012                             * terminated or something else went wrong, so no PID ... */
     
    10101017                            case PROC_STS_TOA:
    10111018                            case PROC_STS_DWN:
    1012                                 /* 
     1019                                /*
    10131020                                 * Process (already) ended, but we want to get the
    1014                                  * PID anyway to retrieve the output in a later call. 
     1021                                 * PID anyway to retrieve the output in a later call.
    10151022                                 */
    10161023                                *aPID = pData->u32PID;
    10171024                                break;
    1018    
     1025
    10191026                            case PROC_STS_ERROR:
    10201027                                vrc = pData->u32Flags; /* u32Flags member contains IPRT error code. */
    10211028                                break;
    1022    
     1029
    10231030                            default:
    10241031                                vrc = VERR_INVALID_PARAMETER; /* Unknown status, should never happen! */
     
    10731080                                rc = setError(E_UNEXPECTED,
    10741081                                              tr("The service call failed with error %Rrc"), vrc);
    1075                         }               
     1082                        }
    10761083                    }
    10771084                    else /* Execution went fine. */
     
    11211128STDMETHODIMP Guest::GetProcessOutput(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData))
    11221129{
     1130/** @todo r=bird: Eventually we should clean up all the timeout parameters
     1131 *        in the API and have the same way of specifying infinite waits!  */
    11231132#ifndef VBOX_WITH_GUEST_CONTROL
    11241133    ReturnComNotImplemented();
     
    11321141
    11331142    AutoCaller autoCaller(this);
    1134     if (FAILED(autoCaller.rc())) return autoCaller.rc(); 
     1143    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    11351144
    11361145    HRESULT rc = S_OK;
     
    11631172                                                     pData, sizeof(CALLBACKDATAEXECOUT), progress);
    11641173        Assert(uContextID > 0);
    1165    
     1174
    11661175        size_t cbData = (size_t)RT_MIN(aSize, _64K);
    11671176        com::SafeArray<BYTE> outputData(cbData);
    1168    
     1177
    11691178        VBOXHGCMSVCPARM paParms[5];
    11701179        int i = 0;
     
    11721181        paParms[i++].setUInt32(aPID);
    11731182        paParms[i++].setUInt32(aFlags); /** @todo Should represent stdout and/or stderr. */
    1174    
     1183
    11751184        int vrc = VINF_SUCCESS;
    1176    
     1185
    11771186        {
    11781187            VMMDev *vmmDev;
    11791188            {
    1180                 /* Make sure mParent is valid, so set the read lock while using. 
     1189                /* Make sure mParent is valid, so set the read lock while using.
    11811190                 * Do not keep this lock while doing the actual call, because in the meanwhile
    11821191                 * another thread could request a write lock which would be a bad idea ... */
    11831192                AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1184        
     1193
    11851194                /* Forward the information to the VMM device. */
    11861195                AssertPtr(mParent);
     
    11951204            }
    11961205        }
    1197    
     1206
    11981207        if (RT_SUCCESS(vrc))
    11991208        {
    12001209            LogFlowFunc(("Waiting for HGCM callback (timeout=%ldms) ...\n", aTimeoutMS));
    1201    
     1210
    12021211            /*
    12031212             * Wait for the HGCM low level callback until the process
     
    12331242                    }
    12341243                    RTThreadSleep(cMsWait);
    1235                 } 
    1236    
     1244                }
     1245
    12371246                /* Was the whole thing canceled? */
    12381247                if (!fCanceled)
     
    12411250                    {
    12421251                        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1243            
     1252
    12441253                        /* Did we get some output? */
    12451254                        pData = (PCALLBACKDATAEXECOUT)it->pvData;
    12461255                        Assert(it->cbData == sizeof(CALLBACKDATAEXECOUT));
    12471256                        AssertPtr(pData);
    1248            
     1257
    12491258                        if (pData->cbData)
    12501259                        {
     
    12521261                            if (pData->cbData > cbData)
    12531262                                outputData.resize(pData->cbData);
    1254            
     1263
    12551264                            /* Fill output in supplied out buffer. */
    12561265                            memcpy(outputData.raw(), pData->pvData, pData->cbData);
     
    12961305            else /* PID lookup failed. */
    12971306                rc = setError(VBOX_E_IPRT_ERROR,
    1298                               tr("Process (PID %u) not found!"), aPID);   
     1307                              tr("Process (PID %u) not found!"), aPID);
    12991308        }
    13001309        else /* HGCM operation failed. */
    13011310            rc = setError(E_UNEXPECTED,
    13021311                          tr("The HGCM call failed with error %Rrc"), vrc);
    1303    
     1312
    13041313        /* Cleanup. */
    13051314        progress->uninit();
     
    13281337
    13291338    AutoCaller autoCaller(this);
    1330     if (FAILED(autoCaller.rc())) return autoCaller.rc(); 
     1339    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    13311340
    13321341    HRESULT rc = S_OK;
     
    13351344    {
    13361345        AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    1337    
     1346
    13381347        GuestProcessIterConst it;
    13391348        for (it = mGuestProcessList.begin(); it != mGuestProcessList.end(); it++)
     
    13421351                break;
    13431352        }
    1344    
     1353
    13451354        if (it != mGuestProcessList.end())
    13461355        {
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