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