ConsoleImpl.cpp revision 35b7a9989091d3faedc945a631950710d185986b
de4157257515400c2c25373591135f110227b68cvboxsync * VBox Console COM Class implementation
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * Copyright (C) 2006-2011 Oracle Corporation
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * available from http://www.virtualbox.org. This file is free software;
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * General Public License (GPL) as published by the Free Software
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b263fac6f6e7fa933c7bfb2a45d598fe8e458c09vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
de4157257515400c2c25373591135f110227b68cvboxsync/** @todo Move the TAP mess back into the driver! */
3b1c0519f63fdaa66ef4bd15f98ff37726c65155vboxsync// generated header
184ef19339e2cb26840653f353296c47fb2a8895vboxsync// VMTask and friends
de4157257515400c2c25373591135f110227b68cvboxsync////////////////////////////////////////////////////////////////////////////////
be6a7ee8f237a71cf075c128e8e391e6c3654687vboxsync * Task structure for asynchronous VM operations.
de4157257515400c2c25373591135f110227b68cvboxsync * Once created, the task structure adds itself as a Console caller. This means:
de4157257515400c2c25373591135f110227b68cvboxsync * 1. The user must check for #rc() before using the created structure
184ef19339e2cb26840653f353296c47fb2a8895vboxsync * (e.g. passing it as a thread function argument). If #rc() returns a
184ef19339e2cb26840653f353296c47fb2a8895vboxsync * failure, the Console object may not be used by the task (see
7d4e1fc3835655581f938a1a387bc32049de8150vboxsync * Console::addCaller() for more details).
7d4e1fc3835655581f938a1a387bc32049de8150vboxsync * 2. On successful initialization, the structure keeps the Console caller
de4157257515400c2c25373591135f110227b68cvboxsync * until destruction (to ensure Console remains in the Ready state and won't
0e17b29891cd74ccbd23b28441e92ae817c2edefvboxsync * be accidentally uninitialized). Forgetting to delete the created task
be6a7ee8f237a71cf075c128e8e391e6c3654687vboxsync * will lead to Console::uninit() stuck waiting for releasing all added
58e7c901bdf9c8c46e6e20a8e8b99a84e206ddf4vboxsync * If \a aUsesVMPtr parameter is true, the task structure will also add itself
58e7c901bdf9c8c46e6e20a8e8b99a84e206ddf4vboxsync * as a Console::mpUVM caller with the same meaning as above. See
58e7c901bdf9c8c46e6e20a8e8b99a84e206ddf4vboxsync * Console::addVMCaller() for more info.
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync /** Releases the VM caller before destruction. Not normally necessary. */
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync : VMTask(aConsole, aProgress, NULL /* aServerProgress */,
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync false /* aUsesVMPtr */),
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync Bstr bstrSavedStateFile; // received from BeginTakeSnapshot()
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync : VMTask(aConsole, aProgress, NULL /* aServerProgress */,
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsync false /* aUsesVMPtr */),
de4157257515400c2c25373591135f110227b68cvboxsync mEnmFaultToleranceState(FaultToleranceState_Inactive)
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsync /* array of progress objects for hard disk reset operations */
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsync typedef std::list<ComPtr<IProgress> > ProgressList;
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync : VMTask(aConsole, NULL /* aProgress */, aServerProgress,
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync true /* aUsesVMPtr */)
3836fdf773a1d1ad60a8ad35465259a78b9dc062vboxsync : VMTask(aConsole, NULL /* aProgress */, aServerProgress,
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync true /* aUsesVMPtr */),
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync// Handler for global events
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync////////////////////////////////////////////////////////////////////////////////
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsyncinline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType);
40295ab70cb24d4b45580b9e03766935cca282abvboxsync STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
40295ab70cb24d4b45580b9e03766935cca282abvboxsync rc = pMachine->COMGETTER(Id)(interestedId.asOutParam());
6db5dfa0985f898dd0497d98716b6d0335a9dde4vboxsync /* now we can operate with redirects */
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync mConsole->onNATRedirectRuleChange(ulSlot, fRemove, proto, hostIp.raw(), hostPort, guestIp.raw(), guestPort);
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsync // handle if needed
f3aabbf17ef1f076732e76f50abafaa4c28551d9vboxsynctypedef ListenerImpl<VmEventListener, Console*> VmEventListenerImpl;
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync// constructor / destructor
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync/////////////////////////////////////////////////////////////////////////////
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync meAttachmentType[slot] = NetworkAttachmentType_Null;
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsync memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
8796769239832e686064138005dd1b45f038348bvboxsync for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++ i)
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync VMM2USERMETHODS *pVmm2UserMethods = (VMM2USERMETHODS *)RTMemAlloc(sizeof(*mpVmm2UserMethods) + sizeof(Console *));
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync pVmm2UserMethods->u32Magic = VMM2USERMETHODS_MAGIC;
7dd5b2ea2a3826ec17c0739510c1e826490d1e76vboxsync pVmm2UserMethods->u32Version = VMM2USERMETHODS_VERSION;
d03529f7488e26f644d57a8d7daebde5b497fa72vboxsync pVmm2UserMethods->pfnSaveState = Console::vmm2User_SaveState;
d03529f7488e26f644d57a8d7daebde5b497fa72vboxsync pVmm2UserMethods->u32EndMagic = VMM2USERMETHODS_MAGIC;
7dd5b2ea2a3826ec17c0739510c1e826490d1e76vboxsync *(Console **)(pVmm2UserMethods + 1) = this; /* lazy bird. */
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync// public initializer/uninitializer for internal purposes only
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsync/////////////////////////////////////////////////////////////////////////////
7519a1c4323fa86fbb19a36a91cd25abfd7af714vboxsyncHRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl)
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync /* Enclose the state transition NotReady->InInit->Ready */
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync LogFlowThisFunc(("aMachine=%p, aControl=%p\n", aMachine, aControl));
9ab5fb4455f72f3d979ff63e8789cb3241b80b52vboxsync /* Cache essential properties and objects */
9ab5fb4455f72f3d979ff63e8789cb3241b80b52vboxsync rc = mMachine->COMGETTER(VRDEServer)(unconst(mVRDEServer).asOutParam());
9ab5fb4455f72f3d979ff63e8789cb3241b80b52vboxsync /* Create associated child COM objects */
9ab5fb4455f72f3d979ff63e8789cb3241b80b52vboxsync // Event source may be needed by other children
9ab5fb4455f72f3d979ff63e8789cb3241b80b52vboxsync rc = mEventSource->init(static_cast<IConsole*>(this));
40295ab70cb24d4b45580b9e03766935cca282abvboxsync rc = mptrExtPackManager->initExtPackManager(NULL, VBOXEXTPACKCTX_VM_PROCESS);
40295ab70cb24d4b45580b9e03766935cca282abvboxsync /* Grab global and machine shared folder lists */
40295ab70cb24d4b45580b9e03766935cca282abvboxsync /* Create other child objects */
40295ab70cb24d4b45580b9e03766935cca282abvboxsync unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this);
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // VirtualBox 4.0: We no longer initialize the VMMDev instance here,
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // which starts the HGCM thread. Instead, this is now done in the
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // power-up thread when a VM is actually being powered up to avoid
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // having HGCM threads all over the place every time a session is
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // opened, even if that session will not run a VM.
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // unconst(m_pVMMDev) = new VMMDev(this);
40295ab70cb24d4b45580b9e03766935cca282abvboxsync // AssertReturn(mVMMDev, E_FAIL);
40295ab70cb24d4b45580b9e03766935cca282abvboxsync /* VirtualBox events registration. */
40295ab70cb24d4b45580b9e03766935cca282abvboxsync rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
7dd5b2ea2a3826ec17c0739510c1e826490d1e76vboxsync rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync eventTypes.push_back(VBoxEventType_OnHostPciDevicePlug);
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync rc = pES->RegisterListener(aVmListener, ComSafeArrayAsInParam(eventTypes), true);
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync /* Confirm a successful initialization when it's the case */
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync /* Let the extension packs have a go at things (hold no locks). */
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync mptrExtPackManager->callAllConsoleReadyHooks(this);
becf3c759c574f9450ebc8b558c1cca8dc8b944bvboxsync * Uninitializes the Console object.
2ff8e2b6836f4ddd408f5bf0b4377d566c55a46fvboxsync /* Enclose the state transition Ready->InUninit->NotReady */
7dd5b2ea2a3826ec17c0739510c1e826490d1e76vboxsync LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
19d5b809210ca8f1ab03a31f36eb28235621350bvboxsync HRESULT rc = mMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
19d5b809210ca8f1ab03a31f36eb28235621350bvboxsync rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());
19d5b809210ca8f1ab03a31f36eb28235621350bvboxsync /* power down the VM if necessary */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync // if the VM had a VMMDev with an HGCM thread, then remove that here
if (mDisplay)
if (mMouse)
if (mKeyboard)
if (mGuest)
if (mConsoleVRDPServer)
delete mConsoleVRDPServer;
#ifdef VBOX_WITH_GUEST_PROPS
void Console::guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
if (!guestPropertiesVRDPEnabled())
if (!guestPropertiesVRDPEnabled())
#ifdef VBOX_WITH_EXTPACK
return mptrExtPackManager;
int Console::VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
return VERR_ACCESS_DENIED;
switch (authType)
case AuthType_Null:
case AuthType_External:
result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
case AuthType_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)
case AuthGuestAccessGranted:
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;
if ( (u32Clients == 0)
mcAudioRefs--;
if (mcAudioRefs <= 0)
if (mAudioSniffer)
if (port)
#ifdef VBOX_WITH_GUEST_PROPS
if (u32Clients == 0)
mcGuestCredentialsProvided = false;
++mcAudioRefs;
if (mAudioSniffer)
if (port)
switch (adapterType)
#ifdef VBOX_WITH_E1000
#ifdef VBOX_WITH_VIRTIO
AssertFailed();
return NULL;
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;
STDMETHODIMP Console::COMGETTER(AttachedPciDevices)(ComSafeArrayOut(IPciDeviceAttachment *, aAttachments))
if (mBusMgr)
return S_OK;
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:
bool fBeganPowerDown = false;
fBeganPowerDown = true;
if (fBeganPowerDown)
return rc;
return setInvalidMachineStateError();
vrc);
return rc;
return vrc;
return setInvalidMachineStateError();
return rc;
if (!fCpuAttached)
bool fLocked = true;
} while (cTries-- > 0);
return rc;
return VINF_SUCCESS;
return setInvalidMachineStateError();
if (fCpuAttached)
vrc);
return rc;
switch (mMachineState)
case MachineState_Running:
case MachineState_Teleporting:
case MachineState_Paused:
case MachineState_Saving:
return setInvalidMachineStateError();
return hrc;
#ifdef VBOX_WITH_EXTPACK
int vrc = mptrExtPackManager->callAllVmPowerOnHooks(this, ptrVM); /** @todo called a few times too many... */
vrc);
return rc;
return setInvalidMachineStateError();
if (pPort)
vrc);
return rc;
return setInvalidMachineStateError();
if (pPort)
bool fHandled = false;
vrc);
return rc;
if (pPort)
bool fEntered = false;
return S_OK;
return setInvalidMachineStateError();
if (pPort)
vrc);
return rc;
return rc;
bool fBeganSavingState = false;
bool fTaskCreationFailed = false;
fBeganSavingState = true;
fTaskCreationFailed = 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
#ifdef VBOX_WITH_USB
++ it;
if (!pUSBDevice)
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)"),
&& m_pVMMDev
return rc;
return rc;
return rc;
tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %s)"),
&& 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)
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,
pVM,
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:
case VMSTATE_RUNNING_FT:
(enmVMState == VMSTATE_RUNNING_LS) ? Utf8Str(tr("Cannot change drive during live migration")) : Utf8Str(tr("Cannot change drive during fault tolerant syncing")),
pVM,
if (fResume)
return rcRet;
if (pINetCfg)
if ( enmVMState == VMSTATE_RUNNING /** @todo LiveMigration: Forbid or deal correctly with the _LS variants */
return rc;
while (pBase)
if (pNetNatCfg)
if (!pNetNatCfg)
return rc;
const char *pszDevice,
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;
if (fResume)
return rcRet;
return rc;
return rc;
return rc;
return rc;
if (aRemove)
return rc;
return rc;
if ( mVRDEServer
if (aRestart)
if (vrdpEnabled)
return rc;
return rc;
fireSharedFolderChangedEvent(mEventSource, aGlobal ? (Scope_T)Scope_Global : (Scope_T)Scope_Machine);
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;
int vrc;
return rc;
#ifndef VBOX_WITH_GUEST_PROPS
return E_INVALIDARG;
return E_POINTER;
return E_POINTER;
return E_POINTER;
using namespace guestProp;
if (aTimestamp)
if (aFlags)
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;
&rc);
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
if (pIBase)
if (!pIMedium)
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
&rc);
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
return rc;
, E_FAIL);
fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayInArg(pShape));
void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
* Additions are available (via VBoxTray/VBoxClient).
*aWinId = 0;
if (aCheck)
if (fDelivered)
if (pCanShowEvent)
if (fDelivered)
if (pShowEvent)
return S_OK;
if (mVMDestroying)
++mVMCallers;
return S_OK;
--mVMCallers;
return a_Quiet
if (!pUVM)
return a_Quiet
return a_Quiet
if (!pVM)
return a_Quiet
return S_OK;
if (cHistoryFiles)
#ifdef VBOX_BLEEDING_EDGE
#ifdef VBOX_OSE
RTProcSelf(),
return hrc;
bool fBeganPoweringUp = false;
throw rc;
#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)
throw rc;
throw rc;
else if (fTeleporterEnabled)
else if (fFaultToleranceSyncEnabled)
if (fTeleporterEnabled)
NULL);
NULL);
throw rc;
throw rc;
fBeganPoweringUp = true;
++slot)
if (!enabled)
switch (netattach)
throw rc;
++it)
++it)
++it)
throw rc;
tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). Delete the saved state prior to starting the VM"),
throw rc;
if (fCanceled)
throw rc;
if (pCurrentSnapshot)
throw rc;
if (!fCurrentSnapshotIsOnline)
throw rc;
for (size_t i = 0;
throw rc;
throw rc;
if (autoReset)
throw rc;
LogFlowThisFunc(("Machine has a current snapshot which is online, skipping immutable images reset\n"));
throw rc;
#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
throw 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 rc;
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)
#ifdef VBOX_WITH_EXTPACK
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;
return rc;
Global::stringifyMachineState(mMachineState), Global::stringifyMachineState(aMachineState), aUpdateServer));
if (aUpdateServer)
return rc;
return S_OK;
if (aSetError)
return VBOX_E_FILE_ERROR;
&& m_pVMMDev
if (aGlobal)
if (online)
if (online)
autoMount));
if (online)
if (online)
return rc;
sizeof(hostPathFull));
return S_OK;
return S_OK;
void *aUser)
switch (aState)
case VMSTATE_OFF:
pProgress));
case VMSTATE_TERMINATED:
if (aVM)
AssertFailed();
case MachineState_Stopping:
case MachineState_Saving:
case MachineState_Starting:
case MachineState_Restoring:
case VMSTATE_RESETTING:
#ifdef VBOX_WITH_GUEST_PROPS
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, PVM pVM, 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;
if (pProgress)
return VINF_SUCCESS;
const char *pszErrorId,
void Console::processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *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 (!pUSBDevice)
if (pVM)
#if defined(RT_OS_WINDOWS)
switch (vrc)
case VERR_FILE_NOT_FOUND:
vrc);
&pVM);
if (machineDebugger)
++it)
"The shared folder setup will not be complete. It is recommended to power down the virtual machine and "
#ifdef VBOX_WITH_EXTPACK
#ifdef VBOX_WITH_EXTPACK
/* -> ConsoleImplTeleporter.cpp */
bool fPowerOffOnFailure;
#ifdef VBOX_WITH_EXTPACK
#ifdef VBOX_WITH_EXTPACK
#ifdef VBOX_WITH_EXTPACK
vrc);
* need to go back to the PoweredOff/Saved state. Reuse
pConsole);
#if defined(RT_OS_WINDOWS)
return VINF_SUCCESS;
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fBuiltinIoCache,
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;
throw rc;
for (size_t i = 0;
throw rc;
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,