Changeset 55535 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Apr 30, 2015 2:13:56 AM (10 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r53127 r55535 91 91 GuestProcessStartupInfo procInfo; 92 92 procInfo.mName = Utf8StrFmt(tr("Reading directory \"%s\""), openInfo.mPath.c_str()); 93 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_LS);93 procInfo.mExecutable= Utf8Str(VBOXSERVICE_TOOL_LS); 94 94 procInfo.mTimeoutMS = 5 * 60 * 1000; /* 5 minutes timeout. */ 95 95 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r55491 r55535 266 266 267 267 #ifdef VBOX_WITH_GUEST_CONTROL 268 LogFlowThisFunc(("mCmd=%s, PID=%RU32\n", 269 mData.mProcess.mCommand.c_str(), mData.mPID)); 268 LogFlowThisFunc(("mExe=%s, PID=%RU32\n", mData.mProcess.mExecutable.c_str(), mData.mPID)); 270 269 271 270 /* Terminate process if not already done yet. */ … … 334 333 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 335 334 336 aExecutablePath = mData.mProcess.m Command;335 aExecutablePath = mData.mProcess.mExecutable; 337 336 338 337 return S_OK; … … 987 986 int GuestProcess::i_startProcess(uint32_t uTimeoutMS, int *pGuestRc) 988 987 { 989 LogFlowThisFunc(("uTimeoutMS=%RU32, proc Cmd=%s, procTimeoutMS=%RU32, procFlags=%x, sessionID=%RU32\n",990 uTimeoutMS, mData.mProcess.m Command.c_str(), mData.mProcess.mTimeoutMS, mData.mProcess.mFlags,988 LogFlowThisFunc(("uTimeoutMS=%RU32, procExe=%s, procTimeoutMS=%RU32, procFlags=%x, sessionID=%RU32\n", 989 uTimeoutMS, mData.mProcess.mExecutable.c_str(), mData.mProcess.mTimeoutMS, mData.mProcess.mFlags, 991 990 mSession->i_getId())); 992 991 … … 1017 1016 GuestSession *pSession = mSession; 1018 1017 AssertPtr(pSession); 1018 uint32_t const uProtocol = pSession->i_getProtocolVersion(); 1019 1019 1020 1020 const GuestCredentials &sessionCreds = pSession->i_getCredentials(); 1021 1021 1022 1022 1023 /* Prepare arguments. */ … … 1029 1030 && cArgs) 1030 1031 { 1031 char **papszArgv = (char**)RTMemAlloc((cArgs + 1) * sizeof(char*));1032 char const **papszArgv = (char const **)RTMemAlloc((cArgs + 1) * sizeof(papszArgv[0])); 1032 1033 AssertReturn(papszArgv, VERR_NO_MEMORY); 1033 1034 1034 for (size_t i = 0; i < cArgs && RT_SUCCESS(vrc); i++) 1035 { 1036 const char *pszCurArg = mData.mProcess.mArguments[i].c_str(); 1037 AssertPtr(pszCurArg); 1038 vrc = RTStrDupEx(&papszArgv[i], pszCurArg); 1035 for (size_t i = 0; i < cArgs; i++) 1036 { 1037 papszArgv[i] = mData.mProcess.mArguments[i].c_str(); 1038 AssertPtr(papszArgv[i]); 1039 1039 } 1040 1040 papszArgv[cArgs] = NULL; 1041 1041 1042 if (RT_SUCCESS(vrc)) 1042 if (uProtocol < UINT32_C(0xdeadbeef) ) /** @todo implement a way of sending argv[0], best idea is a new command. */ 1043 vrc = RTGetOptArgvToString(&pszArgs, papszArgv + 1, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH); 1044 else 1043 1045 vrc = RTGetOptArgvToString(&pszArgs, papszArgv, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH); 1044 1046 1045 if (papszArgv) 1046 { 1047 size_t i = 0; 1048 while (papszArgv[i]) 1049 RTStrFree(papszArgv[i++]); 1050 RTMemFree(papszArgv); 1051 } 1047 RTMemFree(papszArgv); 1052 1048 } 1053 1049 … … 1065 1061 if (RT_SUCCESS(vrc)) 1066 1062 { 1067 AssertPtr(mSession);1068 uint32_t uProtocol = mSession->i_getProtocolVersion();1069 1070 1063 /* Prepare HGCM call. */ 1071 1064 VBOXHGCMSVCPARM paParms[16]; 1072 1065 int i = 0; 1073 1066 paParms[i++].setUInt32(pEvent->ContextID()); 1074 paParms[i++].setPointer((void*)mData.mProcess.m Command.c_str(),1075 (ULONG)mData.mProcess.m Command.length() + 1);1067 paParms[i++].setPointer((void*)mData.mProcess.mExecutable.c_str(), 1068 (ULONG)mData.mProcess.mExecutable.length() + 1); 1076 1069 paParms[i++].setUInt32(mData.mProcess.mFlags); 1077 1070 paParms[i++].setUInt32((uint32_t)mData.mProcess.mArguments.size()); … … 1764 1757 hr = setError(VBOX_E_IPRT_ERROR, 1765 1758 tr("Reading from process \"%s\" (PID %RU32) failed: %Rrc"), 1766 mData.mProcess.m Command.c_str(), mData.mPID, vrc);1759 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1767 1760 break; 1768 1761 } … … 1798 1791 hr = setError(VBOX_E_IPRT_ERROR, 1799 1792 tr("Terminating process \"%s\" (PID %RU32) not supported by installed Guest Additions"), 1800 mData.mProcess.m Command.c_str(), mData.mPID);1793 mData.mProcess.mExecutable.c_str(), mData.mPID); 1801 1794 break; 1802 1795 … … 1804 1797 hr = setError(VBOX_E_IPRT_ERROR, 1805 1798 tr("Terminating process \"%s\" (PID %RU32) failed: %Rrc"), 1806 mData.mProcess.m Command.c_str(), mData.mPID, vrc);1799 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1807 1800 break; 1808 1801 } … … 1834 1827 HRESULT hr = S_OK; 1835 1828 1836 int guestRc; ProcessWaitResult_T waitResult; 1829 int guestRc; 1830 ProcessWaitResult_T waitResult; 1837 1831 int vrc = i_waitFor(aWaitFor, aTimeoutMS, waitResult, &guestRc); 1838 1832 if (RT_SUCCESS(vrc)) … … 1855 1849 hr = setError(VBOX_E_IPRT_ERROR, 1856 1850 tr("Waiting for process \"%s\" (PID %RU32) failed: %Rrc"), 1857 mData.mProcess.m Command.c_str(), mData.mPID, vrc);1851 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1858 1852 break; 1859 1853 } … … 1907 1901 hr = setError(VBOX_E_IPRT_ERROR, 1908 1902 tr("Writing to process \"%s\" (PID %RU32) failed: %Rrc"), 1909 mData.mProcess.m Command.c_str(), mData.mPID, vrc);1903 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1910 1904 break; 1911 1905 } … … 1956 1950 bool fAsync, int *pGuestRc) 1957 1951 { 1958 LogFlowThisFunc(("pGuestSession=%p, szCmd=%s, fAsync=%RTbool\n",1959 pGuestSession, startupInfo.m Command.c_str(), fAsync));1952 LogFlowThisFunc(("pGuestSession=%p, exe=%s, fAsync=%RTbool\n", 1953 pGuestSession, startupInfo.mExecutable.c_str(), fAsync)); 1960 1954 1961 1955 AssertPtrReturn(pGuestSession, VERR_INVALID_POINTER); … … 1967 1961 mStartupInfo.mFlags |= ProcessCreateFlag_Hidden; 1968 1962 1969 int vrc = pSession->i_processCreateExInter al(mStartupInfo, pProcess);1963 int vrc = pSession->i_processCreateExInternal(mStartupInfo, pProcess); 1970 1964 if (RT_SUCCESS(vrc)) 1971 1965 vrc = fAsync -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r54009 r55535 661 661 662 662 GuestProcessStartupInfo procInfo; 663 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_MKDIR);664 procInfo.mFlags = ProcessCreateFlag_Hidden;663 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKDIR); 664 procInfo.mFlags = ProcessCreateFlag_Hidden; 665 665 666 666 try … … 816 816 817 817 GuestProcessStartupInfo procInfo; 818 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_MKTEMP);819 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;818 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_MKTEMP); 819 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 820 820 821 821 try … … 1217 1217 GuestProcessStream streamOut; 1218 1218 1219 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_RM);1220 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;1219 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_RM); 1220 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1221 1221 1222 1222 try … … 1374 1374 /** @todo Merge this with IGuestFile::queryInfo(). */ 1375 1375 GuestProcessStartupInfo procInfo; 1376 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_STAT);1377 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;1376 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_STAT); 1377 procInfo.mFlags = ProcessCreateFlag_WaitForStdOut; 1378 1378 1379 1379 try … … 1837 1837 1838 1838 /** 1839 * Creates but does *not* start the process yet. See GuestProcess::startProcess() or 1840 * GuestProcess::startProcessAsync() for that. 1839 * Creates but does *not* start the process yet. 1840 * 1841 * See GuestProcess::startProcess() or GuestProcess::startProcessAsync() for 1842 * starting the process. 1841 1843 * 1842 1844 * @return IPRT status code. … … 1844 1846 * @param pProcess 1845 1847 */ 1846 int GuestSession::i_processCreateExInter al(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)1847 { 1848 LogFlowFunc(("m Cmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",1849 procInfo.m Command.c_str(), procInfo.mFlags, procInfo.mTimeoutMS));1848 int GuestSession::i_processCreateExInternal(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess) 1849 { 1850 LogFlowFunc(("mExe=%s, mFlags=%x, mTimeoutMS=%RU32\n", 1851 procInfo.mExecutable.c_str(), procInfo.mFlags, procInfo.mTimeoutMS)); 1850 1852 #ifdef DEBUG 1851 1853 if (procInfo.mArguments.size()) … … 3308 3310 } 3309 3311 3310 HRESULT GuestSession::processCreate(const com::Utf8Str &a Command, const std::vector<com::Utf8Str> &aArguments,3312 HRESULT GuestSession::processCreate(const com::Utf8Str &aExecutable, const std::vector<com::Utf8Str> &aArguments, 3311 3313 const std::vector<com::Utf8Str> &aEnvironment, 3312 3314 const std::vector<ProcessCreateFlag_T> &aFlags, … … 3320 3322 std::vector<LONG> affinityIgnored; 3321 3323 3322 return processCreateEx(a Command, aArguments, aEnvironment, aFlags, aTimeoutMS, ProcessPriority_Default,3324 return processCreateEx(aExecutable, aArguments, aEnvironment, aFlags, aTimeoutMS, ProcessPriority_Default, 3323 3325 affinityIgnored, aGuestProcess); 3324 3326 #endif /* VBOX_WITH_GUEST_CONTROL */ 3325 3327 } 3326 3328 3327 HRESULT GuestSession::processCreateEx(const com::Utf8Str &a Command, const std::vector<com::Utf8Str> &aArguments,3329 HRESULT GuestSession::processCreateEx(const com::Utf8Str &aExecutable, const std::vector<com::Utf8Str> &aArguments, 3328 3330 const std::vector<com::Utf8Str> &aEnvironment, 3329 3331 const std::vector<ProcessCreateFlag_T> &aFlags, ULONG aTimeoutMS, … … 3336 3338 LogFlowThisFuncEnter(); 3337 3339 3338 if (RT_UNLIKELY((aCommand.c_str()) == NULL || *(aCommand.c_str()) == '\0')) 3339 return setError(E_INVALIDARG, tr("No command to execute specified")); 3340 3340 /* 3341 * Must have an executable to execute. If none is given, we try use the 3342 * zero'th argument. 3343 */ 3344 const char *pszExecutable = aExecutable.c_str(); 3345 if (RT_UNLIKELY(pszExecutable == NULL || *pszExecutable == '\0')) 3346 { 3347 if (aArguments.size() > 0) 3348 pszExecutable = aArguments[0].c_str(); 3349 if (pszExecutable == NULL || *pszExecutable == '\0') 3350 return setError(E_INVALIDARG, tr("No command to execute specified")); 3351 } 3352 3353 /* 3354 * Check the session. 3355 */ 3341 3356 HRESULT hr = i_isReadyExternal(); 3342 3357 if (FAILED(hr)) 3343 3358 return hr; 3344 3359 3360 /* 3361 * Build the process startup info. 3362 */ 3345 3363 GuestProcessStartupInfo procInfo; 3346 procInfo.mCommand = aCommand; 3347 3364 3365 /* Executable and arguments. */ 3366 procInfo.mExecutable = pszExecutable; 3348 3367 if (aArguments.size()) 3349 3368 for (size_t i = 0; i < aArguments.size(); i++) 3350 3369 procInfo.mArguments.push_back(aArguments[i]); 3351 3352 int rc = VINF_SUCCESS;3353 3370 3354 3371 /* … … 3360 3377 procInfo.mEnvironment = mData.mEnvironment; /* Apply original session environment. */ 3361 3378 3379 int rc = VINF_SUCCESS; 3362 3380 if (aEnvironment.size()) 3363 3381 for (size_t i = 0; i < aEnvironment.size() && RT_SUCCESS(rc); i++) 3382 { 3383 /** @todo r=bird: What ARE you trying to do here??? The documentation is crystal 3384 * clear on that each entry contains ONE pair, however, 3385 * GuestEnvironment::Set(const Utf8Str &) here will split up the input 3386 * into any number of pairs, from what I can tell. Such that for e.g. 3387 * "VBOX_LOG_DEST=file=/tmp/foobared.log" becomes "VBOX_LOG_DEST=file" 3388 * and "/tmp/foobared.log" - which I obviously don't want! */ 3364 3389 rc = procInfo.mEnvironment.Set(aEnvironment[i]); 3390 } 3365 3391 3366 3392 if (RT_SUCCESS(rc)) 3367 3393 { 3394 /* Convert the flag array into a mask. */ 3368 3395 if (aFlags.size()) 3369 3396 for (size_t i = 0; i < aFlags.size(); i++) … … 3372 3399 procInfo.mTimeoutMS = aTimeoutMS; 3373 3400 3401 /** @todo use RTCPUSET instead of archaic 64-bit variables! */ 3374 3402 if (aAffinity.size()) 3375 3403 for (size_t i = 0; i < aAffinity.size(); i++) … … 3379 3407 procInfo.mPriority = aPriority; 3380 3408 3409 /* 3410 * Create a guest process object. 3411 */ 3381 3412 ComObjPtr<GuestProcess> pProcess; 3382 rc = i_processCreateExInter al(procInfo, pProcess);3413 rc = i_processCreateExInternal(procInfo, pProcess); 3383 3414 if (RT_SUCCESS(rc)) 3384 3415 { 3385 3416 /* Return guest session to the caller. */ 3386 3417 HRESULT hr2 = pProcess.queryInterfaceTo(aGuestProcess.asOutParam()); 3387 if (FAILED(hr2)) 3418 if (SUCCEEDED(hr2)) 3419 { 3420 /* 3421 * Start the process. 3422 */ 3423 rc = pProcess->i_startProcessAsync(); 3424 if (RT_FAILURE(rc)) 3425 { 3426 /** @todo r=bird: What happens to the interface that *aGuestProcess points to 3427 * now? Looks like a leak or an undocument hack of sorts... */ 3428 } 3429 } 3430 else 3388 3431 rc = VERR_COM_OBJECT_NOT_FOUND; 3389 3390 if (RT_SUCCESS(rc))3391 rc = pProcess->i_startProcessAsync(); 3392 }3393 }3394 3432 } 3433 } 3434 3435 /** @todo you're better off doing this is 'else if (rc == xxx') statements, 3436 * since there is just one place where you'll get 3437 * VERR_MAX_PROCS_REACHED in the above code. */ 3395 3438 if (RT_FAILURE(rc)) 3396 3439 { -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r53873 r55535 309 309 310 310 GuestProcessStartupInfo procInfo; 311 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_CAT);312 procInfo.mFlags = ProcessCreateFlag_Hidden;311 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_CAT); 312 procInfo.mFlags = ProcessCreateFlag_Hidden; 313 313 314 314 /* Set arguments.*/ … … 318 318 ComObjPtr<GuestProcess> pProcess; int guestRc; 319 319 if (RT_SUCCESS(rc)) 320 rc = pSession->i_processCreateExInter al(procInfo, pProcess);320 rc = pSession->i_processCreateExInternal(procInfo, pProcess); 321 321 if (RT_SUCCESS(rc)) 322 322 { … … 637 637 procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"), 638 638 mSource.c_str(), mDest.c_str(), objData.mObjectSize); 639 procInfo.m Command= Utf8Str(VBOXSERVICE_TOOL_CAT);640 procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;639 procInfo.mExecutable = Utf8Str(VBOXSERVICE_TOOL_CAT); 640 procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut; 641 641 642 642 /* Set arguments.*/ … … 645 645 /* Startup process. */ 646 646 ComObjPtr<GuestProcess> pProcess; 647 rc = pSession->i_processCreateExInter al(procInfo, pProcess);647 rc = pSession->i_processCreateExInternal(procInfo, pProcess); 648 648 if (RT_SUCCESS(rc)) 649 649 rc = pProcess->i_startProcess(30 * 1000 /* 30s timeout */, … … 1040 1040 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1041 1041 Utf8StrFmt(GuestSession::tr("Running update file \"%s\" on guest terminated with exit code %ld"), 1042 procInfo.m Command.c_str(), exitCode));1042 procInfo.mExecutable.c_str(), exitCode)); 1043 1043 break; 1044 1044 … … 1051 1051 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1052 1052 Utf8StrFmt(GuestSession::tr("Update file \"%s\" reported invalid running state"), 1053 procInfo.m Command.c_str()));1053 procInfo.mExecutable.c_str())); 1054 1054 break; 1055 1055 … … 1057 1057 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 1058 1058 Utf8StrFmt(GuestSession::tr("Error while running update file \"%s\" on guest: %Rrc"), 1059 procInfo.m Command.c_str(), vrc));1059 procInfo.mExecutable.c_str(), vrc)); 1060 1060 break; 1061 1061 } … … 1413 1413 * calculate the specific percentage step of each copied file. */ 1414 1414 uint8_t uOffset = 20; /* Start at 20%. */ 1415 uint8_t uStep = 40 / mFiles.size();1415 uint8_t uStep = 40 / (uint8_t)mFiles.size(); Assert(mFiles.size() <= 10); 1416 1416 1417 1417 LogRel(("Copying over Guest Additions update files to the guest ...\n")); … … 1453 1453 * calculate the specific percentage step of each copied file. */ 1454 1454 uint8_t uOffset = 60; /* Start at 60%. */ 1455 uint8_t uStep = 35 / mFiles.size();1455 uint8_t uStep = 35 / (uint8_t)mFiles.size(); Assert(mFiles.size() <= 10); 1456 1456 1457 1457 LogRel(("Executing Guest Additions update files ...\n"));
Note:
See TracChangeset
for help on using the changeset viewer.