GuestSessionImplTasks.cpp revision 510567648d46488f4166e5f69ffffe3eeeeec4d9
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VirtualBox Main - Guest session tasks.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Copyright (C) 2012-2013 Oracle Corporation
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * available from http://www.virtualbox.org. This file is free software;
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * you can redistribute it and/or modify it under the terms of the GNU
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * General Public License (GPL) as published by the Free Software
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/*******************************************************************************
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync* Header Files *
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync*******************************************************************************/
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/*******************************************************************************
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync*******************************************************************************/
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * Update file flags.
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync/** Copy over the file from host to the
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * guest. */
8a7af14e45ca3f1aadcad537ddf79f68a830748cvboxsync/** Execute file on the guest after it has
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync * been successfully transfered. */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync/** File is optional, does not have to be
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync * existent on the .ISO. */
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync// session task classes
1d94ccd0c6d838a45dea3a79ba295adc4caabcf9vboxsync/////////////////////////////////////////////////////////////////////////////
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession)
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsyncint GuestSessionTask::getGuestProperty(const ComObjPtr<Guest> &pGuest,
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync ComObjPtr<Console> pConsole = pGuest->getConsole();
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync const ComPtr<IMachine> pMachine = pConsole->machine();
9d508d63ddd8cbaa227c3e3176bb376ba98ffa53vboxsync HRESULT hr = pMachine->GetGuestProperty(Bstr(strPath).raw(),
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync if (mProgress.isNull()) /* Progress is optional. */
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
b4514c911ccdb647c9c0f503f3cee0660f41104avboxsync if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync AssertMsgFailed(("Setting value of an already completed progress\n"));
7255e1c7174fd3b892a74dede74e72557f6cced9vboxsync HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
e45e3ae4a834169539e689759ba6b3ac71bfe40fvboxsync if (mProgress.isNull()) /* Progress is optional. */
return VINF_SUCCESS;
&& !fCanceled
&& !fCompleted)
return VINF_SUCCESS;
&& !fCanceled
&& !fCompleted)
return hr2;
return vrc;
return rc;
mSourceOffset(0),
mSourceSize(0),
/** @todo Merge this and the above call and let the above call do the open/close file handling so that the
if (mCopyFileFlags)
return VERR_INVALID_PARAMETER;
int rc;
if (!mSourceFile)
procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
&guestRc);
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
&& fCanceled)
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
LogFlowThisFunc(("rc=%Rrc, cbWritten=%RU32, cbToRead=%RU64, cbWrittenTotal=%RU64, cbFileSize=%RU64\n",
if (fCanceled)
mSourceSize > 0
if (!cbToRead)
if ( !fCanceled
if ( mSourceSize > 0
&& cbWrittenTotal == 0)
Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
&& exitCode != 0)
return rc;
return rc;
RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
&guestRc);
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
Utf8StrFmt(GuestSession::tr("Error while creating guest process for copying file \"%s\" from guest to host: %Rrc"),
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
if (cbRead)
&& fCanceled)
LogFlowThisFunc(("rc=%Rrc, guestrc=%Rrc, waitRes=%ld, cbWrittenTotal=%RU64, cbSize=%RI64, cbToRead=%RU64\n",
if ( !fCanceled
&& cbWrittenTotal == 0)
&& exitCode != 0)
return rc;
return rc;
bool fFound = false;
fFound = true;
itDest++;
if (!fFound)
itSource++;
return VERR_NO_MEMORY;
return rc;
if (fOptional)
return VINF_SUCCESS;
return rc;
rc = pSession->startTaskAsync(Utf8StrFmt(GuestSession::tr("Copying Guest Additions installer file \"%s\" to \"%s\" on guest"),
&& fCanceled)
LogRel(("Size of Guest Additions installer file \"%s\" does not match: %RI64 bytes copied, %RU64 bytes expected\n",
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
if (pcbSize)
return rc;
int SessionTaskUpdateAdditions::runFileOnGuest(GuestSession *pSession, GuestProcessStartupInfo &procInfo)
switch (vrc)
case VERR_GSTCTL_GUEST_ERROR:
return vrc;
return rc;
Utf8StrFmt(GuestSession::tr("Guest Additions are installed but not fully loaded yet, aborting automatic update")));
Utf8StrFmt(GuestSession::tr("Guest has too old Guest Additions (%s) installed for automatic updating, please update manually"),
Utf8StrFmt(GuestSession::tr("Windows 2000 and XP are not supported for automatic updating due to WHQL interaction, please update manually")));
Utf8StrFmt(GuestSession::tr("%s (%s) not supported for automatic updating, please update manually"),
Utf8StrFmt(GuestSession::tr("Detected guest OS (%s) does not support automatic Guest Additions updating, please update manually"),
bool fUseInstallDir = false;
fUseInstallDir = true;
if (fUseInstallDir)
int guestRc;
switch (rc)
case VERR_GSTCTL_GUEST_ERROR:
switch (osType)
case eOSType_Windows:
bool fInstallCert = false;
fInstallCert = true;
if (fInstallCert)
case eOSType_Linux:
case eOSType_Solaris:
bool fOptional = false;
fOptional = true;
itFiles++;
itFiles++;
return rc;
return rc;