VirtualBox

Changeset 84648 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jun 3, 2020 8:11:04 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
138400
Message:

Guest Control/Main: Big guest error information revamp, to show more information about the actual context in which an error occurred. bugref:9320

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

Legend:

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

    r83556 r84648  
    604604};
    605605
     606/**
     607 * Class for keeping guest error information.
     608 */
     609class GuestErrorInfo
     610{
     611public:
     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
     696protected:
     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};
    606705
    607706/**
     
    11691268    int waitForEvent(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, VBoxEventType_T *pType, IEvent **ppEvent);
    11701269
     1270#ifndef VBOX_GUESTCTRL_TEST_CASE
     1271    HRESULT setErrorExternal(VirtualBoxBase *pInterface, const Utf8Str &strAction, const GuestErrorInfo &guestErrorInfo);
     1272#endif
     1273
    11711274public:
    11721275
    11731276    static FsObjType_T fileModeToFsObjType(RTFMODE fMode);
     1277    static Utf8Str getErrorAsString(const GuestErrorInfo &guestErrorInfo);
    11741278
    11751279protected:
  • trunk/src/VBox/Main/include/GuestDirectoryImpl.h

    r83489 r84648  
    6666    /** @name Public static internal methods.
    6767     * @{ */
    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);
    7069    /** @}  */
    7170
  • trunk/src/VBox/Main/include/GuestFileImpl.h

    r84054 r84648  
    6161    int             i_closeFile(int *pGuestRc);
    6262    EventSource    *i_getEventSource(void) { return mEventSource; }
    63     static Utf8Str  i_guestErrorToString(int guestRc);
    6463    int             i_onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
    6564    int             i_onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
     
    7069                                 void* pvData, size_t cbData, size_t* pcbRead);
    7170    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);
    7371    int             i_setFileStatus(FileStatus_T fileStatus, int fileRc);
    7472    int             i_waitForOffsetChange(GuestWaitEvent *pEvent, uint32_t uTimeoutMS, uint64_t *puOffset);
     
    7876    int             i_writeData(uint32_t uTimeoutMS, const void *pvData, uint32_t cbData, uint32_t *pcbWritten);
    7977    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);
    8083    /** @}  */
    8184
  • trunk/src/VBox/Main/include/GuestProcessImpl.h

    r82968 r84648  
    7777    /** @name Static internal methods.
    7878     * @{ */
    79     static Utf8Str i_guestErrorToString(int guestRc);
     79    static Utf8Str i_guestErrorToString(int rcGuest, const char *pcszWhat);
    8080    static bool i_isGuestError(int guestRc);
    81     static HRESULT i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
    8281    static ProcessWaitResult_T i_waitFlagsToResultEx(uint32_t fWaitFlags, ProcessStatus_T oldStatus, ProcessStatus_T newStatus, uint32_t uProcFlags, uint32_t uProtocol);
    8382#if 0 /* unused */
     
    271270    /** @}  */
    272271
     272    /** Wrapped @name Static guest error conversion methods.
     273     * @{ */
     274    static Utf8Str guestErrorToString(const char *pszTool, const GuestErrorInfo& guestErrorInfo);
     275    /** @}  */
     276
    273277protected:
    274278
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r84554 r84648  
    309309    Utf8Str                 i_getName(void);
    310310    ULONG                   i_getId(void) { return mData.mSession.mID; }
    311     static Utf8Str          i_guestErrorToString(int guestRc);
    312311    bool                    i_isStarted(void) const;
    313312    HRESULT                 i_isStartedExternal(void);
    314     static bool             i_isTerminated(GuestSessionStatus_T enmStatus);
    315313    bool                    i_isTerminated(void) const;
    316314    int                     i_onRemove(void);
     
    319317    int                     i_startSession(int *pGuestRc);
    320318    int                     i_startSessionAsync(void);
    321     static int              i_startSessionThreadTask(GuestSessionTaskInternalStart *pTask);
    322319    Guest                  *i_getParent(void) { return mParent; }
    323320    uint32_t                i_getProtocolVersion(void) { return mData.mProtocolVersion; }
     
    335332    int                     i_sendMessage(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms,
    336333                                          uint64_t fDst = VBOX_GUESTCTRL_DST_SESSION);
    337     static HRESULT          i_setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
    338334    int                     i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc);
    339335    int                     i_signalWaiters(GuestSessionWaitResult_T enmWaitResult, int rc /*= VINF_SUCCESS */);
     
    343339    int                     i_waitForStatusChange(GuestWaitEvent *pEvent, uint32_t fWaitFlags, uint32_t uTimeoutMS,
    344340                                                  GuestSessionStatus_T *pSessionStatus, int *pGuestRc);
     341    /** @}  */
     342
     343public:
     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);
    345350    /** @}  */
    346351
  • trunk/src/VBox/Main/include/GuestSessionImplTasks.h

    r83336 r84648  
    204204    /** @name File handling primitives.
    205205     * @{ */
    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);
    208209    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);
    211213
    212214    int fileCopyToGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags);
     
    221223    int setProgressSuccess(void);
    222224    HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg);
    223     HRESULT setProgressErrorMsg(HRESULT hrc, int vrc, const char *pszFormat, ...);
     225    HRESULT setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg, const GuestErrorInfo &guestErrorInfo);
    224226
    225227    inline void setTaskDesc(const Utf8Str &strTaskDesc) throw()
  • trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp

    r82968 r84648  
    13021302}
    13031303
     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
    13041377/**
    13051378 * Converts RTFMODE to FsObjType_T.
  • trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp

    r83489 r84648  
    223223}
    224224
     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 */
    225232/* static */
    226 Utf8Str GuestDirectory::i_guestErrorToString(int rcGuest)
    227 {
    228     Utf8Str strError;
     233Utf8Str 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;
    229241
    230242    /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    231243    switch (rcGuest)
    232244    {
    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);
    235252            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;
    247259}
    248260
     
    384396}
    385397
    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 
    395398// implementation of public methods
    396399/////////////////////////////////////////////////////////////////////////////
     
    411414        {
    412415            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()));
    414418                break;
    415419
     
    421425            default:
    422426                hr = setErrorBoth(VBOX_E_IPRT_ERROR, vrc,
    423                                   tr("Terminating open guest directory \"%s\" failed: %Rrc"), mData.mOpenInfo.mPath.c_str(), vrc);
     427                                  tr("Closing guest directory \"%s\" failed: %Rrc"), mData.mOpenInfo.mPath.c_str(), vrc);
    424428                break;
    425429        }
     
    451455        {
    452456            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()));
    454459                break;
    455460
    456461            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"),
    458463                                  mData.mOpenInfo.mPath.c_str(), mData.mProcessTool.getRc());
    459464                break;
    460465
    461466            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"),
    463468                                  mData.mOpenInfo.mPath.c_str());
    464469                break;
     
    466471            case VERR_NO_MORE_FILES:
    467472                /* 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"),
    469474                                  mData.mOpenInfo.mPath.c_str());
    470475                break;
    471476
    472477            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"),
    474479                                  mData.mOpenInfo.mPath.c_str(), vrc);
    475480                break;
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r84564 r84648  
    404404
    405405/**
    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.
    411407 *
    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.
    413411 */
    414 /* static */ Utf8Str GuestFile::i_guestErrorToString(int rcGuest)
    415 {
     412/* static */
     413Utf8Str 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
    416422    /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    417423    switch (rcGuest)
    418424    {
    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);
    424430        default:
    425431        {
    426432            char szDefine[80];
    427433            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;
    431442}
    432443
     
    10131024}
    10141025
    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 
    10241026int GuestFile::i_setFileStatus(FileStatus_T fileStatus, int fileRc)
    10251027{
     
    10521054            hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, fileRc,
    10531055                                   COM_IIDOF(IGuestFile), getComponentName(),
    1054                                    i_guestErrorToString(fileRc));
     1056                                   i_guestErrorToString(fileRc, mData.mOpenInfo.mFilename.c_str()));
    10551057            ComAssertComRC(hr);
    10561058        }
     
    13881390    {
    13891391        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);
    13921396    }
    13931397
     
    14181422                hr = ptrFsObjInfo.queryInterfaceTo(aObjInfo.asOutParam());
    14191423            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);
    14211427        }
    14221428    }
     
    14241430    {
    14251431        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()));
    14271434        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);
    14291437    }
    14301438
     
    14521460    {
    14531461        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()));
    14551464        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);
    14571466    }
    14581467
     
    15061515
    15071516    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());
    15091518
    15101519    LogFlowThisFuncEnter();
     
    15611570
    15621571        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());
    15641574    }
    15651575
     
    15931603     */
    15941604    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());
    15961607
    15971608    /*
     
    16551666        hrc = S_OK;
    16561667    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"),
    16581669                           mData.mOpenInfo.mFilename.c_str(), aSize, aSize, vrc);
    16591670    LogFlowFuncLeaveRC(vrc);
     
    16671678
    16681679    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());
    16701681
    16711682    LogFlowThisFuncEnter();
     
    16771688    int vrc = i_writeData(aTimeoutMS, pvData, cbData, (uint32_t*)aWritten);
    16781689    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"),
    16801691                          aData.size(), mData.mOpenInfo.mFilename.c_str(), vrc);
    16811692
     
    16901701
    16911702    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());
    16931704
    16941705    LogFlowThisFuncEnter();
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r84261 r84648  
    487487}
    488488
     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 */
    489496/* static */
    490 Utf8Str GuestProcess::i_guestErrorToString(int rcGuest)
    491 {
    492     Utf8Str strError;
     497Utf8Str 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;
    493505
    494506    /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    495507    switch (rcGuest)
    496508    {
    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)"));
    539520        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;
    545532}
    546533
     
    974961            hr = errorInfo->initEx(VBOX_E_IPRT_ERROR, mData.mLastError,
    975962                                   COM_IIDOF(IGuestProcess), getComponentName(),
    976                                    i_guestErrorToString(mData.mLastError));
     963                                   i_guestErrorToString(mData.mLastError, mData.mProcess.mExecutable.c_str()));
    977964            ComAssertComRC(hr);
    978965        }
     
    1003990
    1004991    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());
    1014992}
    1015993
     
    18091787        {
    18101788            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()));
    18121791                break;
    18131792
    18141793            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"),
    18161795                                  mData.mProcess.mExecutable.c_str(), mData.mPID, vrc);
    18171796                break;
     
    18411820        {
    18421821           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()));
    18441824                break;
    18451825
    18461826            case VERR_NOT_SUPPORTED:
    18471827                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"),
    18491829                                  mData.mProcess.mExecutable.c_str(), mData.mPID);
    18501830                break;
    18511831
    18521832            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"),
    18541834                                  mData.mProcess.mExecutable.c_str(), mData.mPID, vrc);
    18551835                break;
     
    18991879        {
    19001880            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()));
    19021883                break;
    19031884
     
    19071888
    19081889            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"),
    19101891                                  mData.mProcess.mExecutable.c_str(), mData.mPID, vrc);
    19111892                break;
     
    19521933        {
    19531934            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()));
    19551937                break;
    19561938
    19571939            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"),
    19591941                                  mData.mProcess.mExecutable.c_str(), mData.mPID, vrc);
    19601942                break;
     
    25692551        }
    25702552    }
     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    }
    25712562    else if (!RTStrICmp(pszTool, VBOXSERVICE_TOOL_STAT))
    25722563    {
     
    26002591        switch (iExitCode)
    26012592        {
    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. */
    26032595            default:                 break;
    26042596        }
     
    26122604}
    26132605
     2606/* static */
     2607Utf8Str 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  
    26392639}
    26402640
    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 
    26502641/* Does not do locking; caller is responsible for that! */
    26512642int GuestSession::i_setSessionStatus(GuestSessionStatus_T sessionStatus, int sessionRc)
     
    30733064    {
    30743065        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);
    30773070    }
    30783071
     
    31733166        {
    31743167            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()));
    31773170            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);
    31793172        }
    31803173
     
    33963389    {
    33973390        if (GuestProcess::i_isGuestError(vrc))
    3398             hrc = setErrorBoth(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()));
    34003393        else
    34013394        {
     
    34033396            {
    34043397                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"));
    34063399                    break;
    34073400
    34083401                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"));
    34103403                    break;
    34113404
    34123405                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);
    34143407                    break;
    34153408            }
     
    34433436        {
    34443437            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()));
    34463440                break;
    34473441
    34483442            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"),
    34503444                                  aPath.c_str(), aTemplateName.c_str(), vrc);
    34513445               break;
     
    34853479                        break;
    34863480                    default:
    3487                         hrc = setErrorBoth(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()));
    34893483                        break;
    34903484                }
     
    35493543        {
    35503544            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"),
    35523546                                  aPath.c_str());
    35533547               break;
    35543548
    35553549            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()));
    35573552                break;
    35583553
    35593554            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);
    35613556               break;
    35623557        }
     
    35923587
    35933588            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()));
    35953591                break;
    35963592
     
    36713667
    36723668            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()));
    36743671                break;
    36753672
     
    38153812
    38163813                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()));
    38183816                    break;
    38193817            }
     
    38263824
    38273825        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"),
    38293827                               aPath.c_str(), vrc);
    38303828            break;
     
    39323930
    39333931            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()));
    39353934                break;
    39363935
     
    39623961    {
    39633962        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()));
    39653965        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());
    39673968    }
    39683969
     
    40024003            }
    40034004            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()));
    40054007        }
    40064008        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);
    40084010    }
    40094011
     
    40404042    {
    40414043        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()));
    40434046        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);
    40454048    }
    40464049
     
    40644067    {
    40654068        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()));
    40674071        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);
    40694073    }
    40704074
     
    41184122            case VERR_NOT_SUPPORTED:
    41194123                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"));
    41214125                break;
    41224126
    41234127            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()));
    41254130                break;
    41264131
    41274132            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"),
    41294134                                   aSource.c_str(), vrc);
    41304135                break;
     
    43564361        {
    43574362            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()));
    43594365                break;
    43604366
  • trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp

    r84551 r84648  
    193193}
    194194
     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 */
    195202HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
    196203{
    197     LogFlowFunc(("hr=%Rhrc, strMsg=%s\n",
    198                  hr, strMsg.c_str()));
     204    LogFlowFunc(("hr=%Rhrc, strMsg=%s\n", hr, strMsg.c_str()));
    199205
    200206    if (mProgress.isNull()) /* Progress is optional. */
     
    218224}
    219225
    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 */
     234HRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg, const GuestErrorInfo &guestErrorInfo)
     235{
     236    return setProgressErrorMsg(hr, strMsg + Utf8Str(": ") + GuestBase::getErrorAsString(guestErrorInfo));
    244237}
    245238
     
    353346 *
    354347 * @return VBox status code.
     348 * @param  strSrcFile         Full path of source file on the host to copy.
    355349 * @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.
    356351 * @param  phDstFile          Pointer to host file handle (destination) to copy to. Must be in opened and ready state already.
    357352 * @param  fFileCopyFlags     File copy flags.
     
    359354 * @param  cbSize             Size (in bytes) to copy from the source file.
    360355 */
    361 int GuestSessionTask::fileCopyFromGuestInner(ComObjPtr<GuestFile> &srcFile, PRTFILE phDstFile, FileCopyFlag_T fFileCopyFlags,
    362                                             uint64_t offCopy, uint64_t cbSize)
     356int GuestSessionTask::fileCopyFromGuestInner(const Utf8Str &strSrcFile, ComObjPtr<GuestFile> &srcFile,
     357                                             const Utf8Str &strDstFile, PRTFILE phDstFile,
     358                                             FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize)
    363359{
    364360    RT_NOREF(fFileCopyFlags);
     
    379375        {
    380376            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));
    382379            return rc;
    383380        }
     
    393390        {
    394391            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));
    396394            break;
    397395        }
     
    401399        {
    402400            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));
    404403            break;
    405404        }
     
    439438         * to the destination -> access denied. */
    440439        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()));
    442442        rc = VERR_ACCESS_DENIED;
    443443    }
     
    446446        /* If we did not copy all let the user know. */
    447447        setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    448                             Utf8StrFmt(GuestSession::tr("Copying guest file to host to failed (%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));
    450450        rc = VERR_INTERRUPTED;
    451451    }
     
    463463 * @param  fFileCopyFlags       File copy flags.
    464464 */
    465 int GuestSessionTask::fileCopyFromGuest(const Utf8Str &strSource, const Utf8Str &strDest, FileCopyFlag_T fFileCopyFlags)
    466 {
    467     LogFlowThisFunc(("strSource=%s, strDest=%s, enmFileCopyFlags=0x%x\n", strSource.c_str(), strDest.c_str(), fFileCopyFlags));
     465int 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));
    468468
    469469    GuestFileOpenInfo srcOpenInfo;
    470     srcOpenInfo.mFilename     = strSource;
     470    srcOpenInfo.mFilename     = strSrc;
    471471    srcOpenInfo.mOpenAction   = FileOpenAction_OpenExisting;
    472472    srcOpenInfo.mAccessMode   = FileAccessMode_ReadOnly;
     
    477477    GuestFsObjData srcObjData;
    478478    int rcGuest = VERR_IPE_UNINITIALIZED_STATUS;
    479     int rc = mSession->i_fsQueryInfo(strSource, TRUE /* fFollowSymlinks */, srcObjData, &rcGuest);
     479    int rc = mSession->i_fsQueryInfo(strSrc, TRUE /* fFollowSymlinks */, srcObjData, &rcGuest);
    480480    if (RT_FAILURE(rc))
    481481    {
    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                }
    486504                break;
    487505
    488506            default:
    489507                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()));
    515509                rc = VERR_NOT_A_FILE;
    516510                break;
     
    524518    if (RT_FAILURE(rc))
    525519    {
    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));
    538526    }
    539527
     
    555543            {
    556544                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    557                                     Utf8StrFmt(GuestSession::tr("Destination file \"%s\" already exists"), strDest.c_str()));
     545                                    Utf8StrFmt(GuestSession::tr("Host file \"%s\" already exists"), strDest.c_str()));
    558546                rc = VERR_ALREADY_EXISTS;
    559547            }
     
    566554                {
    567555                    setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    568                                         Utf8StrFmt(GuestSession::tr("Destination file \"%s\" has same or newer modification date"),
     556                                        Utf8StrFmt(GuestSession::tr("Host file \"%s\" has same or newer modification date"),
    569557                                                   strDest.c_str()));
    570558                    fSkip = true;
     
    576564            if (rc != VERR_FILE_NOT_FOUND) /* Destination file does not exist (yet)? */
    577565                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    578                                     Utf8StrFmt(GuestSession::tr("Destination file lookup for \"%s\" failed: %Rrc"),
     566                                    Utf8StrFmt(GuestSession::tr("Host file lookup for \"%s\" failed: %Rrc"),
    579567                                               strDest.c_str(), rc));
    580568        }
     
    595583            {
    596584                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()));
    599586                rc = VERR_ALREADY_EXISTS;
    600587            }
     
    612599                RTPathAppend(szDstPath, sizeof(szDstPath), "/"); /* IPRT can handle / on all hosts. */
    613600
    614             RTPathAppend(szDstPath, sizeof(szDstPath), RTPathFilenameEx(strSource.c_str(), mfPathStyle));
     601            RTPathAppend(szDstPath, sizeof(szDstPath), RTPathFilenameEx(strSrc.c_str(), mfPathStyle));
    615602
    616603            pszDstFile = RTStrDup(szDstPath);
     
    621608            {
    622609                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    623                                     Utf8StrFmt(GuestSession::tr("Destination file \"%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()));
    625612                rc = VERR_IS_A_SYMLINK;
    626613            }
     
    652639            if (RT_SUCCESS(rc))
    653640            {
    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);
    657646
    658647                int rc2 = RTFileClose(hDstFile);
     
    661650            else
    662651                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    663                                     Utf8StrFmt(GuestSession::tr("Opening/creating destination file \"%s\" failed: %Rrc"),
     652                                    Utf8StrFmt(GuestSession::tr("Opening/creating host file \"%s\" failed: %Rrc"),
    664653                                               pszDstFile, rc));
    665654        }
     
    679668 *
    680669 * @return VBox status code.
     670 * @param  strSrcFile         Full path of source file on the host to copy.
    681671 * @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.
    683674 * @param  fFileCopyFlags     File copy flags.
    684675 * @param  offCopy            Offset (in bytes) where to start copying the source file.
    685676 * @param  cbSize             Size (in bytes) to copy from the source file.
    686677 */
    687 int GuestSessionTask::fileCopyToGuestInner(RTVFSFILE hVfsFile, ComObjPtr<GuestFile> &dstFile, FileCopyFlag_T fFileCopyFlags,
    688                                            uint64_t offCopy, uint64_t cbSize)
     678int GuestSessionTask::fileCopyToGuestInner(const Utf8Str &strSrcFile, RTVFSFILE hVfsFile,
     679                                           const Utf8Str &strDstFile, ComObjPtr<GuestFile> &fileDst,
     680                                           FileCopyFlag_T fFileCopyFlags, uint64_t offCopy, uint64_t cbSize)
    689681{
    690682    RT_NOREF(fFileCopyFlags);
     
    705697        {
    706698            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));
    708701            return rc;
    709702        }
     
    719712        {
    720713            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));
    722716            break;
    723717        }
    724718
    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 */);
    726720        if (RT_FAILURE(rc))
    727721        {
    728722            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));
    730725            break;
    731726        }
     
    761756         * to the destination -> access denied. */
    762757        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()));
    764760        rc = VERR_ACCESS_DENIED;
    765761    }
     
    768764        /* If we did not copy all let the user know. */
    769765        setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    770                             Utf8StrFmt(GuestSession::tr("Copying to destination failed (%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));
    772768        rc = VERR_INTERRUPTED;
    773769    }
     
    805801    if (RT_FAILURE(rc))
    806802    {
    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));
    810809        return rc;
    811810    }
     
    824823        {
    825824            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"),
    827826                                           strSrc.c_str(), rc));
    828827        }
     
    843842                        if (RTTimeSpecCompare(&dstModificationTimeTS, &srcObjInfo.ModificationTime) <= 0)
    844843                        {
    845                             LogRel2(("Guest Control: Destination file \"%s\" has same or newer modification date, skipping",
     844                            LogRel2(("Guest Control: Guest file \"%s\" has same or newer modification date, skipping",
    846845                                     strDstFinal.c_str()));
    847846                            fSkip = true;
     
    875874            {
    876875                setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    877                                     Utf8StrFmt(GuestSession::tr("Source file lookup for \"%s\" failed: %Rrc"),
     876                                    Utf8StrFmt(GuestSession::tr("Host file lookup for \"%s\" failed: %Rrc"),
    878877                                               szSrcReal, rc));
    879878            }
     
    897896                             szSrcReal, strDstFinal.c_str(), srcObjInfo.cbObject));
    898897
    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);
    900900
    901901            int rc2 = RTVfsFileRelease(hSrcFile);
     
    904904        else
    905905            setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    906                                 Utf8StrFmt(GuestSession::tr("Opening source file \"%s\" failed: %Rrc"),
     906                                Utf8StrFmt(GuestSession::tr("Opening host file \"%s\" failed: %Rrc"),
    907907                                           szSrcReal, rc));
    908908    }
     
    15311531        if (strErrorInfo.isEmpty())
    15321532            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);
    15341534    }
    15351535
     
    20302030
    20312031int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTVFS hVfsIso,
    2032                                                      Utf8Str const &strFileSource, const Utf8Str &strFileDest,
     2032                                                     Utf8Str const &strFileSrc, const Utf8Str &strFileDst,
    20332033                                                     bool fOptional)
    20342034{
     
    20372037
    20382038    RTVFSFILE hVfsFile = NIL_RTVFSFILE;
    2039     int rc = RTVfsFileOpen(hVfsIso, strFileSource.c_str(),
     2039    int rc = RTVfsFileOpen(hVfsIso, strFileSrc.c_str(),
    20402040                           RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, & hVfsFile);
    20412041    if (RT_SUCCESS(rc))
     
    20462046        {
    20472047            LogRel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n",
    2048                     strFileSource.c_str(), strFileDest.c_str()));
     2048                    strFileSrc.c_str(), strFileDst.c_str()));
    20492049
    20502050            GuestFileOpenInfo dstOpenInfo;
    2051             dstOpenInfo.mFilename    = strFileDest;
     2051            dstOpenInfo.mFilename    = strFileDst;
    20522052            dstOpenInfo.mOpenAction  = FileOpenAction_CreateOrReplace;
    20532053            dstOpenInfo.mAccessMode  = FileAccessMode_WriteOnly;
     
    20622062                {
    20632063                    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()));
    20652065                        break;
    20662066
    20672067                    default:
    20682068                        setProgressErrorMsg(VBOX_E_IPRT_ERROR,
    2069                                             Utf8StrFmt(GuestSession::tr("Destination file \"%s\" could not be opened: %Rrc"),
    2070                                                        strFileDest.c_str(), rc));
     2069                                            Utf8StrFmt(GuestSession::tr("Guest file \"%s\" could not be opened: %Rrc"),
     2070                                                       strFileDst.c_str(), rc));
    20712071                        break;
    20722072                }
     
    20742074            else
    20752075            {
    2076                 rc = fileCopyToGuestInner(hVfsFile, dstFile, FileCopyFlag_None, 0 /*cbOffset*/, cbSrcSize);
     2076                rc = fileCopyToGuestInner(strFileSrc, hVfsFile, strFileDst, dstFile,
     2077                                          FileCopyFlag_None, 0 /*cbOffset*/, cbSrcSize);
    20772078
    20782079                int rc2 = dstFile->i_closeFile(&rcGuest);
     
    21242125
    21252126            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()));
    21272129                break;
    21282130
     
    23882390                        {
    23892391                            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()));
    23912394                                break;
    23922395
    23932396                            default:
    23942397                                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"),
    23962399                                                                    strUpdateDir.c_str(), rc));
    23972400                                break;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette