ConsoleImpl.cpp revision e9088c254e0740d6ae02bd54af5b49598fe46d5f
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VBox Console COM Class implementation
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * available from http://www.virtualbox.org. This file is free software;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * you can redistribute it and/or modify it under the terms of the GNU
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * General Public License (GPL) as published by the Free Software
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * additional information or have any questions.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync// generated header
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync// VMTask and friends
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync////////////////////////////////////////////////////////////////////////////////
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Task structure for asynchronous VM operations.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Once created, the task structure adds itself as a Console caller. This means:
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * 1. The user must check for #rc() before using the created structure
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * (e.g. passing it as a thread function argument). If #rc() returns a
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * failure, the Console object may not be used by the task (see
ce5210fe822f74de78c3dddc74f32a2cabcee5fdvboxsync 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
ce5210fe822f74de78c3dddc74f32a2cabcee5fdvboxsync * will lead to Console::uninit() stuck waiting for releasing all added
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * If \a aUsesVMPtr parameter is true, the task structure will also add itself
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync * as a Console::mpVM caller with the same meaning as above. See
77cce7691847be5aef145f31ba3f9d66fc2cf594vboxsync * Console::addVMCaller() for more info.
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync : mConsole (aConsole), mCallerAdded (false), mVMCallerAdded (false)
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /** Releases the Console caller before destruction. Not normally necessary. */
f350b7cf96f1e2f3b0cfd34cfe8726c754f43584vboxsync /** Releases the VM caller before destruction. Not normally necessary. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync VMProgressTask (Console *aConsole, Progress *aProgress, bool aUsesVMPtr)
8e0c2ca3abd721979958f95b9af73b60665478c8vboxsync : VMTask (aConsole, aUsesVMPtr), mProgress (aProgress) {}
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync VMPowerUpTask (Console *aConsole, Progress *aProgress)
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync : VMProgressTask (aConsole, aProgress, false /* aUsesVMPtr */)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync , mSetVMErrorCallback (NULL), mConfigConstructor (NULL), mStartPaused (false) {}
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync typedef std::list <ComPtr<IHardDisk> > HardDiskList;
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync /* array of progress objects for hard disk reset operations */
3ca89d9d8c4fc158ba28bdf82c9cc3697625ce12vboxsync typedef std::list <ComPtr<IProgress> > ProgressList;
6f6e182fde44ac8c4f95d8684e10fbbea937f26evboxsync VMSaveTask (Console *aConsole, Progress *aProgress)
678e65f634668c9f9a0f45094277cd6b375484cavboxsync : VMProgressTask (aConsole, aProgress, true /* aUsesVMPtr */)
678e65f634668c9f9a0f45094277cd6b375484cavboxsync// constructor / destructor
678e65f634668c9f9a0f45094277cd6b375484cavboxsync/////////////////////////////////////////////////////////////////////////////
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync memset(&mapSharedFolderLed, 0, sizeof(mapSharedFolderLed));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync// public initializer/uninitializer for internal purposes only
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync/////////////////////////////////////////////////////////////////////////////
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncHRESULT Console::init (IMachine *aMachine, IInternalMachineControl *aControl)
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync /* Enclose the state transition NotReady->InInit->Ready */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowThisFunc(("aMachine=%p, aControl=%p\n", aMachine, aControl));
678e65f634668c9f9a0f45094277cd6b375484cavboxsync memset (&mCallbackData, 0, sizeof (mCallbackData));
678e65f634668c9f9a0f45094277cd6b375484cavboxsync /* Cache essential properties and objects */
678e65f634668c9f9a0f45094277cd6b375484cavboxsync rc = mMachine->COMGETTER(VRDPServer) (unconst(mVRDPServer).asOutParam());
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync rc = mMachine->COMGETTER(DVDDrive) (unconst(mDVDDrive).asOutParam());
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync rc = mMachine->COMGETTER(FloppyDrive) (unconst(mFloppyDrive).asOutParam());
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Create associated child COM objects */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Grab global and machine shared folder lists */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Create other child objects */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync unconst(mConsoleVRDPServer) = new ConsoleVRDPServer (this);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Confirm a successful initialization when it's the case */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Uninitializes the Console object.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Enclose the state transition Ready->InUninit->NotReady */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * Uninit all children that use addDependentChild()/removeDependentChild()
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * in their init()/uninit() methods.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* power down the VM if necessary */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Release all callbacks. Do this after uninitializing the components,
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * as some of them are well-behaved and unregister their callbacks.
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * These would trigger error messages complaining about trying to
678e65f634668c9f9a0f45094277cd6b375484cavboxsync * unregister a non-registered callback. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* dynamically allocated members of mCallbackData are uninitialized
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * at the end of powerDown() */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync Assert (!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/EnableGuestPropertiesVRDP"), value.asOutParam());
2a076b740155a538ded6407c44aae5eff986a42fvboxsync return true;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync return false;
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncvoid Console::updateGuestPropertiesVRDPLogon (uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mRemoteDisplayInfo->COMGETTER(ClientName)(clientName.asOutParam());
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), clientName, Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(pszUser), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(pszDomain), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastConnectedClient"), Bstr(pszClientId), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncvoid Console::updateGuestPropertiesVRDPDisconnect (uint32_t u32ClientId)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Name", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/User", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszPropertyName, "/VirtualBox/HostInfo/VRDP/Client/%u/Domain", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr(pszPropertyName), Bstr(""), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = RTStrAPrintf(&pszClientId, "%d", u32ClientId);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VRDP/LastDisconnectedClient"), Bstr(pszClientId), Bstr("RDONLYGUEST"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync#endif /* VBOX_WITH_GUEST_PROPS */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncint Console::VRDPClientLogon (uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync LogFlowFunc (("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /* Console has been already uninitialized, deny request */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync LogRel(("VRDPAUTH: Access denied (Console uninitialized).\n"));
2a076b740155a538ded6407c44aae5eff986a42fvboxsync HRESULT hrc = mMachine->COMGETTER (Id) (id.asOutParam());
2a076b740155a538ded6407c44aae5eff986a42fvboxsync hrc = mVRDPServer->COMGETTER(AuthType) (&authType);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync hrc = mVRDPServer->COMGETTER(AuthTimeout) (&authTimeout);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync VRDPAuthGuestJudgement guestJudgement = VRDPAuthGuestNotAsked;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogRel (("VRDPAUTH: User: [%s]. Domain: [%s]. Authentication type: [%s]\n",
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync "External":
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /* Call the external library. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync result = mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc (("External auth asked for guest judgement\n"));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync } /* pass through */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Issue the request to guest. Assume that the call does not require EMT. It should not. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Ask the guest to judge these credentials. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync uint32_t u32GuestFlags = VMMDEV_SETCREDENTIALS_JUDGE;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync int rc = mVMMDev->getVMMDevPort()->pfnSetCredentials (mVMMDev->getVMMDevPort(),
2a076b740155a538ded6407c44aae5eff986a42fvboxsync /* Wait for guest. */
2a076b740155a538ded6407c44aae5eff986a42fvboxsync rc = mVMMDev->WaitCredentialsJudgement (authTimeout, &u32GuestFlags);
2a076b740155a538ded6407c44aae5eff986a42fvboxsync switch (u32GuestFlags & (VMMDEV_CREDENTIALS_JUDGE_OK | VMMDEV_CREDENTIALS_JUDGE_DENY | VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT))
2a076b740155a538ded6407c44aae5eff986a42fvboxsync case VMMDEV_CREDENTIALS_JUDGE_DENY: guestJudgement = VRDPAuthGuestAccessDenied; break;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync case VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT: guestJudgement = VRDPAuthGuestNoJudgement; break;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync case VMMDEV_CREDENTIALS_JUDGE_OK: guestJudgement = VRDPAuthGuestAccessGranted; break;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync LogFlowFunc (("Invalid guest flags %08X!!!\n", u32GuestFlags)); break;
2a076b740155a538ded6407c44aae5eff986a42fvboxsync LogFlowFunc (("Wait for credentials judgement rc = %Rrc!!!\n", rc));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc (("Guest judgement %d\n", guestJudgement));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc (("Could not set credentials rc = %Rrc!!!\n", rc));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogRel(("VRDPAUTH: Guest judgement %d.\n", guestJudgement));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc (("External auth called again with guest judgement = %d\n", guestJudgement));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync result = mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Reject. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Multiconnection check must be made after authentication, so bad clients would not interfere with a good one. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync hrc = mVRDPServer->COMGETTER(AllowMultiConnection) (&allowMultiConnection);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync hrc = mVRDPServer->COMGETTER(ReuseSingleConnection) (&reuseSingleConnection);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc(("allowMultiConnection %d, reuseSingleConnection = %d, mcVRDPClients = %d, mu32SingleRDPClientId = %d\n", allowMultiConnection, reuseSingleConnection, mcVRDPClients, mu32SingleRDPClientId));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Note: the 'mcVRDPClients' variable is incremented in ClientConnect callback, which is called when the client
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * is successfully connected, that is after the ClientLogon callback. Therefore the mcVRDPClients
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * value is 0 for first client.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* There is a client already.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * If required drop the existing client connection and let the connecting one in.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogRel(("VRDPAUTH: Multiple connections are not enabled. Disconnecting existing client.\n"));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync mConsoleVRDPServer->DisconnectClient (mu32SingleRDPClientId, false);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Reject. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogRel(("VRDPAUTH: Multiple connections are not enabled. Access denied.\n"));
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* Save the connected client id. From now on it will be necessary to disconnect this one. */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync updateGuestPropertiesVRDPLogon (u32ClientId, pszUser, pszDomain);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncvoid Console::VRDPClientConnect (uint32_t u32ClientId)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t u32Clients = ASMAtomicIncU32(&mcVRDPClients);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync true, VRDP_EXPERIENCE_LEVEL_FULL); // @todo configurable
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif /* VBOX_WITH_VRDP */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncvoid Console::VRDPClientDisconnect (uint32_t u32ClientId,
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync uint32_t u32Clients = ASMAtomicDecU32(&mcVRDPClients);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync#endif /* VBOX_WITH_VRDP */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync mConsoleVRDPServer->USBBackendDelete (u32ClientId);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync if (fu32Intercepted & VRDP_CLIENT_INTERCEPT_CLIPBOARD)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync PPDMIAUDIOSNIFFERPORT port = mAudioSniffer->getAudioSnifferPort();
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif /* VBOX_WITH_VRDP */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync HRESULT hrc = mMachine->COMGETTER (Id) (uuid.asOutParam());
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync hrc = mVRDPServer->COMGETTER(AuthType) (&authType);
678e65f634668c9f9a0f45094277cd6b375484cavboxsync mConsoleVRDPServer->AuthDisconnect (uuid, u32ClientId);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync#endif /* VBOX_WITH_GUEST_PROPS */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncvoid Console::VRDPInterceptAudio (uint32_t u32ClientId)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowFunc (("mAudioSniffer %p, u32ClientId %d.\n",
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync PPDMIAUDIOSNIFFERPORT port = mAudioSniffer->getAudioSnifferPort();
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncvoid Console::VRDPInterceptUSB (uint32_t u32ClientId, void **ppvIntercept)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync mConsoleVRDPServer->USBBackendCreate (u32ClientId, ppvIntercept);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncvoid Console::VRDPInterceptClipboard (uint32_t u32ClientId)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync#endif /* VBOX_WITH_VRDP */
2a076b740155a538ded6407c44aae5eff986a42fvboxsyncconst char *Console::sSSMConsoleUnit = "ConsoleData";
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * Loads various console data stored in the saved state file.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * This method does validation of the state file and returns an error info
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * when appropriate.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * The method does nothing if the machine is not in the Saved file or if
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync * console data from it has already been loaded.
2a076b740155a538ded6407c44aae5eff986a42fvboxsync * @note The caller must lock this object for writing.
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync if (mMachineState != MachineState_Saved || mSavedStateDataLoaded)
2a076b740155a538ded6407c44aae5eff986a42fvboxsync HRESULT rc = mMachine->COMGETTER(StateFilePath) (savedStateFile.asOutParam());
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync int vrc = SSMR3Open(Utf8Str(savedStateFile).c_str(), 0, &ssm);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync vrc = SSMR3Seek (ssm, sSSMConsoleUnit, 0 /* iInstance */, &version);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR(sSSMConsoleVer))
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync tr ("The saved state file '%ls' is invalid (%Rrc). "
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync "Discard the saved state and try again"),
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * Callback handler to save various console data to the state file,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * called when the user saves the VM state.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @param pvUser pointer to Console
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @note Locks the Console object for reading.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncConsole::saveStateFileExec (PSSMHANDLE pSSM, void *pvUser)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync int vrc = SSMR3PutU32 (pSSM, (uint32_t)that->mSharedFolders.size());
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync for (SharedFolderMap::const_iterator it = that->mSharedFolders.begin();
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync // don't lock the folder because methods we access are const
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync vrc = SSMR3PutU32 (pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync vrc = SSMR3PutU32 (pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * Callback handler to load various console data from the state file.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * Called when the VM is being restored from the saved state.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param pvUser pointer to Console
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * @param u32Version Console unit version.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * Should match sSSMConsoleVer.
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * @note Should locks the Console object for writing, if necessary.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncConsole::loadStateFileExec (PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync if (SSM_VERSION_MAJOR_CHANGED(u32Version, sSSMConsoleVer))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* Currently, nothing to do when we've been called from VMR3Load. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Method to load various console data from the state file.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Called from #loadDataFromSavedState.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param pvUser pointer to Console
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @param u32Version Console unit version.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Should match sSSMConsoleVer.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * @note Locks the Console object for writing.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncConsole::loadStateFileExecInternal (PSSMHANDLE pSSM, uint32_t u32Version)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync AssertReturn(mSharedFolders.size() == 0, VERR_INTERNAL_ERROR);
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync bool writable = true;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync HRESULT rc = sharedFolder->init (this, name, hostPath, writable);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync mSharedFolders.insert (std::make_pair (name, sharedFolder));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncConsole::doGuestPropNotification (void *pvExtension, uint32_t,
d6c4b5eecea7735227dc41255d4e742543ddc86fvboxsync using namespace guestProp;
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFlowFunc (("pvExtension=%p, pvParms=%p, cbParms=%u\n", pvExtension, pvParms, cbParms));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* No locking, as this is purely a notification which does not make any
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync * changes to the object state. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync PHOSTCALLBACKDATA pCBData = reinterpret_cast<PHOSTCALLBACKDATA>(pvParms);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync AssertReturn(sizeof(HOSTCALLBACKDATA) == cbParms, VERR_INVALID_PARAMETER);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync AssertReturn(HOSTCALLBACKMAGIC == pCBData->u32Magic, VERR_INVALID_PARAMETER);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync ComObjPtr<Console> pConsole = reinterpret_cast <Console *> (pvExtension);
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync LogFlowFunc (("pCBData->pcszName=%s, pCBData->pcszValue=%s, pCBData->pcszFlags=%s\n", pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync || (value.isNull() && (pCBData->pcszValue != NULL))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync || (flags.isNull() && (pCBData->pcszFlags != NULL))
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync HRESULT hrc = pConsole->mControl->PushGuestProperty(name, value,
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync LogFunc (("pConsole->mControl->PushGuestProperty failed, hrc=0x%x\n", hrc));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync LogFunc (("pCBData->pcszName=%s\n", pCBData->pcszName));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync LogFunc (("pCBData->pcszValue=%s\n", pCBData->pcszValue));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFunc (("pCBData->pcszFlags=%s\n", pCBData->pcszFlags));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync rc = VERR_UNRESOLVED_ERROR; /** @todo translate error code */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncHRESULT Console::doEnumerateGuestProperties (CBSTR aPatterns,
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync using namespace guestProp;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync parm[0].u.pointer.addr = utf8Patterns.mutableRaw();
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync parm[0].u.pointer.size = (uint32_t)utf8Patterns.length() + 1;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Now things get slightly complicated. Due to a race with the guest adding
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * properties, there is no good way to know how much to enlarge a buffer for
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * the service to enumerate into. We choose a decent starting size and loop a
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * few times, each time retrying with the size suggested by the service plus
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync for (unsigned i = 0; i < 10 && (VERR_BUFFER_OVERFLOW == vrc); ++i)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3,
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync return setError (E_FAIL, tr ("Internal application error"));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync return setError (E_UNEXPECTED, tr ("Temporary failure due to guest activity, please retry"));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * Finally we have to unpack the data returned by the service into the safe
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * arrays supplied by the caller. We start by counting the number of entries.
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync = reinterpret_cast<const char *>(parm[1].u.pointer.addr);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync unsigned cEntries = 0;
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* The list is terminated by a zero-length string at the end of a set
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync * of four strings. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* We are counting sets of four strings. */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync for (unsigned j = 0; j < 4; ++j)
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync * And now we create the COM safe arrays and fill them in.
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* Rely on the service to have formated the data correctly. */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync for (unsigned i = 0; i < cEntries; ++i)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync timestamps.detachTo(ComSafeArrayOutArg(aTimestamps));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync// IConsole properties
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/////////////////////////////////////////////////////////////////////////////
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(Machine) (IMachine **aMachine)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* mMachine is constant during life time, no need to lock */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(State) (MachineState_T *aMachineState)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* we return our local state (since it's always the same as on the server) */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(Guest) (IGuest **aGuest)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* mGuest is constant during life time, no need to lock */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(Keyboard) (IKeyboard **aKeyboard)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* mKeyboard is constant during life time, no need to lock */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(Mouse) (IMouse **aMouse)
980eeb78f6811c935c7ebbe33de92f757ec3bc78vboxsync /* mMouse is constant during life time, no need to lock */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncSTDMETHODIMP Console::COMGETTER(Display) (IDisplay **aDisplay)
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* mDisplay is constant during life time, no need to lock */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(Debugger) (IMachineDebugger **aDebugger)
f65d92209d8ab9f6093c0e2a90e7d5b73a2254fevboxsync /* we need a write lock because of the lazy mDebugger initialization*/
f65d92209d8ab9f6093c0e2a90e7d5b73a2254fevboxsync /* check if we have to create the debugger object */
f65d92209d8ab9f6093c0e2a90e7d5b73a2254fevboxsyncSTDMETHODIMP Console::COMGETTER(USBDevices) (ComSafeArrayOut(IUSBDevice *, aUSBDevices))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync SafeIfaceArray<IUSBDevice> collection (mUSBDevices);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync collection.detachTo(ComSafeArrayOutArg(aUSBDevices));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::COMGETTER(RemoteUSBDevices) (ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync CheckComArgOutSafeArrayPointerValid(aRemoteUSBDevices);
40577689fbf5c30d288d6c006f34329acdcdd97avboxsync SafeIfaceArray<IHostUSBDevice> collection (mRemoteUSBDevices);
980eeb78f6811c935c7ebbe33de92f757ec3bc78vboxsync collection.detachTo(ComSafeArrayOutArg(aRemoteUSBDevices));
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsyncSTDMETHODIMP Console::COMGETTER(RemoteDisplayInfo) (IRemoteDisplayInfo **aRemoteDisplayInfo)
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /* mDisplay is constant during life time, no need to lock */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync mRemoteDisplayInfo.queryInterfaceTo(aRemoteDisplayInfo);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncConsole::COMGETTER(SharedFolders) (ComSafeArrayOut(ISharedFolder *, aSharedFolders))
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync CheckComArgOutSafeArrayPointerValid(aSharedFolders);
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* loadDataFromSavedState() needs a write lock */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* Read console data stored in the saved state file (if not yet done) */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync// IConsole methods
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync/////////////////////////////////////////////////////////////////////////////
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::PowerUp (IProgress **aProgress)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::PowerUpPaused (IProgress **aProgress)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsyncSTDMETHODIMP Console::PowerDown (IProgress **aProgress)
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* extra nice error message for a common case */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync tr ("Invalid machine state: %d (must be Running, Paused "
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync "or Stuck)"),
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFlowThisFunc(("Initiating SHUTDOWN request...\n"));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* create an IProgress object to track progress of this operation */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* setup task object and thread to carry out the operation asynchronously */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync new VMProgressTask (this, progress, true /* aUsesVMPtr */));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync int vrc = RTThreadCreate (NULL, Console::powerDownThread,
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync "VMPowerDown");
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync ("Could not create VMPowerDown thread (%Rrc)", vrc), E_FAIL);
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync /* task is now owned by powerDownThread(), so release it */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* go to Stopping state to forbid state-dependant operations */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* pass the progress to the caller */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* protect mpVM */
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync /* leave the lock before a VMR3* call (EMT will call us back)! */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync setError (VBOX_E_VM_ERROR, tr ("Could not reset the machine (%Rrc)"), vrc);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync LogFlowThisFunc(("mMachineState=%d, rc=%08X\n", mMachineState, rc));
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* protect mpVM */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* leave the lock before a VMR3* call (EMT will call us back)! */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync tr ("Could not suspend the machine execution (%Rrc)"), vrc);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync tr ("Cannot resume the machine as it is not paused "
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* protect mpVM */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* leave the lock before a VMR3* call (EMT will call us back)! */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync tr ("Could not resume the machine execution (%Rrc)"), vrc);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync /* protect mpVM */
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
3ee1fadbf124a56daa99470bee91759440ef5da9vboxsync vrc = pPort ? pPort->pfnPowerButtonPress(pPort) : VERR_INVALID_POINTER;
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsyncSTDMETHODIMP Console::GetPowerButtonHandled(BOOL *aHandled)
37e7010b28a4667800196960b59cd63b5434b7d7vboxsync /* protect mpVM */
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
9fbcdff887bd2d679720a8a50f5601df57b32b1bvboxsync bool handled = false;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync vrc = pPort ? pPort->pfnGetPowerButtonHandled(pPort, &handled) : VERR_INVALID_POINTER;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync tr ("Checking if the ACPI Power Button event was handled by the "
404c008ee2f58e85158a7c1c3f8974bdf52221e3vboxsyncSTDMETHODIMP Console::GetGuestEnteredACPIMode(BOOL *aEntered)
3c520cf6887d9039d9aa7cf3bbe81fd7de1ffd4cvboxsync tr ("Invalid machine state %d when checking if the guest entered "
733c64713253004dc4de114e345c3e0b667b92ffvboxsync /* protect mpVM */
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync bool entered = false;
13493ab7596e827b8d0caab2c89e635dd65f78f9vboxsync (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
733c64713253004dc4de114e345c3e0b667b92ffvboxsync vrc = pPort ? pPort->pfnGetGuestEnteredACPIMode(pPort, &entered) : VERR_INVALID_POINTER;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* protect mpVM */
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync vrc = pPort ? pPort->pfnSleepButtonPress(pPort) : VERR_INVALID_POINTER;
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync tr ("Sending sleep button event failed (%Rrc)"), vrc);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsyncSTDMETHODIMP Console::SaveState (IProgress **aProgress)
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync tr ("Cannot save the execution state as the machine "
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync "is not running or paused (machine state: %d)"), mMachineState);
1c2c968fd241148110002d75b2c0fdeddc211e14vboxsync /* memorize the current machine state */
f14d3c62ebf4ccb64bd11528e5c4ec60b4528a1avboxsync /* create a progress object to track operation completion */
bool beganSavingState = false;
bool taskCreationFailed = false;
taskCreationFailed = true;
beganSavingState = true;
if (beganSavingState)
Resume();
return rc;
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;
return rc;
return rc;
if (takingSnapshotOnline)
bool beganTakingSnapshot = false;
bool taskCreationFailed = false;
if (takingSnapshotOnline)
taskCreationFailed = true;
beganTakingSnapshot = true;
if (takingSnapshotOnline)
if (combinedProgress)
Resume();
return rc;
return S_OK;
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;
if (!mpVM)
return S_OK;
return S_OK;
bool fPassthrough = false;
switch (eState)
case DriveState_ImageMounted:
case DriveState_NotMounted:
return rc;
if (!mpVM)
return S_OK;
if (!fEnabled)
return S_OK;
return S_OK;
switch (eState)
case DriveState_ImageMounted:
case DriveState_NotMounted:
return rc;
HRESULT Console::doDriveChange (const char *pszDevice, unsigned uInstance, unsigned uLun, DriveState_T eState,
return S_OK;
if (pszPath)
DECLCALLBACK(int) Console::changeDrive (Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun,
bool fResume;
switch (enmVMState)
case VMSTATE_RESETTING:
case VMSTATE_RUNNING:
fResume = true;
case VMSTATE_SUSPENDED:
case VMSTATE_CREATED:
case VMSTATE_OFF:
fResume = false;
indirectly modify the meDVDState/meFloppyState members (pointed to by
switch (*peState)
case DriveState_ImageMounted:
case DriveState_NotMounted:
&& VBOX_SUCCESS (rc = CFGMR3InsertString (pLunL0, "Driver", !strcmp (pszDevice, "i82078") ? "HostFloppy" : "HostDVD"))
&& VBOX_SUCCESS (rc = !strcmp (pszDevice, "i82078") ? VINF_SUCCESS : CFGMR3InsertInteger(pCfg, "Passthrough", fPassthrough)))
rc = PDMR3DeviceAttach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/);
switch (eState)
case DriveState_ImageMounted:
case DriveState_NotMounted:
if (!pIMount)
RC_CHECK();
RC_CHECK();
return rc;
if (!pIMount)
AssertFailed();
return rc;
if (fResume)
return rcRet;
if (!mpVM)
return S_OK;
#ifdef VBOX_WITH_E1000
if (pINetCfg)
#ifdef VBOX_DYNAMIC_NET_ATTACH
return rc;
#ifdef VBOX_DYNAMIC_NET_ATTACH
unsigned uInstance,
unsigned uLun,
return S_OK;
const char *pszDevice,
unsigned uInstance,
unsigned uLun,
AssertMsg ( (!strcmp (pszDevice, "pcnet") && uLun == 0 && uInstance < SchemaDefs::NetworkAdapterCount)
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 (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;
#if !defined (VBOX_WITH_GUEST_PROPS)
return E_INVALIDARG;
return E_POINTER;
return E_POINTER;
return E_POINTER;
using namespace guestProp;
return rc;
#if !defined (VBOX_WITH_GUEST_PROPS)
return E_INVALIDARG;
return E_INVALIDARG;
return E_INVALIDARG;
using namespace guestProp;
return rc;
#if !defined (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)
*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_OSE
RTProcSelf(),
return hrc;
return E_POINTER;
if (!enabled)
switch (netattach)
#ifdef RT_OS_WINDOWS
if (!hostif)
if (autoReset)
if (aProgress)
E_FAIL);
return S_OK;
if (!mVMPoweredOff &&
mVMPoweredOff = true;
if (mConsoleVRDPServer)
if (aProgress)
#ifdef VBOX_WITH_HGCM
# ifdef VBOX_WITH_GUEST_PROPS
if (aProgress)
if (mVMMDev)
if (aProgress)
if (mVMCallers > 0)
mVMDestroying = true;
mVMCallers));
if (aProgress)
if (!mVMPoweredOff)
mVMPoweredOff = false;
if (aProgress)
bool fHasUSBController = false;
fHasUSBController = true;
if (aProgress)
if (fHasUSBController)
if (aProgress)
mVMDestroying = false;
if (aProgress)
return rc;
if (aUpdateServer)
return rc;
return S_OK;
if (aSetError)
return VBOX_E_FILE_ERROR;
if (aGlobal)
if (online)
if (online)
if (online)
return rc;
return S_OK;
return S_OK;
DECLCALLBACK(void)
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 VMSTATE_RUNNING:
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:
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)));
rc = setError(E_FAIL, tr ("could not set up the host networking device for non blocking access: %s"),
switch (rcVBox)
case VERR_ACCESS_DENIED:
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;
fNewDevice = false;
++ it;
if (fNewDevice)
if (fMatched)
++ it;
if (!device)
#if defined(RT_OS_WINDOWS)
#ifdef VBOX_WITH_VRDP
switch (vrc)
case VERR_NET_ADDRESS_IN_USE:
port);
case VERR_FILE_NOT_FOUND:
vrc);
&pVM);
#ifdef VBOX_WITH_VRDP
if (machineDebugger)
++ it)
* 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 (VBOX_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)
int iLUN;
bool fSCSI = false;
switch (enmController)
return VERR_GENERAL_FAILURE;
return VERR_GENERAL_FAILURE;
fSCSI = true;
fSCSI = true;
return VERR_GENERAL_FAILURE;
if (fSCSI)
pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN);
pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/", pcszDevice, lInstance, iLUN);
if (!pLunL1)
if (fSCSI)
#ifdef VBOX_STRICT
char *pszDriver;
bool fHostIP = true;
if (values [i])
fHostIP = false;
if (values [i])
fHostIP = false;
if (!fHostIP)
rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, iLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK();
return rc;
return VINF_SUCCESS;
return VINF_SUCCESS;
typedef struct DRVMAINSTATUS
DECLCALLBACK(void *) Console::drvStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
switch (enmInterface)
case PDMINTERFACE_BASE:
return NULL;
while (iLed-- > 0)
DECLCALLBACK(int) Console::drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags)
return rc;
return rc;
return rc;
AssertMsgFailed(("Configuration error: Invalid unit range %u-%u\n", pData->iFirstLUN, pData->iLastLUN));
return VERR_GENERAL_FAILURE;
pData->pLedPorts = (PPDMILEDPORTS)pDrvIns->pUpBase->pfnQueryInterface(pDrvIns->pUpBase, PDMINTERFACE_LED_PORTS);
return VERR_PDM_MISSING_INTERFACE_ABOVE;
return VINF_SUCCESS;
sizeof(DRVMAINSTATUS),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,