VirtualBox

Changeset 42436 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 27, 2012 2:03:52 PM (12 years ago)
Author:
vboxsync
Message:

Guest Control 2.0: Update.

Location:
trunk/src/VBox/Main
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r42411 r42436  
    9090    inline int callbackRemove(ULONG uContextID);
    9191    inline bool isAlive(void);
    92     HRESULT hgcmResultToError(int rc);
    9392    int onGuestDisconnected(GuestCtrlCallback *pCallback, PCALLBACKDATACLIENTDISCONNECTED pData);
    9493    int onProcessInputStatus(GuestCtrlCallback *pCallback, PCALLBACKDATAEXECINSTATUS pData);
     
    9796    int prepareExecuteEnv(const char *pszEnv, void **ppvList, ULONG *pcbList, ULONG *pcEnvVars);
    9897    int sendCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms);
    99     int signalWaiters(ProcessWaitResult_T enmWaitResult, int rc = VINF_SUCCESS);
     98    int setErrorInternal(int rc, const Utf8Str &strMessage);
     99    int setErrorExternal(void);
     100    int signalWaiters(ProcessWaitResult_T enmWaitResult);
    100101    static DECLCALLBACK(int) startProcessThread(RTTHREAD Thread, void *pvUser);
    101102    HRESULT waitResultToErrorEx(const GuestProcessWaitResult &waitResult, bool fLog);
     
    125126        /** The current process status. */
    126127        ProcessStatus_T          mStatus;
     128        /** The overall rc of the process execution. */
     129        int                      mRC;
     130        /** The overall error message of the
     131         *  process execution. */
     132        Utf8Str                  mErrorMsg;
    127133        /** The next upcoming context ID. */
    128134        ULONG                    mNextContextID;
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r42412 r42436  
    117117    typedef std::vector <ComObjPtr<GuestFile> > SessionFiles;
    118118    /** Map of guest processes. The key specifies the internal process number.
    119      *  To retrieve the process' guest PID use the Id() method of the IProgress interface. */
    120     typedef std::map <ULONG, ComObjPtr<GuestProcess> > SessionProcesses;
     119     *  To retrieve the process' guest PID use the Id() method of the IProcess interface. */
     120    typedef std::map <uint32_t, ComObjPtr<GuestProcess> > SessionProcesses;
    121121
    122122public:
  • trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp

    r42411 r42436  
    702702
    703703#ifdef DEBUG
    704     LogFlowFunc(("uSession=%RU32, uProcess=%RU32, uCount=%RU32\n",
     704    LogFlowFunc(("CID=%RU32, uSession=%RU32, uProcess=%RU32, uCount=%RU32\n",
     705                 pHeader->u32ContextID,
    705706                 VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHeader->u32ContextID),
    706707                 VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(pHeader->u32ContextID),
     
    26862687    LogFlowFuncEnter();
    26872688
    2688     AssertPtrReturn(pvData, VERR_INVALID_POINTER);
    2689     AssertReturn(cbData, VERR_INVALID_PARAMETER);
    2690 
    26912689    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    26922690
     2691    uint32_t uSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID);
     2692#ifdef DEBUG
     2693    LogFlowFunc(("uSessionID=%RU32 (%RU32 total)\n",
     2694                 uSessionID, mData.mGuestSessions.size()));
     2695#endif
    26932696    int rc;
    26942697    GuestSessions::const_iterator itSession
    2695         = mData.mGuestSessions.find(VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID));
     2698        = mData.mGuestSessions.find(uSessionID);
    26962699    if (itSession != mData.mGuestSessions.end())
    26972700    {
     
    27652768
    27662769        mData.mGuestSessions[uNewSessionID] = pGuestSession;
     2770
     2771        LogFlowFunc(("Added new session with session ID=%RU32\n",
     2772                     uNewSessionID));
    27672773    }
    27682774    catch (int rc2)
     
    28182824            case VERR_MAX_PROCS_REACHED:
    28192825                hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest sessions (%ld) reached"),
    2820                               VERR_MAX_PROCS_REACHED);
     2826                              VBOX_GUESTCTRL_MAX_SESSIONS);
    28212827                break;
    28222828
  • trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp

    r42411 r42436  
    374374    while (*pszString != '\0' && RT_SUCCESS(rc))
    375375    {
    376          if (!RT_C_IS_ALNUM(*pszString++))
     376         if (   !RT_C_IS_ALNUM(*pszString)
     377             && !RT_C_IS_GRAPH(*pszString))
    377378             rc = VERR_INVALID_PARAMETER;
     379         *pszString++;
    378380    }
    379381
     
    406408            strValue = listPair.at(p++);
    407409
    408        rc = Set(strKey, strValue);
     410#ifdef DEBUG
     411        LogFlowFunc(("strKey=%s, strValue=%s\n",
     412                     strKey.c_str(), strValue.c_str()));
     413#endif
     414        rc = Set(strKey, strValue);
    409415    }
    410416
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r42412 r42436  
    4141{
    4242    GuestProcessTask(GuestProcess *pProcess)
    43         : mProcess(pProcess) { }
    44 
    45     ~GuestProcessTask(void) { }
    46 
    47     int rc() const { return mRC; }
    48     bool isOk() const { return RT_SUCCESS(rc()); }
     43        : mProcess(pProcess),
     44          mRC(VINF_SUCCESS) { }
     45
     46    virtual ~GuestProcessTask(void) { }
     47
     48    int rc(void) const { return mRC; }
     49    bool isOk(void) const { return RT_SUCCESS(rc()); }
    4950
    5051    const ComObjPtr<GuestProcess>    mProcess;
     
    7475    mData.mPID = 0;
    7576    mData.mProcessID = 0;
     77    mData.mRC = VINF_SUCCESS;
    7678    mData.mStatus = ProcessStatus_Undefined;
    7779
     
    9799int GuestProcess::init(Console *aConsole, GuestSession *aSession, ULONG aProcessID, const GuestProcessInfo &aProcInfo)
    98100{
     101    LogFlowThisFunc(("aConsole=%p, aSession=%p, aProcessID=%RU32\n",
     102                     aConsole, aSession, aProcessID));
     103
    99104    AssertPtrReturn(aSession, VERR_INVALID_POINTER);
    100105
     
    332337        /* Create a new context ID ... */
    333338        uNewContextID = VBOX_GUESTCTRL_CONTEXTID_MAKE(uSessionID,
    334                                                       mData.mProcessID, mData.mNextContextID++);
    335         if (uNewContextID == UINT32_MAX)
     339                                                      mData.mProcessID, mData.mNextContextID);
     340        if (mData.mNextContextID == VBOX_GUESTCTRL_MAX_CONTEXTS)
    336341            mData.mNextContextID = 0;
    337342        /* Is the context ID already used?  Try next ID ... */
     
    344349            break;
    345350        }
     351        mData.mNextContextID++;
    346352
    347353        if (++uTries == UINT32_MAX)
     
    358364        if (puContextID)
    359365            *puContextID = uNewContextID;
     366
     367        LogFlowFunc(("Added new callback (Session: %RU32, Process: %RU32, Count=%RU32) CID=%RU32\n",
     368                     uSessionID, mData.mProcessID, mData.mNextContextID, uNewContextID));
    360369    }
    361370
     
    500509}
    501510
    502 HRESULT GuestProcess::hgcmResultToError(int rc)
    503 {
    504     if (RT_SUCCESS(rc))
    505         return S_OK;
    506 
    507     HRESULT hr;
    508     if (rc == VERR_INVALID_VM_HANDLE)
    509         hr = setErrorNoLog(VBOX_E_VM_ERROR,
    510                            tr("VMM device is not available (is the VM running?)"));
    511     else if (rc == VERR_NOT_FOUND)
    512         hr = setErrorNoLog(VBOX_E_IPRT_ERROR,
    513                            tr("The guest execution service is not ready (yet)"));
    514     else if (rc == VERR_HGCM_SERVICE_NOT_FOUND)
    515         hr= setErrorNoLog(VBOX_E_IPRT_ERROR,
    516                           tr("The guest execution service is not available"));
    517     else /* HGCM call went wrong. */
    518         hr = setErrorNoLog(E_UNEXPECTED,
    519                            tr("The HGCM call failed with error %Rrc"), rc);
    520     return hr;
    521 }
    522 
    523511bool GuestProcess::isReady(void)
    524512{
     
    546534    pCallback->Signal();
    547535
     536    /* Do we need to report a termination? */
     537    ProcessWaitResult_T waitRes;
     538    if (mData.mProcess.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses)
     539        waitRes = ProcessWaitResult_Status; /* No, just report a status. */
     540    else
     541        waitRes = ProcessWaitResult_Terminate;
     542
    548543    /* Signal in any case. */
    549     int rc = signalWaiters(ProcessWaitResult_Status, VERR_CANCELLED);
     544    int rc = signalWaiters(waitRes);
    550545    AssertRC(rc);
    551546
     
    594589        Assert(mData.mPID == pData->u32PID);
    595590
    596     int callbackRC = VINF_SUCCESS;
    597 
    598591    BOOL fSignal = FALSE;
    599     ProcessWaitResult_T enmWaitResult;
     592    ProcessWaitResult_T waitRes;
    600593    uint32_t uWaitFlags = mData.mWaitEvent
    601594                        ? mData.mWaitEvent->GetWaitFlags() : 0;
     
    605598        {
    606599            fSignal = (uWaitFlags & ProcessWaitForFlag_Start);
    607             enmWaitResult = ProcessWaitResult_Status;
     600            waitRes = ProcessWaitResult_Status;
    608601
    609602            mData.mStatus = ProcessStatus_Started;
     
    615608        {
    616609            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    617             enmWaitResult = ProcessWaitResult_Status;
     610            waitRes = ProcessWaitResult_Status;
    618611
    619612            mData.mStatus = ProcessStatus_TerminatedNormally;
     
    625618        {
    626619            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    627             enmWaitResult = ProcessWaitResult_Status;
     620            waitRes = ProcessWaitResult_Status;
    628621
    629622            mData.mStatus = ProcessStatus_TerminatedSignal;
    630623            mData.mExitCode = pData->u32Flags; /* Contains the signal. */
    631 
    632             callbackRC = VERR_INTERRUPTED;
    633624            break;
    634625        }
     
    637628        {
    638629            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    639             enmWaitResult = ProcessWaitResult_Status;
     630            waitRes = ProcessWaitResult_Status;
    640631
    641632            mData.mStatus = ProcessStatus_TerminatedAbnormally;
    642 
    643             callbackRC = VERR_BROKEN_PIPE;
    644633            break;
    645634        }
     
    648637        {
    649638            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    650             enmWaitResult = ProcessWaitResult_Timeout;
     639            waitRes = ProcessWaitResult_Timeout;
    651640
    652641            mData.mStatus = ProcessStatus_TimedOutKilled;
    653 
    654             callbackRC = VERR_TIMEOUT;
    655642            break;
    656643        }
     
    659646        {
    660647            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    661             enmWaitResult = ProcessWaitResult_Timeout;
     648            waitRes = ProcessWaitResult_Timeout;
    662649
    663650            mData.mStatus = ProcessStatus_TimedOutAbnormally;
    664 
    665             callbackRC = VERR_TIMEOUT;
    666651            break;
    667652        }
     
    670655        {
    671656            fSignal = (uWaitFlags & ProcessWaitForFlag_Terminate);
    672             enmWaitResult = ProcessWaitResult_Status;
     657            waitRes = (mData.mProcess.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses)
     658                    ? ProcessWaitResult_Terminate : ProcessWaitResult_Status;
    673659
    674660            mData.mStatus = ProcessStatus_Down;
    675 
    676             /*
    677              * If mFlags has CreateProcessFlag_IgnoreOrphanedProcesses set, we don't report an error to
    678              * our progress object. This is helpful for waiters which rely on the success of our progress object
    679              * even if the executed process was killed because the system/VBoxService is shutting down.
    680              *
    681              * In this case mFlags contains the actual execution flags reached in via Guest::ExecuteProcess().
    682              */
    683             callbackRC = mData.mProcess.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses
    684                        ? VINF_SUCCESS : VERR_OBJECT_DESTROYED;
    685661            break;
    686662        }
     
    689665        {
    690666            fSignal = TRUE; /* Signal in any case. */
    691             enmWaitResult = ProcessWaitResult_Error;
     667            waitRes = ProcessWaitResult_Error;
    692668
    693669            mData.mStatus = ProcessStatus_Error;
    694670
    695             callbackRC = pData->u32Flags; /** @todo int vs. uint32 -- IPRT errors are *negative* !!! */
     671            Utf8Str strError = Utf8StrFmt(tr("Guest process \"%s\" could not be started: ", mData.mProcess.mCommand.c_str()));
     672
     673            /* Note: It's not required that the process has been started before. */
     674            if (mData.mPID)
     675            {
     676                strError += Utf8StrFmt(tr("Error rc=%Rrc occured (PID %RU32)"), rc, mData.mPID);
     677            }
     678            else
     679            {
     680                /** @todo pData->u32Flags; /** @todo int vs. uint32 -- IPRT errors are *negative* !!! */
     681                switch (pData->u32Flags) /* pData->u32Flags contains the IPRT error code from guest side. */
     682                {
     683                    case VERR_FILE_NOT_FOUND: /* This is the most likely error. */
     684                        strError += Utf8StrFmt(tr("The specified file was not found on guest"));
     685                        break;
     686
     687                    case VERR_PATH_NOT_FOUND:
     688                        strError += Utf8StrFmt(tr("Could not resolve path to specified file was not found on guest"));
     689                        break;
     690
     691                    case VERR_BAD_EXE_FORMAT:
     692                        strError += Utf8StrFmt(tr("The specified file is not an executable format on guest"));
     693                        break;
     694
     695                    case VERR_AUTHENTICATION_FAILURE:
     696                        strError += Utf8StrFmt(tr("The specified user was not able to logon on guest"));
     697                        break;
     698
     699                    case VERR_INVALID_NAME:
     700                        strError += Utf8StrFmt(tr("The specified file is an invalid name"));
     701                        break;
     702
     703                    case VERR_TIMEOUT:
     704                        strError += Utf8StrFmt(tr("The guest did not respond within time"));
     705                        break;
     706
     707                    case VERR_CANCELLED:
     708                        strError += Utf8StrFmt(tr("The execution operation was canceled"));
     709                        break;
     710
     711                    case VERR_PERMISSION_DENIED:
     712                        strError += Utf8StrFmt(tr("Invalid user/password credentials"));
     713                        break;
     714
     715                    case VERR_MAX_PROCS_REACHED:
     716                        strError += Utf8StrFmt(tr("Maximum number of parallel guest processes has been reached"));
     717                        break;
     718
     719                    default:
     720                        strError += Utf8StrFmt(tr("Reported error %Rrc"), pData->u32Flags);
     721                        break;
     722                }
     723            }
     724
     725            rc = setErrorInternal(pData->u32Flags, strError);
     726            AssertRC(rc);
    696727            break;
    697728        }
     
    702733            /* Silently skip this request. */
    703734            fSignal = TRUE; /* Signal in any case. */
    704             enmWaitResult = ProcessWaitResult_Status;
     735            waitRes = ProcessWaitResult_Status;
    705736
    706737            mData.mStatus = ProcessStatus_Undefined;
    707 
    708             callbackRC = VERR_NOT_IMPLEMENTED;
    709738            break;
    710739        }
     
    712741
    713742    LogFlowFunc(("Got rc=%Rrc, waitResult=%d\n",
    714                  rc, enmWaitResult));
     743                 rc, waitRes));
    715744
    716745    /*
    717746     * Now do the signalling stuff.
    718747     */
    719     rc = pCallback->Signal(callbackRC);
     748    rc = pCallback->Signal();
    720749
    721750    if (fSignal)
    722751    {
    723         int rc2 = signalWaiters(enmWaitResult, callbackRC);
     752        int rc2 = signalWaiters(waitRes);
    724753        if (RT_SUCCESS(rc))
    725754            rc = rc2;
     
    814843}
    815844
    816 int GuestProcess::signalWaiters(ProcessWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS*/)
    817 {
    818     LogFlowFunc(("enmWaitResult=%d, rc=%Rrc, mWaitCount=%RU32, mWaitEvent=%p\n",
    819                  enmWaitResult, rc, mData.mWaitCount, mData.mWaitEvent));
    820 
    821     /* Note: No write locking here -- already done in the callback dispatcher. */
    822 
    823     int rc2 = VINF_SUCCESS;
    824     if (mData.mWaitEvent)
    825         rc2 = mData.mWaitEvent->Signal(enmWaitResult, rc);
     845int GuestProcess::setErrorInternal(int rc, const Utf8Str &strMessage)
     846{
     847    LogFlowFunc(("rc=%Rrc, strMsg=%s\n", rc, strMessage.c_str()));
     848
     849    Assert(RT_FAILURE(rc));
     850    Assert(!strMessage.isEmpty());
     851
     852#ifdef DEBUG
     853    /* Do not allow overwriting an already set error. If this happens
     854     * this means we forgot some error checking/locking somewhere. */
     855    Assert(RT_SUCCESS(mData.mRC));
     856    Assert(mData.mErrorMsg.isEmpty());
     857#endif
     858
     859    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     860
     861    mData.mStatus = ProcessStatus_Error;
     862    mData.mRC = rc;
     863    mData.mErrorMsg = strMessage;
     864
     865    int rc2 = signalWaiters(ProcessWaitResult_Error);
    826866    LogFlowFuncLeaveRC(rc2);
    827867    return rc2;
     868}
     869
     870int GuestProcess::setErrorExternal(void)
     871{
     872    return RT_SUCCESS(mData.mRC)
     873           ? S_OK : setError(VBOX_E_IPRT_ERROR, "%s", mData.mErrorMsg.c_str());
     874}
     875
     876int GuestProcess::signalWaiters(ProcessWaitResult_T enmWaitResult)
     877{
     878    LogFlowFunc(("enmWaitResult=%d, mWaitCount=%RU32, mWaitEvent=%p\n",
     879                 enmWaitResult, mData.mWaitCount, mData.mWaitEvent));
     880
     881    /* Note: No write locking here -- already done in the caller. */
     882
     883    int rc = VINF_SUCCESS;
     884    if (mData.mWaitEvent)
     885        rc = mData.mWaitEvent->Signal(enmWaitResult);
     886    LogFlowFuncLeaveRC(rc);
     887    return rc;
    828888}
    829889
     
    910970
    911971            rc = sendCommand(HOST_EXEC_CMD, i, paParms);
     972            if (RT_FAILURE(rc))
     973            {
     974                int rc2;
     975                if (rc == VERR_INVALID_VM_HANDLE)
     976                    rc2 = setErrorInternal(rc, tr("VMM device is not available (is the VM running?)"));
     977                else if (rc == VERR_NOT_FOUND)
     978                    rc2 = setErrorInternal(rc, tr("The guest execution service is not ready (yet)"));
     979                else if (rc == VERR_HGCM_SERVICE_NOT_FOUND)
     980                    rc2 = setErrorInternal(rc, tr("The guest execution service is not available"));
     981                else
     982                    rc2 = setErrorInternal(rc, Utf8StrFmt(tr("The HGCM call failed with error %Rrc"), rc));
     983                AssertRC(rc2);
     984            }
    912985        }
    913986
     
    915988        if (pszArgs)
    916989            RTStrFree(pszArgs);
    917 
    918         if (RT_FAILURE(rc))
    919             mData.mStatus = ProcessStatus_Error;
    920990
    921991        uint32_t uTimeoutMS = mData.mProcess.mTimeoutMS;
     
    10061076}
    10071077
    1008 int GuestProcess::waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestProcessWaitResult &guestResult)
     1078int GuestProcess::waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, GuestProcessWaitResult &waitRes)
    10091079{
    10101080    LogFlowThisFuncEnter();
     
    10191089    ProcessStatus_T curStatus = mData.mStatus;
    10201090
    1021     guestResult.mResult = ProcessWaitResult_None;
    1022     guestResult.mRC = VINF_SUCCESS;
    1023 
    1024 #if 1
    1025     if (   (fWaitFlags &  ProcessWaitForFlag_Start)
    1026         && (curStatus  != ProcessStatus_Undefined))
    1027     {
    1028         guestResult.mResult = ProcessWaitResult_Start; /** @todo Fix this. */
    1029     }
    1030 #else
     1091    /* Did some error occur before? Then skip waiting and return. */
     1092    if (curStatus == ProcessStatus_Error)
     1093    {
     1094        waitRes.mResult = ProcessWaitResult_Error;
     1095        return VINF_SUCCESS;
     1096    }
     1097
     1098    waitRes.mResult = ProcessWaitResult_None;
     1099    waitRes.mRC = VINF_SUCCESS;
     1100
    10311101    if (   (fWaitFlags & ProcessWaitForFlag_Terminate)
    10321102        || (fWaitFlags & ProcessWaitForFlag_StdIn)
     
    10401110            case ProcessStatus_TerminatedAbnormally:
    10411111            case ProcessStatus_Down:
    1042                 guestResult.mResult = ProcessWaitResult_Terminate;
     1112                waitRes.mResult = ProcessWaitResult_Terminate;
    10431113                break;
    10441114
    10451115            case ProcessStatus_TimedOutKilled:
    10461116            case ProcessStatus_TimedOutAbnormally:
    1047                 guestResult.mResult = ProcessWaitResult_Timeout;
     1117                waitRes.mResult = ProcessWaitResult_Timeout;
    10481118                break;
    10491119
    10501120            case ProcessStatus_Error:
    1051                 guestResult.mResult = ProcessWaitResult_Error;
     1121                waitRes.mResult = ProcessWaitResult_Error;
     1122                waitRes.mRC = mData.mRC;
     1123                break;
     1124
     1125            case ProcessStatus_Undefined:
     1126            case ProcessStatus_Starting:
     1127                /* Do the waiting below. */
    10521128                break;
    10531129
     
    10641140            case ProcessStatus_Paused:
    10651141            case ProcessStatus_Terminating:
    1066                 guestResult.mResult = ProcessWaitResult_Start;
     1142            case ProcessStatus_TerminatedNormally:
     1143            case ProcessStatus_TerminatedSignal:
     1144            case ProcessStatus_TerminatedAbnormally:
     1145            case ProcessStatus_Down:
     1146                waitRes.mResult = ProcessWaitResult_Start;
     1147                break;
     1148
     1149            case ProcessStatus_Error:
     1150                waitRes.mResult = ProcessWaitResult_Error;
     1151                waitRes.mRC = mData.mRC;
     1152                break;
     1153
     1154            case ProcessStatus_Undefined:
     1155            case ProcessStatus_Starting:
     1156                /* Do the waiting below. */
    10671157                break;
    10681158
     
    10721162        }
    10731163    }
    1074 #endif
     1164
     1165    LogFlowFunc(("waitResult=%ld, waitRC=%Rrc\n", waitRes.mResult, waitRes.mRC));
    10751166
    10761167    /* No waiting needed? Return immediately. */
    1077     if (guestResult.mResult != ProcessWaitResult_None)
     1168    if (waitRes.mResult != ProcessWaitResult_None)
    10781169        return VINF_SUCCESS;
    10791170
     
    10901181    int rc = mData.mWaitEvent->Wait(uTimeoutMS);
    10911182    if (RT_SUCCESS(rc))
    1092         guestResult = mData.mWaitEvent->GetResult();
     1183        waitRes = mData.mWaitEvent->GetResult();
    10931184
    10941185    alock.acquire(); /* Get the lock again. */
     
    12081299                        break;
    12091300
    1210                     case VERR_NOT_AVAILABLE:
    1211                        strMsg += Utf8StrFmt(tr("Guest control service is not ready"));
    1212 
    12131301                    default:
    12141302                        strMsg += Utf8StrFmt(tr("Reported error %Rrc"), rc);
     
    13311419    if (RT_SUCCESS(rc))
    13321420    {
    1333         hr = waitResultToErrorEx(waitRes, true /* fLog */);
    1334         if (SUCCEEDED(hr))
    1335             *aReason = waitRes.mResult;
     1421        *aReason = waitRes.mResult;
     1422        hr = setErrorExternal();
    13361423    }
    13371424    else
    1338         hr = setError(VBOX_E_IPRT_ERROR,
    1339                       tr("Waiting for process \"%s\" (PID %RU32) failed with rc=%Rrc"),
    1340                       mData.mProcess.mCommand.c_str(), mData.mPID, rc);
    1341     LogFlowFuncLeaveRC(hr);
     1425    {
     1426        if (rc == VERR_TIMEOUT)
     1427            hr = setError(VBOX_E_IPRT_ERROR,
     1428                          tr("Process \"%s\" (PID %RU32) did not respond within time (%RU32ms)"),
     1429                          mData.mProcess.mCommand.c_str(), mData.mPID, aTimeoutMS);
     1430        else
     1431            hr = setError(VBOX_E_IPRT_ERROR,
     1432                          tr("Waiting for process \"%s\" (PID %RU32) failed with rc=%Rrc"),
     1433                          mData.mProcess.mCommand.c_str(), mData.mPID, rc);
     1434    }
     1435    LogFlowFuncLeaveRC(rc);
    13421436    return hr;
    13431437#endif /* VBOX_WITH_GUEST_CONTROL */
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r42412 r42436  
    379379    LogFlowFuncEnter();
    380380
    381     AssertPtrReturn(pvData, VERR_INVALID_POINTER);
    382     AssertReturn(cbData, VERR_INVALID_PARAMETER);
    383 
    384381    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    385382
     383    uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(uContextID);
     384#ifdef DEBUG
     385    LogFlowFunc(("uProcessID=%RU32 (%RU32 total)\n",
     386                 uProcessID, mData.mProcesses.size()));
     387    SessionProcesses::const_iterator i = mData.mProcesses.begin();
     388    while (i != mData.mProcesses.end())
     389    {
     390        LogFlowFunc(("\tproc %RU32\n", i->first));
     391        i++;
     392    }
     393#endif
    386394    int rc;
    387395    SessionProcesses::const_iterator itProc
    388         = mData.mProcesses.find(VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(uContextID));
     396        = mData.mProcesses.find(uProcessID);
    389397    if (itProc != mData.mProcesses.end())
    390398    {
     
    448456int GuestSession::processCreateExInteral(GuestProcessInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
    449457{
     458    LogFlowFunc(("mCmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",
     459                 procInfo.mCommand.c_str(), procInfo.mFlags, procInfo.mTimeoutMS));
     460
    450461    /* Validate flags. */
    451462    if (procInfo.mFlags)
     
    469480    /** @tood Implement process priority + affinity. */
    470481
     482    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     483
    471484    int rc = VERR_MAX_PROCS_REACHED;
    472485    if (mData.mProcesses.size() >= VBOX_GUESTCTRL_MAX_PROCESSES)
    473486        return rc;
    474 
    475     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    476487
    477488    /* Create a new (host-based) process ID and assign it. */
     
    504515
    505516        rc = pProcess->init(mData.mParent->getConsole() /* Console */, this /* Session */,
    506                              uNewProcessID, procInfo);
     517                            uNewProcessID, procInfo);
    507518        if (RT_FAILURE(rc)) throw rc;
    508519
    509520        /* Add the created process to our map. */
    510521        mData.mProcesses[uNewProcessID] = pProcess;
     522
     523        LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32\n",
     524                     mData.mId, uNewProcessID));
    511525    }
    512526    catch (int rc2)
     
    10111025        com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
    10121026        for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
    1013             rc = mData.mEnvironment.Set(Utf8Str(environment[i]));
     1027            rc = procInfo.mEnvironment.Set(Utf8Str(environment[i]));
    10141028    }
    10151029
     
    10551069        {
    10561070            case VERR_MAX_PROCS_REACHED:
    1057                 hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes (%ld) reached"),
    1058                               VERR_MAX_PROCS_REACHED);
     1071                hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes per session (%ld) reached"),
     1072                              VBOX_GUESTCTRL_MAX_PROCESSES);
    10591073                break;
    10601074
    10611075            /** @todo Add more errors here. */
    10621076
    1063            default:
     1077            default:
    10641078                hr = setError(VBOX_E_IPRT_ERROR, tr("Could not create guest process, rc=%Rrc"), rc);
    10651079                break;
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