ConsoleImpl.cpp revision 525cfe310305abf78e4fd4cb98bd0fa603694a65
e6d40133bc9f858308654afb1262b8b483ec5922Till Mossakowski * VBox Console COM Class implementation
b4fbc96e05117839ca409f5f20f97b3ac872d1edTill Mossakowski * Copyright (C) 2006-2010 Oracle Corporation
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * This file is part of VirtualBox Open Source Edition (OSE), as
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * available from http://www.virtualbox.org. This file is free software;
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder * you can redistribute it and/or modify it under the terms of the GNU
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * General Public License (GPL) as published by the Free Software
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * Foundation, in version 2 as it comes in the "COPYING" file of the
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5a635ded758223aace5fd93489167f03cc336502Christian Maeder/** @todo Move the TAP mess back into the driver! */
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski// generated header
efcb75d747dcdecc53bc5a584b6b4d98d1ae2755Christian Maeder#include <VBox/HostServices/VBoxClipboardSvc.h>
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski# include <VBox/HostServices/GuestPropertySvc.h>
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder// VMTask and friends
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder////////////////////////////////////////////////////////////////////////////////
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * Task structure for asynchronous VM operations.
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * Once created, the task structure adds itself as a Console caller. This means:
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * 1. The user must check for #rc() before using the created structure
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder * (e.g. passing it as a thread function argument). If #rc() returns a
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * failure, the Console object may not be used by the task (see
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * Console::addCaller() for more details).
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder * 2. On successful initialization, the structure keeps the Console caller
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * until destruction (to ensure Console remains in the Ready state and won't
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * be accidentally uninitialized). Forgetting to delete the created task
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * will lead to Console::uninit() stuck waiting for releasing all added
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * If \a aUsesVMPtr parameter is true, the task structure will also add itself
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder * as a Console::mpVM caller with the same meaning as above. See
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * Console::addVMCaller() for more info.
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder bool isOk() const { return SUCCEEDED(rc()); }
781d04c5e02635caed8b98f0adcf559f9426a39cTill Mossakowski /** Releases the VM caller before destruction. Not normally necessary. */
277f12a72ee6876b9c48f01ef34d7cde65a423c8Christian Maederstruct VMTakeSnapshotTask : public VMProgressTask
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder : VMProgressTask(aConsole, aProgress, false /* aUsesVMPtr */),
5a635ded758223aace5fd93489167f03cc336502Christian Maeder Bstr bstrSavedStateFile; // received from BeginTakeSnapshot()
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maederstruct VMPowerUpTask : public VMProgressTask
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder : VMProgressTask(aConsole, aProgress, false /* aUsesVMPtr */),
5a635ded758223aace5fd93489167f03cc336502Christian Maeder mEnmFaultToleranceState(FaultToleranceState_Inactive)
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder Console::SharedFolderDataMap mSharedFolders;
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder FaultToleranceState_T mEnmFaultToleranceState;
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder /* array of progress objects for hard disk reset operations */
27273a2967ca2f12b5e6ff0ec5e3f66e2ea8fcb2Christian Maeder typedef std::list< ComPtr<IProgress> > ProgressList;
0cb5f9c8582ad87ceef1c16b5d92347ae0878019Christian Maeder VMSaveTask(Console *aConsole, Progress *aProgress)
27273a2967ca2f12b5e6ff0ec5e3f66e2ea8fcb2Christian Maeder : VMProgressTask(aConsole, aProgress, true /* aUsesVMPtr */),
6e6ba3ab90205840b9c0ea408befaed7d1d7b80bChristian Maeder// ConsoleCallbackRegistration
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski////////////////////////////////////////////////////////////////////////////////
6e6ba3ab90205840b9c0ea408befaed7d1d7b80bChristian Maeder * Registered IConsoleCallback, used by Console::CallbackList and
6e6ba3ab90205840b9c0ea408befaed7d1d7b80bChristian Maeder * Console::mCallbacks.
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder * In addition to keeping the interface pointer this also keeps track of the
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder * methods that asked to not be called again. The latter is for reducing
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski * unnecessary IPC.
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder /** Callback bit indexes (for bmDisabled). */
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder /* nothing */
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder /* nothing */
6ab1767d594a99e063bb698c123823411c05700eChristian Maeder#define PREP_ARGS4(a1,a2,a3,a4) a1, a2, a3, a4
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder#define PREP_ARGS5(a1,a2,a3,a4,a5) a1, a2, a3, a4, a5
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder#define PREP_ARGS6(a1,a2,a3,a4,a5,a6) a1, a2, a3, a4, a5, a6
aefb25a4f42b9078ea2b04fe2b599da4ca20cd34Christian Maeder#define PREP_ARGS7(a1,a2,a3,a4,a5,a6,a7) a1, a2, a3, a4, a5, a6, a7
90f31c67ccb0973bf6daf66ea7e541e6151dd982Christian Maeder#define PREP_ARGS8(a1,a2,a3,a4,a5,a6,a7,a8) a1, a2, a3, a4, a5, a6, a7, a8
90f31c67ccb0973bf6daf66ea7e541e6151dd982Christian Maeder * Macro for firing appropriate event.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * @param Event Event, like OnKeyboardLedsChanged.
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * @param InvokeCb Callbacks invocation code
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder * @param PreprEvent Event preparation code
90f31c67ccb0973bf6daf66ea7e541e6151dd982Christian Maeder * @param Args Number of callback arguments
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder#define CONSOLE_DO_CALLBACKS_GEN(Event, Args, MaybeComma) \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder evDesc.init(mEventSource, VBoxEventType_##Event MaybeComma Args); \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder evDesc.fire(/* don't wait for delivery */ 0); \
90f31c67ccb0973bf6daf66ea7e541e6151dd982Christian Maeder/* Actual invocation macroses for different number of parameters */
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder#define CONSOLE_DO_CALLBACKS0(CallbackMethod) \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS0(), NO_COMMA)
0cb5f9c8582ad87ceef1c16b5d92347ae0878019Christian Maeder#define CONSOLE_DO_CALLBACKS1(CallbackMethod,Arg1) \
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS1(Arg1), COMMA)
90f31c67ccb0973bf6daf66ea7e541e6151dd982Christian Maeder#define CONSOLE_DO_CALLBACKS2(CallbackMethod,Arg1,Arg2) \
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS2(Arg1,Arg2),COMMA)
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder#define CONSOLE_DO_CALLBACKS3(CallbackMethod,Arg1,Arg2,Arg3) \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS3(Arg1,Arg2,Arg3), COMMA)
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder#define CONSOLE_DO_CALLBACKS4(CallbackMethod,Arg1,Arg2,Arg3,Arg4) \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS4(Arg1,Arg2,Arg3,Arg4), COMMA)
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder#define CONSOLE_DO_CALLBACKS7(CallbackMethod,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7) \
9929f81562adecc8aafaefb14a0159afcf4a3351Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS7(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7), COMMA)
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder#define CONSOLE_DO_CALLBACKS8(CallbackMethod,Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8) \
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder CONSOLE_DO_CALLBACKS_GEN(CallbackMethod, PREP_ARGS8(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7,Arg8), COMMA)
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder// constructor / destructor
0cb5f9c8582ad87ceef1c16b5d92347ae0878019Christian Maeder/////////////////////////////////////////////////////////////////////////////
add1aac0ed564b88495edb5491efd8c511607ea9Christian Maeder for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder meAttachmentType[slot] = NetworkAttachmentType_Null;
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski memset(mapStorageLeds, 0, sizeof(mapStorageLeds));
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski memset(mapNetworkLeds, 0, sizeof(mapNetworkLeds));
5a635ded758223aace5fd93489167f03cc336502Christian Maeder memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
5a635ded758223aace5fd93489167f03cc336502Christian Maeder for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++ i)
5a635ded758223aace5fd93489167f03cc336502Christian Maeder VMM2USERMETHODS *pVmm2UserMethods = (VMM2USERMETHODS *)RTMemAlloc(sizeof(*mpVmm2UserMethods) + sizeof(Console *));
5a635ded758223aace5fd93489167f03cc336502Christian Maeder pVmm2UserMethods->u32Magic = VMM2USERMETHODS_MAGIC;
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski pVmm2UserMethods->u32Version = VMM2USERMETHODS_VERSION;
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski pVmm2UserMethods->pfnSaveState = Console::vmm2User_SaveState;
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski pVmm2UserMethods->u32EndMagic = VMM2USERMETHODS_MAGIC;
42c01284bba8d7c8d995c8dfb96ace57d28ed1bcTill Mossakowski *(Console **)(pVmm2UserMethods + 1) = this; /* lazy bird. */
c64d33a7fbeae730cbe65193fe3cc24e7aa1ddd6Christian Maeder// public initializer/uninitializer for internal purposes only
#ifdef VBOX_WITH_VRDP
mcAudioRefs = 0;
mcVRDPClients = 0;
return S_OK;
if (mpVM)
powerDown();
if (mpVmm2UserMethods)
if (mAudioSniffer)
delete mAudioSniffer;
if (m_pVMMDev)
delete m_pVMMDev;
if (mRemoteDisplayInfo)
if (mDebugger)
if (mDisplay)
if (mMouse)
if (mKeyboard)
if (mGuest)
if (mConsoleVRDPServer)
delete mConsoleVRDPServer;
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_GUEST_PROPS
void Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
if (!enabledGuestPropertiesVRDP())
int rc;
char *pszPropertyName;
char *pszClientId;
if (!enabledGuestPropertiesVRDP())
int rc;
char *pszPropertyName;
char *pszClientId;
int Console::VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
return VERR_ACCESS_DENIED;
switch (authType)
case VRDPAuthType_Null:
case VRDPAuthType_External:
result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
case VRDPAuthType_Guest:
if ( (m_pVMMDev)
switch (u32GuestFlags & (VMMDEV_CREDENTIALS_JUDGE_OK | VMMDEV_CREDENTIALS_JUDGE_DENY | VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT))
result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
switch (guestJudgement)
AssertFailed();
return VERR_ACCESS_DENIED;
/* Multiconnection check must be made after authentication, so bad clients would not interfere with a good one. */
LogFlowFunc(("allowMultiConnection %d, reuseSingleConnection = %d, mcVRDPClients = %d, mu32SingleRDPClientId = %d\n", allowMultiConnection, reuseSingleConnection, mcVRDPClients, mu32SingleRDPClientId));
/* Note: the 'mcVRDPClients' variable is incremented in ClientConnect callback, which is called when the client
if (mcVRDPClients != 0)
return VERR_ACCESS_DENIED;
#ifdef VBOX_WITH_GUEST_PROPS
&& m_pVMMDev)
return VINF_SUCCESS;
#ifdef VBOX_WITH_VRDP
#ifdef VBOX_WITH_VRDP
if ( (u32Clients == 0)
#ifdef VBOX_WITH_VRDP
mcAudioRefs--;
if (mcAudioRefs <= 0)
if (mAudioSniffer)
if (port)
#ifdef VBOX_WITH_GUEST_PROPS
MLDMemDump();
#ifdef VBOX_WITH_VRDP
++mcAudioRefs;
if (mAudioSniffer)
if (port)
#ifdef VBOX_WITH_VRDP
return S_OK;
return rc;
mSavedStateDataLoaded = true;
return rc;
DECLCALLBACK(void)
++ it)
DECLCALLBACK(int)
return VERR_VERSION_MISMATCH;
bool writable = true;
bool autoMount = false;
delete[] buf;
delete[] buf;
return VINF_SUCCESS;
#ifdef VBOX_WITH_GUEST_PROPS
void *pvParms,
using namespace guestProp;
int rc;
LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
return rc;
using namespace guestProp;
return E_OUTOFMEMORY;
&parm[0]);
const char *pszBuf
unsigned cEntries = 0;
++cEntries;
for (unsigned i = 0; i < cEntries; ++i)
return S_OK;
return E_FAIL;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
if (!mDebugger)
return S_OK;
return S_OK;
STDMETHODIMP Console::COMGETTER(RemoteUSBDevices)(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices))
return S_OK;
return S_OK;
return S_OK;
return S_OK;
return E_POINTER;
switch (mMachineState)
case MachineState_Running:
case MachineState_Paused:
case MachineState_Stuck:
case MachineState_Teleporting:
return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down at this point in a fault tolerant sync"));
case MachineState_Saved:
case MachineState_Stopping:
return S_OK;
return setInvalidMachineStateError();
vrc);
return rc;
return vrc;
return setInvalidMachineStateError();
if (!fCpuAttached)
bool fLocked = true;
} while (cTries-- > 0);
this, aCpu);
return rc;
return VINF_SUCCESS;
return setInvalidMachineStateError();
if (fCpuAttached)
this, aCpu);
vrc);
return rc;
switch (mMachineState)
case MachineState_Running:
case MachineState_Teleporting:
case MachineState_Paused:
case MachineState_Saving:
return setInvalidMachineStateError();
return hrc;
int vrc;
vrc);
return rc;
return setInvalidMachineStateError();
vrc);
return rc;
return setInvalidMachineStateError();
bool handled = false;
vrc);
return rc;
bool entered = false;
return S_OK;
return setInvalidMachineStateError();
vrc);
return rc;
bool fBeganSavingState = false;
bool fTaskCreationFailed = false;
fTaskCreationFailed = true;
fBeganSavingState = true;
if (fBeganSavingState)
Resume();
return rc;
tr("Cannot adopt the saved machine state as the machine is not in Powered Off, Teleported or Aborted state (machine state: %s)"),
return rc;
if (!pLed)
return u32;
switch (aDeviceType)
case DeviceType_Floppy:
case DeviceType_DVD:
case DeviceType_HardDisk:
case DeviceType_Network:
case DeviceType_USB:
case DeviceType_SharedFolder:
case PDMLED_READING:
case PDMLED_WRITING:
return S_OK;
#ifdef VBOX_WITH_USB
return rc;
#ifdef VBOX_WITH_USB
++ it;
if (!device)
return rc2;
return rc;
#ifdef VBOX_WITH_USB
aAddress);
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
return E_NOTIMPL;
tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %s)"),
aName);
if ( mpVM
&& m_pVMMDev
return rc;
tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %s)"),
if ( mpVM
&& m_pVMMDev
return rc;
return rc;
for (size_t i = 0;
return rc;
++cOperations;
// b) one extra sub-operations for online snapshots OR offline snapshots that have a saved state (needs to be copied)
bool fTakingSnapshotOnline = ((mMachineState == MachineState_Running) || (mMachineState == MachineState_Paused));
LogFlowFunc(("fTakingSnapshotOnline = %d, mMachineState = %d\n", fTakingSnapshotOnline, mMachineState));
++cOperations;
return rc;
return E_OUTOFMEMORY;
(void*)pTask,
vrc);
delete pTask;
return rc;
return S_OK;
return S_OK;
return rc;
AssertFailed();
return E_FAIL;
switch (enmCtrlType)
return NULL;
HRESULT Console::convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun)
switch (enmBus)
case StorageBus_IDE:
case StorageBus_Floppy:
return S_OK;
case StorageBus_SATA:
case StorageBus_SCSI:
case StorageBus_SAS:
return S_OK;
uLun = 0;
if (pMedium)
&pReq,
fForce);
return S_OK;
if (!pMedium)
vrc);
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fForce)
bool fResume;
switch (enmVMState)
case VMSTATE_RESETTING:
case VMSTATE_RUNNING:
fResume = true;
case VMSTATE_SUSPENDED:
case VMSTATE_CREATED:
case VMSTATE_OFF:
fResume = false;
case VMSTATE_RUNNING_LS:
pVM,
if (fResume)
return rcRet;
if (mpVM)
switch (adapterType)
#ifdef VBOX_WITH_E1000
#ifdef VBOX_WITH_VIRTIO
AssertFailed();
if (pINetCfg)
#ifdef VBOX_DYNAMIC_NET_ATTACH
if ( enmVMState == VMSTATE_RUNNING /** @todo LiveMigration: Forbid or deal correctly with the _LS variants */
return rc;
#ifdef VBOX_DYNAMIC_NET_ATTACH
unsigned uInstance,
unsigned uLun,
return S_OK;
vrc);
const char *pszDevice,
unsigned uInstance,
unsigned uLun,
&& (uLun == 0)
bool fResume;
switch (enmVMState)
case VMSTATE_RESETTING:
case VMSTATE_RUNNING:
fResume = true;
case VMSTATE_SUSPENDED:
case VMSTATE_CREATED:
case VMSTATE_OFF:
fResume = false;
rcRet = pThis->configNetwork(pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst, true);
if (fResume)
return rcRet;
if (mpVM)
return rc;
if (mpVM)
return rc;
if (mpVM)
return rc;
if (mpVM)
return rc;
if (mpVM)
if (aRemove)
return rc;
if (mpVM)
return rc;
if ( mVRDPServer
if (aRestart)
if (vrdpEnabled)
return rc;
if (mpVM)
return rc;
if (aGlobal)
return rc;
HRESULT Console::onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs)
#ifdef VBOX_WITH_USB
return S_OK;
return E_FAIL;
return rc;
return E_FAIL;
#ifdef VBOX_WITH_USB
++ it;
return S_OK;
return rc;
return E_FAIL;
#ifndef VBOX_WITH_GUEST_PROPS
return E_INVALIDARG;
return E_POINTER;
return E_POINTER;
return E_POINTER;
using namespace guestProp;
vrc);
return rc;
#ifndef VBOX_WITH_GUEST_PROPS
return E_INVALIDARG;
return E_INVALIDARG;
return E_INVALIDARG;
using namespace guestProp;
vrc);
return rc;
#ifndef VBOX_WITH_GUEST_PROPS
return E_POINTER;
return E_POINTER;
return E_POINTER;
return E_POINTER;
return E_POINTER;
if (pProgress)
switch (mMachineState)
return setInvalidMachineStateError();
if (pMedium)
unsigned uLUN;
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
pVM,
&rc);
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
if (pIBase)
if (!pIMedium)
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
pVM,
&rc);
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
return rc;
, E_FAIL);
#ifdef RT_OS_WINDOWS
CONSOLE_DO_CALLBACKS7(OnMousePointerShapeChanged, fVisible, fAlpha, xHot, yHot, width, height, pShape);
CONSOLE_DO_CALLBACKS8(OnMousePointerShapeChanged, fVisible, fAlpha, xHot, yHot, width, height, pShapeSize, pShape);
void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
CONSOLE_DO_CALLBACKS3(OnMouseCapabilityChanged, supportsAbsolute, supportsRelative, needsHostCursor);
* Additions are available (via VBoxTray/VBoxClient).
*aWinId = 0;
if (aCheck)
if (fDelivered)
if (aCanShowEvent)
if (fDelivered)
if (aShowEvent)
return S_OK;
if (mVMDestroying)
++mVMCallers;
return S_OK;
--mVMCallers;
if (cHistoryFiles)
#ifdef VBOX_BLEEDING_EDGE
#ifdef VBOX_OSE
RTProcSelf(),
return hrc;
return E_POINTER;
++slot)
if (!enabled)
switch (netattach)
#ifdef RT_OS_WINDOWS
tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). Delete the saved state prior to starting the VM"),
#if 0 /** @todo we should save it afterwards, but that isn't necessarily a good idea. Find a better place for this (VBoxSVC). */
if (fTeleporterEnabled)
else if (fTeleporterEnabled)
else if (fFaultToleranceSyncEnabled)
if (fTeleporterEnabled)
NULL);
NULL);
return rc;
return rc;
return rc;
if (fCanceled)
if (pCurrentSnapshot)
if (!fCurrentSnapshotIsOnline)
for (size_t i = 0;
if (autoReset)
LogFlowThisFunc(("Machine has a current snapshot which is online, skipping immutable images reset\n"));
#ifdef RT_OS_SOLARIS
HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpEnabled").raw(), value.asOutParam());
mMachine->GetExtraData(Bstr("VBoxInternal2/CoreDumpReplaceSystemDump").raw(), coreDumpReplaceSys.asOutParam());
if ( pszDumpDir
int vrc;
if ( pszDumpDir
return setError(E_FAIL, "Failed to setup CoreDumper. Couldn't create dump directory '%s' (%Rrc)\n", pszDumpDir, vrc);
LogRel(("CoreDumper setup successful. pszDumpDir=%s fFlags=%#x\n", pszDumpDir ? pszDumpDir : ".", fCoreFlags));
if (aProgress)
else if (fTeleporterEnabled)
return S_OK;
LogRel(("Console::powerDown(): A request to power off the VM has been issued (mMachineState=%s, InUninit=%d)\n",
if ( !mVMPoweredOff
mVMPoweredOff = true;
if (mConsoleVRDPServer)
if (aProgress)
mVMDestroying = true;
if (mVMCallers > 0)
mVMCallers));
if (aProgress)
if (!mVMPoweredOff)
mVMPoweredOff = false;
if (aProgress)
#ifdef VBOX_WITH_HGCM
if (m_pVMMDev)
if (aProgress)
bool fHasUSBController = false;
fHasUSBController = true;
if (aProgress)
vrc);
if (fHasUSBController)
if (aProgress)
vrc);
mVMDestroying = false;
if (aProgress)
return rc;
Global::stringifyMachineState(mMachineState), Global::stringifyMachineState(aMachineState), aUpdateServer));
if (aUpdateServer)
return rc;
return S_OK;
if (aSetError)
aName);
return VBOX_E_FILE_ERROR;
&& m_pVMMDev
if (aGlobal)
if (online)
mMachineSharedFolders.insert(std::make_pair(name, SharedFolderData(hostPath, writable, autoMount)));
if (online)
autoMount));
if (online)
return rc;
return S_OK;
return S_OK;
void *aUser)
switch (aState)
case VMSTATE_OFF:
case VMSTATE_TERMINATED:
if (aVM)
AssertFailed();
case MachineState_Stopping:
case MachineState_Saving:
case MachineState_Starting:
case MachineState_Restoring:
case VMSTATE_SUSPENDED:
case MachineState_Teleporting:
case MachineState_Saving:
case MachineState_Restoring:
case MachineState_Stopping:
case MachineState_Running:
case MachineState_Paused:
case VMSTATE_SUSPENDED_LS:
case VMSTATE_SUSPENDED_EXT_LS:
case MachineState_Teleporting:
case MachineState_Saving:
AssertMsgFailed(("%s/%s -> %s\n", Global::stringifyMachineState(that->mMachineState), VMR3GetStateName(aOldState), VMR3GetStateName(aState) ));
case VMSTATE_RUNNING:
case VMSTATE_RUNNING_LS:
("%s/%s -> %s\n", Global::stringifyMachineState(that->mMachineState), VMR3GetStateName(aOldState), VMR3GetStateName(aState) ));
case VMSTATE_RUNNING_FT:
("%s/%s -> %s\n", Global::stringifyMachineState(that->mMachineState), VMR3GetStateName(aOldState), VMR3GetStateName(aState) ));
case VMSTATE_FATAL_ERROR:
case VMSTATE_GURU_MEDITATION:
#ifdef VBOX_WITH_USB
/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
switch (vrc)
case VERR_VUSB_NO_PORTS:
vrc);
return hrc;
DECLCALLBACK(int)
Console::usbAttachCallback(Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote, const char *aAddress, ULONG aMaskedIfs)
if (aRemote)
pvRemoteBackend = that->consoleVRDPServer()->USBBackendRequestPointer(pRemoteUSBDevice->clientId(), &guid);
if (!pvRemoteBackend)
return vrc;
/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
return S_OK;
DECLCALLBACK(int)
if (fRemote)
return vrc;
# ifdef VBOX_STRICT
# ifdef RT_OS_LINUX
memcpy(IfReq.ifr_name, str.c_str(), sizeof(IfReq.ifr_name) - 1); /** @todo bitch about names which are too long... */
if (rcVBox != 0)
LogRel(("Configuration error: Failed to configure /dev/net/tun non blocking. Error: %s\n", strerror(iErr)));
switch (rcVBox)
case VERR_ACCESS_DENIED:
rcVBox);
switch (rcVBox)
case VERR_ACCESS_DENIED:
return rc;
# ifdef VBOX_STRICT
bool isStatic = true;
isStatic = false;
if (isStatic)
return rc;
if (!enabled)
return rc;
return VINF_SUCCESS;
const char *pszErrorId,
void Console::processRemoteUSBDevices(uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList)
LogFlowThisFunc(("u32ClientId = %d, pDevList=%p, cbDevList = %d\n", u32ClientId, pDevList, cbDevList));
++it)
bool fNewDevice = true;
++it)
fNewDevice = false;
if (fNewDevice)
if (fMatched)
++ it;
if (!device)
if (pVM)
#if defined(RT_OS_WINDOWS)
#ifdef VBOX_WITH_VRDP
switch (vrc)
case VERR_FILE_NOT_FOUND:
vrc);
&pVM);
#ifdef VBOX_WITH_VRDP
if (machineDebugger)
++it)
/* -> ConsoleImplTeleporter.cpp */
bool fPowerOffOnFailure;
vrc = FTMR3PowerOn(pVM, (task->mEnmFaultToleranceState == FaultToleranceState_Master) /* fMaster */, uInterval, pszAddress, uPort, pszPassword);
vrc);
* need to go back to the PoweredOff/Saved state. Reuse
console);
#if defined(RT_OS_WINDOWS)
return VINF_SUCCESS;
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
int rc;
#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); return rc; } } while (0)
#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc (%#x)\n", hrc, hrc)); *phrc = hrc; return VERR_GENERAL_FAILURE; } } while (0)
return VINF_SUCCESS;
phrc,
pVM,
RC_CHECK();
#undef H
return VINF_SUCCESS;
bool fBeganTakingSnapshot = false;
bool fSuspenededBySave = false;
throw rc;
fBeganTakingSnapshot = true;
(void*)pTask,
throw rc;
for (size_t i = 0;
throw rc;
throw rc;
throw rc;
throw rc;
throw rc;
throw rc;
that,
atts[i],
&rc);
throw rc;
LogFlowFunc(("EndTakingSnapshot -> %Rhrc [mMachineState=%s]\n", rc, Global::stringifyMachineState(that->mMachineState)));
if (fBeganTakingSnapshot)
LogFunc(("Caught %Rhrc [mMachineState=%s]\n", rc, Global::stringifyMachineState(that->mMachineState)));
switch (enmVMState)
case VMSTATE_RUNNING:
case VMSTATE_RUNNING_LS:
case VMSTATE_DEBUGGING:
case VMSTATE_DEBUGGING_LS:
case VMSTATE_POWERING_OFF:
case VMSTATE_POWERING_OFF_LS:
case VMSTATE_RESETTING:
case VMSTATE_RESETTING_LS:
case VMSTATE_GURU_MEDITATION:
case VMSTATE_FATAL_ERROR:
case VMSTATE_FATAL_ERROR_LS:
case VMSTATE_SUSPENDED:
case VMSTATE_SUSPENDED_LS:
case VMSTATE_SUSPENDING:
case VMSTATE_SUSPENDING_LS:
if (fSuspenededBySave)
delete pTask;
return VINF_SUCCESS;
bool fSuspenededBySave;
return VINF_SUCCESS;
return VINF_SUCCESS;
typedef struct DRVMAINSTATUS
return NULL;
while (iLed-- > 0)
return rc;
return rc;
return rc;
AssertMsgFailed(("Configuration error: Invalid unit range %u-%u\n", pData->iFirstLUN, pData->iLastLUN));
return VERR_GENERAL_FAILURE;
return VINF_SUCCESS;
sizeof(DRVMAINSTATUS),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,