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