Changeset 84648 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jun 3, 2020 8:11:04 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 138400
- Location:
- trunk/src/VBox/Main
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r83556 r84648 604 604 }; 605 605 606 /** 607 * Class for keeping guest error information. 608 */ 609 class GuestErrorInfo 610 { 611 public: 612 613 /** 614 * Enumeration for specifying the guest error type. 615 */ 616 enum Type 617 { 618 /** Guest error is anonymous. Avoid this. */ 619 Type_Anonymous = 0, 620 /** Guest error is from a guest session. */ 621 Type_Session, 622 /** Guest error is from a guest process. */ 623 Type_Process, 624 /** Guest error is from a guest file object. */ 625 Type_File, 626 /** Guest error is from a guest directory object. */ 627 Type_Directory, 628 /** Guest error is from a the built-in toolbox "vbox_cat" command. */ 629 Type_ToolCat, 630 /** Guest error is from a the built-in toolbox "vbox_ls" command. */ 631 Type_ToolLs, 632 /** Guest error is from a the built-in toolbox "vbox_rm" command. */ 633 Type_ToolRm, 634 /** Guest error is from a the built-in toolbox "vbox_mkdir" command. */ 635 Type_ToolMkDir, 636 /** Guest error is from a the built-in toolbox "vbox_mktemp" command. */ 637 Type_ToolMkTemp, 638 /** Guest error is from a the built-in toolbox "vbox_stat" command. */ 639 Type_ToolStat, 640 /** The usual 32-bit hack. */ 641 Type_32BIT_HACK = 0x7fffffff 642 }; 643 644 /** 645 * Initialization constructor. 646 * 647 * @param eType Error type to use. 648 * @param rc IPRT-style rc to use. 649 * @param pcszWhat Subject to use. 650 */ 651 GuestErrorInfo(GuestErrorInfo::Type eType, int rc, const char *pcszWhat) 652 { 653 int rc2 = setV(eType, rc, pcszWhat); 654 if (RT_FAILURE(rc2)) 655 throw rc2; 656 } 657 658 /** 659 * Returns the (IPRT-style) rc of this error. 660 * 661 * @returns VBox status code. 662 */ 663 int getRc(void) const { return mRc; } 664 665 /** 666 * Returns the type of this error. 667 * 668 * @returns Error type. 669 */ 670 Type getType(void) const { return mType; } 671 672 /** 673 * Returns the subject of this error. 674 * 675 * @returns Subject as a string. 676 */ 677 Utf8Str getWhat(void) const { return mWhat; } 678 679 /** 680 * Sets the error information using a variable arguments list (va_list). 681 * 682 * @returns VBox status code. 683 * @param eType Error type to use. 684 * @param rc IPRT-style rc to use. 685 * @param pcszWhat Subject to use. 686 */ 687 int setV(GuestErrorInfo::Type eType, int rc, const char *pcszWhat) 688 { 689 mType = eType; 690 mRc = rc; 691 mWhat = pcszWhat; 692 693 return VINF_SUCCESS; 694 } 695 696 protected: 697 698 /** Error type. */ 699 Type mType; 700 /** IPRT-style error code. */ 701 int mRc; 702 /** Subject string related to this error. */ 703 Utf8Str mWhat; 704 }; 606 705 607 706 /** … … 1169 1268 int waitForEvent(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, VBoxEventType_T *pType, IEvent **ppEvent); 1170 1269 1270 #ifndef VBOX_GUESTCTRL_TEST_CASE 1271 HRESULT setErrorExternal(VirtualBoxBase *pInterface, const Utf8Str &strAction, const GuestErrorInfo &guestErrorInfo); 1272 #endif 1273 1171 1274 public: 1172 1275 1173 1276 static FsObjType_T fileModeToFsObjType(RTFMODE fMode); 1277 static Utf8Str getErrorAsString(const GuestErrorInfo &guestErrorInfo); 1174 1278 1175 1279 protected: -
trunk/src/VBox/Main/include/GuestDirectoryImpl.h
r83489 r84648 66 66 /** @name Public static internal methods. 67 67 * @{ */ 68 static Utf8Str i_guestErrorToString(int guestRc); 69 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc); 68 static Utf8Str i_guestErrorToString(int rcGuest, const char *pcszWhat); 70 69 /** @} */ 71 70 -
trunk/src/VBox/Main/include/GuestFileImpl.h
r84054 r84648 61 61 int i_closeFile(int *pGuestRc); 62 62 EventSource *i_getEventSource(void) { return mEventSource; } 63 static Utf8Str i_guestErrorToString(int guestRc);64 63 int i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); 65 64 int i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData); … … 70 69 void* pvData, size_t cbData, size_t* pcbRead); 71 70 int i_seekAt(int64_t iOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, uint64_t *puOffset); 72 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);73 71 int i_setFileStatus(FileStatus_T fileStatus, int fileRc); 74 72 int i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset); … … 78 76 int i_writeData(uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten); 79 77 int i_writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten); 78 /** @} */ 79 80 /** @name Static helper methods. 81 * @{ */ 82 static Utf8Str i_guestErrorToString(int guestRc, const char *pcszWhat); 80 83 /** @} */ 81 84 -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r82968 r84648 77 77 /** @name Static internal methods. 78 78 * @{ */ 79 static Utf8Str i_guestErrorToString(int guestRc);79 static Utf8Str i_guestErrorToString(int rcGuest, const char *pcszWhat); 80 80 static bool i_isGuestError(int guestRc); 81 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);82 81 static ProcessWaitResult_T i_waitFlagsToResultEx(uint32_t fWaitFlags, ProcessStatus_T oldStatus, ProcessStatus_T newStatus, uint32_t uProcFlags, uint32_t uProtocol); 83 82 #if 0 /* unused */ … … 271 270 /** @} */ 272 271 272 /** Wrapped @name Static guest error conversion methods. 273 * @{ */ 274 static Utf8Str guestErrorToString(const char *pszTool, const GuestErrorInfo& guestErrorInfo); 275 /** @} */ 276 273 277 protected: 274 278 -
trunk/src/VBox/Main/include/GuestSessionImpl.h
r84554 r84648 309 309 Utf8Str i_getName(void); 310 310 ULONG i_getId(void) { return mData.mSession.mID; } 311 static Utf8Str i_guestErrorToString(int guestRc);312 311 bool i_isStarted(void) const; 313 312 HRESULT i_isStartedExternal(void); 314 static bool i_isTerminated(GuestSessionStatus_T enmStatus);315 313 bool i_isTerminated(void) const; 316 314 int i_onRemove(void); … … 319 317 int i_startSession(int *pGuestRc); 320 318 int i_startSessionAsync(void); 321 static int i_startSessionThreadTask(GuestSessionTaskInternalStart *pTask);322 319 Guest *i_getParent(void) { return mParent; } 323 320 uint32_t i_getProtocolVersion(void) { return mData.mProtocolVersion; } … … 335 332 int i_sendMessage(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms, 336 333 uint64_t fDst = VBOX_GUESTCTRL_DST_SESSION); 337 static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);338 334 int i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc); 339 335 int i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */); … … 343 339 int i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS, 344 340 GuestSessionStatus_T *pSessionStatus, int *pGuestRc); 341 /** @} */ 342 343 public: 344 345 /** @name Static helper methods. 346 * @{ */ 347 static Utf8Str i_guestErrorToString(int guestRc); 348 static bool i_isTerminated(GuestSessionStatus_T enmStatus); 349 static int i_startSessionThreadTask(GuestSessionTaskInternalStart *pTask); 345 350 /** @} */ 346 351 -
trunk/src/VBox/Main/include/GuestSessionImplTasks.h
r83336 r84648 204 204 /** @name File handling primitives. 205 205 * @{ */ 206 int fileCopyFromGuestInner(ComObjPtr<GuestFile> &srcFile, PRTFILE phDstFile, FileCopyFlag_T fFileCopyFlags, 207 uint64_t offCopy, uint64_t cbSize); 206 int fileCopyFromGuestInner(const Utf8Str &strSrcFile, ComObjPtr<GuestFile> &srcFile, 207 const Utf8Str &strDstFile, PRTFILE phDstFile, 208 FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize); 208 209 int fileCopyFromGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags); 209 int fileCopyToGuestInner(RTVFSFILE hSrcFile, ComObjPtr<GuestFile> &dstFile, FileCopyFlag_T fFileCopyFlags, 210 uint64_t offCopy, uint64_t cbSize); 210 int fileCopyToGuestInner(const Utf8Str &strSrcFile, RTVFSFILE hSrcFile, 211 const Utf8Str &strDstFile, ComObjPtr<GuestFile> &dstFile, 212 FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize); 211 213 212 214 int fileCopyToGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags); … … 221 223 int setProgressSuccess(void); 222 224 HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg); 223 HRESULT setProgressErrorMsg(HRESULT hr c, int vrc, const char *pszFormat, ...);225 HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg, const GuestErrorInfo &guestErrorInfo); 224 226 225 227 inline void setTaskDesc(const Utf8Str &strTaskDesc) throw() -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r82968 r84648 1302 1302 } 1303 1303 1304 #ifndef VBOX_GUESTCTRL_TEST_CASE 1305 /** 1306 * Returns a user-friendly error message from a given GuestErrorInfo object. 1307 * 1308 * @returns Error message string. 1309 * @param guestErrorInfo Guest error info to return error message for. 1310 */ 1311 /* static */ Utf8Str GuestBase::getErrorAsString(const GuestErrorInfo& guestErrorInfo) 1312 { 1313 AssertMsg(RT_FAILURE(guestErrorInfo.getRc()), ("Guest rc does not indicate a failure\n")); 1314 1315 Utf8Str strErr; 1316 1317 #define CASE_TOOL_ERROR(a_eType, a_strTool) \ 1318 case a_eType: \ 1319 { \ 1320 strErr = GuestProcessTool::guestErrorToString(a_strTool, guestErrorInfo); \ 1321 break; \ 1322 } 1323 1324 switch (guestErrorInfo.getType()) 1325 { 1326 case GuestErrorInfo::Type_Session: 1327 strErr = GuestSession::i_guestErrorToString(guestErrorInfo.getRc()); 1328 break; 1329 1330 case GuestErrorInfo::Type_Process: 1331 strErr = GuestProcess::i_guestErrorToString(guestErrorInfo.getRc(), guestErrorInfo.getWhat().c_str()); 1332 break; 1333 1334 case GuestErrorInfo::Type_File: 1335 strErr = GuestFile::i_guestErrorToString(guestErrorInfo.getRc(), guestErrorInfo.getWhat().c_str()); 1336 break; 1337 1338 case GuestErrorInfo::Type_Directory: 1339 strErr = GuestDirectory::i_guestErrorToString(guestErrorInfo.getRc(), guestErrorInfo.getWhat().c_str()); 1340 break; 1341 1342 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolCat, VBOXSERVICE_TOOL_CAT); 1343 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolLs, VBOXSERVICE_TOOL_LS); 1344 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolMkDir, VBOXSERVICE_TOOL_MKDIR); 1345 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolMkTemp, VBOXSERVICE_TOOL_MKTEMP); 1346 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolRm, VBOXSERVICE_TOOL_RM); 1347 CASE_TOOL_ERROR(GuestErrorInfo::Type_ToolStat, VBOXSERVICE_TOOL_STAT); 1348 1349 default: 1350 AssertMsgFailed(("Type not implemented (type=%RU32, rc=%Rrc)\n", guestErrorInfo.getType(), guestErrorInfo.getRc())); 1351 strErr = Utf8StrFmt("Unknown / Not implemented -- Please file a bug report (type=%RU32, rc=%Rrc)\n", 1352 guestErrorInfo.getType(), guestErrorInfo.getRc()); 1353 break; 1354 } 1355 1356 return strErr; 1357 } 1358 1359 /** 1360 * Sets a guest error as error info, needed for API clients. 1361 * 1362 * @returns HRESULT COM error. 1363 * @param pInterface Interface to set error for. 1364 * @param strAction What action was involved causing this error. 1365 * @param guestErrorInfo Guest error info to use. 1366 */ 1367 /* static */ HRESULT GuestBase::setErrorExternal(VirtualBoxBase *pInterface, 1368 const Utf8Str &strAction, const GuestErrorInfo &guestErrorInfo) 1369 { 1370 AssertPtrReturn(pInterface, E_POINTER); 1371 return pInterface->setErrorBoth(VBOX_E_IPRT_ERROR, 1372 guestErrorInfo.getRc(), 1373 "%s", Utf8StrFmt("%s: %s", strAction.c_str(), GuestBase::getErrorAsString(guestErrorInfo).c_str()).c_str()); 1374 } 1375 #endif /* VBOX_GUESTCTRL_TEST_CASE */ 1376 1304 1377 /** 1305 1378 * Converts RTFMODE to FsObjType_T. -
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r83489 r84648 223 223 } 224 224 225 /** 226 * Converts a given guest directory error to a string. 227 * 228 * @returns Error string. 229 * @param rcGuest Guest file error to return string for. 230 * @param pcszWhat Hint of what was involved when the error occurred. 231 */ 225 232 /* static */ 226 Utf8Str GuestDirectory::i_guestErrorToString(int rcGuest) 227 { 228 Utf8Str strError; 233 Utf8Str GuestDirectory::i_guestErrorToString(int rcGuest, const char *pcszWhat) 234 { 235 AssertPtrReturn(pcszWhat, ""); 236 237 Utf8Str strErr; 238 239 #define CASE_MSG(a_iRc, a_strFormatString, ...) \ 240 case a_iRc: strErr = Utf8StrFmt(a_strFormatString, ##__VA_ARGS__); break; 229 241 230 242 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 231 243 switch (rcGuest) 232 244 { 233 case VERR_CANT_CREATE: 234 strError += Utf8StrFmt("Access denied"); 245 CASE_MSG(VERR_CANT_CREATE , tr("Access to guest directory \"%s\" is denied"), pcszWhat); 246 CASE_MSG(VERR_DIR_NOT_EMPTY, tr("Guest directory \"%s\" is not empty"), pcszWhat); 247 default: 248 { 249 char szDefine[80]; 250 RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/); 251 strErr = Utf8StrFmt("Error %s for guest directory \"%s\" occurred\n", szDefine, pcszWhat); 235 252 break; 236 237 case VERR_DIR_NOT_EMPTY: 238 strError += Utf8StrFmt("Not empty"); 239 break; 240 241 default: 242 strError += Utf8StrFmt("%Rrc", rcGuest); 243 break; 244 } 245 246 return strError; 253 } 254 } 255 256 #undef CASE_MSG 257 258 return strErr; 247 259 } 248 260 … … 384 396 } 385 397 386 /* static */387 HRESULT GuestDirectory::i_setErrorExternal(VirtualBoxBase *pInterface, int rcGuest)388 {389 AssertPtr(pInterface);390 AssertMsg(RT_FAILURE(rcGuest), ("Guest rc does not indicate a failure when setting error\n"));391 392 return pInterface->setError(VBOX_E_IPRT_ERROR, GuestDirectory::i_guestErrorToString(rcGuest).c_str());393 }394 395 398 // implementation of public methods 396 399 ///////////////////////////////////////////////////////////////////////////// … … 411 414 { 412 415 case VERR_GSTCTL_GUEST_ERROR: 413 hr = GuestDirectory::i_setErrorExternal(this, rcGuest); 416 hr = setErrorExternal(this, tr("Closing guest directory failed"), 417 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, mData.mOpenInfo.mPath.c_str())); 414 418 break; 415 419 … … 421 425 default: 422 426 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, 423 tr(" Terminating openguest directory \"%s\" failed: %Rrc"), mData.mOpenInfo.mPath.c_str(), vrc);427 tr("Closing guest directory \"%s\" failed: %Rrc"), mData.mOpenInfo.mPath.c_str(), vrc); 424 428 break; 425 429 } … … 451 455 { 452 456 case VERR_GSTCTL_GUEST_ERROR: 453 hr = GuestDirectory::i_setErrorExternal(this, rcGuest); 457 hr = setErrorExternal(this, tr("Reading guest directory failed"), 458 GuestErrorInfo(GuestErrorInfo::Type_ToolLs, rcGuest, mData.mOpenInfo.mPath.c_str())); 454 459 break; 455 460 456 461 case VERR_GSTCTL_PROCESS_EXIT_CODE: 457 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading directory \"%s\" failed: %Rrc"),462 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: %Rrc"), 458 463 mData.mOpenInfo.mPath.c_str(), mData.mProcessTool.getRc()); 459 464 break; 460 465 461 466 case VERR_PATH_NOT_FOUND: 462 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading directory \"%s\" failed: Path not found"),467 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" failed: Path not found"), 463 468 mData.mOpenInfo.mPath.c_str()); 464 469 break; … … 466 471 case VERR_NO_MORE_FILES: 467 472 /* See SDK reference. */ 468 hr = setErrorBoth(VBOX_E_OBJECT_NOT_FOUND, vrc, tr("Reading directory \"%s\" failed: No more entries"),473 hr = setErrorBoth(VBOX_E_OBJECT_NOT_FOUND, vrc, tr("Reading guest directory \"%s\" failed: No more entries"), 469 474 mData.mOpenInfo.mPath.c_str()); 470 475 break; 471 476 472 477 default: 473 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading directory \"%s\" returned error: %Rrc\n"),478 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading guest directory \"%s\" returned error: %Rrc\n"), 474 479 mData.mOpenInfo.mPath.c_str(), vrc); 475 480 break; -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r84564 r84648 404 404 405 405 /** 406 * @todo r=bird: This is an absolutely cryptic way of reporting errors. You may convert 407 * this to a const char * returning function for explaining rcGuest and 408 * use that as part of a _proper_ error message. This alone extremely 409 * user unfriendly. E.g. which file is not found? One of the source files, 410 * a destination file, what are you referring to?!? 406 * Converts a given guest file error to a string. 411 407 * 412 * I've addressed one of these that annoyed me, you can do the rest of them. 408 * @returns Error string. 409 * @param rcGuest Guest file error to return string for. 410 * @param pcszWhat Hint of what was involved when the error occurred. 413 411 */ 414 /* static */ Utf8Str GuestFile::i_guestErrorToString(int rcGuest) 415 { 412 /* static */ 413 Utf8Str GuestFile::i_guestErrorToString(int rcGuest, const char *pcszWhat) 414 { 415 AssertPtrReturn(pcszWhat, ""); 416 417 Utf8Str strErr; 418 419 #define CASE_MSG(a_iRc, a_strFormatString, ...) \ 420 case a_iRc: strErr = Utf8StrFmt(a_strFormatString, ##__VA_ARGS__); break; 421 416 422 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 417 423 switch (rcGuest) 418 424 { 419 case VERR_ACCESS_DENIED: return tr("Access denied");420 case VERR_ALREADY_EXISTS: return tr("File already exists");421 case VERR_FILE_NOT_FOUND: return tr("File not found");422 case VERR_NET_HOST_NOT_FOUND: return tr("Host name not found");423 case VERR_SHARING_VIOLATION: return tr("Sharing violation");425 CASE_MSG(VERR_ACCESS_DENIED , tr("Access to guest file \"%s\" denied"), pcszWhat); 426 CASE_MSG(VERR_ALREADY_EXISTS , tr("Guest file \"%s\" already exists"), pcszWhat); 427 CASE_MSG(VERR_FILE_NOT_FOUND , tr("Guest file \"%s\" not found"), pcszWhat); 428 CASE_MSG(VERR_NET_HOST_NOT_FOUND, tr("Host name \"%s\", not found"), pcszWhat); 429 CASE_MSG(VERR_SHARING_VIOLATION , tr("Sharing violation for guest file \"%s\""), pcszWhat); 424 430 default: 425 431 { 426 432 char szDefine[80]; 427 433 RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/); 428 return &szDefine[0]; 429 } 430 } 434 strErr = Utf8StrFmt(tr("Error %s for guest file \"%s\" occurred\n"), szDefine, pcszWhat); 435 break; 436 } 437 } 438 439 #undef CASE_MSG 440 441 return strErr; 431 442 } 432 443 … … 1013 1024 } 1014 1025 1015 /* static */1016 HRESULT GuestFile::i_setErrorExternal(VirtualBoxBase *pInterface, int rcGuest)1017 {1018 AssertPtr(pInterface);1019 AssertMsg(RT_FAILURE(rcGuest), ("Guest rc does not indicate a failure when setting error\n"));1020 1021 return pInterface->setError(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest).c_str());1022 }1023 1024 1026 int GuestFile::i_setFileStatus(FileStatus_T fileStatus, int fileRc) 1025 1027 { … … 1052 1054 hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, fileRc, 1053 1055 COM_IIDOF(IGuestFile), getComponentName(), 1054 i_guestErrorToString(fileRc ));1056 i_guestErrorToString(fileRc, mData.mOpenInfo.mFilename.c_str())); 1055 1057 ComAssertComRC(hr); 1056 1058 } … … 1388 1390 { 1389 1391 if (vrc == VERR_GSTCTL_GUEST_ERROR) 1390 return GuestFile::i_setErrorExternal(this, rcGuest); 1391 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Closing guest file failed with %Rrc\n"), vrc); 1392 return setErrorExternal(this, tr("Closing guest file failed"), 1393 GuestErrorInfo(GuestErrorInfo::Type_File, rcGuest, mData.mOpenInfo.mFilename.c_str())); 1394 return setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Closing guest file \"%s\" failed with %Rrc\n"), 1395 mData.mOpenInfo.mFilename.c_str(), vrc); 1392 1396 } 1393 1397 … … 1418 1422 hr = ptrFsObjInfo.queryInterfaceTo(aObjInfo.asOutParam()); 1419 1423 else 1420 hr = setErrorVrc(vrc); 1424 hr = setErrorVrc(vrc, 1425 tr("Initialization of guest file object for \"%s\" failed: %Rrc"), 1426 mData.mOpenInfo.mFilename.c_str(), vrc); 1421 1427 } 1422 1428 } … … 1424 1430 { 1425 1431 if (GuestProcess::i_isGuestError(vrc)) 1426 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1432 hr = setErrorExternal(this, tr("Querying guest file information failed"), 1433 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, mData.mOpenInfo.mFilename.c_str())); 1427 1434 else 1428 hr = setErrorVrc(vrc, tr("Querying file information failed: %Rrc"), vrc); 1435 hr = setErrorVrc(vrc, 1436 tr("Querying guest file information for \"%s\" failed: %Rrc"), mData.mOpenInfo.mFilename.c_str(), vrc); 1429 1437 } 1430 1438 … … 1452 1460 { 1453 1461 if (GuestProcess::i_isGuestError(vrc)) 1454 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1462 hr = setErrorExternal(this, tr("Querying guest file size failed"), 1463 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, mData.mOpenInfo.mFilename.c_str())); 1455 1464 else 1456 hr = setErrorVrc(vrc, tr("Querying file size failed: %Rrc"), vrc);1465 hr = setErrorVrc(vrc, tr("Querying guest file size for \"%s\" failed: %Rrc"), mData.mOpenInfo.mFilename.c_str(), vrc); 1457 1466 } 1458 1467 … … 1506 1515 1507 1516 if (aToRead == 0) 1508 return setError(E_INVALIDARG, tr("The size to read is zero"));1517 return setError(E_INVALIDARG, tr("The size to read for guest file \"%s\" is zero"), mData.mOpenInfo.mFilename.c_str()); 1509 1518 1510 1519 LogFlowThisFuncEnter(); … … 1561 1570 1562 1571 default: 1563 return setError(E_INVALIDARG, tr("Invalid seek type specified")); 1572 return setError(E_INVALIDARG, tr("Invalid seek type for guest file \"%s\" specified"), 1573 mData.mOpenInfo.mFilename.c_str()); 1564 1574 } 1565 1575 … … 1593 1603 */ 1594 1604 if (aSize < 0) 1595 return setError(E_INVALIDARG, tr("The size (%RI64) cannot be a negative value"), aSize); 1605 return setError(E_INVALIDARG, tr("The size (%RI64) for guest file \"%s\" cannot be a negative value"), 1606 aSize, mData.mOpenInfo.mFilename.c_str()); 1596 1607 1597 1608 /* … … 1655 1666 hrc = S_OK; 1656 1667 else 1657 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Setting the file size of '%s'to %RU64 (%#RX64) bytes failed: %Rrc"),1668 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Setting the guest file size of \"%s\" to %RU64 (%#RX64) bytes failed: %Rrc"), 1658 1669 mData.mOpenInfo.mFilename.c_str(), aSize, aSize, vrc); 1659 1670 LogFlowFuncLeaveRC(vrc); … … 1667 1678 1668 1679 if (aData.size() == 0) 1669 return setError(E_INVALIDARG, tr("No data to write specified") );1680 return setError(E_INVALIDARG, tr("No data to write specified"), mData.mOpenInfo.mFilename.c_str()); 1670 1681 1671 1682 LogFlowThisFuncEnter(); … … 1677 1688 int vrc = i_writeData(aTimeoutMS, pvData, cbData, (uint32_t*)aWritten); 1678 1689 if (RT_FAILURE(vrc)) 1679 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Writing %zubytes to file \"%s\" failed: %Rrc"),1690 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Writing %zubytes to guest file \"%s\" failed: %Rrc"), 1680 1691 aData.size(), mData.mOpenInfo.mFilename.c_str(), vrc); 1681 1692 … … 1690 1701 1691 1702 if (aData.size() == 0) 1692 return setError(E_INVALIDARG, tr("No data to write at specified"));1703 return setError(E_INVALIDARG, tr("No data to write at for guest file \"%s\" specified"), mData.mOpenInfo.mFilename.c_str()); 1693 1704 1694 1705 LogFlowThisFuncEnter(); -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r84261 r84648 487 487 } 488 488 489 /** 490 * Converts a given guest process error to a string. 491 * 492 * @returns Error as a string. 493 * @param rcGuest Guest process error to return string for. 494 * @param pcszWhat Hint of what was involved when the error occurred. 495 */ 489 496 /* static */ 490 Utf8Str GuestProcess::i_guestErrorToString(int rcGuest) 491 { 492 Utf8Str strError; 497 Utf8Str GuestProcess::i_guestErrorToString(int rcGuest, const char *pcszWhat) 498 { 499 AssertPtrReturn(pcszWhat, ""); 500 501 Utf8Str strErr; 502 503 #define CASE_MSG(a_iRc, a_strFormatString, ...) \ 504 case a_iRc: strErr = Utf8StrFmt(a_strFormatString, ##__VA_ARGS__); break; 493 505 494 506 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 495 507 switch (rcGuest) 496 508 { 497 case VERR_FILE_NOT_FOUND: /* This is the most likely error. */ 498 RT_FALL_THROUGH(); 499 case VERR_PATH_NOT_FOUND: 500 strError += Utf8StrFmt(tr("No such file or directory on guest")); 501 break; 502 503 case VERR_INVALID_VM_HANDLE: 504 strError += Utf8StrFmt(tr("VMM device is not available (is the VM running?)")); 505 break; 506 507 case VERR_HGCM_SERVICE_NOT_FOUND: 508 strError += Utf8StrFmt(tr("The guest execution service is not available")); 509 break; 510 511 case VERR_BAD_EXE_FORMAT: 512 strError += Utf8StrFmt(tr("The specified file is not an executable format on guest")); 513 break; 514 515 case VERR_AUTHENTICATION_FAILURE: 516 strError += Utf8StrFmt(tr("The specified user was not able to logon on guest")); 517 break; 518 519 case VERR_INVALID_NAME: 520 strError += Utf8StrFmt(tr("The specified file is an invalid name")); 521 break; 522 523 case VERR_TIMEOUT: 524 strError += Utf8StrFmt(tr("The guest did not respond within time")); 525 break; 526 527 case VERR_CANCELLED: 528 strError += Utf8StrFmt(tr("The execution operation was canceled")); 529 break; 530 531 case VERR_GSTCTL_MAX_CID_OBJECTS_REACHED: 532 strError += Utf8StrFmt(tr("Maximum number of concurrent guest processes has been reached")); 533 break; 534 535 case VERR_NOT_FOUND: 536 strError += Utf8StrFmt(tr("The guest execution service is not ready (yet)")); 537 break; 538 509 CASE_MSG(VERR_FILE_NOT_FOUND, tr("No such file or directory \"%s\" on guest"), pcszWhat); /* This is the most likely error. */ 510 CASE_MSG(VERR_PATH_NOT_FOUND, tr("No such file or directory \"%s\" on guest"), pcszWhat); 511 CASE_MSG(VERR_INVALID_VM_HANDLE, tr("VMM device is not available (is the VM running?)")); 512 CASE_MSG(VERR_HGCM_SERVICE_NOT_FOUND, tr("The guest execution service is not available")); 513 CASE_MSG(VERR_BAD_EXE_FORMAT, tr("The file \"%s\" is not an executable format on guest"), pcszWhat); 514 CASE_MSG(VERR_AUTHENTICATION_FAILURE, tr("The user \"%s\" was not able to logon on guest"), pcszWhat); 515 CASE_MSG(VERR_INVALID_NAME, tr("The file \"%s\" is an invalid name"), pcszWhat); 516 CASE_MSG(VERR_TIMEOUT, tr("The guest did not respond within time")); 517 CASE_MSG(VERR_CANCELLED, tr("The execution operation for \"%s\" was canceled"), pcszWhat); 518 CASE_MSG(VERR_GSTCTL_MAX_CID_OBJECTS_REACHED, tr("Maximum number of concurrent guest processes has been reached")); 519 CASE_MSG(VERR_NOT_FOUND, tr("The guest execution service is not ready (yet)")); 539 520 default: 540 strError += Utf8StrFmt("%Rrc", rcGuest); 541 break; 542 } 543 544 return strError; 521 { 522 char szDefine[80]; 523 RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/); 524 strErr = Utf8StrFmt(tr("Error %s for guest process \"%s\" occurred\n"), szDefine, pcszWhat); 525 break; 526 } 527 } 528 529 #undef CASE_MSG 530 531 return strErr; 545 532 } 546 533 … … 974 961 hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, mData.mLastError, 975 962 COM_IIDOF(IGuestProcess), getComponentName(), 976 i_guestErrorToString(mData.mLastError ));963 i_guestErrorToString(mData.mLastError, mData.mProcess.mExecutable.c_str())); 977 964 ComAssertComRC(hr); 978 965 } … … 1003 990 1004 991 return rc; 1005 }1006 1007 /* static */1008 HRESULT GuestProcess::i_setErrorExternal(VirtualBoxBase *pInterface, int rcGuest)1009 {1010 AssertPtr(pInterface);1011 AssertMsg(RT_FAILURE(rcGuest), ("Guest rc does not indicate a failure when setting error\n"));1012 1013 return pInterface->setErrorBoth(VBOX_E_IPRT_ERROR, rcGuest, GuestProcess::i_guestErrorToString(rcGuest).c_str());1014 992 } 1015 993 … … 1809 1787 { 1810 1788 case VERR_GSTCTL_GUEST_ERROR: 1811 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1789 hr = setErrorExternal(this, "Reading from guest process failed", 1790 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, mData.mProcess.mExecutable.c_str())); 1812 1791 break; 1813 1792 1814 1793 default: 1815 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading from process \"%s\" (PID %RU32) failed: %Rrc"),1794 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Reading from guest process \"%s\" (PID %RU32) failed: %Rrc"), 1816 1795 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1817 1796 break; … … 1841 1820 { 1842 1821 case VERR_GSTCTL_GUEST_ERROR: 1843 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1822 hr = setErrorExternal(this, "Terminating guest process failed", 1823 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, mData.mProcess.mExecutable.c_str())); 1844 1824 break; 1845 1825 1846 1826 case VERR_NOT_SUPPORTED: 1847 1827 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, 1848 tr("Terminating process \"%s\" (PID %RU32) not supported by installed Guest Additions"),1828 tr("Terminating guest process \"%s\" (PID %RU32) not supported by installed Guest Additions"), 1849 1829 mData.mProcess.mExecutable.c_str(), mData.mPID); 1850 1830 break; 1851 1831 1852 1832 default: 1853 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Terminating process \"%s\" (PID %RU32) failed: %Rrc"),1833 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Terminating guest process \"%s\" (PID %RU32) failed: %Rrc"), 1854 1834 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1855 1835 break; … … 1899 1879 { 1900 1880 case VERR_GSTCTL_GUEST_ERROR: 1901 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1881 hr = setErrorExternal(this, "Waiting for guest process failed", 1882 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, mData.mProcess.mExecutable.c_str())); 1902 1883 break; 1903 1884 … … 1907 1888 1908 1889 default: 1909 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Waiting for process \"%s\" (PID %RU32) failed: %Rrc"),1890 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Waiting for guest process \"%s\" (PID %RU32) failed: %Rrc"), 1910 1891 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1911 1892 break; … … 1952 1933 { 1953 1934 case VERR_GSTCTL_GUEST_ERROR: 1954 hr = GuestProcess::i_setErrorExternal(this, rcGuest); 1935 hr = setErrorExternal(this, "Writing to guest process failed", 1936 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, mData.mProcess.mExecutable.c_str())); 1955 1937 break; 1956 1938 1957 1939 default: 1958 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Writing to process \"%s\" (PID %RU32) failed: %Rrc"),1940 hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Writing to guest process \"%s\" (PID %RU32) failed: %Rrc"), 1959 1941 mData.mProcess.mExecutable.c_str(), mData.mPID, vrc); 1960 1942 break; … … 2569 2551 } 2570 2552 } 2553 else if (!RTStrICmp(pszTool, VBOXSERVICE_TOOL_LS)) 2554 { 2555 switch (iExitCode) 2556 { 2557 /** @todo Handle access denied? */ 2558 case RTEXITCODE_FAILURE: return VERR_PATH_NOT_FOUND; 2559 default: break; 2560 } 2561 } 2571 2562 else if (!RTStrICmp(pszTool, VBOXSERVICE_TOOL_STAT)) 2572 2563 { … … 2600 2591 switch (iExitCode) 2601 2592 { 2602 case RTEXITCODE_FAILURE: return VERR_ACCESS_DENIED; 2593 case RTEXITCODE_FAILURE: return VERR_FILE_NOT_FOUND; 2594 /** @todo RTPathRmCmd does not yet distinguish between not found and access denied yet. */ 2603 2595 default: break; 2604 2596 } … … 2612 2604 } 2613 2605 2606 /* static */ 2607 Utf8Str GuestProcessTool::guestErrorToString(const char *pszTool, const GuestErrorInfo& guestErrorInfo) 2608 { 2609 Utf8Str strErr; 2610 2611 /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */ 2612 switch (guestErrorInfo.getRc()) 2613 { 2614 case VERR_ACCESS_DENIED: 2615 strErr = Utf8StrFmt(Guest::tr("Access to \"%s\" denied"), guestErrorInfo.getWhat().c_str()); 2616 break; 2617 2618 case VERR_FILE_NOT_FOUND: /* This is the most likely error. */ 2619 RT_FALL_THROUGH(); 2620 case VERR_PATH_NOT_FOUND: 2621 strErr = Utf8StrFmt(Guest::tr("No such file or directory \"%s\""), guestErrorInfo.getWhat().c_str()); 2622 break; 2623 2624 case VERR_INVALID_VM_HANDLE: 2625 strErr = Utf8StrFmt(Guest::tr("VMM device is not available (is the VM running?)")); 2626 break; 2627 2628 case VERR_HGCM_SERVICE_NOT_FOUND: 2629 strErr = Utf8StrFmt(Guest::tr("The guest execution service is not available")); 2630 break; 2631 2632 case VERR_BAD_EXE_FORMAT: 2633 strErr = Utf8StrFmt(Guest::tr("The file \"%s\" is not an executable format"), 2634 guestErrorInfo.getWhat().c_str()); 2635 break; 2636 2637 case VERR_AUTHENTICATION_FAILURE: 2638 strErr = Utf8StrFmt(Guest::tr("The user \"%s\" was not able to logon"), guestErrorInfo.getWhat().c_str()); 2639 break; 2640 2641 case VERR_INVALID_NAME: 2642 strErr = Utf8StrFmt(Guest::tr("The file \"%s\" is an invalid name"), guestErrorInfo.getWhat().c_str()); 2643 break; 2644 2645 case VERR_TIMEOUT: 2646 strErr = Utf8StrFmt(Guest::tr("The guest did not respond within time")); 2647 break; 2648 2649 case VERR_CANCELLED: 2650 strErr = Utf8StrFmt(Guest::tr("The execution operation was canceled")); 2651 break; 2652 2653 case VERR_GSTCTL_MAX_CID_OBJECTS_REACHED: 2654 strErr = Utf8StrFmt(Guest::tr("Maximum number of concurrent guest processes has been reached")); 2655 break; 2656 2657 case VERR_NOT_FOUND: 2658 strErr = Utf8StrFmt(Guest::tr("The guest execution service is not ready (yet)")); 2659 break; 2660 2661 default: 2662 strErr = Utf8StrFmt(Guest::tr("Unhandled error %Rrc for \"%s\" occurred for tool \"%s\" on guest -- please file a bug report"), 2663 guestErrorInfo.getRc(), guestErrorInfo.getWhat(), pszTool); 2664 break; 2665 } 2666 2667 return strErr; 2668 } 2669 -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r84564 r84648 2639 2639 } 2640 2640 2641 /* static */2642 HRESULT GuestSession::i_setErrorExternal(VirtualBoxBase *pInterface, int rcGuest)2643 {2644 AssertPtr(pInterface);2645 AssertMsg(RT_FAILURE(rcGuest), ("Guest rc does not indicate a failure when setting error\n"));2646 2647 return pInterface->setErrorBoth(VBOX_E_IPRT_ERROR, rcGuest, GuestSession::i_guestErrorToString(rcGuest).c_str());2648 }2649 2650 2641 /* Does not do locking; caller is responsible for that! */ 2651 2642 int GuestSession::i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc) … … 3073 3064 { 3074 3065 if (vrc == VERR_GSTCTL_GUEST_ERROR) 3075 return GuestSession::i_setErrorExternal(this, rcGuest); 3076 return setError(VBOX_E_IPRT_ERROR, tr("Closing guest session failed with %Rrc"), vrc); 3066 return setErrorExternal(this, tr("Closing guest session failed"), 3067 GuestErrorInfo(GuestErrorInfo::Type_Session, rcGuest, mData.mSession.mName.c_str())); 3068 return setError(VBOX_E_IPRT_ERROR, tr("Closing guest session \"%s\" failed with %Rrc"), 3069 mData.mSession.mName.c_str(), vrc); 3077 3070 } 3078 3071 … … 3173 3166 { 3174 3167 if (GuestProcess::i_isGuestError(vrc)) 3175 return setError (E_FAIL, tr("Unable to query type for source '%s': %s"), (*itSource).c_str(),3176 GuestProcess::i_guestErrorToString(rcGuest).c_str());3168 return setErrorExternal(this, tr("Querying type for guest source failed"), 3169 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, (*itSource).c_str())); 3177 3170 else 3178 return setError(E_FAIL, tr(" Unable to query type for source '%s' (%Rrc)"), (*itSource).c_str(), vrc);3171 return setError(E_FAIL, tr("Querying type for guest source \"%s\" failed: %Rrc"), (*itSource).c_str(), vrc); 3179 3172 } 3180 3173 … … 3396 3389 { 3397 3390 if (GuestProcess::i_isGuestError(vrc)) 3398 hrc = setError Both(VBOX_E_IPRT_ERROR, rcGuest,3399 tr("Directory creation failed: %s"), GuestDirectory::i_guestErrorToString(rcGuest).c_str());3391 hrc = setErrorExternal(this, tr("Guest directory creation failed"), 3392 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, aPath.c_str())); 3400 3393 else 3401 3394 { … … 3403 3396 { 3404 3397 case VERR_INVALID_PARAMETER: 3405 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr(" Directory creation failed: Invalid parameters given"));3398 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Guest directory creation failed: Invalid parameters given")); 3406 3399 break; 3407 3400 3408 3401 case VERR_BROKEN_PIPE: 3409 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr(" Directory creation failed: Unexpectedly aborted"));3402 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Guest directory creation failed: Unexpectedly aborted")); 3410 3403 break; 3411 3404 3412 3405 default: 3413 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr(" Directory creation failed: %Rrc"), vrc);3406 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Guest directory creation failed: %Rrc"), vrc); 3414 3407 break; 3415 3408 } … … 3443 3436 { 3444 3437 case VERR_GSTCTL_GUEST_ERROR: 3445 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 3438 hrc = setErrorExternal(this, tr("Temporary guest directory creation failed"), 3439 GuestErrorInfo(GuestErrorInfo::Type_ToolMkTemp, rcGuest, aPath.c_str())); 3446 3440 break; 3447 3441 3448 3442 default: 3449 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Temporary directory creation \"%s\" with template \"%s\" failed: %Rrc"),3443 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Temporary guest directory creation \"%s\" with template \"%s\" failed: %Rrc"), 3450 3444 aPath.c_str(), aTemplateName.c_str(), vrc); 3451 3445 break; … … 3485 3479 break; 3486 3480 default: 3487 hrc = setError Both(VBOX_E_IPRT_ERROR, rcGuest, tr("Querying directory existence \"%s\" failed: %s"),3488 aPath.c_str(), GuestProcess::i_guestErrorToString(rcGuest).c_str());3481 hrc = setErrorExternal(this, "Querying directory existence failed", 3482 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, aPath.c_str())); 3489 3483 break; 3490 3484 } … … 3549 3543 { 3550 3544 case VERR_INVALID_PARAMETER: 3551 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Opening directory \"%s\" failed; invalid parameters given"),3545 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Opening guest directory \"%s\" failed; invalid parameters given"), 3552 3546 aPath.c_str()); 3553 3547 break; 3554 3548 3555 3549 case VERR_GSTCTL_GUEST_ERROR: 3556 hrc = GuestDirectory::i_setErrorExternal(this, rcGuest); 3550 hrc = setErrorExternal(this, tr("Opening guest directory failed"), 3551 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, aPath.c_str())); 3557 3552 break; 3558 3553 3559 3554 default: 3560 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Opening directory \"%s\" failed: %Rrc"), aPath.c_str(), vrc);3555 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Opening guest directory \"%s\" failed: %Rrc"), aPath.c_str(), vrc); 3561 3556 break; 3562 3557 } … … 3592 3587 3593 3588 case VERR_GSTCTL_GUEST_ERROR: 3594 hrc = GuestDirectory::i_setErrorExternal(this, rcGuest); 3589 hrc = setErrorExternal(this, tr("Removing guest directory failed"), 3590 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, aPath.c_str())); 3595 3591 break; 3596 3592 … … 3671 3667 3672 3668 case VERR_GSTCTL_GUEST_ERROR: 3673 hrc = GuestFile::i_setErrorExternal(this, rcGuest); 3669 hrc = setErrorExternal(this, tr("Recursively removing guest directory failed"), 3670 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, aPath.c_str())); 3674 3671 break; 3675 3672 … … 3815 3812 3816 3813 default: 3817 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 3814 hrc = setErrorExternal(this, tr("Querying guest file existence failed"), 3815 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, aPath.c_str())); 3818 3816 break; 3819 3817 } … … 3826 3824 3827 3825 default: 3828 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Querying file information for \"%s\" failed: %Rrc"),3826 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Querying guest file information for \"%s\" failed: %Rrc"), 3829 3827 aPath.c_str(), vrc); 3830 3828 break; … … 3932 3930 3933 3931 case VERR_GSTCTL_GUEST_ERROR: 3934 hrc = GuestFile::i_setErrorExternal(this, rcGuest); 3932 hrc = setErrorExternal(this, tr("Opening guest file failed"), 3933 GuestErrorInfo(GuestErrorInfo::Type_File, rcGuest, aPath.c_str())); 3935 3934 break; 3936 3935 … … 3962 3961 { 3963 3962 if (GuestProcess::i_isGuestError(vrc)) 3964 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 3963 hrc = setErrorExternal(this, tr("Querying guest file size failed"), 3964 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, aPath.c_str())); 3965 3965 else 3966 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Querying file size failed: %Rrc"), vrc); 3966 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Querying guest file size of \"%s\" failed: %Rrc"), 3967 vrc, aPath.c_str()); 3967 3968 } 3968 3969 … … 4002 4003 } 4003 4004 else 4004 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 4005 hrc = setErrorExternal(this, tr("Querying guest file existence information failed"), 4006 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, aPath.c_str())); 4005 4007 } 4006 4008 else 4007 hrc = setErrorVrc(vrc, tr("Querying file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);4009 hrc = setErrorVrc(vrc, tr("Querying guest file existence information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc); 4008 4010 } 4009 4011 … … 4040 4042 { 4041 4043 if (GuestProcess::i_isGuestError(vrc)) 4042 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 4044 hrc = setErrorExternal(this, tr("Querying guest file information failed"), 4045 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, aPath.c_str())); 4043 4046 else 4044 hrc = setErrorVrc(vrc, tr("Querying file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc);4047 hrc = setErrorVrc(vrc, tr("Querying guest file information for \"%s\" failed: %Rrc"), aPath.c_str(), vrc); 4045 4048 } 4046 4049 … … 4064 4067 { 4065 4068 if (GuestProcess::i_isGuestError(vrc)) 4066 hrc = GuestProcess::i_setErrorExternal(this, rcGuest); 4069 hrc = setErrorExternal(this, tr("Removing guest file failed"), 4070 GuestErrorInfo(GuestErrorInfo::Type_ToolRm, rcGuest, aPath.c_str())); 4067 4071 else 4068 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Removing file \"%s\" failed: %Rrc"), aPath.c_str(), vrc);4072 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Removing guest file \"%s\" failed: %Rrc"), aPath.c_str(), vrc); 4069 4073 } 4070 4074 … … 4118 4122 case VERR_NOT_SUPPORTED: 4119 4123 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, 4120 tr("Handling renaming guest directories not supported by installed Guest Additions"));4124 tr("Handling renaming guest paths not supported by installed Guest Additions")); 4121 4125 break; 4122 4126 4123 4127 case VERR_GSTCTL_GUEST_ERROR: 4124 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, rcGuest, tr("Renaming guest directory failed: %Rrc"), rcGuest); 4128 hrc = setErrorExternal(this, tr("Renaming guest path failed"), 4129 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, aSource.c_str())); 4125 4130 break; 4126 4131 4127 4132 default: 4128 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Renaming guest directory\"%s\" failed: %Rrc"),4133 hrc = setErrorBoth(VBOX_E_IPRT_ERROR, vrc, tr("Renaming guest path \"%s\" failed: %Rrc"), 4129 4134 aSource.c_str(), vrc); 4130 4135 break; … … 4356 4361 { 4357 4362 case VERR_GSTCTL_GUEST_ERROR: 4358 hrc = GuestSession::i_setErrorExternal(this, rcGuest); 4363 hrc = setErrorExternal(this, tr("Waiting for guest process failed"), 4364 GuestErrorInfo(GuestErrorInfo::Type_Session, rcGuest, mData.mSession.mName.c_str())); 4359 4365 break; 4360 4366 -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r84551 r84648 193 193 } 194 194 195 /** 196 * Sets the task's progress object to an error using a string message. 197 * 198 * @returns Returns \a hr for covenience. 199 * @param hr Progress operation result to set. 200 * @param strMsg Message to set. 201 */ 195 202 HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg) 196 203 { 197 LogFlowFunc(("hr=%Rhrc, strMsg=%s\n", 198 hr, strMsg.c_str())); 204 LogFlowFunc(("hr=%Rhrc, strMsg=%s\n", hr, strMsg.c_str())); 199 205 200 206 if (mProgress.isNull()) /* Progress is optional. */ … … 218 224 } 219 225 220 HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hrc, int vrc, const char *pszFormat, ...) 221 { 222 LogFlowFunc(("hrc=%Rhrc, vrc=%Rrc, pszFormat=%s\n", hrc, vrc, pszFormat)); 223 224 /* The progress object is optional. */ 225 if (!mProgress.isNull()) 226 { 227 BOOL fCanceled; 228 BOOL fCompleted; 229 if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled))) 230 && !fCanceled 231 && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted))) 232 && !fCompleted) 233 { 234 va_list va; 235 va_start(va, pszFormat); 236 HRESULT hrc2 = mProgress->i_notifyCompleteBothV(hrc, vrc, COM_IIDOF(IGuestSession), 237 GuestSession::getStaticComponentName(), pszFormat, va); 238 va_end(va); 239 if (FAILED(hrc2)) 240 hrc = hrc2; 241 } 242 } 243 return hrc; 226 /** 227 * Sets the task's progress object to an error using a string message and a guest error info object. 228 * 229 * @returns Returns \a hr for covenience. 230 * @param hr Progress operation result to set. 231 * @param strMsg Message to set. 232 * @param guestErrorInfo Guest error info to use. 233 */ 234 HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg, const GuestErrorInfo &guestErrorInfo) 235 { 236 return setProgressErrorMsg(hr, strMsg + Utf8Str(": ") + GuestBase::getErrorAsString(guestErrorInfo)); 244 237 } 245 238 … … 353 346 * 354 347 * @return VBox status code. 348 * @param strSrcFile Full path of source file on the host to copy. 355 349 * @param srcFile Guest file (source) to copy to the host. Must be in opened and ready state already. 350 * @param strDstFile Full destination path and file name (guest style) to copy file to. 356 351 * @param phDstFile Pointer to host file handle (destination) to copy to. Must be in opened and ready state already. 357 352 * @param fFileCopyFlags File copy flags. … … 359 354 * @param cbSize Size (in bytes) to copy from the source file. 360 355 */ 361 int GuestSessionTask::fileCopyFromGuestInner(ComObjPtr<GuestFile> &srcFile, PRTFILE phDstFile, FileCopyFlag_T fFileCopyFlags, 362 uint64_t offCopy, uint64_t cbSize) 356 int GuestSessionTask::fileCopyFromGuestInner(const Utf8Str &strSrcFile, ComObjPtr<GuestFile> &srcFile, 357 const Utf8Str &strDstFile, PRTFILE phDstFile, 358 FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize) 363 359 { 364 360 RT_NOREF(fFileCopyFlags); … … 379 375 { 380 376 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 381 Utf8StrFmt(GuestSession::tr("Seeking to offset %RU64 failed: %Rrc"), offCopy, rc)); 377 Utf8StrFmt(GuestSession::tr("Seeking to offset %RU64 of guest file \"%s\" failed: %Rrc"), 378 offCopy, strSrcFile.c_str(), rc)); 382 379 return rc; 383 380 } … … 393 390 { 394 391 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 395 Utf8StrFmt(GuestSession::tr("Reading %RU32 bytes @ %RU64 from guest failed: %Rrc"), cbChunk, cbWrittenTotal, rc)); 392 Utf8StrFmt(GuestSession::tr("Reading %RU32 bytes @ %RU64 from guest \"%s\" failed: %Rrc"), 393 cbChunk, cbWrittenTotal, strSrcFile.c_str(), rc)); 396 394 break; 397 395 } … … 401 399 { 402 400 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 403 Utf8StrFmt(GuestSession::tr("Writing %RU32 bytes to file on host failed: %Rrc"), cbRead, rc)); 401 Utf8StrFmt(GuestSession::tr("Writing %RU32 bytes to host file \"%s\" failed: %Rrc"), 402 cbRead, strDstFile.c_str(), rc)); 404 403 break; 405 404 } … … 439 438 * to the destination -> access denied. */ 440 439 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 441 Utf8StrFmt(GuestSession::tr("Writing guest file to host failed: Access denied"))); 440 Utf8StrFmt(GuestSession::tr("Writing guest file \"%s\" to host file \"%s\" failed: Access denied"), 441 strSrcFile.c_str(), strDstFile.c_str())); 442 442 rc = VERR_ACCESS_DENIED; 443 443 } … … 446 446 /* If we did not copy all let the user know. */ 447 447 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 448 Utf8StrFmt(GuestSession::tr("Copying guest file to host tofailed (%RU64/%RU64 bytes transfered)"),449 cbWrittenTotal, cbSize));448 Utf8StrFmt(GuestSession::tr("Copying guest file \"%s\" to host file \"%s\" failed (%RU64/%RU64 bytes transfered)"), 449 strSrcFile.c_str(), strDstFile.c_str(), cbWrittenTotal, cbSize)); 450 450 rc = VERR_INTERRUPTED; 451 451 } … … 463 463 * @param fFileCopyFlags File copy flags. 464 464 */ 465 int GuestSessionTask::fileCopyFromGuest(const Utf8Str &strS ource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags)466 { 467 LogFlowThisFunc(("strSource=%s, strDest=%s, enmFileCopyFlags=0x%x\n", strS ource.c_str(), strDest.c_str(), fFileCopyFlags));465 int GuestSessionTask::fileCopyFromGuest(const Utf8Str &strSrc, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags) 466 { 467 LogFlowThisFunc(("strSource=%s, strDest=%s, enmFileCopyFlags=0x%x\n", strSrc.c_str(), strDest.c_str(), fFileCopyFlags)); 468 468 469 469 GuestFileOpenInfo srcOpenInfo; 470 srcOpenInfo.mFilename = strS ource;470 srcOpenInfo.mFilename = strSrc; 471 471 srcOpenInfo.mOpenAction = FileOpenAction_OpenExisting; 472 472 srcOpenInfo.mAccessMode = FileAccessMode_ReadOnly; … … 477 477 GuestFsObjData srcObjData; 478 478 int rcGuest = VERR_IPE_UNINITIALIZED_STATUS; 479 int rc = mSession->i_fsQueryInfo(strS ource, TRUE /* fFollowSymlinks */, srcObjData, &rcGuest);479 int rc = mSession->i_fsQueryInfo(strSrc, TRUE /* fFollowSymlinks */, srcObjData, &rcGuest); 480 480 if (RT_FAILURE(rc)) 481 481 { 482 switch (rc) 483 { 484 case VERR_GSTCTL_GUEST_ERROR: 485 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest)); 482 if (rc == VERR_GSTCTL_GUEST_ERROR) 483 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestSession::tr("Guest file lookup failed"), 484 GuestErrorInfo(GuestErrorInfo::Type_ToolStat, rcGuest, strSrc.c_str())); 485 else 486 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 487 Utf8StrFmt(GuestSession::tr("Guest file lookup for \"%s\" failed: %Rrc"), strSrc.c_str(), rc)); 488 } 489 else 490 { 491 switch (srcObjData.mType) 492 { 493 case FsObjType_File: 494 break; 495 496 case FsObjType_Symlink: 497 if (!(fFileCopyFlags & FileCopyFlag_FollowLinks)) 498 { 499 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 500 Utf8StrFmt(GuestSession::tr("Guest file \"%s\" is a symbolic link"), 501 strSrc.c_str())); 502 rc = VERR_IS_A_SYMLINK; 503 } 486 504 break; 487 505 488 506 default: 489 507 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 490 Utf8StrFmt(GuestSession::tr("Source file lookup for \"%s\" failed: %Rrc"), 491 strSource.c_str(), rc)); 492 break; 493 } 494 } 495 else 496 { 497 switch (srcObjData.mType) 498 { 499 case FsObjType_File: 500 break; 501 502 case FsObjType_Symlink: 503 if (!(fFileCopyFlags & FileCopyFlag_FollowLinks)) 504 { 505 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 506 Utf8StrFmt(GuestSession::tr("Source file \"%s\" is a symbolic link"), 507 strSource.c_str(), rc)); 508 rc = VERR_IS_A_SYMLINK; 509 } 510 break; 511 512 default: 513 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 514 Utf8StrFmt(GuestSession::tr("Source element \"%s\" is not a file"), strSource.c_str())); 508 Utf8StrFmt(GuestSession::tr("Guest object \"%s\" is not a file"), strSrc.c_str())); 515 509 rc = VERR_NOT_A_FILE; 516 510 break; … … 524 518 if (RT_FAILURE(rc)) 525 519 { 526 switch (rc) 527 { 528 case VERR_GSTCTL_GUEST_ERROR: 529 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest)); 530 break; 531 532 default: 533 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 534 Utf8StrFmt(GuestSession::tr("Source file \"%s\" could not be opened: %Rrc"), 535 strSource.c_str(), rc)); 536 break; 537 } 520 if (rc == VERR_GSTCTL_GUEST_ERROR) 521 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestSession::tr("Guest file could not be opened"), 522 GuestErrorInfo(GuestErrorInfo::Type_File, rcGuest, strSrc.c_str())); 523 else 524 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 525 Utf8StrFmt(GuestSession::tr("Guest file \"%s\" could not be opened: %Rrc"), strSrc.c_str(), rc)); 538 526 } 539 527 … … 555 543 { 556 544 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 557 Utf8StrFmt(GuestSession::tr(" Destinationfile \"%s\" already exists"), strDest.c_str()));545 Utf8StrFmt(GuestSession::tr("Host file \"%s\" already exists"), strDest.c_str())); 558 546 rc = VERR_ALREADY_EXISTS; 559 547 } … … 566 554 { 567 555 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 568 Utf8StrFmt(GuestSession::tr(" Destinationfile \"%s\" has same or newer modification date"),556 Utf8StrFmt(GuestSession::tr("Host file \"%s\" has same or newer modification date"), 569 557 strDest.c_str())); 570 558 fSkip = true; … … 576 564 if (rc != VERR_FILE_NOT_FOUND) /* Destination file does not exist (yet)? */ 577 565 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 578 Utf8StrFmt(GuestSession::tr(" Destinationfile lookup for \"%s\" failed: %Rrc"),566 Utf8StrFmt(GuestSession::tr("Host file lookup for \"%s\" failed: %Rrc"), 579 567 strDest.c_str(), rc)); 580 568 } … … 595 583 { 596 584 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 597 Utf8StrFmt(GuestSession::tr("Destination file \"%s\" already exists"), 598 strDest.c_str(), rc)); 585 Utf8StrFmt(GuestSession::tr("Host file \"%s\" already exists"), strDest.c_str())); 599 586 rc = VERR_ALREADY_EXISTS; 600 587 } … … 612 599 RTPathAppend(szDstPath, sizeof(szDstPath), "/"); /* IPRT can handle / on all hosts. */ 613 600 614 RTPathAppend(szDstPath, sizeof(szDstPath), RTPathFilenameEx(strS ource.c_str(), mfPathStyle));601 RTPathAppend(szDstPath, sizeof(szDstPath), RTPathFilenameEx(strSrc.c_str(), mfPathStyle)); 615 602 616 603 pszDstFile = RTStrDup(szDstPath); … … 621 608 { 622 609 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 623 Utf8StrFmt(GuestSession::tr(" Destinationfile \"%s\" is a symbolic link"),624 strDest.c_str() , rc));610 Utf8StrFmt(GuestSession::tr("Host file \"%s\" is a symbolic link"), 611 strDest.c_str())); 625 612 rc = VERR_IS_A_SYMLINK; 626 613 } … … 652 639 if (RT_SUCCESS(rc)) 653 640 { 654 LogFlowThisFunc(("Copying '%s' to '%s' (%RI64 bytes) ...\n", strSource.c_str(), pszDstFile, srcObjData.mObjectSize)); 655 656 rc = fileCopyFromGuestInner(srcFile, &hDstFile, fFileCopyFlags, 0 /* Offset, unused */, (uint64_t)srcObjData.mObjectSize); 641 LogFlowThisFunc(("Copying '%s' to '%s' (%RI64 bytes) ...\n", 642 strSrc.c_str(), pszDstFile, srcObjData.mObjectSize)); 643 644 rc = fileCopyFromGuestInner(strSrc, srcFile, pszDstFile, &hDstFile, fFileCopyFlags, 645 0 /* Offset, unused */, (uint64_t)srcObjData.mObjectSize); 657 646 658 647 int rc2 = RTFileClose(hDstFile); … … 661 650 else 662 651 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 663 Utf8StrFmt(GuestSession::tr("Opening/creating destinationfile \"%s\" failed: %Rrc"),652 Utf8StrFmt(GuestSession::tr("Opening/creating host file \"%s\" failed: %Rrc"), 664 653 pszDstFile, rc)); 665 654 } … … 679 668 * 680 669 * @return VBox status code. 670 * @param strSrcFile Full path of source file on the host to copy. 681 671 * @param hVfsFile The VFS file handle to read from. 682 * @param dstFile Guest file (destination) to copy to the guest. Must be in opened and ready state already. 672 * @param strDstFile Full destination path and file name (guest style) to copy file to. 673 * @param fileDst Guest file (destination) to copy to the guest. Must be in opened and ready state already. 683 674 * @param fFileCopyFlags File copy flags. 684 675 * @param offCopy Offset (in bytes) where to start copying the source file. 685 676 * @param cbSize Size (in bytes) to copy from the source file. 686 677 */ 687 int GuestSessionTask::fileCopyToGuestInner(RTVFSFILE hVfsFile, ComObjPtr<GuestFile> &dstFile, FileCopyFlag_T fFileCopyFlags, 688 uint64_t offCopy, uint64_t cbSize) 678 int GuestSessionTask::fileCopyToGuestInner(const Utf8Str &strSrcFile, RTVFSFILE hVfsFile, 679 const Utf8Str &strDstFile, ComObjPtr<GuestFile> &fileDst, 680 FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize) 689 681 { 690 682 RT_NOREF(fFileCopyFlags); … … 705 697 { 706 698 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 707 Utf8StrFmt(GuestSession::tr("Seeking to offset %RU64 failed: %Rrc"), offCopy, rc)); 699 Utf8StrFmt(GuestSession::tr("Seeking to offset %RU64 of host file \"%s\" failed: %Rrc"), 700 offCopy, strSrcFile.c_str(), rc)); 708 701 return rc; 709 702 } … … 719 712 { 720 713 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 721 Utf8StrFmt(GuestSession::tr("Reading %RU32 bytes @ %RU64 from host failed: %Rrc"), cbChunk, cbWrittenTotal, rc)); 714 Utf8StrFmt(GuestSession::tr("Reading %RU32 bytes @ %RU64 from host file \"%s\" failed: %Rrc"), 715 cbChunk, cbWrittenTotal, strSrcFile.c_str(), rc)); 722 716 break; 723 717 } 724 718 725 rc = dstFile->i_writeData(uTimeoutMs, byBuf, (uint32_t)cbRead, NULL /* No partial writes */);719 rc = fileDst->i_writeData(uTimeoutMs, byBuf, (uint32_t)cbRead, NULL /* No partial writes */); 726 720 if (RT_FAILURE(rc)) 727 721 { 728 722 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 729 Utf8StrFmt(GuestSession::tr("Writing %zu bytes to file on guest failed: %Rrc"), cbRead, rc)); 723 Utf8StrFmt(GuestSession::tr("Writing %zu bytes to guest file \"%s\" failed: %Rrc"), 724 cbRead, strDstFile.c_str(), rc)); 730 725 break; 731 726 } … … 761 756 * to the destination -> access denied. */ 762 757 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 763 Utf8StrFmt(GuestSession::tr("Writing to destination file failed: Access denied"))); 758 Utf8StrFmt(GuestSession::tr("Writing to guest file \"%s\" failed: Access denied"), 759 strDstFile.c_str())); 764 760 rc = VERR_ACCESS_DENIED; 765 761 } … … 768 764 /* If we did not copy all let the user know. */ 769 765 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 770 Utf8StrFmt(GuestSession::tr("Copying to destinationfailed (%RU64/%RU64 bytes transfered)"),771 cbWrittenTotal, cbSize));766 Utf8StrFmt(GuestSession::tr("Copying to guest file \"%s\" failed (%RU64/%RU64 bytes transfered)"), 767 strDstFile.c_str(), cbWrittenTotal, cbSize)); 772 768 rc = VERR_INTERRUPTED; 773 769 } … … 805 801 if (RT_FAILURE(rc)) 806 802 { 807 setProgressErrorMsg(VBOX_E_IPRT_ERROR, rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc, 808 GuestSession::tr("Destination file \"%s\" could not be opened: %Rrc"), 809 strDstFinal.c_str(), rc == VERR_GSTCTL_GUEST_ERROR ? rcGuest : rc); 803 if (rc == VERR_GSTCTL_GUEST_ERROR) 804 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestSession::tr("Guest file could not be opened"), 805 GuestErrorInfo(GuestErrorInfo::Type_File, rcGuest, strSrc.c_str())); 806 else 807 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 808 Utf8StrFmt(GuestSession::tr("Guest file \"%s\" could not be opened: %Rrc"), strSrc.c_str(), rc)); 810 809 return rc; 811 810 } … … 824 823 { 825 824 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 826 Utf8StrFmt(GuestSession::tr(" Source path lookup for\"%s\" failed: %Rrc"),825 Utf8StrFmt(GuestSession::tr("Host path lookup for file \"%s\" failed: %Rrc"), 827 826 strSrc.c_str(), rc)); 828 827 } … … 843 842 if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0) 844 843 { 845 LogRel2(("Guest Control: Destinationfile \"%s\" has same or newer modification date, skipping",844 LogRel2(("Guest Control: Guest file \"%s\" has same or newer modification date, skipping", 846 845 strDstFinal.c_str())); 847 846 fSkip = true; … … 875 874 { 876 875 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 877 Utf8StrFmt(GuestSession::tr(" Sourcefile lookup for \"%s\" failed: %Rrc"),876 Utf8StrFmt(GuestSession::tr("Host file lookup for \"%s\" failed: %Rrc"), 878 877 szSrcReal, rc)); 879 878 } … … 897 896 szSrcReal, strDstFinal.c_str(), srcObjInfo.cbObject)); 898 897 899 rc = fileCopyToGuestInner(hSrcFile, dstFile, fFileCopyFlags, 0 /* Offset, unused */, srcObjInfo.cbObject); 898 rc = fileCopyToGuestInner(szSrcReal, hSrcFile, strDstFinal, dstFile, 899 fFileCopyFlags, 0 /* Offset, unused */, srcObjInfo.cbObject); 900 900 901 901 int rc2 = RTVfsFileRelease(hSrcFile); … … 904 904 else 905 905 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 906 Utf8StrFmt(GuestSession::tr("Opening sourcefile \"%s\" failed: %Rrc"),906 Utf8StrFmt(GuestSession::tr("Opening host file \"%s\" failed: %Rrc"), 907 907 szSrcReal, rc)); 908 908 } … … 1531 1531 if (strErrorInfo.isEmpty()) 1532 1532 strErrorInfo = Utf8StrFmt(GuestSession::tr("Failed with %Rrc"), vrc); 1533 setProgressErrorMsg(VBOX_E_IPRT_ERROR, vrc, "%s", strErrorInfo.c_str());1533 setProgressErrorMsg(VBOX_E_IPRT_ERROR, strErrorInfo); 1534 1534 } 1535 1535 … … 2030 2030 2031 2031 int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTVFS hVfsIso, 2032 Utf8Str const &strFileS ource, const Utf8Str &strFileDest,2032 Utf8Str const &strFileSrc, const Utf8Str &strFileDst, 2033 2033 bool fOptional) 2034 2034 { … … 2037 2037 2038 2038 RTVFSFILE hVfsFile = NIL_RTVFSFILE; 2039 int rc = RTVfsFileOpen(hVfsIso, strFileS ource.c_str(),2039 int rc = RTVfsFileOpen(hVfsIso, strFileSrc.c_str(), 2040 2040 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, & hVfsFile); 2041 2041 if (RT_SUCCESS(rc)) … … 2046 2046 { 2047 2047 LogRel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n", 2048 strFileS ource.c_str(), strFileDest.c_str()));2048 strFileSrc.c_str(), strFileDst.c_str())); 2049 2049 2050 2050 GuestFileOpenInfo dstOpenInfo; 2051 dstOpenInfo.mFilename = strFileD est;2051 dstOpenInfo.mFilename = strFileDst; 2052 2052 dstOpenInfo.mOpenAction = FileOpenAction_CreateOrReplace; 2053 2053 dstOpenInfo.mAccessMode = FileAccessMode_WriteOnly; … … 2062 2062 { 2063 2063 case VERR_GSTCTL_GUEST_ERROR: 2064 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest ));2064 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(rcGuest, strFileDst.c_str())); 2065 2065 break; 2066 2066 2067 2067 default: 2068 2068 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 2069 Utf8StrFmt(GuestSession::tr(" Destinationfile \"%s\" could not be opened: %Rrc"),2070 strFileD est.c_str(), rc));2069 Utf8StrFmt(GuestSession::tr("Guest file \"%s\" could not be opened: %Rrc"), 2070 strFileDst.c_str(), rc)); 2071 2071 break; 2072 2072 } … … 2074 2074 else 2075 2075 { 2076 rc = fileCopyToGuestInner(hVfsFile, dstFile, FileCopyFlag_None, 0 /*cbOffset*/, cbSrcSize); 2076 rc = fileCopyToGuestInner(strFileSrc, hVfsFile, strFileDst, dstFile, 2077 FileCopyFlag_None, 0 /*cbOffset*/, cbSrcSize); 2077 2078 2078 2079 int rc2 = dstFile->i_closeFile(&rcGuest); … … 2124 2125 2125 2126 case VERR_GSTCTL_GUEST_ERROR: 2126 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestProcess::i_guestErrorToString(rcGuest)); 2127 setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestSession::tr("Running update file on guest failed"), 2128 GuestErrorInfo(GuestErrorInfo::Type_Process, rcGuest, procInfo.mExecutable.c_str())); 2127 2129 break; 2128 2130 … … 2388 2390 { 2389 2391 case VERR_GSTCTL_GUEST_ERROR: 2390 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestProcess::i_guestErrorToString(rcGuest)); 2392 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestSession::tr("Creating installation directory on guest failed"), 2393 GuestErrorInfo(GuestErrorInfo::Type_Directory, rcGuest, strUpdateDir.c_str())); 2391 2394 break; 2392 2395 2393 2396 default: 2394 2397 hr = setProgressErrorMsg(VBOX_E_IPRT_ERROR, 2395 Utf8StrFmt(GuestSession::tr(" Error creating installation directory \"%s\" on the guest: %Rrc"),2398 Utf8StrFmt(GuestSession::tr("Creating installation directory \"%s\" on guest failed: %Rrc"), 2396 2399 strUpdateDir.c_str(), rc)); 2397 2400 break;
Note:
See TracChangeset
for help on using the changeset viewer.