ConsoleImpl.cpp revision d5c3c56c4e25c8b737a8df2755bcbe44736653b0
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VBox Console COM Class implementation
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Copyright (C) 2005-2015 Oracle Corporation
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * available from http://www.virtualbox.org. This file is free software;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * General Public License (GPL) as published by the Free Software
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** @todo Move the TAP mess back into the driver! */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* VBOX_WITH_NETSHAPER */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync// VMTask and friends
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync////////////////////////////////////////////////////////////////////////////////
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Task structure for asynchronous VM operations.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Once created, the task structure adds itself as a Console caller. This means:
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * 1. The user must check for #rc() before using the created structure
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * (e.g. passing it as a thread function argument). If #rc() returns a
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * failure, the Console object may not be used by the task (see
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Console::addCaller() for more details).
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * 2. On successful initialization, the structure keeps the Console caller
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * until destruction (to ensure Console remains in the Ready state and won't
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * be accidentally uninitialized). Forgetting to delete the created task
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * will lead to Console::uninit() stuck waiting for releasing all added
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * If \a aUsesVMPtr parameter is true, the task structure will also add itself
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * as a Console::mpUVM caller with the same meaning as above. See
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Console::addVMCaller() for more info.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /** Releases the VM caller before destruction. Not normally necessary. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync : VMTask(aConsole, aProgress, NULL /* aServerProgress */,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync false /* aUsesVMPtr */),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync Bstr bstrSavedStateFile; // received from BeginTakeSnapshot()
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync : VMTask(aConsole, aProgress, NULL /* aServerProgress */,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync false /* aUsesVMPtr */),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mEnmFaultToleranceState(FaultToleranceState_Inactive)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* array of progress objects for hard disk reset operations */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync typedef std::list<ComPtr<IProgress> > ProgressList;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync : VMTask(aConsole, NULL /* aProgress */, aServerProgress,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync true /* aUsesVMPtr */)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync : VMTask(aConsole, NULL /* aProgress */, aServerProgress,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync true /* aUsesVMPtr */),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* The local machine state we had before. Required if something fails */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* The reason for saving state */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync// Handler for global events
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync////////////////////////////////////////////////////////////////////////////////
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncinline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync STDMETHOD(HandleEvent)(VBoxEventType_T aType, IEvent * aEvent)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = pMachine->COMGETTER(Id)(interestedId.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* now we can operate with redirects */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mConsole->i_onNATRedirectRuleChange(ulSlot, fRemove, proto, hostIp.raw(), hostPort, guestIp.raw(), guestPort);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case VBoxEventType_OnHostNameResolutionConfigurationChange:
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // handle if needed
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = pEDCEv->COMGETTER(MachineId)(strMachineId.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = pEDCEv->COMGETTER(Value)(strVal.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mConsole->i_onExtraDataChange(strMachineId.raw(), strKey.raw(), strVal.raw());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsynctypedef ListenerImpl<VmEventListener, Console*> VmEventListenerImpl;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync// constructor / destructor
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/////////////////////////////////////////////////////////////////////////////
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (unsigned i = 0; i < RT_ELEMENTS(maStorageDevType); ++i)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync MYVMM2USERMETHODS *pVmm2UserMethods = (MYVMM2USERMETHODS *)RTMemAllocZ(sizeof(*mpVmm2UserMethods) + sizeof(Console *));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->u32Magic = VMM2USERMETHODS_MAGIC;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->u32Version = VMM2USERMETHODS_VERSION;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnSaveState = Console::i_vmm2User_SaveState;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnNotifyEmtInit = Console::i_vmm2User_NotifyEmtInit;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnNotifyEmtTerm = Console::i_vmm2User_NotifyEmtTerm;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnNotifyPdmtInit = Console::i_vmm2User_NotifyPdmtInit;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnNotifyPdmtTerm = Console::i_vmm2User_NotifyPdmtTerm;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->pfnNotifyResetTurnedIntoPowerOff = Console::i_vmm2User_NotifyResetTurnedIntoPowerOff;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pVmm2UserMethods->u32EndMagic = VMM2USERMETHODS_MAGIC;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync MYPDMISECKEY *pIfSecKey = (MYPDMISECKEY *)RTMemAllocZ(sizeof(*mpIfSecKey) + sizeof(Console *));
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pIfSecKey->pfnKeyRetain = Console::i_pdmIfSecKey_KeyRetain;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pIfSecKey->pfnKeyRelease = Console::i_pdmIfSecKey_KeyRelease;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pIfSecKey->pfnPasswordRetain = Console::i_pdmIfSecKey_PasswordRetain;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pIfSecKey->pfnPasswordRelease = Console::i_pdmIfSecKey_PasswordRelease;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync MYPDMISECKEYHLP *pIfSecKeyHlp = (MYPDMISECKEYHLP *)RTMemAllocZ(sizeof(*mpIfSecKeyHlp) + sizeof(Console *));
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pIfSecKeyHlp->pfnKeyMissingNotify = Console::i_pdmIfSecKeyHlp_KeyMissingNotify;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync// public initializer/uninitializer for internal purposes only
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync/////////////////////////////////////////////////////////////////////////////
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsyncHRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType)
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Enclose the state transition NotReady->InInit->Ready */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync LogFlowThisFunc(("aMachine=%p, aControl=%p\n", aMachine, aControl));
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Cache essential properties and objects, and create child objects */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync rc = mptrExtPackManager->initExtPackManager(NULL, VBOXEXTPACKCTX_VM_PROCESS);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // Event source may be needed by other children
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Now the VM specific parts */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync rc = mMachine->COMGETTER(VRDEServer)(unconst(mVRDEServer).asOutParam());
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Grab global and machine shared folder lists */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Create other child objects */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync /* Figure out size of meAttachmentType vector */
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam());
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync for (ULONG slot = 0; slot < maxNetworkAdapters; ++slot)
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync meAttachmentType[slot] = NetworkAttachmentType_Null;
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // VirtualBox 4.0: We no longer initialize the VMMDev instance here,
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // which starts the HGCM thread. Instead, this is now done in the
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // power-up thread when a VM is actually being powered up to avoid
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // having HGCM threads all over the place every time a session is
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // opened, even if that session will not run a VM.
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // unconst(m_pVMMDev) = new VMMDev(this);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync // AssertReturn(mVMMDev, E_FAIL);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync mMachine->COMGETTER(FirmwareType)(&enmFirmwareType);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* VirtualBox events registration. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync eventTypes.push_back(VBoxEventType_OnHostNameResolutionConfigurationChange);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync eventTypes.push_back(VBoxEventType_OnHostPCIDevicePlug);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync eventTypes.push_back(VBoxEventType_OnExtraDataChanged);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = pES->RegisterListener(aVmListener, ComSafeArrayAsInParam(eventTypes), true);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Confirm a successful initialization when it's the case */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Let the extension packs have a go at things (hold no locks). */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mptrExtPackManager->i_callAllConsoleReadyHooks(this);
4f2b002896072b0b5a7cb566341c8bac5e69392bvboxsync * Uninitializes the Console object.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Enclose the state transition Ready->InUninit->NotReady */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT rc = mMachine->COMGETTER(Parent)(pVirtualBox.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* power down the VM if necessary */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // if the VM had a VMMDev with an HGCM thread, then remove that here
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (SecretKeyMap::iterator it = m_mapSecretKeys.begin();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // we don't perform uninit() as it's possible that some pending event refers to this source
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Handles guest properties on a VM reset.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * We must delete properties that are flagged TRANSRESET.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @todo r=bird: Would be more efficient if we added a request to the HGCM
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * service to do this instead of detouring thru VBoxSVC.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * (IMachine::SetGuestProperty ends up in VBoxSVC, which in turns calls
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * back into the VM process and the HGCM service.)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT hrc = i_enumerateGuestProperties("*", names, values, timestamps, flags);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Delete all properties which have the flag "TRANSRESET". */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if (flags[i].contains("TRANSRESET", Utf8Str::CaseInsensitive))
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = mMachine->DeleteGuestProperty(Bstr(names[i]).raw());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("RESET: Could not delete transient property \"%s\", rc=%Rhrc\n",
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("RESET: Unable to enumerate guest properties, rc=%Rhrc\n", hrc));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return true;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return false;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mVRDEServerInfo->COMGETTER(ClientName)(clientName.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szClientId, sizeof(szClientId), "%u", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szClientId, sizeof(szClientId), "%u", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/ActiveClient").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr)
751a35d04fb11f94562583ad77bc0a1382957f49vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/IPAddr", u32ClientId);
751a35d04fb11f94562583ad77bc0a1382957f49vboxsyncvoid Console::i_guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Location", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/OtherInfo", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Attach", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szPropNm, sizeof(szPropNm), "/VirtualBox/HostInfo/VRDP/Client/%u/Attach", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr(szPropNm).raw(), NULL,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync RTStrPrintf(szClientId, sizeof(szClientId), "%d", u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastDisconnectedClient").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/TurnResetIntoPowerOff").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return true;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return false;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Used by VRDEServer and others to talke to the extension pack manager.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * @returns The extension pack manager.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncint Console::i_VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Console has been already uninitialized, deny request */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("AUTH: Access denied (Console uninitialized).\n"));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT hrc = mMachine->COMGETTER(Id)(id.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = mVRDEServer->COMGETTER(AuthTimeout)(&authTimeout);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync AuthGuestJudgement guestJudgement = AuthGuestNotAsked;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("AUTH: User: [%s]. Domain: [%s]. Authentication type: [%s]\n",
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "External":
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Call the external library. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("External auth asked for guest judgement\n"));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync } /* pass through */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync // @todo r=dj locking required here for m_pVMMDev?
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Issue the request to guest. Assume that the call does not require EMT. It should not. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Ask the guest to judge these credentials. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32_t u32GuestFlags = VMMDEV_SETCREDENTIALS_JUDGE;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int rc = pDevPort->pfnSetCredentials(pDevPort, pszUser, pszPassword, pszDomain, u32GuestFlags);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Wait for guest. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = m_pVMMDev->WaitCredentialsJudgement(authTimeout, &u32GuestFlags);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync switch (u32GuestFlags & (VMMDEV_CREDENTIALS_JUDGE_OK | VMMDEV_CREDENTIALS_JUDGE_DENY |
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case VMMDEV_CREDENTIALS_JUDGE_DENY: guestJudgement = AuthGuestAccessDenied; break;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT: guestJudgement = AuthGuestNoJudgement; break;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case VMMDEV_CREDENTIALS_JUDGE_OK: guestJudgement = AuthGuestAccessGranted; break;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("Invalid guest flags %08X!!!\n", u32GuestFlags)); break;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("Wait for credentials judgement rc = %Rrc!!!\n", rc));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("Guest judgement %d\n", guestJudgement));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("Could not set credentials rc = %Rrc!!!\n", rc));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("AUTH: Guest judgement %d.\n", guestJudgement));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("External auth called again with guest judgement = %d\n", guestJudgement));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Reject. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Multiconnection check must be made after authentication, so bad clients would not interfere with a good one. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = mVRDEServer->COMGETTER(AllowMultiConnection)(&allowMultiConnection);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = mVRDEServer->COMGETTER(ReuseSingleConnection)(&reuseSingleConnection);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogFlowFunc(("allowMultiConnection %d, reuseSingleConnection = %d, mcVRDPClients = %d, mu32SingleRDPClientId = %d\n",
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync allowMultiConnection, reuseSingleConnection, mcVRDPClients, mu32SingleRDPClientId));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Note: the 'mcVRDPClients' variable is incremented in ClientConnect callback, which is called when the client
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * is successfully connected, that is after the ClientLogon callback. Therefore the mcVRDPClients
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * value is 0 for first client.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* There is a client already.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * If required drop the existing client connection and let the connecting one in.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("AUTH: Multiple connections are not enabled. Disconnecting existing client.\n"));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mConsoleVRDPServer->DisconnectClient(mu32SingleRDPClientId, false);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Reject. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync LogRel(("AUTH: Multiple connections are not enabled. Access denied.\n"));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Save the connected client id. From now on it will be necessary to disconnect this one. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateLogon(u32ClientId, pszUser, pszDomain);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Check if the successfully verified credentials are to be sent to the guest. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = mMachine->GetExtraData(Bstr("VRDP/ProvideGuestCredentials").raw(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Provide credentials only if there are no logged in users. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync hrc = i_getGuestProperty("/VirtualBox/GuestInfo/OS/NoLoggedInUsers",
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if (SUCCEEDED(hrc) && noLoggedInUsersValue != "false")
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* And only if there are no connected clients. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if (ASMAtomicCmpXchgBool(&mcGuestCredentialsProvided, true, false))
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // @todo r=dj locking required here for m_pVMMDev?
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32_t u32GuestFlags = VMMDEV_SETCREDENTIALS_GUESTLOGON;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync PPDMIVMMDEVPORT pDevPort = m_pVMMDev->getVMMDevPort();
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int rc = pDevPort->pfnSetCredentials(m_pVMMDev->getVMMDevPort(),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncvoid Console::i_VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Parse the status string. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateClientAttach(u32ClientId, true);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateClientAttach(u32ClientId, false);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync else if (RTStrNICmp(pszStatus, "NAME=", strlen("NAME=")) == 0)
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync i_guestPropertiesVRDPUpdateNameChange(u32ClientId, pszStatus + strlen("NAME="));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else if (RTStrNICmp(pszStatus, "CIPA=", strlen("CIPA=")) == 0)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateIPAddrChange(u32ClientId, pszStatus + strlen("CIPA="));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else if (RTStrNICmp(pszStatus, "CLOCATION=", strlen("CLOCATION=")) == 0)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateLocationChange(u32ClientId, pszStatus + strlen("CLOCATION="));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync else if (RTStrNICmp(pszStatus, "COINFO=", strlen("COINFO=")) == 0)
edde275acba04aca58db4172a163741e3abadfbcvboxsync i_guestPropertiesVRDPUpdateOtherInfoChange(u32ClientId, pszStatus + strlen("COINFO="));
edde275acba04aca58db4172a163741e3abadfbcvboxsyncvoid Console::i_VRDPClientConnect(uint32_t u32ClientId)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32_t u32Clients = ASMAtomicIncU32(&mcVRDPClients);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync i_guestPropertiesVRDPUpdateActiveClient(u32ClientId);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsyncvoid Console::i_VRDPClientDisconnect(uint32_t u32ClientId,
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync uint32_t u32Clients = ASMAtomicDecU32(&mcVRDPClients);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync if (fu32Intercepted & VRDE_CLIENT_INTERCEPT_CLIPBOARD)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync mAudioVRDE->onVRDEControl(false /* fEnable */, 0 /* uFlags */);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync PPDMIAUDIOSNIFFERPORT port = mAudioSniffer->getAudioSnifferPort();
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync HRESULT hrc = mMachine->COMGETTER(Id)(uuid.asOutParam());
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync mConsoleVRDPServer->AuthDisconnect(uuid, u32ClientId);
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync i_guestPropertiesVRDPUpdateDisconnect(u32ClientId);
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
edde275acba04aca58db4172a163741e3abadfbcvboxsyncvoid Console::i_VRDPInterceptAudio(uint32_t u32ClientId)
edde275acba04aca58db4172a163741e3abadfbcvboxsync mAudioVRDE->onVRDEControl(true /* fEnable */, 0 /* uFlags */);
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync PPDMIAUDIOSNIFFERPORT port = mAudioSniffer->getAudioSnifferPort();
edde275acba04aca58db4172a163741e3abadfbcvboxsyncvoid Console::i_VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept)
edde275acba04aca58db4172a163741e3abadfbcvboxsync mConsoleVRDPServer->USBBackendCreate(u32ClientId, ppvIntercept);
edde275acba04aca58db4172a163741e3abadfbcvboxsyncvoid Console::i_VRDPInterceptClipboard(uint32_t u32ClientId)
edde275acba04aca58db4172a163741e3abadfbcvboxsyncconst char *Console::sSSMConsoleUnit = "ConsoleData";
edde275acba04aca58db4172a163741e3abadfbcvboxsyncinline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType)
edde275acba04aca58db4172a163741e3abadfbcvboxsync return "pcnet";
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsync return "e1000";
edde275acba04aca58db4172a163741e3abadfbcvboxsync return "virtio-net";
edde275acba04aca58db4172a163741e3abadfbcvboxsync return "unknown";
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Loads various console data stored in the saved state file.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * This method does validation of the state file and returns an error info
edde275acba04aca58db4172a163741e3abadfbcvboxsync * when appropriate.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * The method does nothing if the machine is not in the Saved file or if
edde275acba04aca58db4172a163741e3abadfbcvboxsync * console data from it has already been loaded.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @note The caller must lock this object for writing.
edde275acba04aca58db4172a163741e3abadfbcvboxsync if (mMachineState != MachineState_Saved || mSavedStateDataLoaded)
edde275acba04aca58db4172a163741e3abadfbcvboxsync HRESULT rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsync int vrc = SSMR3Open(Utf8Str(savedStateFile).c_str(), 0, &ssm);
edde275acba04aca58db4172a163741e3abadfbcvboxsync vrc = SSMR3Seek(ssm, sSSMConsoleUnit, 0 /* iInstance */, &version);
edde275acba04aca58db4172a163741e3abadfbcvboxsync if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR(sSSMConsoleVer))
edde275acba04aca58db4172a163741e3abadfbcvboxsync tr("The saved state file '%ls' is invalid (%Rrc). Delete the saved state and try again"),
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Callback handler to save various console data to the state file,
edde275acba04aca58db4172a163741e3abadfbcvboxsync * called when the user saves the VM state.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param pvUser pointer to Console
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @note Locks the Console object for reading.
edde275acba04aca58db4172a163741e3abadfbcvboxsyncDECLCALLBACK(void) Console::i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser)
edde275acba04aca58db4172a163741e3abadfbcvboxsync int vrc = SSMR3PutU32(pSSM, (uint32_t)that->m_mapSharedFolders.size());
edde275acba04aca58db4172a163741e3abadfbcvboxsync for (SharedFolderMap::const_iterator it = that->m_mapSharedFolders.begin();
edde275acba04aca58db4172a163741e3abadfbcvboxsync vrc = SSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
edde275acba04aca58db4172a163741e3abadfbcvboxsync vrc = SSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
edde275acba04aca58db4172a163741e3abadfbcvboxsync vrc = SSMR3PutBool(pSSM, !!pSF->i_isAutoMounted());
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Callback handler to load various console data from the state file.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Called when the VM is being restored from the saved state.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param pvUser pointer to Console
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param uVersion Console unit version.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Should match sSSMConsoleVer.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param uPass The data pass.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @note Should locks the Console object for writing, if necessary.
edde275acba04aca58db4172a163741e3abadfbcvboxsyncConsole::i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
edde275acba04aca58db4172a163741e3abadfbcvboxsync if (SSM_VERSION_MAJOR_CHANGED(uVersion, sSSMConsoleVer))
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* Currently, nothing to do when we've been called from VMR3Load*. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Method to load various console data from the state file.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Called from #loadDataFromSavedState.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param pvUser pointer to Console
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @param u32Version Console unit version.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Should match sSSMConsoleVer.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * @note Locks the Console object for writing.
edde275acba04aca58db4172a163741e3abadfbcvboxsyncint Console::i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version)
edde275acba04aca58db4172a163741e3abadfbcvboxsync AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
edde275acba04aca58db4172a163741e3abadfbcvboxsync AssertReturn(m_mapSharedFolders.size() == 0, VERR_INTERNAL_ERROR);
edde275acba04aca58db4172a163741e3abadfbcvboxsync bool writable = true;
edde275acba04aca58db4172a163741e3abadfbcvboxsync bool autoMount = false;
edde275acba04aca58db4172a163741e3abadfbcvboxsync false /* fFailOnError */);
edde275acba04aca58db4172a163741e3abadfbcvboxsync m_mapSharedFolders.insert(std::make_pair(strName, pSharedFolder));
edde275acba04aca58db4172a163741e3abadfbcvboxsyncDECLCALLBACK(int) Console::i_doGuestPropNotification(void *pvExtension,
edde275acba04aca58db4172a163741e3abadfbcvboxsync using namespace guestProp;
edde275acba04aca58db4172a163741e3abadfbcvboxsync * No locking, as this is purely a notification which does not make any
edde275acba04aca58db4172a163741e3abadfbcvboxsync * changes to the object state.
edde275acba04aca58db4172a163741e3abadfbcvboxsync PHOSTCALLBACKDATA pCBData = reinterpret_cast<PHOSTCALLBACKDATA>(pvParms);
edde275acba04aca58db4172a163741e3abadfbcvboxsync AssertReturn(sizeof(HOSTCALLBACKDATA) == cbParms, VERR_INVALID_PARAMETER);
edde275acba04aca58db4172a163741e3abadfbcvboxsync AssertReturn(HOSTCALLBACKMAGIC == pCBData->u32Magic, VERR_INVALID_PARAMETER);
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlow(("Console::doGuestPropNotification: pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
edde275acba04aca58db4172a163741e3abadfbcvboxsync pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
edde275acba04aca58db4172a163741e3abadfbcvboxsync ComObjPtr<Console> pConsole = reinterpret_cast<Console *>(pvExtension);
edde275acba04aca58db4172a163741e3abadfbcvboxsync HRESULT hrc = pConsole->mControl->PushGuestProperty(name.raw(),
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlow(("Console::doGuestPropNotification: hrc=%Rhrc pCBData={.pcszName=%s, .pcszValue=%s, .pcszFlags=%s}\n",
edde275acba04aca58db4172a163741e3abadfbcvboxsync hrc, pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
edde275acba04aca58db4172a163741e3abadfbcvboxsync using namespace guestProp;
edde275acba04aca58db4172a163741e3abadfbcvboxsync parm[0].u.pointer.size = (uint32_t)aPatterns.length() + 1;
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Now things get slightly complicated. Due to a race with the guest adding
edde275acba04aca58db4172a163741e3abadfbcvboxsync * properties, there is no good way to know how much to enlarge a buffer for
edde275acba04aca58db4172a163741e3abadfbcvboxsync * the service to enumerate into. We choose a decent starting size and loop a
edde275acba04aca58db4172a163741e3abadfbcvboxsync * few times, each time retrying with the size suggested by the service plus
edde275acba04aca58db4172a163741e3abadfbcvboxsync for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i)
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync vrc = m_pVMMDev->hgcmHostCall("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3,
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync return setError(E_FAIL, tr("Internal application error"));
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync tr("Temporary failure due to guest activity, please retry"));
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync * Finally we have to unpack the data returned by the service into the safe
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync * arrays supplied by the caller. We start by counting the number of entries.
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync = reinterpret_cast<const char *>(parm[1].u.pointer.addr);
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync unsigned cEntries = 0;
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync /* The list is terminated by a zero-length string at the end of a set
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync * of four strings. */
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync /* We are counting sets of four strings. */
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsync for (unsigned j = 0; j < 4; ++j)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* Rely on the service to have formated the data correctly. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync for (unsigned i = 0; i < cEntries; ++i)
edde275acba04aca58db4172a163741e3abadfbcvboxsync#endif /* VBOX_WITH_GUEST_PROPS */
edde275acba04aca58db4172a163741e3abadfbcvboxsync// IConsole properties
edde275acba04aca58db4172a163741e3abadfbcvboxsync/////////////////////////////////////////////////////////////////////////////
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getMachine(ComPtr<IMachine> &aMachine)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mMachine is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* callers expect to get a valid reference, better fail than crash them */
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* we return our local state (since it's always the same as on the server) */
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mGuest is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getKeyboard(ComPtr<IKeyboard> &aKeyboard)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mKeyboard is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsync mKeyboard.queryInterfaceTo(aKeyboard.asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mMouse is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getDisplay(ComPtr<IDisplay> &aDisplay)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mDisplay is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getDebugger(ComPtr<IMachineDebugger> &aDebugger)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* we need a write lock because of the lazy mDebugger initialization*/
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* check if we have to create the debugger object */
edde275acba04aca58db4172a163741e3abadfbcvboxsync mDebugger.queryInterfaceTo(aDebugger.asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getUSBDevices(std::vector<ComPtr<IUSBDevice> > &aUSBDevices)
edde275acba04aca58db4172a163741e3abadfbcvboxsync for (USBDeviceList::const_iterator it = mUSBDevices.begin(); it != mUSBDevices.end(); ++i, ++it)
edde275acba04aca58db4172a163741e3abadfbcvboxsync (*it).queryInterfaceTo(aUSBDevices[i].asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getRemoteUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aRemoteUSBDevices)
edde275acba04aca58db4172a163741e3abadfbcvboxsync aRemoteUSBDevices.resize(mRemoteUSBDevices.size());
edde275acba04aca58db4172a163741e3abadfbcvboxsync for (RemoteUSBDeviceList::const_iterator it = mRemoteUSBDevices.begin(); it != mRemoteUSBDevices.end(); ++i, ++it)
edde275acba04aca58db4172a163741e3abadfbcvboxsync (*it).queryInterfaceTo(aRemoteUSBDevices[i].asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getVRDEServerInfo(ComPtr<IVRDEServerInfo> &aVRDEServerInfo)
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* mVRDEServerInfo is constant during life time, no need to lock */
edde275acba04aca58db4172a163741e3abadfbcvboxsync mVRDEServerInfo.queryInterfaceTo(aVRDEServerInfo.asOutParam());
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::getEmulatedUSB(ComPtr<IEmulatedUSB> &aEmulatedUSB)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync /* mEmulatedUSB is constant during life time, no need to lock */
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync mEmulatedUSB.queryInterfaceTo(aEmulatedUSB.asOutParam());
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync /* loadDataFromSavedState() needs a write lock */
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync /* Read console data stored in the saved state file (if not yet done) */
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync for (SharedFolderMap::const_iterator it = m_mapSharedFolders.begin(); it != m_mapSharedFolders.end(); ++i, ++it)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync (it)->second.queryInterfaceTo(aSharedFolders[i].asOutParam());
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::getEventSource(ComPtr<IEventSource> &aEventSource)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync // no need to lock - lifetime constant
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync mEventSource.queryInterfaceTo(aEventSource.asOutParam());
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::getAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttachedPCIDevices)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync mBusMgr->listAttachedPCIDevices(aAttachedPCIDevices);
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::getUseHostClipboard(BOOL *aUseHostClipboard)
dca3cdd56f38abf4257b94ff13268323ea52e0a7vboxsyncHRESULT Console::setUseHostClipboard(BOOL aUseHostClipboard)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync// IConsole methods
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync/////////////////////////////////////////////////////////////////////////////
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::powerUp(ComPtr<IProgress> &aProgress)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync i_powerUp(pProgress.asOutParam(), false /* aPaused */);
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync pProgress.queryInterfaceTo(aProgress.asOutParam());
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsyncHRESULT Console::powerUpPaused(ComPtr<IProgress> &aProgress)
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync i_powerUp(pProgress.asOutParam(), true /* aPaused */);
edde275acba04aca58db4172a163741e3abadfbcvboxsync pProgress.queryInterfaceTo(aProgress.asOutParam());
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::powerDown(ComPtr<IProgress> &aProgress)
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* Try cancel the teleportation. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down at this point in a teleportation"));
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* Try cancel the live snapshot. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down at this point in a live snapshot"));
f3b077ba3204fcb9c310e3929340db83bc9b77cdvboxsync /* Try cancel the FT sync. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down at this point in a fault tolerant sync"));
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* extra nice error message for a common case */
edde275acba04aca58db4172a163741e3abadfbcvboxsync return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down a saved virtual machine"));
edde275acba04aca58db4172a163741e3abadfbcvboxsync return setError(VBOX_E_INVALID_VM_STATE, tr("The virtual machine is being powered down"));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr("Invalid machine state: %s (must be Running, Paused or Stuck)"),
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync LogFlowThisFunc(("Initiating SHUTDOWN request...\n"));
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* memorize the current machine state */
edde275acba04aca58db4172a163741e3abadfbcvboxsync mMachine->DeleteGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw());
edde275acba04aca58db4172a163741e3abadfbcvboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw(),
edde275acba04aca58db4172a163741e3abadfbcvboxsync Bstr("PowerOff").raw(), Bstr("RDONLYGUEST").raw());
edde275acba04aca58db4172a163741e3abadfbcvboxsync * request a progress object from the server
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * (this will set the machine state to Stopping on the server to block
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * others from accessing this machine)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync rc = mControl->BeginPoweringDown(pProgress.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* sync the state with the server */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* setup task object and thread to carry out the operation asynchronously */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync std::auto_ptr<VMPowerDownTask> task(new VMPowerDownTask(this, pProgress));
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int vrc = RTThreadCreate(NULL, Console::i_powerDownThread,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync "VMPwrDwn");
edde275acba04aca58db4172a163741e3abadfbcvboxsync rc = setError(E_FAIL, "Could not create VMPowerDown thread (%Rrc)", vrc);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* task is now owned by powerDownThread(), so release it */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* pass the progress to the caller */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pProgress.queryInterfaceTo(aProgress.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* preserve existing error info */
edde275acba04aca58db4172a163741e3abadfbcvboxsync * cancel the requested power down procedure.
edde275acba04aca58db4172a163741e3abadfbcvboxsync * This will reset the machine state to the state it had right
edde275acba04aca58db4172a163741e3abadfbcvboxsync * before calling mControl->BeginPoweringDown().
edde275acba04aca58db4172a163741e3abadfbcvboxsync mControl->EndPoweringDown(eik.getResultCode(), eik.getText().raw()); }
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
edde275acba04aca58db4172a163741e3abadfbcvboxsync /** @todo r=bird: This should be allowed on paused VMs as well. Later. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* protect mpUVM */
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync LogFlowThisFunc(("mMachineState=%d, rc=%Rhrc\n", mMachineState, rc));
edde275acba04aca58db4172a163741e3abadfbcvboxsync/*static*/ DECLCALLBACK(int) Console::i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu)
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsync LogFlowFunc(("pThis=%p pVM=%p idCpu=%u\n", pThis, pUVM, idCpu));
edde275acba04aca58db4172a163741e3abadfbcvboxsync int vrc = PDMR3DeviceDetach(pUVM, "acpi", 0, idCpu, 0);
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::i_doCPURemove(ULONG aCpu, PUVM pUVM)
edde275acba04aca58db4172a163741e3abadfbcvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
edde275acba04aca58db4172a163741e3abadfbcvboxsync PPDMIVMMDEVPORT pVmmDevPort = m_pVMMDev->getVMMDevPort();
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Check if the CPU is present */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync return setError(E_FAIL, tr("CPU %d is not attached"), aCpu);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Leave the lock before any EMT/VMMDev call. */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync bool fLocked = true;
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Check if the CPU is unlocked */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync int vrc = PDMR3QueryDeviceLun(pUVM, "acpi", 0, aCpu, &pBase);
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsync PPDMIACPIPORT pApicPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Notify the guest if possible. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync vrc = pVmmDevPort->pfnCpuHotUnplug(pVmmDevPort, idCpuCore, idCpuPackage);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* It will take some time until the event is processed in the guest. Wait... */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync vrc = pApicPort ? pApicPort->pfnGetCpuStatus(pApicPort, aCpu, &fLocked) : VERR_INVALID_POINTER;
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Sleep a bit */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync } while (cTries-- > 0);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync else if (vrc == VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Query one time. It is possible that the user ejected the CPU. */
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsync vrc = pApicPort ? pApicPort->pfnGetCpuStatus(pApicPort, aCpu, &fLocked) : VERR_INVALID_POINTER;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* If the CPU was unlocked we can detach it now. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync * Call worker in EMT, that's faster and safer than doing everything
edde275acba04aca58db4172a163741e3abadfbcvboxsync * using VMR3ReqCall.
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* Detach it from the VM */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync tr("Hot-Remove was aborted because the CPU may still be used by the guest"), VERR_RESOURCE_BUSY);
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync LogFlowThisFunc(("mMachineState=%d, rc=%Rhrc\n", mMachineState, rc));
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync/*static*/ DECLCALLBACK(int) Console::i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu)
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync PCFGMNODE pInst = CFGMR3GetChild(CFGMR3GetRootU(pUVM), "Devices/acpi/0/");
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync /* nuke anything which might have been left behind. */
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%u", idCpu));
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } } while (0)
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", idCpu); RC_CHECK();
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync rc = CFGMR3InsertString(pLunL0, "Driver", "ACPICpu"); RC_CHECK();
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK();
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync * Attach the driver.
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync rc = PDMR3DeviceAttach(pUVM, "acpi", 0, idCpu, 0, &pBase); RC_CHECK();
edde275acba04aca58db4172a163741e3abadfbcvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
edde275acba04aca58db4172a163741e3abadfbcvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /** @todo r=bird: This should be allowed on paused VMs as well. Later. */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync PPDMIVMMDEVPORT pDevPort = m_pVMMDev->getVMMDevPort();
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /* Check if the CPU is present */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync * Call worker in EMT, that's faster and safer than doing everything
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync * using VMR3ReqCall. Note that we separate VMR3ReqCall from VMR3ReqWait
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync * here to make requests from under the lock in order to serialize them.
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync int vrc = VMR3ReqCallU(pUVM, 0, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /* Notify the guest if possible. */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync vrc = VMR3GetCpuCoreAndPackageIdFromCpuId(pUVM, aCpu, &idCpuCore, &idCpuPackage); AssertRC(vrc);
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync vrc = pDevPort->pfnCpuHotPlug(pDevPort, idCpuCore, idCpuPackage);
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /** @todo warning if the guest doesn't support it */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync LogFlowThisFunc(("mMachineState=%d, rc=%Rhrc\n", mMachineState, rc));
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /* get the VM handle. */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync // no need to release lock, as there are no cross-thread callbacks
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync /* get the acpi device interface and press the button. */
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsync PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
4221c34ed2180fbc3a82504145c4a66c589e9e6avboxsyncHRESULT Console::getPowerButtonHandled(BOOL *aHandled)
b4ac1123bab63c58a3323bc1eb96dc7fde868aafvboxsync /* get the VM handle. */
485f31dd3495c289f625c9c5b900cf0b95838ed6vboxsync // no need to release lock, as there are no cross-thread callbacks
485f31dd3495c289f625c9c5b900cf0b95838ed6vboxsync /* get the acpi device interface and check if the button press was handled. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
edde275acba04aca58db4172a163741e3abadfbcvboxsync bool fHandled = false;
edde275acba04aca58db4172a163741e3abadfbcvboxsync vrc = pPort->pfnGetPowerButtonHandled(pPort, &fHandled);
edde275acba04aca58db4172a163741e3abadfbcvboxsync tr("Checking if the ACPI Power Button event was handled by the guest OS failed (%Rrc)"),
edde275acba04aca58db4172a163741e3abadfbcvboxsyncHRESULT Console::getGuestEnteredACPIMode(BOOL *aEntered)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr("Invalid machine state %s when checking if the guest entered the ACPI mode)"),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* get the VM handle. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync // no need to release lock, as there are no cross-thread callbacks
edde275acba04aca58db4172a163741e3abadfbcvboxsync /* get the acpi device interface and query the information. */
edde275acba04aca58db4172a163741e3abadfbcvboxsync int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
edde275acba04aca58db4172a163741e3abadfbcvboxsync PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
edde275acba04aca58db4172a163741e3abadfbcvboxsync bool fEntered = false;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync vrc = pPort->pfnGetGuestEnteredACPIMode(pPort, &fEntered);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* get the VM handle. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync // no need to release lock, as there are no cross-thread callbacks
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* get the acpi device interface and press the sleep button. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int vrc = PDMR3QueryDeviceLun(ptrVM.rawUVM(), "acpi", 0, 0, &pBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync PPDMIACPIPORT pPort = PDMIBASE_QUERY_INTERFACE(pBase, PDMIACPIPORT);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncHRESULT Console::saveState(ComPtr<IProgress> &aProgress)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT rc = i_saveState(Reason_Unspecified, pProgress.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync pProgress.queryInterfaceTo(aProgress.asOutParam());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncHRESULT Console::adoptSavedState(const com::Utf8Str &aSavedStateFile)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr("Cannot adopt the saved machine state as the machine is not in Powered Off, Teleported or Aborted state (machine state: %s)"),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync return mControl->AdoptSavedState(Bstr(aSavedStateFile.c_str()).raw());
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncHRESULT Console::discardSavedState(BOOL aFRemoveFile)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr("Cannot delete the machine state as the machine is not in the saved state (machine state: %s)"),
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync HRESULT rc = mControl->SetRemoveSavedStateFile(aFRemoveFile);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Saved -> PoweredOff transition will be detected in the SessionMachine
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * and properly handled.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync/** read the value of a LED. */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync uint32_t u32 = pLed->Actual.u32 | pLed->Asserted.u32;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsyncHRESULT Console::getDeviceActivity(const std::vector<DeviceType_T> &aType,
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * Note: we don't lock the console object here because
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync * readAndClearLed() should be thread safe.
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Get LED array to read */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (unsigned i = 0; i < RT_ELEMENTS(mapStorageLeds); ++i)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync for (unsigned i = 0; i < RT_ELEMENTS(mapNetworkLeds); ++i)
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsync for (unsigned i = 0; i < RT_ELEMENTS(mapUSBLed); ++i)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync /* Compose the result */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync switch (SumLed.u32 & (PDMLED_READING | PDMLED_WRITING))
b2560fc359a998cb1002e5de6eba0ef716d48803vboxsyncHRESULT Console::attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename)
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr("Cannot attach a USB device to the machine which is not running or paused (machine state: %s)"),
if (!mfVMHasUsbController)
#ifdef VBOX_WITH_USB
++it;
if (!pUSBDevice)
return rc;
return rc;
#ifdef VBOX_WITH_USB
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
return E_NOTIMPL;
HRESULT Console::createSharedFolder(const com::Utf8Str &aName, const com::Utf8Str &aHostPath, BOOL aWritable, BOOL aAutomount)
tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %s)"),
!!aWritable,
!!aAutomount,
&& 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;
if (!(pTask = new VMTakeSnapshotTask(this, pProgress, Bstr(aName).raw(), Bstr(aDescription).raw())))
return E_OUTOFMEMORY;
(void *)pTask,
vrc);
delete pTask;
return rc;
HRESULT rc = mControl->DeleteSnapshot((IConsole *)this, Bstr(aId.toString()).raw(), Bstr(aId.toString()).raw(),
return S_OK;
HRESULT rc = mControl->DeleteSnapshot((IConsole *)this, Bstr(aId.toString()).raw(), Bstr(aId.toString()).raw(),
return S_OK;
HRESULT Console::deleteSnapshotRange(const com::Guid &aStartId, const com::Guid &aEndId, ComPtr<IProgress> &aProgress)
HRESULT rc = mControl->DeleteSnapshot((IConsole *)this, Bstr(aStartId.toString()).raw(), Bstr(aEndId.toString()).raw(),
return S_OK;
HRESULT rc = mControl->RestoreSnapshot((IConsole*)this, iSnapshot, &machineState, iProgress.asOutParam());
return S_OK;
vrc);
return hrc;
HRESULT Console::addDiskEncryptionPasswords(const std::vector<com::Utf8Str> &aIds, const std::vector<com::Utf8Str> &aPasswords,
return hrc;
delete pKey;
return S_OK;
it++)
it++)
return S_OK;
return rc;
switch (enmCtrlType)
return NULL;
HRESULT Console::i_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;
case StorageBus_USB:
uLun = 0;
return S_OK;
uLun = 0;
*pfResume = false;
switch (enmVMState)
case VMSTATE_RESETTING:
case VMSTATE_RUNNING:
mVMStateChangeCallbackDisabled = true;
if (pAlock)
if (pAlock)
mVMStateChangeCallbackDisabled = false;
*pfResume = true;
case VMSTATE_SUSPENDED:
return S_OK;
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
if (pMedium)
bool fResume = false;
return rc;
if (fResume)
return S_OK;
if (pMedium)
vrc);
* @note The VM must not be running since it might have pending I/O to the drive which is being changed.
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fForce)
pUVM,
return rc;
HRESULT Console::i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent)
if (pMedium)
bool fResume = false;
return rc;
if (fResume)
return S_OK;
if (!pMedium)
vrc);
* @note The VM must not be running since it might have pending I/O to the drive which is being changed.
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fSilent)
pUVM,
NULL);
return rc;
HRESULT Console::i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent)
if (pMedium)
bool fResume = false;
return rc;
if (fResume)
return S_OK;
if (!pMedium)
vrc);
* @note The VM must not be running since it might have pending I/O to the drive which is being changed.
const char *pcszDevice,
unsigned uInstance,
bool fSilent)
unsigned uLUN;
#undef H
if (pLunL0)
if (fSilent)
return rcRet;
if (pINetCfg)
return rc;
while (pBase)
if (pNetNatCfg)
if (!pNetNatCfg)
return rc;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
if (pBase)
return m_pVMMDev;
return mDisplay;
&& *psz)
psz++;
return VERR_INVALID_PARAMETER;
&& *psz)
psz++;
if (*ppszKey)
if (!*ppszVal)
return rc;
unsigned uLUN;
if (pIBase)
if (pIMedium)
return hrc;
unsigned uLUN;
if (pIBase)
if (pIMedium)
return hrc;
return hrc;
unsigned uLUN;
if (pIBase)
if (!pIMedium)
return setError(VBOX_E_PASSWORD_INCORRECT, tr("The provided password for ID \"%s\" is not correct for at least one disk using this ID"),
return hrc;
while ( *psz
pszEnd++;
&& pszUuid
&& pszKeyEnc)
rc);
if (pszUuid)
if (pszKeyEnc)
if (ppszEnd)
return hrc;
while ( *pszCfg
return hrc;
delete pKey;
it++;
const char *pszDevice,
unsigned uInstance,
unsigned uLun,
bool fResume = false;
return hr;
if (fResume)
return S_OK;
const char *pszDevice,
unsigned uInstance,
unsigned uLun,
if (pVirtualBox)
if (pSystemProperties)
&& uLun == 0
return rc;
return S_OK;
return S_OK;
return S_OK;
return rc;
if (aRemove)
return rc;
return rc;
return rc;
return rc;
mfVRDEChangePending = true;
mfVRDEChangeInProcess = true;
mfVRDEChangePending = false;
if ( mVRDEServer
if (aRestart)
if (vrdpEnabled)
mfVRDEChangeInProcess = false;
return rc;
return i_setInvalidMachineStateError();
if (pPort)
vrc);
return rc;
if (mDisplay)
if (fEnabled)
return rc;
return S_OK;
fireSharedFolderChangedEvent(mEventSource, aGlobal ? (Scope_T)Scope_Global : (Scope_T)Scope_Machine);
return rc;
HRESULT Console::i_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;
vrc = PDMR3AsyncCompletionBwMgrSetMaxForFile(ptrVM.rawUVM(), Utf8Str(strName).c_str(), (uint32_t)cMax);
#ifdef VBOX_WITH_NETSHAPER
return rc;
HRESULT Console::i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent)
if (aRemove)
return rc;
if (!aMachineId)
return S_OK;
return hrc;
return hrc;
HRESULT Console::i_getGuestProperty(const Utf8Str &aName, Utf8Str *aValue, LONG64 *aTimestamp, Utf8Str *aFlags)
#ifndef VBOX_WITH_GUEST_PROPS
return E_POINTER;
return E_POINTER;
return E_POINTER;
using namespace guestProp;
if (aTimestamp)
if (aFlags)
vrc);
return rc;
HRESULT Console::i_setGuestProperty(const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags)
#ifndef VBOX_WITH_GUEST_PROPS
using namespace guestProp;
int vrc;
hrc = setError(VBOX_E_IPRT_ERROR, tr("The VBoxGuestPropSvc service call failed with the error %Rrc"), vrc);
return hrc;
#ifndef VBOX_WITH_GUEST_PROPS
using namespace guestProp;
hrc = setError(VBOX_E_IPRT_ERROR, tr("The VBoxGuestPropSvc service call failed with the error %Rrc"), vrc);
return hrc;
#ifndef VBOX_WITH_GUEST_PROPS
if (pProgress)
switch (mMachineState)
return i_setInvalidMachineStateError();
if (pMedium)
unsigned uLUN;
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
if (pIBase)
if (!pIMedium)
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
mVMStateChangeCallbackDisabled = true;
mVMStateChangeCallbackDisabled = false;
return rc;
return rc;
* in module VBoxC (and ConsoleImpl.cpp is part of it and thus can call it).
if (mGuest)
switch (mMachineState)
case MachineState_Running:
case MachineState_Teleporting:
case MachineState_Paused:
case MachineState_Saving:
return i_setInvalidMachineStateError();
return hrc;
int vrc;
#ifdef VBOX_WITH_EXTPACK
vrc);
return rc;
mMachine->GetExtraData(Bstr("VBoxInternal2/DisableSaveState").raw(), strDisableSaveState.asOutParam());
return hrc;
bool fBeganSavingState = false;
bool fTaskCreationFailed = false;
fBeganSavingState = true;
aReason));
fTaskCreationFailed = true;
if (fBeganSavingState)
return rc;
, E_FAIL);
if (pu8Shape)
fireMousePointerShapeChangedEvent(mEventSource, fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shape));
fireMouseCapabilityChangedEvent(mEventSource, supportsAbsolute, supportsRelative, supportsMT, needsHostCursor);
* Additions are available (via VBoxTray/VBoxClient).
*aWinId = 0;
if (aCheck)
if (fDelivered)
if (pCanShowEvent)
AssertFailed();
if (fDelivered)
if (pShowEvent)
AssertFailed();
return S_OK;
if (mVMDestroying)
++mVMCallers;
return S_OK;
--mVMCallers;
return a_Quiet
if (!pUVM)
return a_Quiet
return a_Quiet
return S_OK;
if (*a_ppUVM)
return hrc;
if (cHistoryFiles)
return hrc;
bool fBeganPoweringUp = false;
throw rc;
#ifdef VBOX_OPENSSL_FIPS
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)
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;
++it)
++it)
++it)
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"));
#ifdef VBOX_WITH_EXTPACK
#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
LogRel(("CoreDumper setup successful. pszDumpDir=%s fFlags=%#x\n", pszDumpDir ? pszDumpDir : ".", fCoreFlags));
for (VMPowerUpTask::ProgressList::const_iterator it = progresses.begin(); it != progresses.end(); ++it)
++cOperations;
else if (fTeleporterEnabled)
else if (fFaultToleranceSyncEnabled)
throw rc;
throw rc;
fBeganPoweringUp = true;
throw rc;
if (fCanceled)
++slot)
if (!enabled)
switch (netattach)
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",
Global::stringifyMachineState(mMachineState), getObjectState().getState() == ObjectState::InUninit));
if ( !mVMPoweredOff
mVMPoweredOff = true;
if (mDisplay)
if (mConsoleVRDPServer)
if (aProgress)
mVMDestroying = true;
if (mVMCallers > 0)
if (aProgress)
if (!mVMPoweredOff)
#ifdef VBOX_WITH_EXTPACK
if (aProgress)
#ifdef VBOX_WITH_HGCM
if (m_pVMMDev)
if (aProgress)
if (mfVMHasUsbController)
if (aProgress)
vrc);
if (mfVMHasUsbController)
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)
if (online)
if (online)
return rc;
sizeof(hostPathFull));
bool fMissing = false;
fMissing = true;
if (fMissing)
return S_OK;
return S_OK;
DECLCALLBACK(void) Console::i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser)
switch (enmState)
case VMSTATE_OFF:
#ifdef VBOX_WITH_GUEST_PROPS
case VMSTATE_TERMINATED:
if (pUVM)
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:
case VMSTATE_RUNNING:
case VMSTATE_RUNNING_LS:
case VMSTATE_RUNNING_FT:
case VMSTATE_FATAL_ERROR:
case VMSTATE_GURU_MEDITATION:
case VMSTATE_CREATED:
switch (aClipboardMode)
case ClipboardMode_Disabled:
switch (aDnDMode)
case DnDMode_Disabled:
case DnDMode_GuestToHost:
case DnDMode_HostToGuest:
case DnDMode_Bidirectional:
return rc;
#ifdef VBOX_WITH_USB
if (fRemote)
pvRemoteBackend = i_consoleVRDPServer()->USBBackendRequestPointer(pRemoteUSBDevice->clientId(), &uuid);
if (!pvRemoteBackend)
switch (vrc)
case VERR_VUSB_NO_PORTS:
hrc = setError(E_FAIL, tr("Failed to attach the USB device. (No available ports on the USB controller)."));
hrc = setError(E_FAIL, tr("Failed to create a proxy device for the USB device. (Error: %Rrc)"), vrc);
return hrc;
DECLCALLBACK(int)
Console::i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote,
const char *pszCaptureFilename)
return vrc;
if (fRemote)
return S_OK;
DECLCALLBACK(int)
return vrc;
# ifdef VBOX_STRICT
# ifdef RT_OS_LINUX
RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), str.c_str()); /** @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 (pVirtualBox)
if (pSystemProperties)
if (!enabled)
return rc;
if (pProgress)
return VINF_SUCCESS;
const char *pszErrorId,
if (mfVMHasUsbController)
return S_OK;
void Console::i_processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList, bool fDescExt)
++it)
if (e->oManufacturer)
if (e->oProduct)
if (e->oSerialNumber)
bool fNewDevice = true;
++it)
fNewDevice = false;
if (fNewDevice)
if (fMatched)
++it;
if (!pUSBDevice)
if (pUVM)
rc = task->mProgress->SetNextOperation(BstrFmt(tr("Disk Image Reset Operation - Immutable Image")).raw(), 1);
switch (vrc)
case VERR_FILE_NOT_FOUND:
vrc);
vrc = SSMR3RegisterExternal(pConsole->mpUVM, sSSMConsoleUnit, 0 /*iInstance*/, sSSMConsoleVer, 0 /* cbGuess */,
if (machineDebugger)
++it)
#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
#if defined(RT_OS_WINDOWS)
return VINF_SUCCESS;
const char *pcszDevice,
unsigned uInstance,
bool fUseHostIOCache,
bool fBuiltinIOCache,
bool fSetupMerge,
unsigned uMergeSource,
unsigned uMergeTarget,
#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,
pUVM,
return rc;
#undef H
return VINF_SUCCESS;
bool fBeganTakingSnapshot = false;
bool fSuspenededBySave = false;
throw rc;
fBeganTakingSnapshot = true;
int vrc;
throw rc;
for (size_t i = 0;
throw rc;
throw rc;
throw rc;
throw rc;
throw rc;
throw rc;
throw 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;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
return VINF_SUCCESS;
return VERR_NOT_FOUND;
Console::i_pdmIfSecKey_PasswordRetain(PPDMISECKEY pInterface, const char *pszId, const char **ppszPassword)
return VINF_SUCCESS;
return VERR_NOT_FOUND;
if (!cRefs)
return VINF_SUCCESS;
return VERR_NOT_FOUND;
return VINF_SUCCESS;
typedef struct DRVMAINSTATUS
/** Map for translating PDM storage controller/LUN information to
char *pszDeviceInstance;
if (!fHostDrive)
return VINF_SUCCESS;
return NULL;
while (iLed-- > 0)
DECLCALLBACK(int) Console::i_drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
if (!CFGMR3AreValuesValid(pCfg, "papLeds\0pmapMediumAttachments\0DeviceInstance\0pConsole\0First\0Last\0"))
return rc;
rc = CFGMR3QueryPtrDef(pCfg, "pmapMediumAttachments", (void **)&pThis->pmapMediumAttachments, NULL);
AssertMsgFailed(("Configuration error: Failed to query the \"pmapMediumAttachments\" value! rc=%Rrc\n", rc));
return rc;
AssertMsgFailed(("Configuration error: Failed to query the \"DeviceInstance\" value! rc=%Rrc\n", rc));
return rc;
return rc;
return rc;
return rc;
AssertMsgFailed(("Configuration error: Invalid unit range %u-%u\n", pThis->iFirstLUN, pThis->iLastLUN));
return VERR_GENERAL_FAILURE;
return VINF_SUCCESS;
sizeof(DRVMAINSTATUS),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,