diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:23:06 +0000 |
commit | d9533c342dd90bb3404ecfba87ad3703e038bb6d (patch) | |
tree | 01cfef67ccc5acb2f347a1af9b2168be816a0afa /src/VBox/Main/src-client/GuestSessionImplTasks.cpp | |
parent | Adding debian version 7.0.18-dfsg-2. (diff) | |
download | virtualbox-d9533c342dd90bb3404ecfba87ad3703e038bb6d.tar.xz virtualbox-d9533c342dd90bb3404ecfba87ad3703e038bb6d.zip |
Merging upstream version 7.0.20-dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Main/src-client/GuestSessionImplTasks.cpp')
-rw-r--r-- | src/VBox/Main/src-client/GuestSessionImplTasks.cpp | 190 |
1 files changed, 108 insertions, 82 deletions
diff --git a/src/VBox/Main/src-client/GuestSessionImplTasks.cpp b/src/VBox/Main/src-client/GuestSessionImplTasks.cpp index 9a74e050..b8666f20 100644 --- a/src/VBox/Main/src-client/GuestSessionImplTasks.cpp +++ b/src/VBox/Main/src-client/GuestSessionImplTasks.cpp @@ -2571,7 +2571,7 @@ int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTV vrc = RTVfsFileQuerySize(hVfsFile, &cbSrcSize); if (RT_SUCCESS(vrc)) { - LogRel(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n", + LogRel(("Guest Additions Update: Copying installer file \"%s\" to \"%s\" on guest ...\n", strFileSrc.c_str(), strFileDst.c_str())); GuestFileOpenInfo dstOpenInfo; @@ -2588,13 +2588,14 @@ int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTV switch (vrc) { case VERR_GSTCTL_GUEST_ERROR: - setProgressErrorMsg(VBOX_E_IPRT_ERROR, GuestFile::i_guestErrorToString(vrcGuest, strFileDst.c_str())); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + GuestFile::i_guestErrorToString(vrcGuest, strFileDst.c_str())); break; default: - setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Guest file \"%s\" could not be opened: %Rrc"), - strFileDst.c_str(), vrc)); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Guest file \"%s\" could not be opened: %Rrc"), + strFileDst.c_str(), vrc)); break; } } @@ -2617,6 +2618,34 @@ int GuestSessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, RTV } /** + * Sets an update error message to the current progress object + logs to release log. + * + * @returns Returns \a hrc for convenience. + * @param hrc Progress operation result to set. + * @param strMsg Message to set. + */ +HRESULT GuestSessionTaskUpdateAdditions::setUpdateErrorMsg(HRESULT hrc, const Utf8Str &strMsg) +{ + Utf8Str const strLog = "Guest Additions Update failed: " + strMsg; + LogRel(("%s\n", strLog.c_str())); + return GuestSessionTask::setProgressErrorMsg(hrc, strLog); +} + +/** + * Sets an update error message to the current progress object + logs to release log. + * + * @returns Returns \a hrc for convenience. + * @param hrc Progress operation result to set. + * @param strMsg Message to set. + * @param guestErrorInfo Guest error info to use. + */ +HRESULT GuestSessionTaskUpdateAdditions::setUpdateErrorMsg(HRESULT hrc, const Utf8Str &strMsg, const GuestErrorInfo &guestErrorInfo) +{ + Utf8Str const strLog = strMsg + Utf8Str(": ") + GuestBase::getErrorAsString(guestErrorInfo); + return GuestSessionTaskUpdateAdditions::setProgressErrorMsg(hrc, strLog); +} + +/** * Helper function to run (start) a file on the guest. * * @returns VBox status code. @@ -2628,7 +2657,7 @@ int GuestSessionTaskUpdateAdditions::runFileOnGuest(GuestSession *pSession, Gues { AssertPtrReturn(pSession, VERR_INVALID_POINTER); - LogRel(("Running %s ...\n", procInfo.mName.c_str())); + LogRel(("Guest Additions Update: Running \"%s\" ...\n", procInfo.mName.c_str())); GuestProcessTool procTool; int vrcGuest = VERR_IPE_UNINITIALIZED_STATUS; @@ -2647,26 +2676,26 @@ int GuestSessionTaskUpdateAdditions::runFileOnGuest(GuestSession *pSession, Gues switch (vrc) { case VERR_GSTCTL_PROCESS_EXIT_CODE: - setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Running update file \"%s\" on guest failed: %Rrc"), - procInfo.mExecutable.c_str(), procTool.getRc())); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Running update file \"%s\" on guest failed: %Rrc"), + procInfo.mExecutable.c_str(), procTool.getRc())); break; case VERR_GSTCTL_GUEST_ERROR: - setProgressErrorMsg(VBOX_E_IPRT_ERROR, tr("Running update file on guest failed"), - GuestErrorInfo(GuestErrorInfo::Type_Process, vrcGuest, procInfo.mExecutable.c_str())); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, tr("Running update file on guest failed"), + GuestErrorInfo(GuestErrorInfo::Type_Process, vrcGuest, procInfo.mExecutable.c_str())); break; case VERR_INVALID_STATE: /** @todo Special guest control vrc needed! */ - setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Update file \"%s\" reported invalid running state"), - procInfo.mExecutable.c_str())); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Update file \"%s\" reported invalid running state"), + procInfo.mExecutable.c_str())); break; default: - setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Error while running update file \"%s\" on guest: %Rrc"), - procInfo.mExecutable.c_str(), vrc)); + setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Error while running update file \"%s\" on guest: %Rrc"), + procInfo.mExecutable.c_str(), vrc)); break; } } @@ -2708,16 +2737,14 @@ int GuestSessionTaskUpdateAdditions::checkGuestAdditionsStatus(GuestSession *pSe vrc = runFileOnGuest(pSession, procInfo, true /* fSilent */); if (RT_FAILURE(vrc)) - hrc = setProgressErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, - Utf8StrFmt(tr("Automatic update of Guest Additions has failed: " - "files were installed, but user services were not reloaded automatically. " - "Please consider rebooting the guest"))); + hrc = setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Files were installed, but user services were not reloaded automatically. " + "Please consider rebooting the guest"))); } else - hrc = setProgressErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, - Utf8StrFmt(tr("Automatic update of Guest Additions has failed: " - "files were installed, but kernel modules were not reloaded automatically. " - "Please consider rebooting the guest"))); + hrc = setUpdateErrorMsg(VBOX_E_GSTCTL_GUEST_ERROR, + Utf8StrFmt(tr("Files were installed, but kernel modules were not reloaded automatically. " + "Please consider rebooting the guest"))); } return vrc; @@ -2768,9 +2795,9 @@ int GuestSessionTaskUpdateAdditions::waitForGuestSession(ComObjPtr<Guest> pGuest /* Make sure Guest Additions were reloaded on the guest side. */ vrc = checkGuestAdditionsStatus(pSession, osType); if (RT_SUCCESS(vrc)) - LogRel(("Guest Additions were successfully reloaded after installation\n")); + LogRel(("Guest Additions Update: Guest Additions were successfully reloaded after installation\n")); else - LogRel(("Guest Additions were failed to reload after installation, please consider rebooting the guest\n")); + LogRel(("Guest Additions Update: Guest Additions were failed to reload after installation, please consider rebooting the guest\n")); vrc = pSession->Close(); vrcRet = VINF_SUCCESS; @@ -2805,7 +2832,7 @@ int GuestSessionTaskUpdateAdditions::Run(void) HRESULT hrc = S_OK; - LogRel(("Automatic update of Guest Additions started, using \"%s\"\n", mSource.c_str())); + LogRel(("Guest Additions Update: Automatic update started, using \"%s\"\n", mSource.c_str())); ComObjPtr<Guest> pGuest(mSession->i_getParent()); #if 0 @@ -2829,8 +2856,8 @@ int GuestSessionTaskUpdateAdditions::Run(void) if (FAILED(hrc)) vrc = VERR_TIMEOUT; if (vrc == VERR_TIMEOUT) - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Guest Additions were not ready within time, giving up"))); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Guest Additions were not ready within time, giving up"))); #else /* * For use with the GUI we don't want to wait, just return so that the manual .ISO mounting @@ -2842,11 +2869,11 @@ int GuestSessionTaskUpdateAdditions::Run(void) && addsRunLevel != AdditionsRunLevelType_Desktop)) { if (addsRunLevel == AdditionsRunLevelType_System) - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Guest Additions are installed but not fully loaded yet, aborting automatic update"))); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Guest Additions are installed but not fully loaded yet, aborting automatic update"))); else - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Guest Additions not installed or ready, aborting automatic update"))); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Guest Additions not installed or ready, aborting automatic update"))); vrc = VERR_NOT_SUPPORTED; } #endif @@ -2862,9 +2889,9 @@ int GuestSessionTaskUpdateAdditions::Run(void) if ( RT_SUCCESS(vrc) && RTStrVersionCompare(strAddsVer.c_str(), "4.1") < 0) { - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Guest has too old Guest Additions (%s) installed for automatic updating, please update manually"), - strAddsVer.c_str())); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Guest has too old Guest Additions (%s) installed for automatic updating, please update manually"), + strAddsVer.c_str())); vrc = VERR_NOT_SUPPORTED; } } @@ -2891,8 +2918,8 @@ int GuestSessionTaskUpdateAdditions::Run(void) vrc = getGuestProperty(pGuest, "/VirtualBox/GuestInfo/OS/Release", strOSVer); if (RT_FAILURE(vrc)) { - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Unable to detected guest OS version, please update manually"))); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Unable to detected guest OS version, please update manually"))); vrc = VERR_NOT_SUPPORTED; } @@ -2911,17 +2938,17 @@ int GuestSessionTaskUpdateAdditions::Run(void) * (and the user has to deal with it in the guest). */ if (!(mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly)) { - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Windows 2000 and XP are not supported for automatic updating due to WHQL interaction, please update manually"))); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Windows 2000 and XP are not supported for automatic updating due to WHQL interaction, please update manually"))); vrc = VERR_NOT_SUPPORTED; } } } else { - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("%s (%s) not supported for automatic updating, please update manually"), - strOSType.c_str(), strOSVer.c_str())); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("%s (%s) not supported for automatic updating, please update manually"), + strOSType.c_str(), strOSVer.c_str())); vrc = VERR_NOT_SUPPORTED; } } @@ -2937,9 +2964,9 @@ int GuestSessionTaskUpdateAdditions::Run(void) && osType != eOSType_Linux)) /** @todo Support Solaris. */ { - hrc = setProgressErrorMsg(VBOX_E_NOT_SUPPORTED, - Utf8StrFmt(tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"), - strOSType.c_str())); + hrc = setUpdateErrorMsg(VBOX_E_NOT_SUPPORTED, + Utf8StrFmt(tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"), + strOSType.c_str())); vrc = VERR_NOT_SUPPORTED; } } @@ -2954,9 +2981,9 @@ int GuestSessionTaskUpdateAdditions::Run(void) vrc = RTVfsFileOpenNormal(mSource.c_str(), RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE, &hVfsFileIso); if (RT_FAILURE(vrc)) { - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Unable to open Guest Additions .ISO file \"%s\": %Rrc"), - mSource.c_str(), vrc)); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Unable to open Guest Additions .ISO file \"%s\": %Rrc"), + mSource.c_str(), vrc)); } else { @@ -2964,8 +2991,8 @@ int GuestSessionTaskUpdateAdditions::Run(void) vrc = RTFsIso9660VolOpen(hVfsFileIso, 0 /*fFlags*/, &hVfsIso, NULL); if (RT_FAILURE(vrc)) { - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Unable to open file as ISO 9660 file system volume: %Rrc"), vrc)); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Unable to open file as ISO 9660 file system volume: %Rrc"), vrc)); } else { @@ -2990,21 +3017,21 @@ int GuestSessionTaskUpdateAdditions::Run(void) else strUpdateDir.append("/"); - LogRel(("Guest Additions update directory is: %s\n", strUpdateDir.c_str())); + LogRel(("Guest Additions Update: Update directory is '%s'\n", strUpdateDir.c_str())); } else { switch (vrc) { case VERR_GSTCTL_GUEST_ERROR: - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, tr("Creating update directory on guest failed"), - GuestErrorInfo(GuestErrorInfo::Type_Directory, vrcGuest, strUpdateDir.c_str())); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, tr("Creating update directory on guest failed"), + GuestErrorInfo(GuestErrorInfo::Type_Directory, vrcGuest, strUpdateDir.c_str())); break; default: - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Creating update directory \"%s\" on guest failed: %Rrc"), - strUpdateDir.c_str(), vrc)); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Creating update directory \"%s\" on guest failed: %Rrc"), + strUpdateDir.c_str(), vrc)); break; } } @@ -3028,10 +3055,10 @@ int GuestSessionTaskUpdateAdditions::Run(void) if (RTStrVersionCompare(strOSVer.c_str(), "5.0") >= 0) { fInstallCert = true; - LogRel(("Certificates for auto updating WHQL drivers will be installed\n")); + LogRel(("Guest Additions Update: Certificates for auto updating WHQL drivers will be installed\n")); } else - LogRel(("Skipping installation of certificates for WHQL drivers\n")); + LogRel(("Guest Additions Update: Skipping installation of certificates for WHQL drivers\n")); if (fInstallCert) { @@ -3176,7 +3203,7 @@ int GuestSessionTaskUpdateAdditions::Run(void) uint8_t uOffset = 20; /* Start at 20%. */ uint8_t uStep = 40 / (uint8_t)mFiles.size(); Assert(mFiles.size() <= 10); - LogRel(("Copying over Guest Additions update files to the guest ...\n")); + LogRel(("Guest Additions Update: Copying over update files to the guest ...\n")); std::vector<ISOFile>::const_iterator itFiles = mFiles.begin(); while (itFiles != mFiles.end()) @@ -3189,9 +3216,9 @@ int GuestSessionTaskUpdateAdditions::Run(void) vrc = copyFileToGuest(pSession, hVfsIso, itFiles->strSource, itFiles->strDest, fOptional); if (RT_FAILURE(vrc)) { - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Error while copying file \"%s\" to \"%s\" on the guest: %Rrc"), - itFiles->strSource.c_str(), itFiles->strDest.c_str(), vrc)); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Error while copying file \"%s\" to \"%s\" on the guest: %Rrc"), + itFiles->strSource.c_str(), itFiles->strDest.c_str(), vrc)); break; } } @@ -3215,7 +3242,7 @@ int GuestSessionTaskUpdateAdditions::Run(void) uint8_t uOffset = 60; /* Start at 60%. */ uint8_t uStep = 35 / (uint8_t)mFiles.size(); Assert(mFiles.size() <= 10); - LogRel(("Executing Guest Additions update files ...\n")); + LogRel(("Guest Additions Update: Executing update files ...\n")); std::vector<ISOFile>::iterator itFiles = mFiles.begin(); while (itFiles != mFiles.end()) @@ -3247,27 +3274,26 @@ int GuestSessionTaskUpdateAdditions::Run(void) { if (pSession->i_isTerminated()) { - LogRel(("Old guest session has terminated, waiting updated guest services to start\n")); + LogRel(("Guest Additions Update: Old guest session has terminated, waiting updated guest services to start\n")); /* Wait for VBoxService to restart. */ vrc = waitForGuestSession(pSession->i_getParent(), osType); if (RT_FAILURE(vrc)) - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Automatic update of Guest Additions has failed: " - "guest services were not restarted, please reinstall Guest Additions manually"))); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Guest services were not restarted, please reinstall Guest Additions manually"))); } else { vrc = VERR_TRY_AGAIN; - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Old guest session is still active, guest services were not restarted " - "after installation, please reinstall Guest Additions manually"))); + hrc = setUpdateErrorMsg(VBOX_E_IPRT_ERROR, + Utf8StrFmt(tr("Old guest session is still active, guest services were not restarted " + "after installation, please reinstall Guest Additions manually"))); } } if (RT_SUCCESS(vrc)) { - LogRel(("Automatic update of Guest Additions succeeded\n")); + LogRel(("Guest Additions Update: Automatic update succeeded\n")); hrc = setProgressSuccess(); } } @@ -3281,17 +3307,17 @@ int GuestSessionTaskUpdateAdditions::Run(void) { if (vrc == VERR_CANCELLED) { - LogRel(("Automatic update of Guest Additions was canceled\n")); + LogRel(("Guest Additions Update: Automatic update was canceled\n")); - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Installation was canceled"))); + hrc = setUpdateErrorMsg(E_ABORT, + Utf8StrFmt(tr("Operation was canceled"))); } else if (vrc == VERR_TIMEOUT) { - LogRel(("Automatic update of Guest Additions has timed out\n")); + LogRel(("Guest Additions Update: Automatic update has timed out\n")); - hrc = setProgressErrorMsg(VBOX_E_IPRT_ERROR, - Utf8StrFmt(tr("Installation has timed out"))); + hrc = setUpdateErrorMsg(E_FAIL, + Utf8StrFmt(tr("Operation has timed out"))); } else { @@ -3313,11 +3339,11 @@ int GuestSessionTaskUpdateAdditions::Run(void) } } - LogRel(("Automatic update of Guest Additions failed: %s (%Rhrc)\n", - strError.c_str(), hrc)); + LogRel(("Guest Additions Update: Automatic update failed: %s (vrc=%Rrc, hrc=%Rhrc)\n", + strError.c_str(), vrc, hrc)); } - LogRel(("Please install Guest Additions manually\n")); + LogRel(("Guest Additions Update: An error has occurred (see above). Please install Guest Additions manually\n")); } /** @todo Clean up copied / left over installation files. */ |