GuestCtrlImpl.cpp revision 453a9827c24f86e02899063c971ee6af1e294777
/* $Id$ */
/** @file
* VirtualBox COM class implementation: Guest
*/
/*
* Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "GuestImpl.h"
#include "GuestCtrlImplPrivate.h"
#include "Global.h"
#include "ConsoleImpl.h"
#include "ProgressImpl.h"
#include "VMMDev.h"
#include "AutoCaller.h"
#include "Logging.h"
#ifdef VBOX_WITH_GUEST_CONTROL
#endif
#include <memory>
// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
#ifdef VBOX_WITH_GUEST_CONTROL
/**
* Appends environment variables to the environment block.
*
* Each var=value pair is separated by the null character ('\\0'). The whole
* block will be stored in one blob and disassembled on the guest side later to
* fit into the HGCM param structure.
*
* @returns VBox status code.
*
* @param pszEnvVar The environment variable=value to append to the
* environment block.
* @param ppvList This is actually a pointer to a char pointer
* variable which keeps track of the environment block
* that we're constructing.
* @param pcbList Pointer to the variable holding the current size of
* the environment block. (List is a misnomer, go
* ahead a be confused.)
* @param pcEnvVars Pointer to the variable holding count of variables
* stored in the environment block.
*/
int Guest::prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnvVars)
{
int rc = VINF_SUCCESS;
if (*ppvList)
{
rc = VERR_NO_MEMORY;
else
{
}
}
else
{
char *pszTmp;
{
/* Reset counters. */
*pcEnvVars = 0;
*pcbList = 0;
}
}
if (RT_SUCCESS(rc))
{
}
return rc;
}
/**
* Adds a callback with a user provided data block and an optional progress object
* to the callback map. A callback is identified by a unique context ID which is used
* to identify a callback from the guest side.
*
* @return IPRT status code.
* @param puContextID
* @param pCallbackData
*/
{
int rc;
/* Create a new context ID and assign it. */
uint32_t uNewContextID = 0;
for (;;)
{
/* Create a new context ID ... */
if (uNewContextID == UINT32_MAX)
/* Is the context ID already used? Try next ID ... */
if (!callbackExists(uNewContextID))
{
/* Callback with context ID was not found. This means
* we can use this context ID for our new callback we want
* to add below. */
rc = VINF_SUCCESS;
break;
}
}
if (RT_SUCCESS(rc))
{
/* Add callback with new context ID to our callback map. */
/* Report back new context ID. */
}
return rc;
}
/**
* Does not do locking!
*
* @param uContextID
*/
{
/* Notify callback (if necessary). */
{
{
}
/* Remove callback context (not used anymore). */
}
}
{
AssertReturn(uContextID, false);
}
{
if (pvData)
{
}
}
{
/* pEnmType is optional. */
/* pcbData is optional. */
{
if (pEnmType)
if (pcbData)
return VINF_SUCCESS;
}
return VERR_NOT_FOUND;
}
/* Does not do locking! Caller has to take care of it because the caller needs to
* modify the data ...*/
{
/* pcbData is optional. */
{
if (pcbData)
}
return NULL;
}
{
AssertReturn(uContextID, true);
{
}
if (pProgress)
{
&& !fCanceled)
{
return false;
}
}
return true; /* No progress / error means canceled. */
}
{
AssertReturn(uContextID, true);
{
}
if (pProgress)
{
&& fCompleted)
{
return true;
}
}
return false;
}
{
{
}
if (pProgress)
{
return VERR_CANCELLED;
return VINF_SUCCESS;
}
return VERR_NOT_FOUND;
}
/**
* TODO
*
* @return IPRT status code.
* @param uContextID
* @param iRC
* @param pszMessage
*/
{
LogFlowFunc(("Notifying callback with CID=%u, iRC=%d, pszMsg=%s ...\n",
{
}
#if 0
&& fCanceled)
{
/* If progress already canceled do nothing here. */
return VINF_SUCCESS;
}
#endif
if (pProgress)
{
/*
* Assume we didn't complete to make sure we clean up even if the
* following call fails.
*/
&& !fCompleted)
{
/*
* To get waitForCompletion completed (unblocked) we have to notify it if necessary (only
* cancel won't work!). This could happen if the client thread (e.g. VBoxService, thread of a spawned process)
* is disconnecting without having the chance to sending a status message before, so we
* progress object to become signalled.
*/
if ( RT_SUCCESS(iRC)
&& !pszMessage)
{
}
else
{
}
}
/*
* Do *not* NULL pProgress here, because waiting function like executeProcess()
* will still rely on this object for checking whether they have to give up!
*/
}
/* If pProgress is not found (anymore) that's fine.
* Might be destroyed already. */
return S_OK;
}
/**
* TODO
*
* @return IPRT status code.
* @param uPID
* @param iRC
* @param pszMessage
*/
{
int vrc = VINF_SUCCESS;
{
{
break;
/* When waiting for process output while the process is destroyed,
* make sure we also destroy the actual waiting operation (internal progress object)
* in order to not block the caller. */
{
break;
}
/* When waiting for injecting process input while the process is destroyed,
* make sure we also destroy the actual waiting operation (internal progress object)
* in order to not block the caller. */
{
break;
}
default:
AssertMsgFailed(("Unknown callback type %d, iRC=%d, message=%s\n",
break;
}
if (RT_FAILURE(vrc))
break;
}
return vrc;
}
{
}
{
/*
* Wait for the HGCM low level callback until the process
* has been started (or something went wrong). This is necessary to
* get the PID.
*/
int vrc = VINF_SUCCESS;
{
else
}
if (RT_SUCCESS(vrc))
{
if (lStage < 0)
else
{
if (!callbackIsComplete(uContextID))
}
else
vrc = VERR_TIMEOUT;
}
return vrc;
}
/**
* Static callback function for receiving updates on guest control commands
* from the guest. Acts as a dispatcher for the actual class instance.
*
* @returns VBox status code.
*
* @todo
*
*/
void *pvParms,
{
using namespace guestControl;
/*
* No locking, as this is purely a notification which does not make any
* changes to the object state.
*/
#ifdef DEBUG_andy
LogFlowFunc(("pvExtension = %p, u32Function = %d, pvParms = %p, cbParms = %d\n",
#endif
int rc = VINF_SUCCESS;
switch (u32Function)
{
case GUEST_DISCONNECTED:
{
//LogFlowFunc(("GUEST_DISCONNECTED\n"));
PCALLBACKDATACLIENTDISCONNECTED pCBData = reinterpret_cast<PCALLBACKDATACLIENTDISCONNECTED>(pvParms);
AssertReturn(CALLBACKDATAMAGIC_CLIENT_DISCONNECTED == pCBData->hdr.u32Magic, VERR_INVALID_PARAMETER);
break;
}
case GUEST_EXEC_SEND_STATUS:
{
//LogFlowFunc(("GUEST_EXEC_SEND_STATUS\n"));
break;
}
case GUEST_EXEC_SEND_OUTPUT:
{
//LogFlowFunc(("GUEST_EXEC_SEND_OUTPUT\n"));
break;
}
{
//LogFlowFunc(("GUEST_EXEC_SEND_INPUT_STATUS\n"));
break;
}
default:
break;
}
return rc;
}
/* Function for handling the execution start/termination notification. */
/* Callback can be called several times. */
{
/* Scope write locks as much as possible. */
{
if (pCallbackData)
{
/** @todo Copy void* buffer contents? */
}
else
AssertReleaseMsgFailed(("Process status (PID=%u) does not have allocated callback data!\n",
}
int vrc = VINF_SUCCESS;
/* Was progress canceled before? */
if (!fCbCanceled)
{
/* Do progress handling. */
{
case PROC_STS_STARTED:
break;
case PROC_STS_TEN: /* Terminated normally. */
break;
case PROC_STS_TEA: /* Terminated abnormally. */
LogRel(("Guest process (PID %u) terminated abnormally with exit code = %u\n",
break;
case PROC_STS_TES: /* Terminated through signal. */
LogRel(("Guest process (PID %u) terminated through signal with exit code = %u\n",
break;
case PROC_STS_TOK:
LogRel(("Guest process (PID %u) timed out and was killed\n", pData->u32PID)); /** @todo Add process name */
break;
case PROC_STS_TOA:
LogRel(("Guest process (PID %u) timed out and could not be killed\n", pData->u32PID)); /** @todo Add process name */
break;
case PROC_STS_DWN:
LogRel(("Guest process (PID %u) killed because system is shutting down\n", pData->u32PID)); /** @todo Add process name */
/*
* If u32Flags has ExecuteProcessFlag_IgnoreOrphanedProcesses set, we don't report an error to
* our progress object. This is helpful for waiters which rely on the success of our progress object
* even if the executed process was killed because the system/VBoxService is shutting down.
*
* In this case u32Flags contains the actual execution flags reached in via Guest::ExecuteProcess().
*/
{
}
else
break;
case PROC_STS_ERROR:
LogRel(("Guest process (PID %u) could not be started because of rc=%Rrc\n",
break;
default:
break;
}
/* Handle process map. */
/** @todo How to deal with multiple updates at once? */
{
if (vrc == VERR_NOT_FOUND)
{
/* Not found, add to map. */
0 /*Flags. */);
}
else if (RT_SUCCESS(vrc))
{
/* Process found, update process map. */
0 /*Flags. */);
}
else
AssertReleaseMsgFailed(("Process was neither found nor absent!?\n"));
}
}
else
if (!callbackIsComplete(uContextID))
{
|| fCbCanceled) /* If canceled we have to report E_FAIL! */
{
/* Notify all callbacks which are still waiting on something
* which is related to the current PID. */
{
if (RT_FAILURE(vrc))
LogFlowFunc(("Failed to notify other callbacks for PID=%u\n",
}
/* Let the caller know what went wrong ... */
if (RT_FAILURE(rc2))
{
LogFlowFunc(("Failed to notify callback CID=%u for PID=%u\n",
if (RT_SUCCESS(vrc))
}
LogFlowFunc(("Process (CID=%u, status=%u) reported error: %s\n",
}
}
return vrc;
}
/* Function for handling the execution output notification. */
{
/* Scope write locks as much as possible. */
{
if (pCallbackData)
{
/* Make sure we really got something! */
{
/* Allocate data buffer and copy it */
}
else /* Nothing received ... */
{
pCallbackData->cbData = 0;
}
}
else
AssertReleaseMsgFailed(("Process output status (PID=%u) does not have allocated callback data!\n",
}
int vrc;
{
}
else
return vrc;
}
/* Function for handling the execution input status notification. */
{
/* Scope write locks as much as possible. */
{
if (pCallbackData)
{
/* Save bytes processed. */
}
else
AssertReleaseMsgFailed(("Process input status (PID=%u) does not have allocated callback data!\n",
}
return callbackNotifyComplete(uContextID);
}
{
/* u32Function is 0. */
}
{
{
return VINF_SUCCESS;
}
return VERR_ALREADY_EXISTS;
}
{
{
return VINF_SUCCESS;
}
return VERR_NOT_FOUND;
}
int Guest::processSetStatus(uint32_t u32PID, ExecuteProcessStatus_T enmStatus, uint32_t uExitCode, uint32_t uFlags)
{
{
return VINF_SUCCESS;
}
return VERR_NOT_FOUND;
}
{
if (rc == VERR_NOT_FOUND)
tr("VMM device is not available (is the VM running?)"));
else if (rc == VERR_CANCELLED)
tr("Process execution has been canceled"));
else if (rc == VERR_TIMEOUT)
tr("The guest did not respond within time"));
else
return hRC;
}
{
if (rc == VERR_INVALID_VM_HANDLE)
tr("VMM device is not available (is the VM running?)"));
else if (rc == VERR_NOT_FOUND)
tr("The guest execution service is not ready (yet)"));
else if (rc == VERR_HGCM_SERVICE_NOT_FOUND)
tr("The guest execution service is not available"));
else /* HGCM call went wrong. */
return hRC;
}
#endif /* VBOX_WITH_GUEST_CONTROL */
{
/** @todo r=bird: Eventually we should clean up all the timeout parameters
* in the API and have the same way of specifying infinite waits! */
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
/* Do not allow anonymous executions (with system rights). */
LogRel(("Executing guest process \"%s\" as user \"%s\" ...\n",
#endif
}
#ifdef VBOX_WITH_GUEST_CONTROL
/**
* Executes and waits for an internal tool (that is, a tool which is integrated into
* VBoxService, beginning with "vbox_" (e.g. "vbox_ls")) to finish its operation.
*
* @return HRESULT
* @param aTool Name of tool to execute.
* @param aDescription Friendly description of the operation.
* @param aFlags Execution flags.
* @param aUsername Username to execute tool under.
* @param aPassword The user's password.
* @param aProgress Pointer which receives the tool's progress object. Optional.
* @param aPID Pointer which receives the tool's PID. Optional.
*/
{
5 * 1000 /* Wait 5s for getting the process started. */,
{
/* Wait for process to exit ... */
if (!fCompleted)
if (fCompleted)
{
{
{
if (!uRetExitCode)
{
tr("Error %u occurred while %s"),
}
else
{
if (aProgress)
{
/* Return the progress to the caller. */
}
if (aPID)
}
}
}
}
else if (fCanceled)
{
}
else
AssertReleaseMsgFailed(("Operation \"%s\" neither completed nor canceled!?\n",
}
return rc;
}
{
/* Did we get some status? */
switch (pExecStatus->u32Status)
{
case PROC_STS_STARTED:
/* Process is (still) running; get PID. */
break;
/* In any other case the process either already
* terminated or something else went wrong, so no PID ... */
case PROC_STS_TEN: /* Terminated normally. */
case PROC_STS_TEA: /* Terminated abnormally. */
case PROC_STS_TES: /* Terminated through signal. */
case PROC_STS_TOK:
case PROC_STS_TOA:
case PROC_STS_DWN:
/*
* Process (already) ended, but we want to get the
* PID anyway to retrieve the output in a later call.
*/
break;
case PROC_STS_ERROR:
{
else if (vrc == VERR_PATH_NOT_FOUND)
else if (vrc == VERR_BAD_EXE_FORMAT)
else if (vrc == VERR_AUTHENTICATION_FAILURE)
else if (vrc == VERR_TIMEOUT)
else if (vrc == VERR_CANCELLED)
tr("The execution operation was canceled"));
else if (vrc == VERR_PERMISSION_DENIED)
else if (vrc == VERR_MAX_PROCS_REACHED)
tr("Concurrent guest process limit is reached"));
else
{
else
}
}
break;
case PROC_STS_UNDEFINED: /* . */
tr("The operation did not complete within time"));
break;
default:
AssertReleaseMsgFailed(("Process (PID %u) reported back an undefined state!\n",
pExecStatus->u32PID));
rc = E_UNEXPECTED;
break;
}
return rc;
}
/**
* Gets the next stream block from a formerly processed guest stream. Will return
* E_UNEXPECTED if not enough guest stream data was read yet, otherwise S_OK or an appropriate
* error.
*
* @return HRESULT
* @param aPID PID of process to get the next stream block from.
* @param stream Reference to an already filled guest process stream.
* @param streamBlock Reference to a stream block which receives the parsed data.
*/
{
ULONG cbOutputData = 0;
int vrc;
for (;;)
{
10 * 1000 /* Timeout in ms */,
&& aOutputData.size())
{
{
break;
}
else
{
/* Try to parse the stream output we gathered until now. If we still need more
* data the parsing routine will tell us and we just do another poll round. */
if (RT_SUCCESS(vrc))
{
/* Yay, we're done! */
break;
}
else if (vrc == VERR_MORE_DATA)
{
/* We need another poll round. */
continue;
}
else
}
}
else /* No more output! */
{
if (vrc == VERR_MORE_DATA)
break;
}
}
return rc;
}
/**
* Gets output from a formerly started guest process, tries to parse all of its guest
* stream (as long as data is available) and returns a stream object which can contain
* multiple stream blocks (which in turn then can contain key=value pairs).
*
* @return HRESULT
* @param streamObjects Reference to a guest stream object structure for
* storing the parsed data.
*/
{
ULONG cbOutputData = 0;
for (;;)
{
10 * 1000 /* Timeout in ms */,
&& aOutputData.size())
{
{
break;
}
}
else /* No more output! */
break;
}
{
for (;;)
{
{
else
break; /* No more data. */
}
else
{
tr("Error while parsing guest stream block"));
break;
}
}
}
return rc;
}
/**
* Does busy waiting on a formerly started guest process.
*
* @return HRESULT
* @param uPID PID of guest process to wait for.
* @param uTimeoutMS Waiting timeout (in ms). Specify 0 for an infinite timeout.
* @param pRetStatus Pointer which receives current process status after the change.
* Optional.
* @param puRetExitCode Pointer which receives the final exit code in case of guest process
* termination. Optional.
*/
{
if (uTimeoutMS == 0)
return hRC;
do
{
if ( uTimeoutMS != UINT32_MAX
{
tr("The process (PID %u) did not change its status within time (%ums)"),
uPID, uTimeoutMS);
break;
}
break;
RTThreadSleep(100);
} while(*pRetStatus == curStatus);
{
if (pRetStatus)
*pRetStatus = curStatus;
if (puRetExitCode)
}
return hRC;
}
/**
* Does the actual guest process execution, internal function.
*
* @return HRESULT
* @param aCommand Command line to execute.
* @param aFlags Execution flags.
* @param Username Username to execute the process with.
* @param aPassword The user's password.
* @param aTimeoutMS Timeout (in ms) to wait for the execution operation.
* @param aPID Pointer that receives the guest process' PID.
* @param aProgress Pointer that receives the guest process' progress object.
* @param pRC Pointer that receives the internal IPRT return code. Optional.
*/
{
/** @todo r=bird: Eventually we should clean up all the timeout parameters
* in the API and have the same way of specifying infinite waits! */
using namespace guestControl;
AutoCaller autoCaller(this);
/* Validate flags. */
if (aFlags != ExecuteProcessFlag_None)
{
&& !(aFlags & ExecuteProcessFlag_Hidden)
&& !(aFlags & ExecuteProcessFlag_NoProfile))
{
if (pRC)
}
}
try
{
/*
* Create progress object. Note that this is a multi operation
* object to perform the following steps:
* - Operation 2 (1): Wait for process to exit.
* If this progress completed successfully (S_OK), the process
* occurred.
*/
{
TRUE,
2, /* Number of operations. */
}
/*
* Prepare process execution.
*/
int vrc = VINF_SUCCESS;
/* Adjust timeout. If set to 0, we define
* an infinite timeout. */
if (aTimeoutMS == 0)
/* Prepare arguments. */
if (aArguments)
{
}
if (RT_SUCCESS(vrc))
{
uint32_t uContextID = 0;
if (uNumArgs > 0)
if (RT_SUCCESS(vrc))
{
/* Prepare environment. */
if (aEnvironment)
{
{
if (RT_FAILURE(vrc))
break;
}
}
if (RT_SUCCESS(vrc))
{
/* Allocate payload. */
PCALLBACKDATAEXECSTATUS pStatus = (PCALLBACKDATAEXECSTATUS)RTMemAlloc(sizeof(CALLBACKDATAEXECSTATUS));
/* Create callback. */
if (RT_SUCCESS(vrc))
{
int i = 0;
/*
* If the WaitForProcessStartOnly flag is set, we only want to define and wait for a timeout
* until the process was started - the process itself then gets an infinite timeout for execution.
* This is handy when we want to start a process inside a worker thread within a certain timeout
* but let the started process perform lengthly operations then.
*/
else
{
/* Make sure mParent is valid, so set the read lock while using.
* Do not keep this lock while doing the actual call, because in the meanwhile
* another thread could request a write lock which would be a bad idea ... */
/* Forward the information to the VMM device. */
}
if (pVMMDev)
{
LogFlowFunc(("hgcmHostCall numParms=%d\n", i));
i, paParms);
}
else
}
}
}
if (RT_SUCCESS(vrc))
{
/*
* Wait for the HGCM low level callback until the process
* has been started (or something went wrong). This is necessary to
* get the PID.
*/
/*
* Wait for the first stage (=0) to complete (that is starting the process).
*/
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
pExecStatus, aPID);
}
else
{
tr("Unable to retrieve process execution status data"));
}
}
else
/*
* Do *not* remove the callback yet - we might wait with the IProgress object on something
* else (like end of process) ...
*/
}
else
for (unsigned i = 0; i < uNumArgs; i++)
}
{
/* Return the progress to the caller. */
}
else
{
if (!pRC) /* Skip logging internal calls. */
LogRel(("Executing guest process \"%s\" as user \"%s\" failed with %Rrc\n",
}
if (pRC)
}
{
rc = E_OUTOFMEMORY;
}
return rc;
}
#endif /* VBOX_WITH_GUEST_CONTROL */
STDMETHODIMP Guest::SetProcessInput(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ComSafeArrayIn(BYTE, aData), ULONG *aBytesWritten)
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
/* Validate flags. */
if (aFlags)
{
if (!(aFlags & ProcessInputFlag_EndOfFile))
}
AutoCaller autoCaller(this);
try
{
if (RT_SUCCESS(vrc))
{
/* PID exists; check if process is still running. */
}
else
{
uint32_t uContextID = 0;
/*
* Create progress object.
* This progress object, compared to the one in executeProgress() above,
* is only single-stage local and is used to determine whether the operation
* finished or got canceled.
*/
{
TRUE /* Cancelable */);
}
/* Adjust timeout. */
if (aTimeoutMS == 0)
/* Construct callback data. */
/* Save PID + output flags for later use. */
/* Add the callback. */
if (RT_SUCCESS(vrc))
{
int i = 0;
{
{
/* Make sure mParent is valid, so set the read lock while using.
* Do not keep this lock while doing the actual call, because in the meanwhile
* another thread could request a write lock which would be a bad idea ... */
/* Forward the information to the VMM device. */
}
if (pVMMDev)
{
LogFlowFunc(("hgcmHostCall numParms=%d\n", i));
i, paParms);
}
}
}
if (RT_SUCCESS(vrc))
{
LogFlowFunc(("Waiting for HGCM callback ...\n"));
/*
* Wait for the HGCM low level callback until the process
* has been started (or something went wrong). This is necessary to
* get the PID.
*/
/*
* Wait for the first stage (=0) to complete (that is starting the process).
*/
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
switch (pExecStatusIn->u32Status)
{
case INPUT_STS_WRITTEN:
break;
default:
break;
}
}
else
{
tr("Unable to retrieve process input status data"));
}
}
else
}
else
{
/* Nothing to do here yet. */
}
/* The callback isn't needed anymore -- just was kept locally. */
/* Cleanup. */
}
}
{
rc = E_OUTOFMEMORY;
}
return rc;
#endif
}
STDMETHODIMP Guest::GetProcessOutput(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, LONG64 aSize, ComSafeArrayOut(BYTE, aData))
{
/** @todo r=bird: Eventually we should clean up all the timeout parameters
* in the API and have the same way of specifying infinite waits! */
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
if (aSize < 0)
if (aSize == 0)
if (aFlags)
{
if (!(aFlags & ProcessOutputFlag_StdErr))
{
}
}
AutoCaller autoCaller(this);
try
{
if (RT_FAILURE(vrc))
{
uint32_t uContextID = 0;
/*
* Create progress object.
* This progress object, compared to the one in executeProgress() above,
* is only single-stage local and is used to determine whether the operation
* finished or got canceled.
*/
{
TRUE /* Cancelable */);
}
/* Adjust timeout. */
if (aTimeoutMS == 0)
/* Set handle ID. */
if (aFlags & ProcessOutputFlag_StdErr)
/* Construct callback data. */
/* Save PID + output flags for later use. */
/* Add the callback. */
if (RT_SUCCESS(vrc))
{
int i = 0;
{
/* Make sure mParent is valid, so set the read lock while using.
* Do not keep this lock while doing the actual call, because in the meanwhile
* another thread could request a write lock which would be a bad idea ... */
/* Forward the information to the VMM device. */
}
if (pVMMDev)
{
LogFlowFunc(("hgcmHostCall numParms=%d\n", i));
i, paParms);
}
}
if (RT_SUCCESS(vrc))
{
/*
* Wait for the HGCM low level callback until the process
* has been started (or something went wrong). This is necessary to
* get the PID.
*/
/*
* Wait for the first stage (=0) to complete (that is starting the process).
*/
if (RT_SUCCESS(vrc))
{
if (RT_SUCCESS(vrc))
{
{
/* Do we need to resize the array? */
/* Fill output in supplied out buffer. */
}
else
{
/* No data within specified timeout available. */
outputData.resize(0);
}
/* Detach output buffer to output argument. */
}
else
{
tr("Unable to retrieve process output data"));
}
}
else
}
else
{
}
/* The callback isn't needed anymore -- just was kept locally. */
/* Cleanup. */
}
}
{
rc = E_OUTOFMEMORY;
}
return rc;
#endif
}
STDMETHODIMP Guest::GetProcessStatus(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ExecuteProcessStatus_T *aStatus)
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
AutoCaller autoCaller(this);
try
{
if (RT_SUCCESS(vrc))
{
}
else
}
{
rc = E_OUTOFMEMORY;
}
return rc;
#endif
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
AutoCaller autoCaller(this);
/* Validate flags. */
if (aFlags != CopyFileFlag_None)
{
if ( !(aFlags & CopyFileFlag_Recursive)
&& !(aFlags & CopyFileFlag_Update)
&& !(aFlags & CopyFileFlag_FollowLinks))
{
}
}
try
{
/* Create the progress object. */
TRUE /* aCancelable */);
/* Initialize our worker task. */
/* Assign data - aSource is the source file on the host,
* aDest reflects the full path on the guest. */
/* Don't destruct on success. */
}
{
}
{
/* Return progress to the caller. */
}
return rc;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
AutoCaller autoCaller(this);
/* Validate flags. */
if (aFlags != CopyFileFlag_None)
{
if ( !(aFlags & CopyFileFlag_Recursive)
&& !(aFlags & CopyFileFlag_Update)
&& !(aFlags & CopyFileFlag_FollowLinks))
{
}
}
try
{
/* Create the progress object. */
TRUE /* aCancelable */);
/* Initialize our worker task. */
/* Assign data - aSource is the source file on the host,
* aDest reflects the full path on the guest. */
/* Don't destruct on success. */
}
{
}
{
/* Return progress to the caller. */
}
return rc;
#endif /* VBOX_WITH_GUEST_CONTROL */
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
AutoCaller autoCaller(this);
/* Validate flags. */
if (aFlags)
{
}
try
{
/* Create the progress object. */
TRUE /* aCancelable */);
/* Initialize our worker task. */
/* Assign data - in that case aSource is the full path
* to the Guest Additions .ISO we want to mount. */
/* Don't destruct on success. */
}
{
}
{
/* Return progress to the caller. */
}
return rc;
#endif /* VBOX_WITH_GUEST_CONTROL */
}