ConsoleImpl.h revision b81d6e6fb5abcc59eb9e794ec1ef9bbc74951181
df8bdeb362277e8d95a74d6c097341fe97409948johnz * VBox Console COM Class definition
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Copyright (C) 2006-2011 Oracle Corporation
df8bdeb362277e8d95a74d6c097341fe97409948johnz * This file is part of VirtualBox Open Source Edition (OSE), as
df8bdeb362277e8d95a74d6c097341fe97409948johnz * available from http://www.virtualbox.org. This file is free software;
df8bdeb362277e8d95a74d6c097341fe97409948johnz * you can redistribute it and/or modify it under the terms of the GNU
df8bdeb362277e8d95a74d6c097341fe97409948johnz * General Public License (GPL) as published by the Free Software
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Foundation, in version 2 as it comes in the "COPYING" file of the
df8bdeb362277e8d95a74d6c097341fe97409948johnz * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
df8bdeb362277e8d95a74d6c097341fe97409948johnz * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
df8bdeb362277e8d95a74d6c097341fe97409948johnz# include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
735564919188238196dbd0d320770dda59b38369Anthony Scarpino# include "../src-server/win/VBoxComEvents.h"
735564919188238196dbd0d320770dda59b38369Anthony Scarpino///////////////////////////////////////////////////////////////////////////////
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Checks the availability of the underlying VM device driver corresponding
df8bdeb362277e8d95a74d6c097341fe97409948johnz * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
df8bdeb362277e8d95a74d6c097341fe97409948johnz * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * The translatable error message is defined in null context.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Intended to used only within Console children (i.e. Keyboard, Mouse,
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Display, etc.).
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @param drv driver pointer to check (compare it with NULL)
df8bdeb362277e8d95a74d6c097341fe97409948johnz return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
df8bdeb362277e8d95a74d6c097341fe97409948johnz } while (0)
df8bdeb362277e8d95a74d6c097341fe97409948johnz///////////////////////////////////////////////////////////////////////////////
df8bdeb362277e8d95a74d6c097341fe97409948johnz/** IConsole implementation class */
df8bdeb362277e8d95a74d6c097341fe97409948johnz VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Console, IConsole)
735564919188238196dbd0d320770dda59b38369Anthony Scarpino // public initializers/uninitializers for internal purposes only
735564919188238196dbd0d320770dda59b38369Anthony Scarpino HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl);
df8bdeb362277e8d95a74d6c097341fe97409948johnz // IConsole properties
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(COMGETTER(State))(MachineState_T *aMachineState);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(Guest))(IGuest **aGuest);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(Keyboard))(IKeyboard **aKeyboard);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(Mouse))(IMouse **aMouse);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(Display))(IDisplay **aDisplay);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(Debugger))(IMachineDebugger **aDebugger);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IUSBDevice *, aUSBDevices));
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(RemoteUSBDevices))(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices));
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(VRDEServerInfo))(IVRDEServerInfo **aVRDEServerInfo);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(COMGETTER(AttachedPciDevices))(ComSafeArrayOut(IPciDeviceAttachment *, aAttachments));
df8bdeb362277e8d95a74d6c097341fe97409948johnz // IConsole methods
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(GetPowerButtonHandled)(BOOL *aHandled);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(GetGuestEnteredACPIMode)(BOOL *aEntered);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(SaveState)(IProgress **aProgress);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(DiscardSavedState)(BOOL aRemoveFile);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType,
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(DetachUSBDevice)(IN_BSTR aId, IUSBDevice **aDevice);
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice);
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice);
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription,
df8bdeb362277e8d95a74d6c097341fe97409948johnz STDMETHOD(DeleteSnapshot)(IN_BSTR aId, IProgress **aProgress);
735564919188238196dbd0d320770dda59b38369Anthony Scarpino STDMETHOD(RestoreSnapshot)(ISnapshot *aSnapshot, IProgress **aProgress);
9f0bc604621fbb9b9b038e6de7da8f9c46e28608Wyllys Ingersoll STDMETHOD(Teleport)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress);
9f0bc604621fbb9b9b038e6de7da8f9c46e28608Wyllys Ingersoll // public methods for internal purposes only
9f0bc604621fbb9b9b038e6de7da8f9c46e28608Wyllys Ingersoll * Note: the following methods do not increase refcount. intended to be
9f0bc604621fbb9b9b038e6de7da8f9c46e28608Wyllys Ingersoll * called only by the VM execution thread.
735564919188238196dbd0d320770dda59b38369Anthony Scarpino Keyboard *getKeyboard() const { return mKeyboard; }
735564919188238196dbd0d320770dda59b38369Anthony Scarpino Display *getDisplay() const { return mDisplay; }
735564919188238196dbd0d320770dda59b38369Anthony Scarpino MachineDebugger *getMachineDebugger() const { return mDebugger; }
735564919188238196dbd0d320770dda59b38369Anthony Scarpino AudioSniffer *getAudioSniffer() const { return mAudioSniffer; }
735564919188238196dbd0d320770dda59b38369Anthony Scarpino const ComPtr<IMachine> &machine() const { return mMachine; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Method is called only from ConsoleVRDPServer */
df8bdeb362277e8d95a74d6c097341fe97409948johnz IVRDEServer *getVRDEServer() const { return mVRDEServer; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT updateMachineState(MachineState_T aMachineState);
df8bdeb362277e8d95a74d6c097341fe97409948johnz // events from IInternalSessionControl
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onParallelPortChange(IParallelPort *aParallelPort);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT getGuestProperty(IN_BSTR aKey, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT onlineMergeMedium(IMediumAttachment *aMediumAttachment,
df8bdeb362277e8d95a74d6c097341fe97409948johnz AudioSniffer *getAudioSniffer() { return mAudioSniffer; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz EventSource *getEventSource() { return mEventSource; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
df8bdeb362277e8d95a74d6c097341fe97409948johnz void VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
df8bdeb362277e8d95a74d6c097341fe97409948johnz void VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
df8bdeb362277e8d95a74d6c097341fe97409948johnz void processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList);
df8bdeb362277e8d95a74d6c097341fe97409948johnz // callback callers (partly; for some events console callbacks are notified
df8bdeb362277e8d95a74d6c097341fe97409948johnz // directly from IInternalSessionControl event handlers declared above)
df8bdeb362277e8d95a74d6c097341fe97409948johnz void onMousePointerShapeChange(bool fVisible, bool fAlpha,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM void onStateChange(MachineState_T aMachineState);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM void onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM void onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
df8bdeb362277e8d95a74d6c097341fe97409948johnz void onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static HRESULT setErrorStatic(HRESULT aResultCode, const char *pcsz, ...);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT setInvalidMachineStateError();
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static HRESULT handleUnexpectedExceptions(RT_SRC_POS_DECL);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM // Called from event listener
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT onNATRedirectRuleChange(ULONG ulInstance, BOOL aNatRuleRemove,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * Base template for AutoVMCaller and SaveVMPtr. Template arguments
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * have the same meaning as arguments of Console::addVMCaller().
df8bdeb362277e8d95a74d6c097341fe97409948johnz template <bool taQuiet = false, bool taAllowNullVM = false>
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(S_OK)
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM mRC = aThat->addVMCaller(taQuiet, taAllowNullVM);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Decreases the number of callers before the instance is destroyed. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Restores the number of callers after by #release(). #rc() must be
df8bdeb362277e8d95a74d6c097341fe97409948johnz * rechecked to ensure the operation succeeded. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Returns the result of Console::addVMCaller() */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Shortcut to SUCCEEDED(rc()) */
735564919188238196dbd0d320770dda59b38369Anthony Scarpino * Helper class that protects sections of code using the mpVM pointer by
df8bdeb362277e8d95a74d6c097341fe97409948johnz * automatically calling addVMCaller() on construction and
df8bdeb362277e8d95a74d6c097341fe97409948johnz * releaseVMCaller() on destruction. Intended for Console methods dealing
df8bdeb362277e8d95a74d6c097341fe97409948johnz * with mpVM. The usage pattern is:
df8bdeb362277e8d95a74d6c097341fe97409948johnz * AutoVMCaller autoVMCaller(this);
df8bdeb362277e8d95a74d6c097341fe97409948johnz * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
df8bdeb362277e8d95a74d6c097341fe97409948johnz * VMR3ReqCall (mpVM, ...
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @note Temporarily locks the argument for writing.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @sa SafeVMPtr, SafeVMPtrQuiet
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @obsolete Use SafeVMPtr
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Same as AutoVMCaller but doesn't set extended error info on failure.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @note Temporarily locks the argument for writing.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @obsolete Use SafeVMPtrQuiet
df8bdeb362277e8d95a74d6c097341fe97409948johnz typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
df8bdeb362277e8d95a74d6c097341fe97409948johnz * instead of assertion).
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @note Temporarily locks the argument for writing.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @obsolete Use SafeVMPtr
df8bdeb362277e8d95a74d6c097341fe97409948johnz typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * Same as AutoVMCaller but doesn't set extended error info on failure
df8bdeb362277e8d95a74d6c097341fe97409948johnz * and allows a null VM pointer (to trigger an error instead of
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * @note Temporarily locks the argument for writing.
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * @obsolete Use SafeVMPtrQuiet
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * Base template for SaveVMPtr and SaveVMPtrQuiet.
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef AutoVMCallerBase<taQuiet, true> Base;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SafeVMPtrBase(Console *aThat) : Base(aThat), mpVM(NULL), mpUVM(NULL)
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM Base::mRC = aThat->safeVMPtrRetainer(&mpVM, &mpUVM, taQuiet);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Smart SaveVMPtr to PVM cast operator */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM operator PVM() const { return mpVM; }
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Direct PVM access for printf()-like functions */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Direct PUVM access for printf()-like functions */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM PUVM rawUVM() const { return mpUVM; }
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Release the handles. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Helper class that safely manages the Console::mpVM pointer
df8bdeb362277e8d95a74d6c097341fe97409948johnz * by calling addVMCaller() on construction and releaseVMCaller() on
df8bdeb362277e8d95a74d6c097341fe97409948johnz * destruction. Intended for Console children. The usage pattern is:
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Console::SaveVMPtr pVM(mParent);
df8bdeb362277e8d95a74d6c097341fe97409948johnz * if (FAILED(pVM.rc())) return pVM.rc();
df8bdeb362277e8d95a74d6c097341fe97409948johnz * VMR3ReqCall(pVM, ...
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * printf("%p\n", pVM.raw());
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * @note Temporarily locks the argument for writing.
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * @sa SafeVMPtrQuiet, AutoVMCaller
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef SafeVMPtrBase<false> SafeVMPtr;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * A deviation of SaveVMPtr that doesn't set the error info on failure.
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * Intended for pieces of code that don't need to return the VM access
df8bdeb362277e8d95a74d6c097341fe97409948johnz * failure to the caller. The usage pattern is:
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Console::SaveVMPtrQuiet pVM(mParent);
df8bdeb362277e8d95a74d6c097341fe97409948johnz * if (pVM.rc())
df8bdeb362277e8d95a74d6c097341fe97409948johnz * VMR3ReqCall(pVM, ...
df8bdeb362277e8d95a74d6c097341fe97409948johnz * return S_OK;
df8bdeb362277e8d95a74d6c097341fe97409948johnz * @note Temporarily locks the argument for writing.
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM * @sa SafeVMPtr, AutoVMCaller
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef SafeVMPtrBase<true> SafeVMPtrQuiet;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SharedFolderData(const Utf8Str &aHostPath,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM // copy constructor
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SharedFolderData(const SharedFolderData& aThat)
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM : m_strHostPath(aThat.m_strHostPath),
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT safeVMPtrRetainer(PVM *a_ppVM, PUVM *a_ppUVM, bool aQuiet);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM void safeVMPtrReleaser(PVM *a_ppVM, PUVM *a_ppUVM);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT powerUp(IProgress **aProgress, bool aPaused);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT powerDown(IProgress *aProgress = NULL);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM/* Note: FreeBSD needs this whether netflt is used or not. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT setMachineStateLocally(MachineState_T aMachineState)
df8bdeb362277e8d95a74d6c097341fe97409948johnz return setMachineState(aMachineState, false /* aUpdateServer */);
df8bdeb362277e8d95a74d6c097341fe97409948johnz bool aSetError = false);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole);
df8bdeb362277e8d95a74d6c097341fe97409948johnz int configConstructorInner(PVM pVM, AutoWriteLock *pAlock);
df8bdeb362277e8d95a74d6c097341fe97409948johnz int configCfgmOverlay(PVM pVM, IVirtualBox *pVirtualBox, IMachine *pMachine);
df8bdeb362277e8d95a74d6c097341fe97409948johnz const char *pcszDevice,
df8bdeb362277e8d95a74d6c097341fe97409948johnz const char *pcszBwGroup,
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) reconfigureMediumAttachment(Console *pConsole,
df8bdeb362277e8d95a74d6c097341fe97409948johnz const char *pcszDevice,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) changeRemovableMedium(Console *pThis,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM int configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM bool fAttachDetach, bool fIgnoreConnectFailure);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) configGuestProperties(void *pvConsole);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) configGuestControl(void *pvConsole);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) unplugCpu(Console *pThis, PVM pVM, unsigned uCpu);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) plugCpu(Console *pThis, PVM pVM, unsigned uCpu);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PVM pVM);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT doNetworkAdapterChange(PVM pVM, const char *pszDevice, unsigned uInstance,
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, PVM pVM, const char *pszDevice,
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT detachUSBDevice(USBDeviceList::iterator &aIt);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) usbAttachCallback(Console *that, PVM pVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
df8bdeb362277e8d95a74d6c097341fe97409948johnz bool aRemote, const char *aAddress, ULONG aMaskedIfs);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) usbDetachCallback(Console *that, PVM pVM, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) attachStorageDevice(Console *pThis,
df8bdeb362277e8d95a74d6c097341fe97409948johnz const char *pcszDevice,
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) detachStorageDevice(Console *pThis,
df8bdeb362277e8d95a74d6c097341fe97409948johnz const char *pcszDevice,
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PVM pVM);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PVM pVM);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) stateProgressCallback(PVM pVM, unsigned uPercent, void *pvUser);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(void) genericVMSetErrorCallback(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
df8bdeb362277e8d95a74d6c097341fe97409948johnz static void setVMRuntimeErrorCallbackF(PVM pVM, void *pvUser, uint32_t fFatal,
2225707c7e7edf7c636ed349df2592ef85329cddValerie Bubb Fenwick static DECLCALLBACK(void) setVMRuntimeErrorCallback(PVM pVM, void *pvUser, uint32_t fFatal,
2225707c7e7edf7c636ed349df2592ef85329cddValerie Bubb Fenwick const char *pszErrorId, const char *pszFormat, va_list va);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) powerUpThread(RTTHREAD Thread, void *pvUser);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) saveStateThread(RTTHREAD Thread, void *pvUser);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) powerDownThread(RTTHREAD Thread, void *pvUser);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
df8bdeb362277e8d95a74d6c097341fe97409948johnz uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz static const char *sSSMConsoleUnit;
df8bdeb362277e8d95a74d6c097341fe97409948johnz int loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(void) saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
df8bdeb362277e8d95a74d6c097341fe97409948johnz void guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
df8bdeb362277e8d95a74d6c097341fe97409948johnz void guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** @name Teleporter support
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
df8bdeb362277e8d95a74d6c097341fe97409948johnz HRESULT teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
df8bdeb362277e8d95a74d6c097341fe97409948johnz static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM const ComObjPtr<MachineDebugger> mDebugger;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SharedFolderDataMap m_mapGlobalSharedFolders;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SharedFolderDataMap m_mapMachineSharedFolders;
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM SharedFolderMap m_mapSharedFolders; // the console instances
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** The user mode VM handle. */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Holds the number of "readonly" mpVM callers (users) */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** Semaphore posted when the number of mpVM callers drops to zero */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** true when Console has entered the mpVM destruction phase */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** true when power down is initiated by vmstateChangeCallback (EMT) */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** true when vmstateChangeCallback shouldn't initiate a power down. */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM /** true if we already showed the snapshot folder size warning. */
8bab47abcb471dffa36ddbf409a8ef5303398ddfJohn.Zolnowsky@Sun.COM bool mfSnapshotFolderSizeWarningShown : 1;
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** true if we already showed the snapshot folder ext4/xfs bug warning. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** true if we already listed the disk type of the snapshot folder. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Pointer to the VMM -> User (that's us) callbacks. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** The current network attachment type in the VM.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * This doesn't have to match the network attachment type maintained in the
df8bdeb362277e8d95a74d6c097341fe97409948johnz * NetworkAdapter. This is needed to change the network attachment
df8bdeb362277e8d95a74d6c097341fe97409948johnz * dynamically.
df8bdeb362277e8d95a74d6c097341fe97409948johnz NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount];
df8bdeb362277e8d95a74d6c097341fe97409948johnz cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas
df8bdeb362277e8d95a74d6c097341fe97409948johnz PPDMLED mapNetworkLeds[SchemaDefs::NetworkAdapterCount];
df8bdeb362277e8d95a74d6c097341fe97409948johnz/* Note: FreeBSD needs this whether netflt is used or not. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Local machine state value. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** Pointer to the progress object of a live cancelable task.
df8bdeb362277e8d95a74d6c097341fe97409948johnz * This is currently only used by Console::Teleport(), but is intended to later
df8bdeb362277e8d95a74d6c097341fe97409948johnz * be used by the live snapshot code path as well. Actions like
df8bdeb362277e8d95a74d6c097341fe97409948johnz * Console::PowerDown, which automatically cancels out the running snapshot /
df8bdeb362277e8d95a74d6c097341fe97409948johnz * teleportation operation, will cancel the teleportation / live snapshot
df8bdeb362277e8d95a74d6c097341fe97409948johnz * operation before starting. */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** OnMousePointerShapeChange() cache */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** OnMouseCapabilityChange() cache */
df8bdeb362277e8d95a74d6c097341fe97409948johnz /** OnKeyboardLedsChange() cache */
bool valid;
bool numLock;
bool capsLock;
bool scrollLock;
klc;
void clear()