ConsoleImpl.h revision c654f1ecae5fd97ff32f08e5e0d7a7e64af9e514
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VBox Console COM Class definition
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Copyright (C) 2005-2014 Oracle Corporation
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * available from http://www.virtualbox.org. This file is free software;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * you can redistribute it and/or modify it under the terms of the GNU
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * General Public License (GPL) as published by the Free Software
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f0d866e126dd288169fed591c259c1c6b4016e5vboxsync# include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
9ad3427071ba81a2bbf60f5d9a04eb69c147ea6evboxsync///////////////////////////////////////////////////////////////////////////////
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Checks the availability of the underlying VM device driver corresponding
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * The translatable error message is defined in null context.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Intended to used only within Console children (i.e. Keyboard, Mouse,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Display, etc.).
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @param drv driver pointer to check (compare it with NULL)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync } while (0)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync///////////////////////////////////////////////////////////////////////////////
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync virtual VMMDevMouseInterface *getVMMDevMouseInterface() = 0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync virtual DisplayMouseInterface *getDisplayMouseInterface() = 0;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync virtual void onMouseCapabilityChange(BOOL supportsAbsolute,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/** IConsole implementation class */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync VBOX_SCRIPTABLE_IMPL(IConsole), public ConsoleMouseInterface
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Console, IConsole)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // public initializers/uninitializers for internal purposes only
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // IConsole properties
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(Machine))(IMachine **aMachine);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(State))(MachineState_T *aMachineState);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(Keyboard))(IKeyboard **aKeyboard);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(Display))(IDisplay **aDisplay);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(Debugger))(IMachineDebugger **aDebugger);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IUSBDevice *, aUSBDevices));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(RemoteUSBDevices))(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(VRDEServerInfo))(IVRDEServerInfo **aVRDEServerInfo);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(AttachedPCIDevices))(ComSafeArrayOut(IPCIDeviceAttachment *, aAttachments));
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(UseHostClipboard))(BOOL *aUseHostClipboard);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMSETTER(UseHostClipboard))(BOOL aUseHostClipboard);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(COMGETTER(EmulatedUSB))(IEmulatedUSB **aEmulatedUSB);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // IConsole methods
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(GetGuestEnteredACPIMode)(BOOL *aEntered);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(DetachUSBDevice)(IN_BSTR aId, IUSBDevice **aDevice);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(DeleteSnapshot)(IN_BSTR aId, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(DeleteSnapshotAndAllChildren)(IN_BSTR aId, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(DeleteSnapshotRange)(IN_BSTR aStartId, IN_BSTR aEndId, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(RestoreSnapshot)(ISnapshot *aSnapshot, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync STDMETHOD(Teleport)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // public methods for internal purposes only
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Note: the following methods do not increase refcount. intended to be
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync * called only by the VM execution thread.
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync Keyboard *getKeyboard() const { return mKeyboard; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync MachineDebugger *getMachineDebugger() const { return mDebugger; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync AudioVRDE *getAudioVRDE() const { return mAudioVRDE; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync AudioSniffer *getAudioSniffer() const { return mAudioSniffer; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync const ComPtr<IMachine> &machine() const { return mMachine; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync bool useHostClipboard() { return mfUseHostClipboard; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync /** Method is called only from ConsoleVRDPServer */
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync IVRDEServer *getVRDEServer() const { return mVRDEServer; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; }
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync HRESULT updateMachineState(MachineState_T aMachineState);
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync // events from IInternalSessionControl
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync HRESULT onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync HRESULT onSerialPortChange(ISerialPort *aSerialPort);
615c2f5544718590f05af51eff75bd1bbac4be54vboxsync HRESULT onParallelPortChange(IParallelPort *aParallelPort);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onExtraDataChange(IN_BSTR aMachineId, IN_BSTR aKey, IN_BSTR aVal);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT getGuestProperty(IN_BSTR aKey, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT enumerateGuestProperties(IN_BSTR aPatterns,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onlineMergeMedium(IMediumAttachment *aMediumAttachment,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync AudioSniffer *getAudioSniffer() { return mAudioSniffer; }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync EventSource *getEventSource() { return mEventSource; }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync UsbCardReader *getUsbCardReader() { return mUsbCardReader; }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList, bool fDescExt);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void reportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync mControl->ReportVmStatistics(aValidStats, aCpuUser, aCpuKernel, aCpuIdle,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT saveState(Reason_T aReason, IProgress **aProgress);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // callback callers (partly; for some events console callbacks are notified
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // directly from IInternalSessionControl event handlers declared above)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void onMousePointerShapeChange(bool fVisible, bool fAlpha,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static HRESULT setErrorStatic(HRESULT aResultCode, const char *pcsz, ...);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // Called from event listener
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT onNATRedirectRuleChange(ULONG ulInstance, BOOL aNatRuleRemove,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // Mouse interface
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync EmulatedUSB *getEmulatedUSB(void) { return mEmulatedUSB; }
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Base template for AutoVMCaller and SafeVMPtr. Template arguments
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * have the same meaning as arguments of Console::addVMCaller().
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync template <bool taQuiet = false, bool taAllowNullVM = false>
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(S_OK)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Decreases the number of callers before the instance is destroyed. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Restores the number of callers after by #release(). #rc() must be
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * rechecked to ensure the operation succeeded. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Returns the result of Console::addVMCaller() */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Shortcut to SUCCEEDED(rc()) */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Helper class that protects sections of code using the mpUVM pointer by
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * automatically calling addVMCaller() on construction and
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * releaseVMCaller() on destruction. Intended for Console methods dealing
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * with mpUVM. The usage pattern is:
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * AutoVMCaller autoVMCaller(this);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VMR3ReqCall (mpUVM, ...
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @note Temporarily locks the argument for writing.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @sa SafeVMPtr, SafeVMPtrQuiet
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @obsolete Use SafeVMPtr
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync typedef AutoVMCallerBase<false, false> AutoVMCaller;
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * Same as AutoVMCaller but doesn't set extended error info on failure.
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * @note Temporarily locks the argument for writing.
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * @obsolete Use SafeVMPtrQuiet
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * instead of assertion).
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * @note Temporarily locks the argument for writing.
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * @obsolete Use SafeVMPtr
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * Same as AutoVMCaller but doesn't set extended error info on failure
76d3e53889c5a02a3881bd3cfa31509d61cea9d0vboxsync * and allows a null VM pointer (to trigger an error instead of
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync * assertion).
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync * @note Temporarily locks the argument for writing.
91b5f2a7d9797385e53af76c22883fa15fd25adfvboxsync * @obsolete Use SafeVMPtrQuiet
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync * Base template for SafeVMPtr and SafeVMPtrQuiet.
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync SafeVMPtrBase(Console *aThat) : Base(aThat), mpUVM(NULL)
d8818699735c83c36fc9555f85e6d86b610cdc67vboxsync Base::mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet);
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync /** Direct PUVM access. */
109c0d54dc2438e7887f198daefb7e164c8a9dffvboxsync /** Release the handles. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Helper class that safely manages the Console::mpUVM pointer
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * by calling addVMCaller() on construction and releaseVMCaller() on
9ad3427071ba81a2bbf60f5d9a04eb69c147ea6evboxsync * destruction. Intended for Console children. The usage pattern is:
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Console::SafeVMPtr ptrVM(mParent);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * if (!ptrVM.isOk())
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * return ptrVM.rc();
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VMR3ReqCall(ptrVM.rawUVM(), ...
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * printf("%p\n", ptrVM.rawUVM());
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @note Temporarily locks the argument for writing.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @sa SafeVMPtrQuiet, AutoVMCaller
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * A deviation of SafeVMPtr that doesn't set the error info on failure.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Intended for pieces of code that don't need to return the VM access
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * failure to the caller. The usage pattern is:
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Console::SafeVMPtrQuiet pVM(mParent);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * if (pVM.rc())
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * VMR3ReqCall(pVM, ...
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * return S_OK;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @note Temporarily locks the argument for writing.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * @sa SafeVMPtr, AutoVMCaller
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync // copy constructor
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Class for managing emulated USB MSDs.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** The UUID associated with the USB device. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Port of the storage device. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::map<Utf8Str, ComPtr<IMediumAttachment> > MediumAttachmentMap;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::list <USBStorageDevice> USBStorageDeviceList;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT powerUp(IProgress **aProgress, bool aPaused);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/* Note: FreeBSD needs this whether netflt is used or not. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT setMachineStateLocally(MachineState_T aMachineState)
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync return setMachineState(aMachineState, false /* aUpdateServer */);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync bool aSetError = false);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync bool findOtherSharedFolder(const Utf8Str &straName,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT removeSharedFolder(const Utf8Str &strName);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT suspendBeforeConfigChange(PUVM pUVM, AutoWriteLock *pAlock, bool *pfResume);
4d93fcdfb645b86163cfea77f687172295988d16vboxsync static DECLCALLBACK(int) configConstructor(PUVM pUVM, PVM pVM, void *pvConsole);
4d93fcdfb645b86163cfea77f687172295988d16vboxsync int configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock);
4d93fcdfb645b86163cfea77f687172295988d16vboxsync int configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
4d93fcdfb645b86163cfea77f687172295988d16vboxsync int configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) reconfigureMediumAttachment(Console *pThis,
3e7e8dae1bd305767a63ff29f1ae8bd8dccb8000vboxsync static DECLCALLBACK(int) changeRemovableMedium(Console *pThis,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
3e7e8dae1bd305767a63ff29f1ae8bd8dccb8000vboxsync void attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync Console::MediumAttachmentMap *pmapMediumAttachments,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) configGuestProperties(void *pvConsole, PUVM pUVM);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) configGuestControl(void *pvConsole);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(void) vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void changeClipboardMode(ClipboardMode_T aClipboardMode);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
3e7e8dae1bd305767a63ff29f1ae8bd8dccb8000vboxsync bool aRemote, const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) attachStorageDevice(Console *pThis,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) detachStorageDevice(Console *pThis,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync HRESULT doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(void) genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void setVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(void) setVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync const char *pszErrorId, const char *pszFormat, va_list va);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(int) powerUpThread(RTTHREAD Thread, void *pvUser);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(int) saveStateThread(RTTHREAD Thread, void *pvUser);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(int) powerDownThread(RTTHREAD Thread, void *pvUser);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(int) vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
1d9b8ac46277d5cbab832794c5cfcce1e0521873vboxsync static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static const char *sSSMConsoleUnit;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync int loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(void) saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync static DECLCALLBACK(int) doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync HRESULT doEnumerateGuestProperties(CBSTR aPatterns,
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync void guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync void guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** @name Teleporter support
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync HRESULT teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** This can safely be used without holding any locks.
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync * An AutoCaller suffices to prevent it being destroy while in use and
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync * internally there is a lock providing the necessary serialization. */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync const ComObjPtr<ExtPackManager> mptrExtPackManager;
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync SharedFolderMap m_mapSharedFolders; // the console instances
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** The user mode VM handle. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Holds the number of "readonly" mpUVM callers (users). */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** Semaphore posted when the number of mpUVM callers drops to zero. */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** true when Console has entered the mpUVM destruction phase. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true when power down is initiated by vmstateChangeCallback (EMT). */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** true when vmstateChangeCallback shouldn't initiate a power down. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true if we already showed the snapshot folder size warning. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true if we already showed the snapshot folder ext4/xfs bug warning. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true if we already listed the disk type of the snapshot folder. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true if a USB controller is available (i.e. USB devices can be attached). */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** true if the VM power off was caused by reset. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Pointer to the VMM -> User (that's us) callbacks. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** The current network attachment type in the VM.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * This doesn't have to match the network attachment type maintained in the
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * NetworkAdapter. This is needed to change the network attachment
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * dynamically.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas + cLedUsb
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync PPDMLED mapNetworkLeds[36]; /**< @todo adapt this to the maximum network card count */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** List of attached USB storage devices. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync/* Note: FreeBSD needs this whether netflt is used or not. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Local machine state value. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /** Pointer to the progress object of a live cancelable task.
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * This is currently only used by Console::Teleport(), but is intended to later
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * be used by the live snapshot code path as well. Actions like
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * Console::PowerDown, which automatically cancels out the running snapshot /
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * teleportation operation, will cancel the teleportation / live snapshot
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync * operation before starting. */
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync /* The purpose of caching of some events is probably in order to
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync automatically fire them at new event listeners. However, there is no
831acea16fc15fff2cf90a217d02eea69bf27a40vboxsync (longer?) any code making use of this... */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** OnMousePointerShapeChange() cache */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** OnMouseCapabilityChange() cache */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /** OnKeyboardLedsChange() cache */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync /* We cannot RT_ZERO mpsc because of shape's vtable. */
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync mpsc.xHot = mpsc.yHot = mpsc.width = mpsc.height = 0;
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync#endif // !____H_CONSOLEIMPL
6a89b975ab84f4a47fb86fc27ba6c33c701720cfvboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */