ConsoleImpl.cpp revision e67c6527ea1482264eb46a12493f9a0a4bcf4690
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * VBox Console COM Class implementation
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * available from http://www.virtualbox.org. This file is free software;
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * you can redistribute it and/or modify it under the terms of the GNU
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * General Public License (GPL) as published by the Free Software
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1c94c0a63ba68be1a7b2c640e70d7a06464e4fcavboxsync * additional information or have any questions.
456f370fcde010d585d9174df045978a6c9893c1vboxsync/** @todo Move the TAP mess back into the driver! */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync// generated header
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync// VMTask and friends
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync////////////////////////////////////////////////////////////////////////////////
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * Task structure for asynchronous VM operations.
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * Once created, the task structure adds itself as a Console caller. This means:
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * 1. The user must check for #rc() before using the created structure
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * (e.g. passing it as a thread function argument). If #rc() returns a
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * failure, the Console object may not be used by the task (see
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * Console::addCaller() for more details).
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * 2. On successful initialization, the structure keeps the Console caller
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * until destruction (to ensure Console remains in the Ready state and won't
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * be accidentally uninitialized). Forgetting to delete the created task
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * will lead to Console::uninit() stuck waiting for releasing all added
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * If \a aUsesVMPtr parameter is true, the task structure will also add itself
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * as a Console::mpVM caller with the same meaning as above. See
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * Console::addVMCaller() for more info.
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /** Releases the VM caller before destruction. Not normally necessary. */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync : VMProgressTask(aConsole, aProgress, false /* aUsesVMPtr */),
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync Bstr bstrSavedStateFile; // received from BeginTakeSnapshot()
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync : VMProgressTask(aConsole, aProgress, false /* aUsesVMPtr */),
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* array of progress objects for hard disk reset operations */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync typedef std::list< ComPtr<IProgress> > ProgressList;
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync : VMProgressTask(aConsole, aProgress, true /* aUsesVMPtr */),
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync// constructor / destructor
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync/////////////////////////////////////////////////////////////////////////////
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync meAttachmentType[slot] = NetworkAttachmentType_Null;
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++ i)
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync// public initializer/uninitializer for internal purposes only
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync/////////////////////////////////////////////////////////////////////////////
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsyncHRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl)
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Enclose the state transition NotReady->InInit->Ready */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync LogFlowThisFunc(("aMachine=%p, aControl=%p\n", aMachine, aControl));
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Cache essential properties and objects */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync rc = mMachine->COMGETTER(VRDPServer)(unconst(mVRDPServer).asOutParam());
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Create associated child COM objects */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Grab global and machine shared folder lists */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Create other child objects */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this);
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Confirm a successful initialization when it's the case */
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync * Uninitializes the Console object.
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync /* Enclose the state transition Ready->InUninit->NotReady */
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync * Uninit all children that use addDependentChild()/removeDependentChild()
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync * in their init()/uninit() methods.
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync /* power down the VM if necessary */
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync /* Release all callbacks. Do this after uninitializing the components,
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync * as some of them are well-behaved and unregister their callbacks.
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync * These would trigger error messages complaining about trying to
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync * unregister a non-registered callback. */
771761cda2c81e899526a0dce22c8cd2510fff82vboxsync /* dynamically allocated members of mCallbackData are uninitialized
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync * at the end of powerDown() */
df3d4c8e9c81584c535676a3d40c57d868ac61bbvboxsync Assert(!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
f902ede7eb073d09a81c1d470c089c7b14921714vboxsync HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP"), value.asOutParam());
22e47c581ecabc66ee210e93099727074f74b2b9vboxsync return true;
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync return false;
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsyncvoid Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
7bff28e0cedd8656acd24b420759649184d8cf00vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync mRemoteDisplayInfo->COMGETTER(ClientName)(clientName.asOutParam());
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), clientName, Bstr("RDONLYGUEST"));
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(pszUser), Bstr("RDONLYGUEST"));
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(pszDomain), Bstr("RDONLYGUEST"));
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId);
f4ccb18a71e0e531719734918583f84fbc72ebfevboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient"), Bstr(pszClientId), Bstr("RDONLYGUEST"));
13b516eac15d19e108e587a9d9ecc85e1961ac6dvboxsyncvoid Console::updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId)
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), bstrReadOnlyGuest);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
f4ccb18a71e0e531719734918583f84fbc72ebfevboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), bstrReadOnlyGuest);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
13b516eac15d19e108e587a9d9ecc85e1961ac6dvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), bstrReadOnlyGuest);
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId);
6e3cc82d5d5effda92c9fec18b870d54386f99favboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastDisconnectedClient"), Bstr(pszClientId), bstrReadOnlyGuest);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
f4ccb18a71e0e531719734918583f84fbc72ebfevboxsyncint Console::VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync LogFlowFunc(("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync /* Console has been already uninitialized, deny request */
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync LogRel(("VRDPAUTH: Access denied (Console uninitialized).\n"));
9a08dd6ed47cffa9cacbb9d53db1ce71d04db61fvboxsync HRESULT hrc = mMachine->COMGETTER(Id)(id.asOutParam());
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync hrc = mVRDPServer->COMGETTER(AuthTimeout)(&authTimeout);
1d258b8772ee104b5fab3d1743eabc2f5cfe2fa4vboxsync VRDPAuthGuestJudgement guestJudgement = VRDPAuthGuestNotAsked;
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync LogRel(("VRDPAUTH: User: [%s]. Domain: [%s]. Authentication type: [%s]\n",
f4ccb18a71e0e531719734918583f84fbc72ebfevboxsync "External":
76800c2d8e954bb5249d2d30f4af41c6ea03ad5evboxsync /* Call the external library. */
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync LogFlowFunc(("External auth asked for guest judgement\n"));
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync } /* pass through */
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync /* Issue the request to guest. Assume that the call does not require EMT. It should not. */
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync /* Ask the guest to judge these credentials. */
8dc3361c3de6b4f38230d57c547ab74b713f6ff1vboxsync uint32_t u32GuestFlags = VMMDEV_SETCREDENTIALS_JUDGE;
1ace73711fa06807748eff26632c7273a1f7c2dbvboxsync int rc = mVMMDev->getVMMDevPort()->pfnSetCredentials(mVMMDev->getVMMDevPort(),
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
&& mVMMDev)
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
#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;
delete[] buf;
delete[] buf;
return VINF_SUCCESS;
#ifdef VBOX_WITH_GUEST_PROPS
void *pvParms,
using namespace guestProp;
int rc;
flags);
LogFunc(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
return rc;
using namespace guestProp;
// parm[0].u.pointer.size = (uint32_t)utf8Patterns.length() + 1;
// parm[0].u.pointer.size = 1;
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 E_POINTER;
switch (mMachineState)
case MachineState_Running:
case MachineState_Paused:
case MachineState_Stuck:
case MachineState_Teleporting:
case MachineState_Saved:
case MachineState_Stopping:
return S_OK;
vrc);
return rc;
return vrc;
if (!fCpuAttached)
bool fLocked = true;
vrc = getVMMDev()->getVMMDevPort()->pfnCpuHotUnplug(getVMMDev()->getVMMDevPort(), idCpuCore, idCpuPackage);
} while (cTries-- > 0);
this, aCpu);
return rc;
return VINF_SUCCESS;
if (fCpuAttached)
this, aCpu);
vrc);
vrc = getVMMDev()->getVMMDevPort()->pfnCpuHotPlug(getVMMDev()->getVMMDevPort(), idCpuCore, idCpuPackage);
return rc;
switch (mMachineState)
case MachineState_Running:
case MachineState_Teleporting:
case MachineState_Paused:
case MachineState_Saving:
return hrc;
int vrc;
vrc);
return rc;
vrc);
return rc;
bool handled = false;
vrc);
return rc;
bool entered = false;
return S_OK;
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);
return rc;
tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %s)"),
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;
#if 0 /** @todo r=bird,r=pritesh: must check that the interface id match correct or we might screw up with old code! */
void *dummy;
return hrc;
return S_OK;
return S_OK;
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;
unsigned uInstance = 0;
unsigned uLun = 0;
uInstance = 0;
this, pszDevice, uInstance, uLun, !!fHostDrive, location.raw(), format.raw(), !!fPassthrough, fForce);
return S_OK;
vrc);
* @todo the error handling in this method needs to be improved seriously - what if mounting fails...
DECLCALLBACK(int) Console::changeDrive(Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun,
/// @todo change this to use the same code as in ConsoleImpl2.cpp
LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u fHostDrive=%d pszPath=%p:{%s} pszFormat=%p:{%s} fPassthrough=%d fForce=%d\n",
pThis, pszDevice, pszDevice, uInstance, uLun, fHostDrive, pszPath, pszPath, pszFormat, pszFormat, fPassthrough, 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:
indirectly modify the meDVDState/meFloppyState members (pointed to by
if (fHostDrive)
rc = CFGMR3InsertString(pLunL0, "Driver", !strcmp(pszDevice, "i82078") ? "HostFloppy" : "HostDVD"); RC_CHECK();
rc = CFGMR3InsertString(pCfg, "Type", !strcmp(pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK();
rc = PDMR3DeviceAttach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, &pBase); RC_CHECK();
if (!pIMount)
AssertFailed();
return rc;
if (fResume)
return rcRet;
if (!mpVM)
return S_OK;
switch (adapterType)
#ifdef VBOX_WITH_E1000
#ifdef VBOX_WITH_VIRTIO
AssertFailed();
if (pINetCfg)
#ifdef VBOX_DYNAMIC_NET_ATTACH
if ( enmVMState == VMSTATE_RUNNING /** @todo LiveMigration: Forbit 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 = configNetwork(pThis, pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst, true);
if (fResume)
return rcRet;
if (!mpVM)
return S_OK;
return rc;
if (!mpVM)
return S_OK;
return rc;
if (!mpVM)
return S_OK;
return rc;
if (!mpVM)
return S_OK;
return rc;
if (!mpVM)
return S_OK;
if (aRemove)
return rc;
if ( mVRDPServer
if (vrdpEnabled)
return rc;
if (!mpVM)
return S_OK;
return rc;
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;
, E_FAIL);
void *pShape)
if (!wasValid)
void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
*aWinId = 0;
if (aCheck)
return rc;
return rc;
if (*aWinId == 0)
return S_OK;
if (mVMDestroying)
++ mVMCallers;
return S_OK;
--mVMCallers;
if (uLogHistoryCount)
#ifdef VBOX_BLEEDING_EDGE
#ifdef VBOX_OSE
RTProcSelf(),
return hrc;
return E_POINTER;
++slot)
if (!enabled)
switch (netattach)
#ifdef RT_OS_WINDOWS
if (!hostif)
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)
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"));
if (aProgress)
E_FAIL);
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)
if (mVMCallers > 0)
mVMDestroying = true;
mVMCallers));
if (aProgress)
if (!mVMPoweredOff)
mVMPoweredOff = false;
if (aProgress)
#ifdef VBOX_WITH_HGCM
if (mVMMDev)
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;
if (aGlobal)
if (online)
if (online)
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 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_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.raw(), 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);
memcpy(szTapdev + strlen(szTapdev), str.raw(), sizeof(szTapdev) - strlen(szTapdev) - 1); /** @todo bitch about names which are too long... */
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 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 */
vrc);
* need to go back to the PoweredOff/Saved state. Reuse
console);
#if defined(RT_OS_WINDOWS)
return VINF_SUCCESS;
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)
unsigned iLUN;
AssertMsgReturn(pcszDevice, ("invalid disk controller type: %d\n", enmController), VERR_GENERAL_FAILURE);
return VINF_SUCCESS;
pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN);
pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/", pcszDevice, lInstance, iLUN);
if (!pLunL1)
#ifdef VBOX_STRICT
char *pszDriver;
bool fHostIP = true;
fHostIP = false;
fHostIP = false;
if (!fHostIP)
rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, iLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK();
return rc;
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;
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,