GuestSessionImplTasks.cpp revision 05150d9b570a7efbd6923eedcef64f2ec351b52e
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * VirtualBox Main - XXX.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Copyright (C) 2012 Oracle Corporation
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * General Public License (GPL) as published by the Free Software
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*******************************************************************************
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync* Header Files *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync*******************************************************************************/
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync/*******************************************************************************
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync*******************************************************************************/
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * Update file flags.
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync/** Copy over the file from host to the
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * guest. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync/** Execute file on the guest after it has
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * been successfully transfered. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync/** File is optional, does not have to be
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * existent on the .ISO. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync// session task classes
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync/////////////////////////////////////////////////////////////////////////////
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsyncint GuestSessionTask::getGuestProperty(const ComObjPtr<Guest> &pGuest,
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync ComObjPtr<Console> pConsole = pGuest->getConsole();
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync const ComPtr<IMachine> pMachine = pConsole->machine();
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync HRESULT hr = pMachine->GetGuestProperty(Bstr(strPath).raw(),
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync if (mProgress.isNull()) /* Progress is optional. */
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync AssertMsgFailed(("Setting value of an already completed progress\n"));
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync if (mProgress.isNull()) /* Progress is optional. */
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync return VERR_COM_UNEXPECTED; /** @todo Find a better rc. */
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsyncHRESULT GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (mProgress.isNull()) /* Progress is optional. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync/** @todo Merge this and the above call and let the above call do the open/close file handling so that the
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync * inner code only has to deal with file handles. No time now ... */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync PRTFILE pSourceFile, size_t cbSourceOffset, uint64_t cbSourceSize,
fb41ad77bcfbdb3aaa1fc9503a37ee6a70dc6461vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync Utf8StrFmt(GuestSession::tr("Copy flags (%#x) not implemented yet"),
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync /* Does our source file exist? */
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync Utf8StrFmt(GuestSession::tr("Source file \"%s\" does not exist or is not a file"),
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync Utf8StrFmt(GuestSession::tr("Could not open source file \"%s\" for reading: %Rrc"),
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync Utf8StrFmt(GuestSession::tr("Could not query file size of \"%s\": %Rrc"),
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync /* Size + offset are optional. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync /* Set arguments.*/
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync /* Startup process. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync && waitRes != ProcessWaitResult_WaitFlagNotSupported))
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync /* If the guest does not support waiting for stdin, we now yield in
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync * order to reduce the CPU load due to busy waiting. */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync if (waitRes == ProcessWaitResult_WaitFlagNotSupported)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (mSourceSize) /* If we have nothing to write, take a shortcut. */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync /** @todo Not very efficient, but works for now. */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync rc = RTFileSeek(*pFile, mSourceOffset + cbWrittenTotal,
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync * Some other error occured? There might be a chance that RTFileRead
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync * could not resolve/map the native error code to an IPRT code, so just
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync * print a generic error.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Could not read from file \"%s\" (%Rrc)"),
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Utf8StrFmt(GuestSession::tr("Seeking file \"%s\" to offset %RU64 failed: %Rrc"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Did we reach the end of the content we want to transfer (last chunk)? */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Did we reach the last block which is exactly _64K? */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* ... or does the user want to cancel? */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync && SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFunc(("Writing last chunk cbRead=%RU64\n", cbRead));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Writing to file \"%s\" (offset %RU64) failed: %Rrc"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Only subtract bytes reported written by the guest. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Update total bytes written to the guest. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFunc(("rc=%Rrc, cbWritten=%RU32, cbToRead=%RU64, cbWrittenTotal=%RU64, cbFileSize=%RU64\n",
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync rc, cbWritten, cbToRead, cbWrittenTotal, mSourceSize));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Did the user cancel the operation above? */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Update the progress.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Watch out for division by zero. */
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync ? rc = setProgress((ULONG)(cbWrittenTotal * 100 / mSourceSize))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* End of file reached? */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync } /* for */
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync LogFlowThisFunc(("Copy loop ended with rc=%Rrc\n" ,rc));
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * Even if we succeeded until here make sure to check whether we really transfered
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * everything.
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync * to the destination -> access denied. */
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync /* If we did not copy all let the user know. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed: %Rrc"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
7e8ef90d3160234df0f254131b87af4243d79476vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
7e8ef90d3160234df0f254131b87af4243d79476vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
7e8ef90d3160234df0f254131b87af4243d79476vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %ld"),
7e8ef90d3160234df0f254131b87af4243d79476vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync } /* processCreateExInteral */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync if (!mSourceFile) /* Only close locally opened files. */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsyncint SessionTaskCopyTo::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, mCopyFileFlags=%x\n",
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mCopyFileFlags));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyTo::taskThread, this,
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync "gctlCpyTo");
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/* static */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncint SessionTaskCopyTo::taskThread(RTTHREAD Thread, void *pvUser)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync std::auto_ptr<SessionTaskCopyTo> task(static_cast<SessionTaskCopyTo*>(pvUser));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSessionTaskCopyFrom::SessionTaskCopyFrom(GuestSession *pSession,
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync * Note: There will be races between querying file size + reading the guest file's
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync * content because we currently *do not* lock down the guest file when doing the
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync * actual operations.
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync ** @todo Implement guest file locking!
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync int rc = pSession->fileQueryInfoInternal(Utf8Str(mSource), objData, &guestRc);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync Utf8StrFmt(GuestSession::tr("Querying guest file information for \"%s\" failed: %Rrc"),
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync else if (objData.mType != FsObjType_File) /* Only single files are supported at the moment. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Object \"%s\" on the guest is not a file"), mSource.c_str()));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Error opening destination file \"%s\": %Rrc"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync mSource.c_str(), mDest.c_str(), objData.mObjectSize);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Set arguments.*/
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync procInfo.mArguments.push_back(mSource); /* Which file to output? */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Startup process. */
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
fb41ad77bcfbdb3aaa1fc9503a37ee6a70dc6461vboxsync Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync || waitRes == ProcessWaitResult_WaitFlagNotSupported)
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync /* If the guest does not support waiting for stdin, we now yield in
fb41ad77bcfbdb3aaa1fc9503a37ee6a70dc6461vboxsync * order to reduce the CPU load due to busy waiting. */
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync if (waitRes == ProcessWaitResult_WaitFlagNotSupported)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"),
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */);
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync Utf8StrFmt(GuestSession::tr("Error writing to file \"%s\" (%RU64 bytes left): %Rrc"),
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync /* Only subtract bytes reported written by the guest. */
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync /* Update total bytes written to the guest. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize);
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync /* Did the user cancel the operation above? */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0)));
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync } /* for */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync LogFlowThisFunc(("rc=%Rrc, guestrc=%Rrc, waitRes=%ld, cbWrittenTotal=%RU64, cbSize=%RI64, cbToRead=%RU64\n",
ecf100db90e8e3af96312908282d3c20e754fbe8vboxsync rc, guestRc, waitRes, cbWrittenTotal, objData.mObjectSize, cbToRead));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * Even if we succeeded until here make sure to check whether we really transfered
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * everything.
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * to the destination -> access denied. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync else if (cbWrittenTotal < (uint64_t)objData.mObjectSize)
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* If we did not copy all let the user know. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RI64 bytes transfered)"),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync mSource.c_str(), cbWrittenTotal, objData.mObjectSize));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync else /* Yay, success! */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsyncint SessionTaskCopyFrom::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, uFlags=%x\n",
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mFlags));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyFrom::taskThread, this,
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync "gctlCpyFrom");
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync/* static */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncint SessionTaskCopyFrom::taskThread(RTTHREAD Thread, void *pvUser)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync std::auto_ptr<SessionTaskCopyFrom> task(static_cast<SessionTaskCopyFrom*>(pvUser));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncSessionTaskUpdateAdditions::SessionTaskUpdateAdditions(GuestSession *pSession,
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsyncSessionTaskUpdateAdditions::~SessionTaskUpdateAdditions(void)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint SessionTaskUpdateAdditions::copyFileToGuest(GuestSession *pSession, PRTISOFSFILE pISO,
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync Utf8Str const &strFileSource, const Utf8Str &strFileDest,
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* pcbSize is optional. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync int rc = RTIsoFsGetFileInfo(pISO, strFileSource.c_str(), &cbOffset, &cbSize);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync rc = RTFileSeek(pISO->file, cbOffset, RTFILE_SEEK_BEGIN, NULL);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* Copy over the Guest Additions file to the guest. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowThisFunc(("Copying Guest Additions installer file \"%s\" to \"%s\" on guest ...\n",
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(pSession /* GuestSession */,
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = pSession->startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync HRESULT hr = pProgressCopyTo->WaitForCompletion(-1);
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync if ( SUCCEEDED(pProgressCopyTo->COMGETTER(Canceled)(&fCanceled))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /** @todo Note: Since there is no file locking involved at the moment, there can be modifications
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * between finished copying, the verification and the actual execution. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* Determine where the installer image ended up and if it has the correct size. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync LogFlowThisFunc(("Verifying Guest Additions installer file \"%s\" ...\n",
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync rc = pSession->fileQuerySizeInternal(strFileDest, &cbSizeOnGuest, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowThisFunc(("Guest Additions installer file \"%s\" successfully verified\n",
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowThisFunc(("Size of Guest Additions installer file \"%s\" does not match: %RI64bytes copied, %RU64bytes expected\n",
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync rc = VERR_BROKEN_PIPE; /** @todo Find a better error. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Error while querying size for file \"%s\": %Rrc"),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsyncint SessionTaskUpdateAdditions::runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogRel(("Running %s ...\n", procInfo.mName.c_str()));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync int vrc = procTool.Init(pSession, procInfo, false /* Async */, &guestRc);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync case VERR_NOT_EQUAL: /** @todo Special guest control rc needed! */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Running update file \"%s\" on guest terminated with exit code %ld"),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Error while running update file \"%s\" on guest: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync LogRel(("Automatic update of Guest Additions started, using \"%s\"\n", mSource.c_str()));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * Wait for the guest being ready within 30 seconds.
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync while ( SUCCEEDED(hr = pGuest->COMGETTER(AdditionsRunLevel)(&addsRunLevel))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync && ( addsRunLevel != AdditionsRunLevelType_Userland
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Guest Additions were not ready within time, giving up")));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * For use with the GUI we don't want to wait, just return so that the manual .ISO mounting
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * can continue.
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if ( FAILED(hr = pGuest->COMGETTER(AdditionsRunLevel)(&addsRunLevel))
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync || ( addsRunLevel != AdditionsRunLevelType_Userland
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync Utf8StrFmt(GuestSession::tr("Guest Additions are installed but not fully loaded yet, aborting automatic update")));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Guest Additions not installed or ready, aborting automatic update")));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Determine if we are able to update automatically. This only works
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * if there are recent Guest Additions installed already.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = getGuestProperty(pGuest, "/VirtualBox/GuestAdd/Version", strAddsVer);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync && RTStrVersionCompare(strAddsVer.c_str(), "4.1") < 0)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Guest has too old Guest Additions (%s) installed for automatic updating, please update manually"),
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * Determine guest OS type and the required installer image.
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync rc = getGuestProperty(pGuest, "/VirtualBox/GuestInfo/OS/Product", strOSType);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync if ( strOSType.contains("Microsoft", Utf8Str::CaseInsensitive)
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync || strOSType.contains("Windows", Utf8Str::CaseInsensitive))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * Determine guest OS version.
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync rc = getGuestProperty(pGuest, "/VirtualBox/GuestInfo/OS/Release", strOSVer);
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Unable to detected guest OS version, please update manually")));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* Because Windows 2000 + XP and is bitching with WHQL popups even if we have signed drivers we
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * can't do automated updates here. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* Windows XP 64-bit (5.2) is a Windows 2003 Server actually, so skip this here. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync && ( strOSVer.startsWith("5.0") /* Exclude the build number. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync || strOSVer.startsWith("5.1")) /* Exclude the build number. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* If we don't have AdditionsUpdateFlag_WaitForUpdateStartOnly set we can't continue
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * because the Windows Guest Additions installer will fail because of WHQL popups. If the
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * flag is set this update routine ends successfully as soon as the installer was started
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * (and the user has to deal with it in the guest). */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync if (!(mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly))
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync Utf8StrFmt(GuestSession::tr("Windows 2000 and XP are not supported for automatic updating due to WHQL interaction, please update manually")));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync else if (strOSType.contains("Solaris", Utf8Str::CaseInsensitive))
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync else /* Everything else hopefully means Linux :-). */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#if 1 /* Only Windows is supported (and tested) at the moment. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync * Try to open the .ISO file to extract all needed files.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Unable to open Guest Additions .ISO file \"%s\": %Rrc"),
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /* Set default installation directories. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Try looking up the Guest Additions installation directory. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Try getting the installed Guest Additions version to know whether we
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * can install our temporary Guest Addition data into the original installation
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync * directory.
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Because versions prior to 4.2 had bugs wrt spaces in paths we have to choose
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * a different location then.
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync rc = getGuestProperty(pGuest, "/VirtualBox/GuestAdd/Version", strAddsVer);
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync && RTStrVersionCompare(strAddsVer.c_str(), "4.2r80329") > 0)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = getGuestProperty(pGuest, "/VirtualBox/GuestAdd/InstallDir", strUpdateDir);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync LogRel(("Guest Additions update directory is: %s\n",
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Create the installation directory. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = pSession->directoryCreateInternal(strUpdateDir,
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync 755 /* Mode */, DirectoryCreateFlag_Parents, &guestRc);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync Utf8StrFmt(GuestSession::tr("Error creating installation directory \"%s\" on the guest: %Rrc"),
81096b0da0061583a511da27088643aa949a1ec9vboxsync /* Prepare the file(s) we want to copy over to the guest and
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync * (maybe) want to run. */
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync /* Do we need to install our certificates? We do this for W2K and up. */
510567648d46488f4166e5f69ffffe3eeeeec4d9vboxsync bool fInstallCert = false;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Only Windows 2000 and up need certificates to be installed. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (RTStrVersionCompare(strOSVer.c_str(), "5.0") >= 0)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync LogRel(("Certificates for auto updating WHQL drivers will be installed\n"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogRel(("Skipping installation of certificates for WHQL drivers\n"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* Our certificate. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync mFiles.push_back(InstallerFile("CERT/ORACLE_VBOX.CER",
004d74842597dacc4009803171296dfcf9398c69vboxsync UPDATEFILE_FLAG_COPY_FROM_ISO | UPDATEFILE_FLAG_OPTIONAL));
004d74842597dacc4009803171296dfcf9398c69vboxsync /* Our certificate installation utility. */
004d74842597dacc4009803171296dfcf9398c69vboxsync /* First pass: Copy over the file + execute it to remove any existing
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync * VBox certificates. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync siCertUtilRem.mName = "VirtualBox Certificate Utility, removing old VirtualBox certificates";
004d74842597dacc4009803171296dfcf9398c69vboxsync siCertUtilRem.mArguments.push_back(Utf8Str("remove-trusted-publisher"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync siCertUtilRem.mArguments.push_back(Utf8Str("--root")); /* Add root certificate as well. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync siCertUtilRem.mArguments.push_back(Utf8Str(strUpdateDir + "oracle-vbox.cer"));
004d74842597dacc4009803171296dfcf9398c69vboxsync siCertUtilRem.mArguments.push_back(Utf8Str(strUpdateDir + "oracle-vbox.cer"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync mFiles.push_back(InstallerFile("CERT/VBOXCERTUTIL.EXE",
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync UPDATEFILE_FLAG_COPY_FROM_ISO | UPDATEFILE_FLAG_EXECUTE | UPDATEFILE_FLAG_OPTIONAL,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* Second pass: Only execute (but don't copy) again, this time installng the
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync * recent certificates just copied over. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync siCertUtilAdd.mName = "VirtualBox Certificate Utility, installing VirtualBox certificates";
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siCertUtilAdd.mArguments.push_back(Utf8Str("add-trusted-publisher"));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siCertUtilAdd.mArguments.push_back(Utf8Str("--root")); /* Add root certificate as well. */
004d74842597dacc4009803171296dfcf9398c69vboxsync siCertUtilAdd.mArguments.push_back(Utf8Str(strUpdateDir + "oracle-vbox.cer"));
004d74842597dacc4009803171296dfcf9398c69vboxsync siCertUtilAdd.mArguments.push_back(Utf8Str(strUpdateDir + "oracle-vbox.cer"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync mFiles.push_back(InstallerFile("CERT/VBOXCERTUTIL.EXE",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync UPDATEFILE_FLAG_EXECUTE | UPDATEFILE_FLAG_OPTIONAL,
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* The installers in different flavors, as we don't know (and can't assume)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * the guest's bitness. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_X86.EXE",
51da1b42a8a60004d6b24ebedd4aa3fe853e4b24vboxsync mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS_AMD64.EXE",
51da1b42a8a60004d6b24ebedd4aa3fe853e4b24vboxsync /* The stub loader which decides which flavor to run. */
51da1b42a8a60004d6b24ebedd4aa3fe853e4b24vboxsync siInstaller.mName = "VirtualBox Windows Guest Additions Installer";
51da1b42a8a60004d6b24ebedd4aa3fe853e4b24vboxsync /* Set a running timeout of 5 minutes -- the Windows Guest Additions
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * setup can take quite a while, so be on the safe side. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siInstaller.mArguments.push_back(Utf8Str("/S")); /* We want to install in silent mode. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siInstaller.mArguments.push_back(Utf8Str("/l")); /* ... and logging enabled. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Don't quit VBoxService during upgrade because it still is used for this
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * piece of code we're in right now (that is, here!) ... */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siInstaller.mArguments.push_back(Utf8Str("/no_vboxservice_exit"));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Tell the installer to report its current installation status
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * using a running VBoxTray instance via balloon messages in the
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * Windows taskbar. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siInstaller.mArguments.push_back(Utf8Str("/post_installstatus"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync /* If the caller does not want to wait for out guest update process to end,
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * complete the progress object now so that the caller can do other work. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (mFlags & AdditionsUpdateFlag_WaitForUpdateStartOnly)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync siInstaller.mFlags |= ProcessCreateFlag_WaitForProcessStartOnly;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync mFiles.push_back(InstallerFile("VBOXWINDOWSADDITIONS.EXE",
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync UPDATEFILE_FLAG_COPY_FROM_ISO | UPDATEFILE_FLAG_EXECUTE, siInstaller));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /** @todo Add Linux support. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /** @todo Add Solaris support. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync AssertReleaseMsgFailed(("Unsupported guest type: %d\n", osType));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* We want to spend 40% total for all copying operations. So roughly
c55bf74b54ecdfb5ebc4e5d90b620d0fee31737evboxsync * calculate the specific percentage step of each copied file. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync LogRel(("Copying over Guest Additions update files to the guest ...\n"));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync std::vector<InstallerFile>::const_iterator itFiles = mFiles.begin();
81096b0da0061583a511da27088643aa949a1ec9vboxsync if (itFiles->fFlags & UPDATEFILE_FLAG_COPY_FROM_ISO)
81096b0da0061583a511da27088643aa949a1ec9vboxsync bool fOptional = false;
81096b0da0061583a511da27088643aa949a1ec9vboxsync rc = copyFileToGuest(pSession, &iso, itFiles->strSource, itFiles->strDest,
81096b0da0061583a511da27088643aa949a1ec9vboxsync Utf8StrFmt(GuestSession::tr("Error while copying file \"%s\" to \"%s\" on the guest: %Rrc"),
81096b0da0061583a511da27088643aa949a1ec9vboxsync itFiles->strSource.c_str(), itFiles->strDest.c_str(), rc));
81096b0da0061583a511da27088643aa949a1ec9vboxsync /* Done copying, close .ISO file. */
81096b0da0061583a511da27088643aa949a1ec9vboxsync /* We want to spend 35% total for all copying operations. So roughly
81096b0da0061583a511da27088643aa949a1ec9vboxsync * calculate the specific percentage step of each copied file. */
d8e12fa5dd1c35282b98cb165e42b6b395cf971bvboxsync LogRel(("Executing Guest Additions update files ...\n"));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync std::vector<InstallerFile>::iterator itFiles = mFiles.begin();
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync LogRel(("Automatic update of Guest Additions succeeded\n"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogRel(("Automatic update of Guest Additions was canceled\n"));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync Utf8StrFmt(GuestSession::tr("Installation was canceled")));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8Str strError = Utf8StrFmt("No further error information available (%Rrc)", rc);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (!mProgress.isNull()) /* Progress object is optional. */
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync hr = mProgress->COMGETTER(ErrorInfo)(pError.asOutParam());
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync LogRel(("Automatic update of Guest Additions failed: %s\n", strError.c_str()));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsync LogRel(("Please install Guest Additions manually\n"));
4171ffb38eb8720b2ae9a8d13e95103ab26cfd12vboxsyncint SessionTaskUpdateAdditions::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, uFlags=%x\n",
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync int rc = RTThreadCreate(NULL, SessionTaskUpdateAdditions::taskThread, this,
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync "gctlUpGA");
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync/* static */
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncint SessionTaskUpdateAdditions::taskThread(RTTHREAD Thread, void *pvUser)