1 | /* $Id: ConsoleImpl.h 47106 2013-07-12 09:36:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Console COM Class definition
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2005-2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_CONSOLEIMPL
|
---|
19 | #define ____H_CONSOLEIMPL
|
---|
20 |
|
---|
21 | #include "VirtualBoxBase.h"
|
---|
22 | #include "VBox/com/array.h"
|
---|
23 | #include "EventImpl.h"
|
---|
24 |
|
---|
25 | class Guest;
|
---|
26 | class Keyboard;
|
---|
27 | class Mouse;
|
---|
28 | class Display;
|
---|
29 | class MachineDebugger;
|
---|
30 | class TeleporterStateSrc;
|
---|
31 | class OUSBDevice;
|
---|
32 | class RemoteUSBDevice;
|
---|
33 | class SharedFolder;
|
---|
34 | class VRDEServerInfo;
|
---|
35 | class AudioSniffer;
|
---|
36 | class Nvram;
|
---|
37 | #ifdef VBOX_WITH_USB_VIDEO
|
---|
38 | class EmWebcam;
|
---|
39 | #endif
|
---|
40 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
41 | class UsbCardReader;
|
---|
42 | #endif
|
---|
43 | class ConsoleVRDPServer;
|
---|
44 | class VMMDev;
|
---|
45 | class Progress;
|
---|
46 | class BusAssignmentManager;
|
---|
47 | COM_STRUCT_OR_CLASS(IEventListener);
|
---|
48 | #ifdef VBOX_WITH_EXTPACK
|
---|
49 | class ExtPackManager;
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #include <VBox/RemoteDesktop/VRDE.h>
|
---|
53 | #include <VBox/vmm/pdmdrv.h>
|
---|
54 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
55 | # include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifdef RT_OS_WINDOWS
|
---|
59 | # include "../src-server/win/VBoxComEvents.h"
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | struct VUSBIRHCONFIG;
|
---|
63 | typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
|
---|
64 |
|
---|
65 | #include <list>
|
---|
66 | #include <vector>
|
---|
67 |
|
---|
68 | // defines
|
---|
69 | ///////////////////////////////////////////////////////////////////////////////
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * Checks the availability of the underlying VM device driver corresponding
|
---|
73 | * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
|
---|
74 | * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
|
---|
75 | * The translatable error message is defined in null context.
|
---|
76 | *
|
---|
77 | * Intended to used only within Console children (i.e. Keyboard, Mouse,
|
---|
78 | * Display, etc.).
|
---|
79 | *
|
---|
80 | * @param drv driver pointer to check (compare it with NULL)
|
---|
81 | */
|
---|
82 | #define CHECK_CONSOLE_DRV(drv) \
|
---|
83 | do { \
|
---|
84 | if (!(drv)) \
|
---|
85 | return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
|
---|
86 | } while (0)
|
---|
87 |
|
---|
88 | // Console
|
---|
89 | ///////////////////////////////////////////////////////////////////////////////
|
---|
90 |
|
---|
91 | /** IConsole implementation class */
|
---|
92 | class ATL_NO_VTABLE Console :
|
---|
93 | public VirtualBoxBase,
|
---|
94 | VBOX_SCRIPTABLE_IMPL(IConsole)
|
---|
95 | {
|
---|
96 | Q_OBJECT
|
---|
97 |
|
---|
98 | public:
|
---|
99 |
|
---|
100 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Console, IConsole)
|
---|
101 |
|
---|
102 | DECLARE_NOT_AGGREGATABLE(Console)
|
---|
103 |
|
---|
104 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
105 |
|
---|
106 | BEGIN_COM_MAP(Console)
|
---|
107 | VBOX_DEFAULT_INTERFACE_ENTRIES(IConsole)
|
---|
108 | END_COM_MAP()
|
---|
109 |
|
---|
110 | Console();
|
---|
111 | ~Console();
|
---|
112 |
|
---|
113 | HRESULT FinalConstruct();
|
---|
114 | void FinalRelease();
|
---|
115 |
|
---|
116 | // public initializers/uninitializers for internal purposes only
|
---|
117 | HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
|
---|
118 | void uninit();
|
---|
119 |
|
---|
120 | // IConsole properties
|
---|
121 | STDMETHOD(COMGETTER(Machine))(IMachine **aMachine);
|
---|
122 | STDMETHOD(COMGETTER(State))(MachineState_T *aMachineState);
|
---|
123 | STDMETHOD(COMGETTER(Guest))(IGuest **aGuest);
|
---|
124 | STDMETHOD(COMGETTER(Keyboard))(IKeyboard **aKeyboard);
|
---|
125 | STDMETHOD(COMGETTER(Mouse))(IMouse **aMouse);
|
---|
126 | STDMETHOD(COMGETTER(Display))(IDisplay **aDisplay);
|
---|
127 | STDMETHOD(COMGETTER(Debugger))(IMachineDebugger **aDebugger);
|
---|
128 | STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IUSBDevice *, aUSBDevices));
|
---|
129 | STDMETHOD(COMGETTER(RemoteUSBDevices))(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices));
|
---|
130 | STDMETHOD(COMGETTER(VRDEServerInfo))(IVRDEServerInfo **aVRDEServerInfo);
|
---|
131 | STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
|
---|
132 | STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);
|
---|
133 | STDMETHOD(COMGETTER(AttachedPCIDevices))(ComSafeArrayOut(IPCIDeviceAttachment *, aAttachments));
|
---|
134 | STDMETHOD(COMGETTER(UseHostClipboard))(BOOL *aUseHostClipboard);
|
---|
135 | STDMETHOD(COMSETTER(UseHostClipboard))(BOOL aUseHostClipboard);
|
---|
136 |
|
---|
137 | // IConsole methods
|
---|
138 | STDMETHOD(PowerUp)(IProgress **aProgress);
|
---|
139 | STDMETHOD(PowerUpPaused)(IProgress **aProgress);
|
---|
140 | STDMETHOD(PowerDown)(IProgress **aProgress);
|
---|
141 | STDMETHOD(Reset)();
|
---|
142 | STDMETHOD(Pause)();
|
---|
143 | STDMETHOD(Resume)();
|
---|
144 | STDMETHOD(PowerButton)();
|
---|
145 | STDMETHOD(SleepButton)();
|
---|
146 | STDMETHOD(GetPowerButtonHandled)(BOOL *aHandled);
|
---|
147 | STDMETHOD(GetGuestEnteredACPIMode)(BOOL *aEntered);
|
---|
148 | STDMETHOD(SaveState)(IProgress **aProgress);
|
---|
149 | STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
|
---|
150 | STDMETHOD(DiscardSavedState)(BOOL aRemoveFile);
|
---|
151 | STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType,
|
---|
152 | DeviceActivity_T *aDeviceActivity);
|
---|
153 | STDMETHOD(AttachUSBDevice)(IN_BSTR aId);
|
---|
154 | STDMETHOD(DetachUSBDevice)(IN_BSTR aId, IUSBDevice **aDevice);
|
---|
155 | STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice);
|
---|
156 | STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice);
|
---|
157 | STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
|
---|
158 | STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
|
---|
159 | STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription,
|
---|
160 | IProgress **aProgress);
|
---|
161 | STDMETHOD(DeleteSnapshot)(IN_BSTR aId, IProgress **aProgress);
|
---|
162 | STDMETHOD(DeleteSnapshotAndAllChildren)(IN_BSTR aId, IProgress **aProgress);
|
---|
163 | STDMETHOD(DeleteSnapshotRange)(IN_BSTR aStartId, IN_BSTR aEndId, IProgress **aProgress);
|
---|
164 | STDMETHOD(RestoreSnapshot)(ISnapshot *aSnapshot, IProgress **aProgress);
|
---|
165 | STDMETHOD(Teleport)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress);
|
---|
166 |
|
---|
167 | // public methods for internal purposes only
|
---|
168 |
|
---|
169 | /*
|
---|
170 | * Note: the following methods do not increase refcount. intended to be
|
---|
171 | * called only by the VM execution thread.
|
---|
172 | */
|
---|
173 |
|
---|
174 | Guest *getGuest() const { return mGuest; }
|
---|
175 | Keyboard *getKeyboard() const { return mKeyboard; }
|
---|
176 | Mouse *getMouse() const { return mMouse; }
|
---|
177 | Display *getDisplay() const { return mDisplay; }
|
---|
178 | MachineDebugger *getMachineDebugger() const { return mDebugger; }
|
---|
179 | AudioSniffer *getAudioSniffer() const { return mAudioSniffer; }
|
---|
180 |
|
---|
181 | const ComPtr<IMachine> &machine() const { return mMachine; }
|
---|
182 |
|
---|
183 | bool useHostClipboard() { return mfUseHostClipboard; }
|
---|
184 |
|
---|
185 | /** Method is called only from ConsoleVRDPServer */
|
---|
186 | IVRDEServer *getVRDEServer() const { return mVRDEServer; }
|
---|
187 |
|
---|
188 | ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; }
|
---|
189 |
|
---|
190 | HRESULT updateMachineState(MachineState_T aMachineState);
|
---|
191 |
|
---|
192 | // events from IInternalSessionControl
|
---|
193 | HRESULT onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
|
---|
194 | HRESULT onSerialPortChange(ISerialPort *aSerialPort);
|
---|
195 | HRESULT onParallelPortChange(IParallelPort *aParallelPort);
|
---|
196 | HRESULT onStorageControllerChange();
|
---|
197 | HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
|
---|
198 | HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
|
---|
199 | HRESULT onCPUExecutionCapChange(ULONG aExecutionCap);
|
---|
200 | HRESULT onClipboardModeChange(ClipboardMode_T aClipboardMode);
|
---|
201 | HRESULT onDragAndDropModeChange(DragAndDropMode_T aDragAndDropMode);
|
---|
202 | HRESULT onVRDEServerChange(BOOL aRestart);
|
---|
203 | HRESULT onVideoCaptureChange();
|
---|
204 | HRESULT onUSBControllerChange();
|
---|
205 | HRESULT onSharedFolderChange(BOOL aGlobal);
|
---|
206 | HRESULT onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
|
---|
207 | HRESULT onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
|
---|
208 | HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
|
---|
209 | HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
|
---|
210 | HRESULT getGuestProperty(IN_BSTR aKey, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags);
|
---|
211 | HRESULT setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags);
|
---|
212 | HRESULT enumerateGuestProperties(IN_BSTR aPatterns,
|
---|
213 | ComSafeArrayOut(BSTR, aNames),
|
---|
214 | ComSafeArrayOut(BSTR, aValues),
|
---|
215 | ComSafeArrayOut(LONG64, aTimestamps),
|
---|
216 | ComSafeArrayOut(BSTR, aFlags));
|
---|
217 | HRESULT onlineMergeMedium(IMediumAttachment *aMediumAttachment,
|
---|
218 | ULONG aSourceIdx, ULONG aTargetIdx,
|
---|
219 | IMedium *aSource, IMedium *aTarget,
|
---|
220 | BOOL aMergeForward, IMedium *aParentForTarget,
|
---|
221 | ComSafeArrayIn(IMedium *, aChildrenToReparent),
|
---|
222 | IProgress *aProgress);
|
---|
223 | VMMDev *getVMMDev() { return m_pVMMDev; }
|
---|
224 | AudioSniffer *getAudioSniffer() { return mAudioSniffer; }
|
---|
225 | #ifdef VBOX_WITH_EXTPACK
|
---|
226 | ExtPackManager *getExtPackManager();
|
---|
227 | #endif
|
---|
228 | EventSource *getEventSource() { return mEventSource; }
|
---|
229 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
230 | UsbCardReader *getUsbCardReader() { return mUsbCardReader; }
|
---|
231 | #endif
|
---|
232 | #ifdef VBOX_WITH_USB_VIDEO
|
---|
233 | EmWebcam *getEmWebcam() { return mEmWebcam; }
|
---|
234 | #endif
|
---|
235 |
|
---|
236 | int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
|
---|
237 | void VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus);
|
---|
238 | void VRDPClientConnect(uint32_t u32ClientId);
|
---|
239 | void VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
|
---|
240 | void VRDPInterceptAudio(uint32_t u32ClientId);
|
---|
241 | void VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
|
---|
242 | void VRDPInterceptClipboard(uint32_t u32ClientId);
|
---|
243 |
|
---|
244 | void processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList, bool fDescExt);
|
---|
245 | void reportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
|
---|
246 | ULONG aCpuKernel, ULONG aCpuIdle,
|
---|
247 | ULONG aMemTotal, ULONG aMemFree,
|
---|
248 | ULONG aMemBalloon, ULONG aMemShared,
|
---|
249 | ULONG aMemCache, ULONG aPageTotal,
|
---|
250 | ULONG aAllocVMM, ULONG aFreeVMM,
|
---|
251 | ULONG aBalloonedVMM, ULONG aSharedVMM,
|
---|
252 | ULONG aVmNetRx, ULONG aVmNetTx)
|
---|
253 | {
|
---|
254 | mControl->ReportVmStatistics(aValidStats, aCpuUser, aCpuKernel, aCpuIdle,
|
---|
255 | aMemTotal, aMemFree, aMemBalloon, aMemShared,
|
---|
256 | aMemCache, aPageTotal, aAllocVMM, aFreeVMM,
|
---|
257 | aBalloonedVMM, aSharedVMM, aVmNetRx, aVmNetTx);
|
---|
258 | }
|
---|
259 | void enableVMMStatistics(BOOL aEnable);
|
---|
260 |
|
---|
261 | HRESULT pause(Reason_T aReason);
|
---|
262 | HRESULT resume(Reason_T aReason);
|
---|
263 | HRESULT saveState(Reason_T aReason, IProgress **aProgress);
|
---|
264 |
|
---|
265 | // callback callers (partly; for some events console callbacks are notified
|
---|
266 | // directly from IInternalSessionControl event handlers declared above)
|
---|
267 | void onMousePointerShapeChange(bool fVisible, bool fAlpha,
|
---|
268 | uint32_t xHot, uint32_t yHot,
|
---|
269 | uint32_t width, uint32_t height,
|
---|
270 | ComSafeArrayIn(uint8_t, aShape));
|
---|
271 | void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor);
|
---|
272 | void onStateChange(MachineState_T aMachineState);
|
---|
273 | void onAdditionsStateChange();
|
---|
274 | void onAdditionsOutdated();
|
---|
275 | void onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
|
---|
276 | void onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
|
---|
277 | IVirtualBoxErrorInfo *aError);
|
---|
278 | void onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
|
---|
279 | HRESULT onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
|
---|
280 | void onVRDEServerInfoChange();
|
---|
281 |
|
---|
282 | static const PDMDRVREG DrvStatusReg;
|
---|
283 |
|
---|
284 | static HRESULT setErrorStatic(HRESULT aResultCode, const char *pcsz, ...);
|
---|
285 | HRESULT setInvalidMachineStateError();
|
---|
286 |
|
---|
287 | static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
|
---|
288 | static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
|
---|
289 | // Called from event listener
|
---|
290 | HRESULT onNATRedirectRuleChange(ULONG ulInstance, BOOL aNatRuleRemove,
|
---|
291 | NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
|
---|
292 |
|
---|
293 | private:
|
---|
294 |
|
---|
295 | /**
|
---|
296 | * Base template for AutoVMCaller and SafeVMPtr. Template arguments
|
---|
297 | * have the same meaning as arguments of Console::addVMCaller().
|
---|
298 | */
|
---|
299 | template <bool taQuiet = false, bool taAllowNullVM = false>
|
---|
300 | class AutoVMCallerBase
|
---|
301 | {
|
---|
302 | public:
|
---|
303 | AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(S_OK)
|
---|
304 | {
|
---|
305 | Assert(aThat);
|
---|
306 | mRC = aThat->addVMCaller(taQuiet, taAllowNullVM);
|
---|
307 | }
|
---|
308 | ~AutoVMCallerBase()
|
---|
309 | {
|
---|
310 | if (SUCCEEDED(mRC))
|
---|
311 | mThat->releaseVMCaller();
|
---|
312 | }
|
---|
313 | /** Decreases the number of callers before the instance is destroyed. */
|
---|
314 | void releaseCaller()
|
---|
315 | {
|
---|
316 | AssertReturnVoid(SUCCEEDED(mRC));
|
---|
317 | mThat->releaseVMCaller();
|
---|
318 | mRC = E_FAIL;
|
---|
319 | }
|
---|
320 | /** Restores the number of callers after by #release(). #rc() must be
|
---|
321 | * rechecked to ensure the operation succeeded. */
|
---|
322 | void addYY()
|
---|
323 | {
|
---|
324 | AssertReturnVoid(!SUCCEEDED(mRC));
|
---|
325 | mRC = mThat->addVMCaller(taQuiet, taAllowNullVM);
|
---|
326 | }
|
---|
327 | /** Returns the result of Console::addVMCaller() */
|
---|
328 | HRESULT rc() const { return mRC; }
|
---|
329 | /** Shortcut to SUCCEEDED(rc()) */
|
---|
330 | bool isOk() const { return SUCCEEDED(mRC); }
|
---|
331 | protected:
|
---|
332 | Console *mThat;
|
---|
333 | HRESULT mRC;
|
---|
334 | private:
|
---|
335 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase)
|
---|
336 | };
|
---|
337 |
|
---|
338 | #if 0
|
---|
339 | /**
|
---|
340 | * Helper class that protects sections of code using the mpUVM pointer by
|
---|
341 | * automatically calling addVMCaller() on construction and
|
---|
342 | * releaseVMCaller() on destruction. Intended for Console methods dealing
|
---|
343 | * with mpUVM. The usage pattern is:
|
---|
344 | * <code>
|
---|
345 | * AutoVMCaller autoVMCaller(this);
|
---|
346 | * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
|
---|
347 | * ...
|
---|
348 | * VMR3ReqCall (mpUVM, ...
|
---|
349 | * </code>
|
---|
350 | *
|
---|
351 | * @note Temporarily locks the argument for writing.
|
---|
352 | *
|
---|
353 | * @sa SafeVMPtr, SafeVMPtrQuiet
|
---|
354 | * @obsolete Use SafeVMPtr
|
---|
355 | */
|
---|
356 | typedef AutoVMCallerBase<false, false> AutoVMCaller;
|
---|
357 | #endif
|
---|
358 |
|
---|
359 | /**
|
---|
360 | * Same as AutoVMCaller but doesn't set extended error info on failure.
|
---|
361 | *
|
---|
362 | * @note Temporarily locks the argument for writing.
|
---|
363 | * @obsolete Use SafeVMPtrQuiet
|
---|
364 | */
|
---|
365 | typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
|
---|
366 |
|
---|
367 | /**
|
---|
368 | * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
|
---|
369 | * instead of assertion).
|
---|
370 | *
|
---|
371 | * @note Temporarily locks the argument for writing.
|
---|
372 | * @obsolete Use SafeVMPtr
|
---|
373 | */
|
---|
374 | typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Same as AutoVMCaller but doesn't set extended error info on failure
|
---|
378 | * and allows a null VM pointer (to trigger an error instead of
|
---|
379 | * assertion).
|
---|
380 | *
|
---|
381 | * @note Temporarily locks the argument for writing.
|
---|
382 | * @obsolete Use SafeVMPtrQuiet
|
---|
383 | */
|
---|
384 | typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
|
---|
385 |
|
---|
386 | /**
|
---|
387 | * Base template for SafeVMPtr and SafeVMPtrQuiet.
|
---|
388 | */
|
---|
389 | template<bool taQuiet = false>
|
---|
390 | class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
|
---|
391 | {
|
---|
392 | typedef AutoVMCallerBase<taQuiet, true> Base;
|
---|
393 | public:
|
---|
394 | SafeVMPtrBase(Console *aThat) : Base(aThat), mpUVM(NULL)
|
---|
395 | {
|
---|
396 | if (SUCCEEDED(Base::mRC))
|
---|
397 | Base::mRC = aThat->safeVMPtrRetainer(&mpUVM, taQuiet);
|
---|
398 | }
|
---|
399 | ~SafeVMPtrBase()
|
---|
400 | {
|
---|
401 | if (SUCCEEDED(Base::mRC))
|
---|
402 | release();
|
---|
403 | }
|
---|
404 | /** Direct PUVM access. */
|
---|
405 | PUVM rawUVM() const { return mpUVM; }
|
---|
406 | /** Release the handles. */
|
---|
407 | void release()
|
---|
408 | {
|
---|
409 | AssertReturnVoid(SUCCEEDED(Base::mRC));
|
---|
410 | Base::mThat->safeVMPtrReleaser(&mpUVM);
|
---|
411 | Base::releaseCaller();
|
---|
412 | }
|
---|
413 |
|
---|
414 | private:
|
---|
415 | PUVM mpUVM;
|
---|
416 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase)
|
---|
417 | };
|
---|
418 |
|
---|
419 | public:
|
---|
420 |
|
---|
421 | /*
|
---|
422 | * Helper class that safely manages the Console::mpUVM pointer
|
---|
423 | * by calling addVMCaller() on construction and releaseVMCaller() on
|
---|
424 | * destruction. Intended for Console children. The usage pattern is:
|
---|
425 | * <code>
|
---|
426 | * Console::SafeVMPtr ptrVM(mParent);
|
---|
427 | * if (!ptrVM.isOk())
|
---|
428 | * return ptrVM.rc();
|
---|
429 | * ...
|
---|
430 | * VMR3ReqCall(ptrVM.rawUVM(), ...
|
---|
431 | * ...
|
---|
432 | * printf("%p\n", ptrVM.rawUVM());
|
---|
433 | * </code>
|
---|
434 | *
|
---|
435 | * @note Temporarily locks the argument for writing.
|
---|
436 | *
|
---|
437 | * @sa SafeVMPtrQuiet, AutoVMCaller
|
---|
438 | */
|
---|
439 | typedef SafeVMPtrBase<false> SafeVMPtr;
|
---|
440 |
|
---|
441 | /**
|
---|
442 | * A deviation of SafeVMPtr that doesn't set the error info on failure.
|
---|
443 | * Intended for pieces of code that don't need to return the VM access
|
---|
444 | * failure to the caller. The usage pattern is:
|
---|
445 | * <code>
|
---|
446 | * Console::SafeVMPtrQuiet pVM(mParent);
|
---|
447 | * if (pVM.rc())
|
---|
448 | * VMR3ReqCall(pVM, ...
|
---|
449 | * return S_OK;
|
---|
450 | * </code>
|
---|
451 | *
|
---|
452 | * @note Temporarily locks the argument for writing.
|
---|
453 | *
|
---|
454 | * @sa SafeVMPtr, AutoVMCaller
|
---|
455 | */
|
---|
456 | typedef SafeVMPtrBase<true> SafeVMPtrQuiet;
|
---|
457 |
|
---|
458 | class SharedFolderData
|
---|
459 | {
|
---|
460 | public:
|
---|
461 | SharedFolderData()
|
---|
462 | { }
|
---|
463 |
|
---|
464 | SharedFolderData(const Utf8Str &aHostPath,
|
---|
465 | bool aWritable,
|
---|
466 | bool aAutoMount)
|
---|
467 | : m_strHostPath(aHostPath),
|
---|
468 | m_fWritable(aWritable),
|
---|
469 | m_fAutoMount(aAutoMount)
|
---|
470 | { }
|
---|
471 |
|
---|
472 | // copy constructor
|
---|
473 | SharedFolderData(const SharedFolderData& aThat)
|
---|
474 | : m_strHostPath(aThat.m_strHostPath),
|
---|
475 | m_fWritable(aThat.m_fWritable),
|
---|
476 | m_fAutoMount(aThat.m_fAutoMount)
|
---|
477 | { }
|
---|
478 |
|
---|
479 | Utf8Str m_strHostPath;
|
---|
480 | bool m_fWritable;
|
---|
481 | bool m_fAutoMount;
|
---|
482 | };
|
---|
483 |
|
---|
484 | typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
|
---|
485 | typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
|
---|
486 | typedef std::map<Utf8Str, ComPtr<IMediumAttachment> > MediumAttachmentMap;
|
---|
487 |
|
---|
488 | private:
|
---|
489 |
|
---|
490 | typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
|
---|
491 | typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
|
---|
492 |
|
---|
493 | HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
|
---|
494 | void releaseVMCaller();
|
---|
495 | HRESULT safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
|
---|
496 | void safeVMPtrReleaser(PUVM *a_ppUVM);
|
---|
497 |
|
---|
498 | HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
|
---|
499 |
|
---|
500 | HRESULT powerUp(IProgress **aProgress, bool aPaused);
|
---|
501 | HRESULT powerDown(IProgress *aProgress = NULL);
|
---|
502 |
|
---|
503 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
504 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
505 | HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
|
---|
506 | HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
|
---|
507 | #endif
|
---|
508 | HRESULT powerDownHostInterfaces();
|
---|
509 |
|
---|
510 | HRESULT setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
|
---|
511 | HRESULT setMachineStateLocally(MachineState_T aMachineState)
|
---|
512 | {
|
---|
513 | return setMachineState(aMachineState, false /* aUpdateServer */);
|
---|
514 | }
|
---|
515 |
|
---|
516 | HRESULT findSharedFolder(const Utf8Str &strName,
|
---|
517 | ComObjPtr<SharedFolder> &aSharedFolder,
|
---|
518 | bool aSetError = false);
|
---|
519 |
|
---|
520 | HRESULT fetchSharedFolders(BOOL aGlobal);
|
---|
521 | bool findOtherSharedFolder(const Utf8Str &straName,
|
---|
522 | SharedFolderDataMap::const_iterator &aIt);
|
---|
523 |
|
---|
524 | HRESULT createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
|
---|
525 | HRESULT removeSharedFolder(const Utf8Str &strName);
|
---|
526 |
|
---|
527 | static DECLCALLBACK(int) configConstructor(PUVM pUVM, PVM pVM, void *pvConsole);
|
---|
528 | int configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock);
|
---|
529 | int configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
530 | int configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
531 |
|
---|
532 | int configGraphicsController(PCFGMNODE pDevices, const char *pcszDevice,
|
---|
533 | BusAssignmentManager *pBusMgr,
|
---|
534 | const ComPtr<IMachine> &pMachine,
|
---|
535 | const ComPtr<IBIOSSettings> &biosSettings,
|
---|
536 | bool fHMEnabled);
|
---|
537 | int configMediumAttachment(PCFGMNODE pCtlInst,
|
---|
538 | const char *pcszDevice,
|
---|
539 | unsigned uInstance,
|
---|
540 | StorageBus_T enmBus,
|
---|
541 | bool fUseHostIOCache,
|
---|
542 | bool fBuiltinIoCache,
|
---|
543 | bool fSetupMerge,
|
---|
544 | unsigned uMergeSource,
|
---|
545 | unsigned uMergeTarget,
|
---|
546 | IMediumAttachment *pMediumAtt,
|
---|
547 | MachineState_T aMachineState,
|
---|
548 | HRESULT *phrc,
|
---|
549 | bool fAttachDetach,
|
---|
550 | bool fForceUnmount,
|
---|
551 | bool fHotplug,
|
---|
552 | PUVM pUVM,
|
---|
553 | DeviceType_T *paLedDevType);
|
---|
554 | int configMedium(PCFGMNODE pLunL0,
|
---|
555 | bool fPassthrough,
|
---|
556 | DeviceType_T enmType,
|
---|
557 | bool fUseHostIOCache,
|
---|
558 | bool fBuiltinIoCache,
|
---|
559 | bool fSetupMerge,
|
---|
560 | unsigned uMergeSource,
|
---|
561 | unsigned uMergeTarget,
|
---|
562 | const char *pcszBwGroup,
|
---|
563 | bool fDiscard,
|
---|
564 | IMedium *pMedium,
|
---|
565 | MachineState_T aMachineState,
|
---|
566 | HRESULT *phrc);
|
---|
567 | static DECLCALLBACK(int) reconfigureMediumAttachment(Console *pConsole,
|
---|
568 | PUVM pUVM,
|
---|
569 | const char *pcszDevice,
|
---|
570 | unsigned uInstance,
|
---|
571 | StorageBus_T enmBus,
|
---|
572 | bool fUseHostIOCache,
|
---|
573 | bool fBuiltinIoCache,
|
---|
574 | bool fSetupMerge,
|
---|
575 | unsigned uMergeSource,
|
---|
576 | unsigned uMergeTarget,
|
---|
577 | IMediumAttachment *aMediumAtt,
|
---|
578 | MachineState_T aMachineState,
|
---|
579 | HRESULT *phrc);
|
---|
580 | static DECLCALLBACK(int) changeRemovableMedium(Console *pThis,
|
---|
581 | PUVM pUVM,
|
---|
582 | const char *pcszDevice,
|
---|
583 | unsigned uInstance,
|
---|
584 | StorageBus_T enmBus,
|
---|
585 | bool fUseHostIOCache,
|
---|
586 | IMediumAttachment *aMediumAtt,
|
---|
587 | bool fForce);
|
---|
588 |
|
---|
589 | HRESULT attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
|
---|
590 | void attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds,
|
---|
591 | uint64_t uFirst, uint64_t uLast,
|
---|
592 | Console::MediumAttachmentMap *pmapMediumAttachments,
|
---|
593 | const char *pcszDevice, unsigned uInstance);
|
---|
594 |
|
---|
595 | int configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
|
---|
596 | INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
|
---|
597 | PCFGMNODE pLunL0, PCFGMNODE pInst,
|
---|
598 | bool fAttachDetach, bool fIgnoreConnectFailure);
|
---|
599 |
|
---|
600 | static DECLCALLBACK(int) configGuestProperties(void *pvConsole, PUVM pUVM);
|
---|
601 | static DECLCALLBACK(int) configGuestControl(void *pvConsole);
|
---|
602 | static DECLCALLBACK(void) vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
|
---|
603 | static DECLCALLBACK(int) unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
|
---|
604 | static DECLCALLBACK(int) plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
|
---|
605 | HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
|
---|
606 | HRESULT doCPURemove(ULONG aCpu, PUVM pUVM);
|
---|
607 | HRESULT doCPUAdd(ULONG aCpu, PUVM pUVM);
|
---|
608 |
|
---|
609 | HRESULT doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
|
---|
610 | unsigned uLun, INetworkAdapter *aNetworkAdapter);
|
---|
611 | static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
|
---|
612 | unsigned uInstance, unsigned uLun,
|
---|
613 | INetworkAdapter *aNetworkAdapter);
|
---|
614 |
|
---|
615 | void changeClipboardMode(ClipboardMode_T aClipboardMode);
|
---|
616 | void changeDragAndDropMode(DragAndDropMode_T aDragAndDropMode);
|
---|
617 |
|
---|
618 | #ifdef VBOX_WITH_USB
|
---|
619 | HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
|
---|
620 | HRESULT detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
|
---|
621 |
|
---|
622 | static DECLCALLBACK(int) usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
|
---|
623 | bool aRemote, const char *aAddress, void *pvRemoteBackend, USHORT aPortVersion, ULONG aMaskedIfs);
|
---|
624 | static DECLCALLBACK(int) usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
|
---|
625 | #endif
|
---|
626 |
|
---|
627 | static DECLCALLBACK(int) attachStorageDevice(Console *pThis,
|
---|
628 | PUVM pUVM,
|
---|
629 | const char *pcszDevice,
|
---|
630 | unsigned uInstance,
|
---|
631 | StorageBus_T enmBus,
|
---|
632 | bool fUseHostIOCache,
|
---|
633 | IMediumAttachment *aMediumAtt,
|
---|
634 | bool fSilent);
|
---|
635 | static DECLCALLBACK(int) detachStorageDevice(Console *pThis,
|
---|
636 | PUVM pUVM,
|
---|
637 | const char *pcszDevice,
|
---|
638 | unsigned uInstance,
|
---|
639 | StorageBus_T enmBus,
|
---|
640 | IMediumAttachment *aMediumAtt,
|
---|
641 | bool fSilent);
|
---|
642 | HRESULT doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
|
---|
643 | HRESULT doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
|
---|
644 |
|
---|
645 | static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
|
---|
646 |
|
---|
647 | static DECLCALLBACK(int) stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
|
---|
648 |
|
---|
649 | static DECLCALLBACK(void) genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
|
---|
650 | const char *pszErrorFmt, va_list va);
|
---|
651 |
|
---|
652 | void setVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
|
---|
653 | static DECLCALLBACK(void) setVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
|
---|
654 | const char *pszErrorId, const char *pszFormat, va_list va);
|
---|
655 |
|
---|
656 | HRESULT captureUSBDevices(PUVM pUVM);
|
---|
657 | void detachAllUSBDevices(bool aDone);
|
---|
658 |
|
---|
659 | static DECLCALLBACK(int) powerUpThread(RTTHREAD Thread, void *pvUser);
|
---|
660 | static DECLCALLBACK(int) saveStateThread(RTTHREAD Thread, void *pvUser);
|
---|
661 | static DECLCALLBACK(int) powerDownThread(RTTHREAD Thread, void *pvUser);
|
---|
662 |
|
---|
663 | static DECLCALLBACK(int) vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
664 | static DECLCALLBACK(void) vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
665 | static DECLCALLBACK(void) vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
666 | static DECLCALLBACK(void) vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
667 | static DECLCALLBACK(void) vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
668 |
|
---|
669 | static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
670 | static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
|
---|
671 | static DECLCALLBACK(int) drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
|
---|
672 | static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
|
---|
673 | static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
674 |
|
---|
675 | int mcAudioRefs;
|
---|
676 | volatile uint32_t mcVRDPClients;
|
---|
677 | uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
|
---|
678 | volatile bool mcGuestCredentialsProvided;
|
---|
679 |
|
---|
680 | static const char *sSSMConsoleUnit;
|
---|
681 | static uint32_t sSSMConsoleVer;
|
---|
682 |
|
---|
683 | HRESULT loadDataFromSavedState();
|
---|
684 | int loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
|
---|
685 |
|
---|
686 | static DECLCALLBACK(void) saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
|
---|
687 | static DECLCALLBACK(int) loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
|
---|
688 |
|
---|
689 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
690 | static DECLCALLBACK(int) doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
|
---|
691 | HRESULT doEnumerateGuestProperties(CBSTR aPatterns,
|
---|
692 | ComSafeArrayOut(BSTR, aNames),
|
---|
693 | ComSafeArrayOut(BSTR, aValues),
|
---|
694 | ComSafeArrayOut(LONG64, aTimestamps),
|
---|
695 | ComSafeArrayOut(BSTR, aFlags));
|
---|
696 |
|
---|
697 | void guestPropertiesHandleVMReset(void);
|
---|
698 | bool guestPropertiesVRDPEnabled(void);
|
---|
699 | void guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
|
---|
700 | void guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
|
---|
701 | void guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
|
---|
702 | void guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
|
---|
703 | void guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
|
---|
704 | void guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
|
---|
705 | void guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
|
---|
706 | void guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
|
---|
707 | #endif
|
---|
708 |
|
---|
709 | /** @name Teleporter support
|
---|
710 | * @{ */
|
---|
711 | static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
|
---|
712 | HRESULT teleporterSrc(TeleporterStateSrc *pState);
|
---|
713 | HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
|
---|
714 | HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
|
---|
715 | HRESULT teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
|
---|
716 | Progress *pProgress, bool *pfPowerOffOnFailure);
|
---|
717 | static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
|
---|
718 | /** @} */
|
---|
719 |
|
---|
720 | bool mSavedStateDataLoaded : 1;
|
---|
721 |
|
---|
722 | const ComPtr<IMachine> mMachine;
|
---|
723 | const ComPtr<IInternalMachineControl> mControl;
|
---|
724 |
|
---|
725 | const ComPtr<IVRDEServer> mVRDEServer;
|
---|
726 |
|
---|
727 | ConsoleVRDPServer * const mConsoleVRDPServer;
|
---|
728 | bool mfVRDEChangeInProcess;
|
---|
729 | bool mfVRDEChangePending;
|
---|
730 |
|
---|
731 | const ComObjPtr<Guest> mGuest;
|
---|
732 | const ComObjPtr<Keyboard> mKeyboard;
|
---|
733 | const ComObjPtr<Mouse> mMouse;
|
---|
734 | const ComObjPtr<Display> mDisplay;
|
---|
735 | const ComObjPtr<MachineDebugger> mDebugger;
|
---|
736 | const ComObjPtr<VRDEServerInfo> mVRDEServerInfo;
|
---|
737 | /** This can safely be used without holding any locks.
|
---|
738 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
739 | * internally there is a lock providing the necessary serialization. */
|
---|
740 | const ComObjPtr<EventSource> mEventSource;
|
---|
741 | #ifdef VBOX_WITH_EXTPACK
|
---|
742 | const ComObjPtr<ExtPackManager> mptrExtPackManager;
|
---|
743 | #endif
|
---|
744 |
|
---|
745 | USBDeviceList mUSBDevices;
|
---|
746 | RemoteUSBDeviceList mRemoteUSBDevices;
|
---|
747 |
|
---|
748 | SharedFolderDataMap m_mapGlobalSharedFolders;
|
---|
749 | SharedFolderDataMap m_mapMachineSharedFolders;
|
---|
750 | SharedFolderMap m_mapSharedFolders; // the console instances
|
---|
751 |
|
---|
752 | /** The user mode VM handle. */
|
---|
753 | PUVM mpUVM;
|
---|
754 | /** Holds the number of "readonly" mpUVM callers (users). */
|
---|
755 | uint32_t mVMCallers;
|
---|
756 | /** Semaphore posted when the number of mpUVM callers drops to zero. */
|
---|
757 | RTSEMEVENT mVMZeroCallersSem;
|
---|
758 | /** true when Console has entered the mpUVM destruction phase. */
|
---|
759 | bool mVMDestroying : 1;
|
---|
760 | /** true when power down is initiated by vmstateChangeCallback (EMT). */
|
---|
761 | bool mVMPoweredOff : 1;
|
---|
762 | /** true when vmstateChangeCallback shouldn't initiate a power down. */
|
---|
763 | bool mVMIsAlreadyPoweringOff : 1;
|
---|
764 | /** true if we already showed the snapshot folder size warning. */
|
---|
765 | bool mfSnapshotFolderSizeWarningShown : 1;
|
---|
766 | /** true if we already showed the snapshot folder ext4/xfs bug warning. */
|
---|
767 | bool mfSnapshotFolderExt4WarningShown : 1;
|
---|
768 | /** true if we already listed the disk type of the snapshot folder. */
|
---|
769 | bool mfSnapshotFolderDiskTypeShown : 1;
|
---|
770 |
|
---|
771 | /** Pointer to the VMM -> User (that's us) callbacks. */
|
---|
772 | struct MYVMM2USERMETHODS : public VMM2USERMETHODS
|
---|
773 | {
|
---|
774 | Console *pConsole;
|
---|
775 | } *mpVmm2UserMethods;
|
---|
776 |
|
---|
777 | /** The current network attachment type in the VM.
|
---|
778 | * This doesn't have to match the network attachment type maintained in the
|
---|
779 | * NetworkAdapter. This is needed to change the network attachment
|
---|
780 | * dynamically.
|
---|
781 | */
|
---|
782 | typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
|
---|
783 | NetworkAttachmentTypeVector meAttachmentType;
|
---|
784 |
|
---|
785 | VMMDev * m_pVMMDev;
|
---|
786 | AudioSniffer * const mAudioSniffer;
|
---|
787 | Nvram * const mNvram;
|
---|
788 | #ifdef VBOX_WITH_USB_VIDEO
|
---|
789 | EmWebcam * const mEmWebcam;
|
---|
790 | #endif
|
---|
791 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
792 | UsbCardReader * const mUsbCardReader;
|
---|
793 | #endif
|
---|
794 | BusAssignmentManager* mBusMgr;
|
---|
795 |
|
---|
796 | enum
|
---|
797 | {
|
---|
798 | iLedFloppy = 0,
|
---|
799 | cLedFloppy = 2,
|
---|
800 | iLedIde = iLedFloppy + cLedFloppy,
|
---|
801 | cLedIde = 4,
|
---|
802 | iLedSata = iLedIde + cLedIde,
|
---|
803 | cLedSata = 30,
|
---|
804 | iLedScsi = iLedSata + cLedSata,
|
---|
805 | cLedScsi = 16,
|
---|
806 | iLedSas = iLedScsi + cLedScsi,
|
---|
807 | cLedSas = 8,
|
---|
808 | cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas
|
---|
809 | };
|
---|
810 | DeviceType_T maStorageDevType[cLedStorage];
|
---|
811 | PPDMLED mapStorageLeds[cLedStorage];
|
---|
812 | PPDMLED mapNetworkLeds[36]; /**< @todo adapt this to the maximum network card count */
|
---|
813 | PPDMLED mapSharedFolderLed;
|
---|
814 | PPDMLED mapUSBLed[2];
|
---|
815 |
|
---|
816 | MediumAttachmentMap mapMediumAttachments;
|
---|
817 |
|
---|
818 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
819 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
820 | Utf8Str maTAPDeviceName[8];
|
---|
821 | RTFILE maTapFD[8];
|
---|
822 | #endif
|
---|
823 |
|
---|
824 | bool mVMStateChangeCallbackDisabled;
|
---|
825 |
|
---|
826 | bool mfUseHostClipboard;
|
---|
827 |
|
---|
828 | /** Local machine state value. */
|
---|
829 | MachineState_T mMachineState;
|
---|
830 |
|
---|
831 | /** Pointer to the progress object of a live cancelable task.
|
---|
832 | *
|
---|
833 | * This is currently only used by Console::Teleport(), but is intended to later
|
---|
834 | * be used by the live snapshot code path as well. Actions like
|
---|
835 | * Console::PowerDown, which automatically cancels out the running snapshot /
|
---|
836 | * teleportation operation, will cancel the teleportation / live snapshot
|
---|
837 | * operation before starting. */
|
---|
838 | ComObjPtr<Progress> mptrCancelableProgress;
|
---|
839 |
|
---|
840 | /* The purpose of caching of some events is probably in order to
|
---|
841 | automatically fire them at new event listeners. However, there is no
|
---|
842 | (longer?) any code making use of this... */
|
---|
843 | #ifdef CONSOLE_WITH_EVENT_CACHE
|
---|
844 | struct
|
---|
845 | {
|
---|
846 | /** OnMousePointerShapeChange() cache */
|
---|
847 | struct
|
---|
848 | {
|
---|
849 | bool valid;
|
---|
850 | bool visible;
|
---|
851 | bool alpha;
|
---|
852 | uint32_t xHot;
|
---|
853 | uint32_t yHot;
|
---|
854 | uint32_t width;
|
---|
855 | uint32_t height;
|
---|
856 | com::SafeArray<BYTE> shape;
|
---|
857 | } mpsc;
|
---|
858 |
|
---|
859 | /** OnMouseCapabilityChange() cache */
|
---|
860 | struct
|
---|
861 | {
|
---|
862 | bool valid;
|
---|
863 | BOOL supportsAbsolute;
|
---|
864 | BOOL supportsRelative;
|
---|
865 | BOOL needsHostCursor;
|
---|
866 | } mcc;
|
---|
867 |
|
---|
868 | /** OnKeyboardLedsChange() cache */
|
---|
869 | struct
|
---|
870 | {
|
---|
871 | bool valid;
|
---|
872 | bool numLock;
|
---|
873 | bool capsLock;
|
---|
874 | bool scrollLock;
|
---|
875 | } klc;
|
---|
876 |
|
---|
877 | void clear()
|
---|
878 | {
|
---|
879 | RT_ZERO(mcc);
|
---|
880 | RT_ZERO(klc);
|
---|
881 |
|
---|
882 | /* We cannot RT_ZERO mpsc because of shape's vtable. */
|
---|
883 | mpsc.shape.setNull();
|
---|
884 | mpsc.valid = mpsc.visible = mpsc.alpha = false;
|
---|
885 | mpsc.xHot = mpsc.yHot = mpsc.width = mpsc.height = 0;
|
---|
886 | }
|
---|
887 | } mCallbackData;
|
---|
888 | #endif
|
---|
889 | ComPtr<IEventListener> mVmListener;
|
---|
890 |
|
---|
891 | friend struct VMTask;
|
---|
892 | };
|
---|
893 |
|
---|
894 | #endif // !____H_CONSOLEIMPL
|
---|
895 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|