1 | /* $Id: ConsoleImpl.h 59787 2016-02-23 13:40:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Console COM Class definition
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2005-2016 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 | #include "SecretKeyStore.h"
|
---|
25 | #include "ConsoleWrap.h"
|
---|
26 |
|
---|
27 | class Guest;
|
---|
28 | class Keyboard;
|
---|
29 | class Mouse;
|
---|
30 | class Display;
|
---|
31 | class MachineDebugger;
|
---|
32 | class TeleporterStateSrc;
|
---|
33 | class OUSBDevice;
|
---|
34 | class RemoteUSBDevice;
|
---|
35 | class SharedFolder;
|
---|
36 | class VRDEServerInfo;
|
---|
37 | class EmulatedUSB;
|
---|
38 | class AudioVRDE;
|
---|
39 | class Nvram;
|
---|
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 | class VMMDevMouseInterface;
|
---|
52 | class DisplayMouseInterface;
|
---|
53 |
|
---|
54 | #include <iprt/uuid.h>
|
---|
55 | #include <iprt/memsafer.h>
|
---|
56 | #include <VBox/RemoteDesktop/VRDE.h>
|
---|
57 | #include <VBox/vmm/pdmdrv.h>
|
---|
58 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
59 | # include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #ifdef RT_OS_WINDOWS
|
---|
63 | # include "../src-server/win/VBoxComEvents.h"
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | struct VUSBIRHCONFIG;
|
---|
67 | typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
|
---|
68 |
|
---|
69 | #include <list>
|
---|
70 | #include <vector>
|
---|
71 |
|
---|
72 | // defines
|
---|
73 | ///////////////////////////////////////////////////////////////////////////////
|
---|
74 |
|
---|
75 | /**
|
---|
76 | * Checks the availability of the underlying VM device driver corresponding
|
---|
77 | * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
|
---|
78 | * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
|
---|
79 | * The translatable error message is defined in null context.
|
---|
80 | *
|
---|
81 | * Intended to used only within Console children (i.e. Keyboard, Mouse,
|
---|
82 | * Display, etc.).
|
---|
83 | *
|
---|
84 | * @param drv driver pointer to check (compare it with NULL)
|
---|
85 | */
|
---|
86 | #define CHECK_CONSOLE_DRV(drv) \
|
---|
87 | do { \
|
---|
88 | if (!(drv)) \
|
---|
89 | return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
|
---|
90 | } while (0)
|
---|
91 |
|
---|
92 | // Console
|
---|
93 | ///////////////////////////////////////////////////////////////////////////////
|
---|
94 |
|
---|
95 | class ConsoleMouseInterface
|
---|
96 | {
|
---|
97 | public:
|
---|
98 | virtual VMMDevMouseInterface *i_getVMMDevMouseInterface(){return NULL;}
|
---|
99 | virtual DisplayMouseInterface *i_getDisplayMouseInterface(){return NULL;}
|
---|
100 | virtual void i_onMouseCapabilityChange(BOOL supportsAbsolute,
|
---|
101 | BOOL supportsRelative,
|
---|
102 | BOOL supportsMT,
|
---|
103 | BOOL needsHostCursor){NOREF(supportsAbsolute); NOREF(supportsRelative); NOREF(supportsMT); NOREF(needsHostCursor);}
|
---|
104 | };
|
---|
105 |
|
---|
106 | /** IConsole implementation class */
|
---|
107 | class ATL_NO_VTABLE Console :
|
---|
108 | public ConsoleWrap,
|
---|
109 | public ConsoleMouseInterface
|
---|
110 | {
|
---|
111 |
|
---|
112 | public:
|
---|
113 |
|
---|
114 | DECLARE_EMPTY_CTOR_DTOR(Console)
|
---|
115 |
|
---|
116 | HRESULT FinalConstruct();
|
---|
117 | void FinalRelease();
|
---|
118 |
|
---|
119 | // public initializers/uninitializers for internal purposes only
|
---|
120 | HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
|
---|
121 | void uninit();
|
---|
122 |
|
---|
123 |
|
---|
124 | // public methods for internal purposes only
|
---|
125 |
|
---|
126 | /*
|
---|
127 | * Note: the following methods do not increase refcount. intended to be
|
---|
128 | * called only by the VM execution thread.
|
---|
129 | */
|
---|
130 |
|
---|
131 | Guest *i_getGuest() const { return mGuest; }
|
---|
132 | Keyboard *i_getKeyboard() const { return mKeyboard; }
|
---|
133 | Mouse *i_getMouse() const { return mMouse; }
|
---|
134 | Display *i_getDisplay() const { return mDisplay; }
|
---|
135 | MachineDebugger *i_getMachineDebugger() const { return mDebugger; }
|
---|
136 | AudioVRDE *i_getAudioVRDE() const { return mAudioVRDE; }
|
---|
137 |
|
---|
138 | const ComPtr<IMachine> &i_machine() const { return mMachine; }
|
---|
139 | const Bstr &i_getId() const { return mstrUuid; }
|
---|
140 |
|
---|
141 | bool i_useHostClipboard() { return mfUseHostClipboard; }
|
---|
142 |
|
---|
143 | /** Method is called only from ConsoleVRDPServer */
|
---|
144 | IVRDEServer *i_getVRDEServer() const { return mVRDEServer; }
|
---|
145 |
|
---|
146 | ConsoleVRDPServer *i_consoleVRDPServer() const { return mConsoleVRDPServer; }
|
---|
147 |
|
---|
148 | HRESULT i_updateMachineState(MachineState_T aMachineState);
|
---|
149 | HRESULT i_getNominalState(MachineState_T &aNominalState);
|
---|
150 |
|
---|
151 | // events from IInternalSessionControl
|
---|
152 | HRESULT i_onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
|
---|
153 | HRESULT i_onSerialPortChange(ISerialPort *aSerialPort);
|
---|
154 | HRESULT i_onParallelPortChange(IParallelPort *aParallelPort);
|
---|
155 | HRESULT i_onStorageControllerChange();
|
---|
156 | HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
|
---|
157 | HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
|
---|
158 | HRESULT i_onCPUExecutionCapChange(ULONG aExecutionCap);
|
---|
159 | HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
|
---|
160 | HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
|
---|
161 | HRESULT i_onVRDEServerChange(BOOL aRestart);
|
---|
162 | HRESULT i_onVideoCaptureChange();
|
---|
163 | HRESULT i_onUSBControllerChange();
|
---|
164 | HRESULT i_onSharedFolderChange(BOOL aGlobal);
|
---|
165 | HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs,
|
---|
166 | const Utf8Str &aCaptureFilename);
|
---|
167 | HRESULT i_onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
|
---|
168 | HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
|
---|
169 | HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
|
---|
170 | HRESULT i_onExtraDataChange(IN_BSTR aMachineId, IN_BSTR aKey, IN_BSTR aVal);
|
---|
171 |
|
---|
172 | HRESULT i_getGuestProperty(const Utf8Str &aName, Utf8Str *aValue, LONG64 *aTimestamp, Utf8Str *aFlags);
|
---|
173 | HRESULT i_setGuestProperty(const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags);
|
---|
174 | HRESULT i_deleteGuestProperty(const Utf8Str &aName);
|
---|
175 | HRESULT i_enumerateGuestProperties(const Utf8Str &aPatterns,
|
---|
176 | std::vector<Utf8Str> &aNames,
|
---|
177 | std::vector<Utf8Str> &aValues,
|
---|
178 | std::vector<LONG64> &aTimestamps,
|
---|
179 | std::vector<Utf8Str> &aFlags);
|
---|
180 | HRESULT i_onlineMergeMedium(IMediumAttachment *aMediumAttachment,
|
---|
181 | ULONG aSourceIdx, ULONG aTargetIdx,
|
---|
182 | IProgress *aProgress);
|
---|
183 | HRESULT i_reconfigureMediumAttachments(const std::vector<ComPtr<IMediumAttachment> > &aAttachments);
|
---|
184 | int i_hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName);
|
---|
185 | VMMDev *i_getVMMDev() { return m_pVMMDev; }
|
---|
186 | AudioVRDE *i_getAudioVRDE() { return mAudioVRDE; }
|
---|
187 |
|
---|
188 | #ifdef VBOX_WITH_EXTPACK
|
---|
189 | ExtPackManager *i_getExtPackManager();
|
---|
190 | #endif
|
---|
191 | EventSource *i_getEventSource() { return mEventSource; }
|
---|
192 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
193 | UsbCardReader *i_getUsbCardReader() { return mUsbCardReader; }
|
---|
194 | #endif
|
---|
195 |
|
---|
196 | int i_VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
|
---|
197 | void i_VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus);
|
---|
198 | void i_VRDPClientConnect(uint32_t u32ClientId);
|
---|
199 | void i_VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
|
---|
200 | void i_VRDPInterceptAudio(uint32_t u32ClientId);
|
---|
201 | void i_VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
|
---|
202 | void i_VRDPInterceptClipboard(uint32_t u32ClientId);
|
---|
203 |
|
---|
204 | void i_processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList, bool fDescExt);
|
---|
205 | void i_reportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
|
---|
206 | ULONG aCpuKernel, ULONG aCpuIdle,
|
---|
207 | ULONG aMemTotal, ULONG aMemFree,
|
---|
208 | ULONG aMemBalloon, ULONG aMemShared,
|
---|
209 | ULONG aMemCache, ULONG aPageTotal,
|
---|
210 | ULONG aAllocVMM, ULONG aFreeVMM,
|
---|
211 | ULONG aBalloonedVMM, ULONG aSharedVMM,
|
---|
212 | ULONG aVmNetRx, ULONG aVmNetTx)
|
---|
213 | {
|
---|
214 | mControl->ReportVmStatistics(aValidStats, aCpuUser, aCpuKernel, aCpuIdle,
|
---|
215 | aMemTotal, aMemFree, aMemBalloon, aMemShared,
|
---|
216 | aMemCache, aPageTotal, aAllocVMM, aFreeVMM,
|
---|
217 | aBalloonedVMM, aSharedVMM, aVmNetRx, aVmNetTx);
|
---|
218 | }
|
---|
219 | void i_enableVMMStatistics(BOOL aEnable);
|
---|
220 |
|
---|
221 | HRESULT i_pause(Reason_T aReason);
|
---|
222 | HRESULT i_resume(Reason_T aReason, AutoWriteLock &alock);
|
---|
223 | HRESULT i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress, const Utf8Str &aStateFilePath, bool fPauseVM, bool &fLeftPaused);
|
---|
224 | HRESULT i_cancelSaveState();
|
---|
225 |
|
---|
226 | // callback callers (partly; for some events console callbacks are notified
|
---|
227 | // directly from IInternalSessionControl event handlers declared above)
|
---|
228 | void i_onMousePointerShapeChange(bool fVisible, bool fAlpha,
|
---|
229 | uint32_t xHot, uint32_t yHot,
|
---|
230 | uint32_t width, uint32_t height,
|
---|
231 | const uint8_t *pu8Shape,
|
---|
232 | uint32_t cbShape);
|
---|
233 | void i_onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,
|
---|
234 | BOOL supportsMT, BOOL needsHostCursor);
|
---|
235 | void i_onStateChange(MachineState_T aMachineState);
|
---|
236 | void i_onAdditionsStateChange();
|
---|
237 | void i_onAdditionsOutdated();
|
---|
238 | void i_onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
|
---|
239 | void i_onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
|
---|
240 | IVirtualBoxErrorInfo *aError);
|
---|
241 | void i_onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
|
---|
242 | HRESULT i_onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
|
---|
243 | void i_onVRDEServerInfoChange();
|
---|
244 | HRESULT i_sendACPIMonitorHotPlugEvent();
|
---|
245 |
|
---|
246 | static const PDMDRVREG DrvStatusReg;
|
---|
247 |
|
---|
248 | static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcsz, ...);
|
---|
249 | HRESULT i_setInvalidMachineStateError();
|
---|
250 |
|
---|
251 | static const char *i_convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
|
---|
252 | static HRESULT i_convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
|
---|
253 | // Called from event listener
|
---|
254 | HRESULT i_onNATRedirectRuleChange(ULONG ulInstance, BOOL aNatRuleRemove,
|
---|
255 | NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
|
---|
256 | HRESULT i_onNATDnsChanged();
|
---|
257 |
|
---|
258 | // Mouse interface
|
---|
259 | VMMDevMouseInterface *i_getVMMDevMouseInterface();
|
---|
260 | DisplayMouseInterface *i_getDisplayMouseInterface();
|
---|
261 |
|
---|
262 | EmulatedUSB *i_getEmulatedUSB(void) { return mEmulatedUSB; }
|
---|
263 |
|
---|
264 | /**
|
---|
265 | * Sets the disk encryption keys.
|
---|
266 | *
|
---|
267 | * @returns COM status code.
|
---|
268 | * @þaram strCfg The config for the disks.
|
---|
269 | *
|
---|
270 | * @note: One line in the config string contains all required data for one disk.
|
---|
271 | * The format for one disk is some sort of comma separated value using
|
---|
272 | * key=value pairs.
|
---|
273 | * There are two keys defined at the moment:
|
---|
274 | * - uuid: The uuid of the base image the key is for (with or without)
|
---|
275 | * the curly braces.
|
---|
276 | * - dek: The data encryption key in base64 encoding
|
---|
277 | */
|
---|
278 | HRESULT i_setDiskEncryptionKeys(const Utf8Str &strCfg);
|
---|
279 |
|
---|
280 | private:
|
---|
281 |
|
---|
282 | // wraped IConsole properties
|
---|
283 | HRESULT getMachine(ComPtr<IMachine> &aMachine);
|
---|
284 | HRESULT getState(MachineState_T *aState);
|
---|
285 | HRESULT getGuest(ComPtr<IGuest> &aGuest);
|
---|
286 | HRESULT getKeyboard(ComPtr<IKeyboard> &aKeyboard);
|
---|
287 | HRESULT getMouse(ComPtr<IMouse> &aMouse);
|
---|
288 | HRESULT getDisplay(ComPtr<IDisplay> &aDisplay);
|
---|
289 | HRESULT getDebugger(ComPtr<IMachineDebugger> &aDebugger);
|
---|
290 | HRESULT getUSBDevices(std::vector<ComPtr<IUSBDevice> > &aUSBDevices);
|
---|
291 | HRESULT getRemoteUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aRemoteUSBDevices);
|
---|
292 | HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
|
---|
293 | HRESULT getVRDEServerInfo(ComPtr<IVRDEServerInfo> &aVRDEServerInfo);
|
---|
294 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
295 | HRESULT getAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttachedPCIDevices);
|
---|
296 | HRESULT getUseHostClipboard(BOOL *aUseHostClipboard);
|
---|
297 | HRESULT setUseHostClipboard(BOOL aUseHostClipboard);
|
---|
298 | HRESULT getEmulatedUSB(ComPtr<IEmulatedUSB> &aEmulatedUSB);
|
---|
299 |
|
---|
300 | // wraped IConsole methods
|
---|
301 | HRESULT powerUp(ComPtr<IProgress> &aProgress);
|
---|
302 | HRESULT powerUpPaused(ComPtr<IProgress> &aProgress);
|
---|
303 | HRESULT powerDown(ComPtr<IProgress> &aProgress);
|
---|
304 | HRESULT reset();
|
---|
305 | HRESULT pause();
|
---|
306 | HRESULT resume();
|
---|
307 | HRESULT powerButton();
|
---|
308 | HRESULT sleepButton();
|
---|
309 | HRESULT getPowerButtonHandled(BOOL *aHandled);
|
---|
310 | HRESULT getGuestEnteredACPIMode(BOOL *aEntered);
|
---|
311 | HRESULT getDeviceActivity(const std::vector<DeviceType_T> &aType,
|
---|
312 | std::vector<DeviceActivity_T> &aActivity);
|
---|
313 | HRESULT attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
|
---|
314 | HRESULT detachUSBDevice(const com::Guid &aId,
|
---|
315 | ComPtr<IUSBDevice> &aDevice);
|
---|
316 | HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
|
---|
317 | ComPtr<IUSBDevice> &aDevice);
|
---|
318 | HRESULT findUSBDeviceById(const com::Guid &aId,
|
---|
319 | ComPtr<IUSBDevice> &aDevice);
|
---|
320 | HRESULT createSharedFolder(const com::Utf8Str &aName,
|
---|
321 | const com::Utf8Str &aHostPath,
|
---|
322 | BOOL aWritable,
|
---|
323 | BOOL aAutomount);
|
---|
324 | HRESULT removeSharedFolder(const com::Utf8Str &aName);
|
---|
325 | HRESULT teleport(const com::Utf8Str &aHostname,
|
---|
326 | ULONG aTcpport,
|
---|
327 | const com::Utf8Str &aPassword,
|
---|
328 | ULONG aMaxDowntime,
|
---|
329 | ComPtr<IProgress> &aProgress);
|
---|
330 | HRESULT addDiskEncryptionPassword(const com::Utf8Str &aId, const com::Utf8Str &aPassword,
|
---|
331 | BOOL aClearOnSuspend);
|
---|
332 | HRESULT addDiskEncryptionPasswords(const std::vector<com::Utf8Str> &aIds, const std::vector<com::Utf8Str> &aPasswords,
|
---|
333 | BOOL aClearOnSuspend);
|
---|
334 | HRESULT removeDiskEncryptionPassword(const com::Utf8Str &aId);
|
---|
335 | HRESULT clearAllDiskEncryptionPasswords();
|
---|
336 |
|
---|
337 | void notifyNatDnsChange(PUVM pUVM, const char *pszDevice, ULONG ulInstanceMax);
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * Base template for AutoVMCaller and SafeVMPtr. Template arguments
|
---|
341 | * have the same meaning as arguments of Console::addVMCaller().
|
---|
342 | */
|
---|
343 | template <bool taQuiet = false, bool taAllowNullVM = false>
|
---|
344 | class AutoVMCallerBase
|
---|
345 | {
|
---|
346 | public:
|
---|
347 | AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(E_FAIL)
|
---|
348 | {
|
---|
349 | Assert(aThat);
|
---|
350 | mRC = aThat->i_addVMCaller(taQuiet, taAllowNullVM);
|
---|
351 | }
|
---|
352 | ~AutoVMCallerBase()
|
---|
353 | {
|
---|
354 | doRelease();
|
---|
355 | }
|
---|
356 | /** Decreases the number of callers before the instance is destroyed. */
|
---|
357 | void releaseCaller()
|
---|
358 | {
|
---|
359 | Assert(SUCCEEDED(mRC));
|
---|
360 | doRelease();
|
---|
361 | }
|
---|
362 | /** Restores the number of callers after by #release(). #rc() must be
|
---|
363 | * rechecked to ensure the operation succeeded. */
|
---|
364 | void addYY()
|
---|
365 | {
|
---|
366 | AssertReturnVoid(!SUCCEEDED(mRC));
|
---|
367 | mRC = mThat->i_addVMCaller(taQuiet, taAllowNullVM);
|
---|
368 | }
|
---|
369 | /** Returns the result of Console::addVMCaller() */
|
---|
370 | HRESULT rc() const { return mRC; }
|
---|
371 | /** Shortcut to SUCCEEDED(rc()) */
|
---|
372 | bool isOk() const { return SUCCEEDED(mRC); }
|
---|
373 | protected:
|
---|
374 | Console *mThat;
|
---|
375 | void doRelease()
|
---|
376 | {
|
---|
377 | if (SUCCEEDED(mRC))
|
---|
378 | {
|
---|
379 | mThat->i_releaseVMCaller();
|
---|
380 | mRC = E_FAIL;
|
---|
381 | }
|
---|
382 | }
|
---|
383 | private:
|
---|
384 | HRESULT mRC; /* Whether the caller was added. */
|
---|
385 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase)
|
---|
386 | };
|
---|
387 |
|
---|
388 | #if 0
|
---|
389 | /**
|
---|
390 | * Helper class that protects sections of code using the mpUVM pointer by
|
---|
391 | * automatically calling addVMCaller() on construction and
|
---|
392 | * releaseVMCaller() on destruction. Intended for Console methods dealing
|
---|
393 | * with mpUVM. The usage pattern is:
|
---|
394 | * <code>
|
---|
395 | * AutoVMCaller autoVMCaller(this);
|
---|
396 | * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
|
---|
397 | * ...
|
---|
398 | * VMR3ReqCall (mpUVM, ...
|
---|
399 | * </code>
|
---|
400 | *
|
---|
401 | * @note Temporarily locks the argument for writing.
|
---|
402 | *
|
---|
403 | * @sa SafeVMPtr, SafeVMPtrQuiet
|
---|
404 | * @obsolete Use SafeVMPtr
|
---|
405 | */
|
---|
406 | typedef AutoVMCallerBase<false, false> AutoVMCaller;
|
---|
407 | #endif
|
---|
408 |
|
---|
409 | /**
|
---|
410 | * Same as AutoVMCaller but doesn't set extended error info on failure.
|
---|
411 | *
|
---|
412 | * @note Temporarily locks the argument for writing.
|
---|
413 | * @obsolete Use SafeVMPtrQuiet
|
---|
414 | */
|
---|
415 | typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
|
---|
416 |
|
---|
417 | /**
|
---|
418 | * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
|
---|
419 | * instead of assertion).
|
---|
420 | *
|
---|
421 | * @note Temporarily locks the argument for writing.
|
---|
422 | * @obsolete Use SafeVMPtr
|
---|
423 | */
|
---|
424 | typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
|
---|
425 |
|
---|
426 | /**
|
---|
427 | * Same as AutoVMCaller but doesn't set extended error info on failure
|
---|
428 | * and allows a null VM pointer (to trigger an error instead of
|
---|
429 | * assertion).
|
---|
430 | *
|
---|
431 | * @note Temporarily locks the argument for writing.
|
---|
432 | * @obsolete Use SafeVMPtrQuiet
|
---|
433 | */
|
---|
434 | typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
|
---|
435 |
|
---|
436 | /**
|
---|
437 | * Base template for SafeVMPtr and SafeVMPtrQuiet.
|
---|
438 | */
|
---|
439 | template<bool taQuiet = false>
|
---|
440 | class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
|
---|
441 | {
|
---|
442 | typedef AutoVMCallerBase<taQuiet, true> Base;
|
---|
443 | public:
|
---|
444 | SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(E_FAIL), mpUVM(NULL)
|
---|
445 | {
|
---|
446 | if (Base::isOk())
|
---|
447 | mRC = aThat->i_safeVMPtrRetainer(&mpUVM, taQuiet);
|
---|
448 | }
|
---|
449 | ~SafeVMPtrBase()
|
---|
450 | {
|
---|
451 | doRelease();
|
---|
452 | }
|
---|
453 | /** Direct PUVM access. */
|
---|
454 | PUVM rawUVM() const { return mpUVM; }
|
---|
455 | /** Release the handles. */
|
---|
456 | void release()
|
---|
457 | {
|
---|
458 | Assert(SUCCEEDED(mRC));
|
---|
459 | doRelease();
|
---|
460 | }
|
---|
461 |
|
---|
462 | /** The combined result of Console::addVMCaller() and Console::safeVMPtrRetainer */
|
---|
463 | HRESULT rc() const { return Base::isOk()? mRC: Base::rc(); }
|
---|
464 | /** Shortcut to SUCCEEDED(rc()) */
|
---|
465 | bool isOk() const { return SUCCEEDED(mRC) && Base::isOk(); }
|
---|
466 |
|
---|
467 | private:
|
---|
468 | void doRelease()
|
---|
469 | {
|
---|
470 | if (SUCCEEDED(mRC))
|
---|
471 | {
|
---|
472 | Base::mThat->i_safeVMPtrReleaser(&mpUVM);
|
---|
473 | mRC = E_FAIL;
|
---|
474 | }
|
---|
475 | Base::doRelease();
|
---|
476 | }
|
---|
477 | HRESULT mRC; /* Whether the VM ptr was retained. */
|
---|
478 | PUVM mpUVM;
|
---|
479 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase)
|
---|
480 | };
|
---|
481 |
|
---|
482 | public:
|
---|
483 |
|
---|
484 | /*
|
---|
485 | * Helper class that safely manages the Console::mpUVM pointer
|
---|
486 | * by calling addVMCaller() on construction and releaseVMCaller() on
|
---|
487 | * destruction. Intended for Console children. The usage pattern is:
|
---|
488 | * <code>
|
---|
489 | * Console::SafeVMPtr ptrVM(mParent);
|
---|
490 | * if (!ptrVM.isOk())
|
---|
491 | * return ptrVM.rc();
|
---|
492 | * ...
|
---|
493 | * VMR3ReqCall(ptrVM.rawUVM(), ...
|
---|
494 | * ...
|
---|
495 | * printf("%p\n", ptrVM.rawUVM());
|
---|
496 | * </code>
|
---|
497 | *
|
---|
498 | * @note Temporarily locks the argument for writing.
|
---|
499 | *
|
---|
500 | * @sa SafeVMPtrQuiet, AutoVMCaller
|
---|
501 | */
|
---|
502 | typedef SafeVMPtrBase<false> SafeVMPtr;
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * A deviation of SafeVMPtr that doesn't set the error info on failure.
|
---|
506 | * Intended for pieces of code that don't need to return the VM access
|
---|
507 | * failure to the caller. The usage pattern is:
|
---|
508 | * <code>
|
---|
509 | * Console::SafeVMPtrQuiet pVM(mParent);
|
---|
510 | * if (pVM.rc())
|
---|
511 | * VMR3ReqCall(pVM, ...
|
---|
512 | * return S_OK;
|
---|
513 | * </code>
|
---|
514 | *
|
---|
515 | * @note Temporarily locks the argument for writing.
|
---|
516 | *
|
---|
517 | * @sa SafeVMPtr, AutoVMCaller
|
---|
518 | */
|
---|
519 | typedef SafeVMPtrBase<true> SafeVMPtrQuiet;
|
---|
520 |
|
---|
521 | class SharedFolderData
|
---|
522 | {
|
---|
523 | public:
|
---|
524 | SharedFolderData()
|
---|
525 | { }
|
---|
526 |
|
---|
527 | SharedFolderData(const Utf8Str &aHostPath,
|
---|
528 | bool aWritable,
|
---|
529 | bool aAutoMount)
|
---|
530 | : m_strHostPath(aHostPath),
|
---|
531 | m_fWritable(aWritable),
|
---|
532 | m_fAutoMount(aAutoMount)
|
---|
533 | { }
|
---|
534 |
|
---|
535 | // copy constructor
|
---|
536 | SharedFolderData(const SharedFolderData& aThat)
|
---|
537 | : m_strHostPath(aThat.m_strHostPath),
|
---|
538 | m_fWritable(aThat.m_fWritable),
|
---|
539 | m_fAutoMount(aThat.m_fAutoMount)
|
---|
540 | { }
|
---|
541 |
|
---|
542 | Utf8Str m_strHostPath;
|
---|
543 | bool m_fWritable;
|
---|
544 | bool m_fAutoMount;
|
---|
545 | };
|
---|
546 |
|
---|
547 | /**
|
---|
548 | * Class for managing emulated USB MSDs.
|
---|
549 | */
|
---|
550 | class USBStorageDevice
|
---|
551 | {
|
---|
552 | public:
|
---|
553 | USBStorageDevice()
|
---|
554 | { }
|
---|
555 | /** The UUID associated with the USB device. */
|
---|
556 | RTUUID mUuid;
|
---|
557 | /** Port of the storage device. */
|
---|
558 | LONG iPort;
|
---|
559 | };
|
---|
560 |
|
---|
561 | typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
|
---|
562 | typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
|
---|
563 | typedef std::map<Utf8Str, ComPtr<IMediumAttachment> > MediumAttachmentMap;
|
---|
564 | typedef std::list <USBStorageDevice> USBStorageDeviceList;
|
---|
565 |
|
---|
566 | static DECLCALLBACK(int) i_powerUpThread(RTTHREAD Thread, void *pvUser);
|
---|
567 | static DECLCALLBACK(int) i_powerDownThread(RTTHREAD Thread, void *pvUser);
|
---|
568 |
|
---|
569 | private:
|
---|
570 |
|
---|
571 | typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
|
---|
572 | typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
|
---|
573 |
|
---|
574 | HRESULT i_addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
|
---|
575 | void i_releaseVMCaller();
|
---|
576 | HRESULT i_safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
|
---|
577 | void i_safeVMPtrReleaser(PUVM *a_ppUVM);
|
---|
578 |
|
---|
579 | HRESULT i_consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
|
---|
580 |
|
---|
581 | HRESULT i_powerUp(IProgress **aProgress, bool aPaused);
|
---|
582 | HRESULT i_powerDown(IProgress *aProgress = NULL);
|
---|
583 |
|
---|
584 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
585 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
586 | HRESULT i_attachToTapInterface(INetworkAdapter *networkAdapter);
|
---|
587 | HRESULT i_detachFromTapInterface(INetworkAdapter *networkAdapter);
|
---|
588 | #endif
|
---|
589 | HRESULT i_powerDownHostInterfaces();
|
---|
590 |
|
---|
591 | HRESULT i_setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
|
---|
592 | HRESULT i_setMachineStateLocally(MachineState_T aMachineState)
|
---|
593 | {
|
---|
594 | return i_setMachineState(aMachineState, false /* aUpdateServer */);
|
---|
595 | }
|
---|
596 |
|
---|
597 | HRESULT i_findSharedFolder(const Utf8Str &strName,
|
---|
598 | ComObjPtr<SharedFolder> &aSharedFolder,
|
---|
599 | bool aSetError = false);
|
---|
600 |
|
---|
601 | HRESULT i_fetchSharedFolders(BOOL aGlobal);
|
---|
602 | bool i_findOtherSharedFolder(const Utf8Str &straName,
|
---|
603 | SharedFolderDataMap::const_iterator &aIt);
|
---|
604 |
|
---|
605 | HRESULT i_createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
|
---|
606 | HRESULT i_removeSharedFolder(const Utf8Str &strName);
|
---|
607 |
|
---|
608 | HRESULT i_suspendBeforeConfigChange(PUVM pUVM, AutoWriteLock *pAlock, bool *pfResume);
|
---|
609 | void i_resumeAfterConfigChange(PUVM pUVM);
|
---|
610 |
|
---|
611 | static DECLCALLBACK(int) i_configConstructor(PUVM pUVM, PVM pVM, void *pvConsole);
|
---|
612 | int i_configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock);
|
---|
613 | int i_configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
614 | int i_configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
615 |
|
---|
616 | int i_configGraphicsController(PCFGMNODE pDevices,
|
---|
617 | const GraphicsControllerType_T graphicsController,
|
---|
618 | BusAssignmentManager *pBusMgr,
|
---|
619 | const ComPtr<IMachine> &ptrMachine,
|
---|
620 | const ComPtr<IBIOSSettings> &ptrBiosSettings,
|
---|
621 | bool fHMEnabled);
|
---|
622 | int i_configMediumAttachment(const char *pcszDevice,
|
---|
623 | unsigned uInstance,
|
---|
624 | StorageBus_T enmBus,
|
---|
625 | bool fUseHostIOCache,
|
---|
626 | bool fBuiltinIoCache,
|
---|
627 | bool fSetupMerge,
|
---|
628 | unsigned uMergeSource,
|
---|
629 | unsigned uMergeTarget,
|
---|
630 | IMediumAttachment *pMediumAtt,
|
---|
631 | MachineState_T aMachineState,
|
---|
632 | HRESULT *phrc,
|
---|
633 | bool fAttachDetach,
|
---|
634 | bool fForceUnmount,
|
---|
635 | bool fHotplug,
|
---|
636 | PUVM pUVM,
|
---|
637 | DeviceType_T *paLedDevType,
|
---|
638 | PCFGMNODE *ppLunL0);
|
---|
639 | int i_configMedium(PCFGMNODE pLunL0,
|
---|
640 | bool fPassthrough,
|
---|
641 | DeviceType_T enmType,
|
---|
642 | bool fUseHostIOCache,
|
---|
643 | bool fBuiltinIoCache,
|
---|
644 | bool fSetupMerge,
|
---|
645 | unsigned uMergeSource,
|
---|
646 | unsigned uMergeTarget,
|
---|
647 | const char *pcszBwGroup,
|
---|
648 | bool fDiscard,
|
---|
649 | IMedium *pMedium,
|
---|
650 | MachineState_T aMachineState,
|
---|
651 | HRESULT *phrc);
|
---|
652 | int i_configMediumProperties(PCFGMNODE pCur, IMedium *pMedium, bool *pfHostIP, bool *pfEncrypted);
|
---|
653 | static DECLCALLBACK(int) i_reconfigureMediumAttachment(Console *pThis,
|
---|
654 | PUVM pUVM,
|
---|
655 | const char *pcszDevice,
|
---|
656 | unsigned uInstance,
|
---|
657 | StorageBus_T enmBus,
|
---|
658 | bool fUseHostIOCache,
|
---|
659 | bool fBuiltinIoCache,
|
---|
660 | bool fSetupMerge,
|
---|
661 | unsigned uMergeSource,
|
---|
662 | unsigned uMergeTarget,
|
---|
663 | IMediumAttachment *aMediumAtt,
|
---|
664 | MachineState_T aMachineState,
|
---|
665 | HRESULT *phrc);
|
---|
666 | static DECLCALLBACK(int) i_changeRemovableMedium(Console *pThis,
|
---|
667 | PUVM pUVM,
|
---|
668 | const char *pcszDevice,
|
---|
669 | unsigned uInstance,
|
---|
670 | StorageBus_T enmBus,
|
---|
671 | bool fUseHostIOCache,
|
---|
672 | IMediumAttachment *aMediumAtt,
|
---|
673 | bool fForce);
|
---|
674 |
|
---|
675 | HRESULT i_attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
|
---|
676 | void i_attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds,
|
---|
677 | uint64_t uFirst, uint64_t uLast,
|
---|
678 | Console::MediumAttachmentMap *pmapMediumAttachments,
|
---|
679 | const char *pcszDevice, unsigned uInstance);
|
---|
680 |
|
---|
681 | int i_configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
|
---|
682 | INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
|
---|
683 | PCFGMNODE pLunL0, PCFGMNODE pInst,
|
---|
684 | bool fAttachDetach, bool fIgnoreConnectFailure);
|
---|
685 |
|
---|
686 | static DECLCALLBACK(int) i_configGuestProperties(void *pvConsole, PUVM pUVM);
|
---|
687 | static DECLCALLBACK(int) i_configGuestControl(void *pvConsole);
|
---|
688 | static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
|
---|
689 | static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
|
---|
690 | static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
|
---|
691 | HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
|
---|
692 | HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM);
|
---|
693 | HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM);
|
---|
694 |
|
---|
695 | HRESULT i_doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
|
---|
696 | unsigned uLun, INetworkAdapter *aNetworkAdapter);
|
---|
697 | static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
|
---|
698 | unsigned uInstance, unsigned uLun,
|
---|
699 | INetworkAdapter *aNetworkAdapter);
|
---|
700 |
|
---|
701 | void i_changeClipboardMode(ClipboardMode_T aClipboardMode);
|
---|
702 | int i_changeDnDMode(DnDMode_T aDnDMode);
|
---|
703 |
|
---|
704 | #ifdef VBOX_WITH_USB
|
---|
705 | HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename);
|
---|
706 | HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
|
---|
707 |
|
---|
708 | static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
|
---|
709 | const char *aBackend, const char *aAddress, void *pvRemoteBackend,
|
---|
710 | USHORT aPortVersion, ULONG aMaskedIfs, const char *pszCaptureFilename);
|
---|
711 | static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
|
---|
712 | #endif
|
---|
713 |
|
---|
714 | static DECLCALLBACK(int) i_attachStorageDevice(Console *pThis,
|
---|
715 | PUVM pUVM,
|
---|
716 | const char *pcszDevice,
|
---|
717 | unsigned uInstance,
|
---|
718 | StorageBus_T enmBus,
|
---|
719 | bool fUseHostIOCache,
|
---|
720 | IMediumAttachment *aMediumAtt,
|
---|
721 | bool fSilent);
|
---|
722 | static DECLCALLBACK(int) i_detachStorageDevice(Console *pThis,
|
---|
723 | PUVM pUVM,
|
---|
724 | const char *pcszDevice,
|
---|
725 | unsigned uInstance,
|
---|
726 | StorageBus_T enmBus,
|
---|
727 | IMediumAttachment *aMediumAtt,
|
---|
728 | bool fSilent);
|
---|
729 | HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
|
---|
730 | HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
|
---|
731 |
|
---|
732 | static DECLCALLBACK(int) i_stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
|
---|
733 |
|
---|
734 | static DECLCALLBACK(void) i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
|
---|
735 | const char *pszErrorFmt, va_list va);
|
---|
736 |
|
---|
737 | void i_setVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
|
---|
738 | static DECLCALLBACK(void) i_setVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
|
---|
739 | const char *pszErrorId, const char *pszFormat, va_list va);
|
---|
740 |
|
---|
741 | HRESULT i_captureUSBDevices(PUVM pUVM);
|
---|
742 | void i_detachAllUSBDevices(bool aDone);
|
---|
743 |
|
---|
744 |
|
---|
745 | static DECLCALLBACK(int) i_vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
746 | static DECLCALLBACK(void) i_vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
747 | static DECLCALLBACK(void) i_vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
748 | static DECLCALLBACK(void) i_vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
749 | static DECLCALLBACK(void) i_vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
750 | static DECLCALLBACK(void) i_vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
751 |
|
---|
752 | static DECLCALLBACK(void *) i_drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
753 | static DECLCALLBACK(void) i_drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
|
---|
754 | static DECLCALLBACK(int) i_drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
|
---|
755 | static DECLCALLBACK(void) i_drvStatus_Destruct(PPDMDRVINS pDrvIns);
|
---|
756 | static DECLCALLBACK(int) i_drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
757 |
|
---|
758 | static DECLCALLBACK(int) i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey,
|
---|
759 | size_t *pcbKey);
|
---|
760 | static DECLCALLBACK(int) i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId);
|
---|
761 | static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRetain(PPDMISECKEY pInterface, const char *pszId, const char **ppszPassword);
|
---|
762 | static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRelease(PPDMISECKEY pInterface, const char *pszId);
|
---|
763 |
|
---|
764 | static DECLCALLBACK(int) i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface);
|
---|
765 |
|
---|
766 | int mcAudioRefs;
|
---|
767 | volatile uint32_t mcVRDPClients;
|
---|
768 | uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
|
---|
769 | volatile bool mcGuestCredentialsProvided;
|
---|
770 |
|
---|
771 | static const char *sSSMConsoleUnit;
|
---|
772 | static uint32_t sSSMConsoleVer;
|
---|
773 |
|
---|
774 | HRESULT i_loadDataFromSavedState();
|
---|
775 | int i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
|
---|
776 |
|
---|
777 | static DECLCALLBACK(void) i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
|
---|
778 | static DECLCALLBACK(int) i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
|
---|
779 |
|
---|
780 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
781 | static DECLCALLBACK(int) i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
|
---|
782 | HRESULT i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
|
---|
783 | std::vector<Utf8Str> &aNames,
|
---|
784 | std::vector<Utf8Str> &aValues,
|
---|
785 | std::vector<LONG64> &aTimestamps,
|
---|
786 | std::vector<Utf8Str> &aFlags);
|
---|
787 |
|
---|
788 | void i_guestPropertiesHandleVMReset(void);
|
---|
789 | bool i_guestPropertiesVRDPEnabled(void);
|
---|
790 | void i_guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
|
---|
791 | void i_guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
|
---|
792 | void i_guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
|
---|
793 | void i_guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
|
---|
794 | void i_guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
|
---|
795 | void i_guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
|
---|
796 | void i_guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
|
---|
797 | void i_guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
|
---|
798 | #endif
|
---|
799 |
|
---|
800 | bool i_isResetTurnedIntoPowerOff(void);
|
---|
801 |
|
---|
802 | /** @name Disk encryption support
|
---|
803 | * @{ */
|
---|
804 | HRESULT i_consoleParseDiskEncryption(const char *psz, const char **ppszEnd);
|
---|
805 | HRESULT i_configureEncryptionForDisk(const Utf8Str &strId, unsigned *pcDisksConfigured);
|
---|
806 | HRESULT i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(const Utf8Str &strId);
|
---|
807 | HRESULT i_initSecretKeyIfOnAllAttachments(void);
|
---|
808 | int i_consoleParseKeyValue(const char *psz, const char **ppszEnd,
|
---|
809 | char **ppszKey, char **ppszVal);
|
---|
810 | void i_removeSecretKeysOnSuspend();
|
---|
811 | /** @} */
|
---|
812 |
|
---|
813 | /** @name Teleporter support
|
---|
814 | * @{ */
|
---|
815 | static DECLCALLBACK(int) i_teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
|
---|
816 | HRESULT i_teleporterSrc(TeleporterStateSrc *pState);
|
---|
817 | HRESULT i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
|
---|
818 | HRESULT i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
|
---|
819 | HRESULT i_teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
|
---|
820 | Progress *pProgress, bool *pfPowerOffOnFailure);
|
---|
821 | static DECLCALLBACK(int) i_teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
|
---|
822 | /** @} */
|
---|
823 |
|
---|
824 | bool mSavedStateDataLoaded : 1;
|
---|
825 |
|
---|
826 | const ComPtr<IMachine> mMachine;
|
---|
827 | const ComPtr<IInternalMachineControl> mControl;
|
---|
828 |
|
---|
829 | const ComPtr<IVRDEServer> mVRDEServer;
|
---|
830 |
|
---|
831 | ConsoleVRDPServer * const mConsoleVRDPServer;
|
---|
832 | bool mfVRDEChangeInProcess;
|
---|
833 | bool mfVRDEChangePending;
|
---|
834 |
|
---|
835 | const ComObjPtr<Guest> mGuest;
|
---|
836 | const ComObjPtr<Keyboard> mKeyboard;
|
---|
837 | const ComObjPtr<Mouse> mMouse;
|
---|
838 | const ComObjPtr<Display> mDisplay;
|
---|
839 | const ComObjPtr<MachineDebugger> mDebugger;
|
---|
840 | const ComObjPtr<VRDEServerInfo> mVRDEServerInfo;
|
---|
841 | /** This can safely be used without holding any locks.
|
---|
842 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
843 | * internally there is a lock providing the necessary serialization. */
|
---|
844 | const ComObjPtr<EventSource> mEventSource;
|
---|
845 | #ifdef VBOX_WITH_EXTPACK
|
---|
846 | const ComObjPtr<ExtPackManager> mptrExtPackManager;
|
---|
847 | #endif
|
---|
848 | const ComObjPtr<EmulatedUSB> mEmulatedUSB;
|
---|
849 |
|
---|
850 | USBDeviceList mUSBDevices;
|
---|
851 | RemoteUSBDeviceList mRemoteUSBDevices;
|
---|
852 |
|
---|
853 | SharedFolderDataMap m_mapGlobalSharedFolders;
|
---|
854 | SharedFolderDataMap m_mapMachineSharedFolders;
|
---|
855 | SharedFolderMap m_mapSharedFolders; // the console instances
|
---|
856 |
|
---|
857 | /** The user mode VM handle. */
|
---|
858 | PUVM mpUVM;
|
---|
859 | /** Holds the number of "readonly" mpUVM callers (users). */
|
---|
860 | uint32_t mVMCallers;
|
---|
861 | /** Semaphore posted when the number of mpUVM callers drops to zero. */
|
---|
862 | RTSEMEVENT mVMZeroCallersSem;
|
---|
863 | /** true when Console has entered the mpUVM destruction phase. */
|
---|
864 | bool mVMDestroying : 1;
|
---|
865 | /** true when power down is initiated by vmstateChangeCallback (EMT). */
|
---|
866 | bool mVMPoweredOff : 1;
|
---|
867 | /** true when vmstateChangeCallback shouldn't initiate a power down. */
|
---|
868 | bool mVMIsAlreadyPoweringOff : 1;
|
---|
869 | /** true if we already showed the snapshot folder size warning. */
|
---|
870 | bool mfSnapshotFolderSizeWarningShown : 1;
|
---|
871 | /** true if we already showed the snapshot folder ext4/xfs bug warning. */
|
---|
872 | bool mfSnapshotFolderExt4WarningShown : 1;
|
---|
873 | /** true if we already listed the disk type of the snapshot folder. */
|
---|
874 | bool mfSnapshotFolderDiskTypeShown : 1;
|
---|
875 | /** true if a USB controller is available (i.e. USB devices can be attached). */
|
---|
876 | bool mfVMHasUsbController : 1;
|
---|
877 | /** true if the VM power off was caused by reset. */
|
---|
878 | bool mfPowerOffCausedByReset : 1;
|
---|
879 |
|
---|
880 | /** Pointer to the VMM -> User (that's us) callbacks. */
|
---|
881 | struct MYVMM2USERMETHODS : public VMM2USERMETHODS
|
---|
882 | {
|
---|
883 | Console *pConsole;
|
---|
884 | } *mpVmm2UserMethods;
|
---|
885 |
|
---|
886 | /** The current network attachment type in the VM.
|
---|
887 | * This doesn't have to match the network attachment type maintained in the
|
---|
888 | * NetworkAdapter. This is needed to change the network attachment
|
---|
889 | * dynamically.
|
---|
890 | */
|
---|
891 | typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
|
---|
892 | NetworkAttachmentTypeVector meAttachmentType;
|
---|
893 |
|
---|
894 | VMMDev * m_pVMMDev;
|
---|
895 | AudioVRDE * const mAudioVRDE;
|
---|
896 | Nvram * const mNvram;
|
---|
897 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
898 | UsbCardReader * const mUsbCardReader;
|
---|
899 | #endif
|
---|
900 | BusAssignmentManager* mBusMgr;
|
---|
901 |
|
---|
902 | enum
|
---|
903 | {
|
---|
904 | iLedFloppy = 0,
|
---|
905 | cLedFloppy = 2,
|
---|
906 | iLedIde = iLedFloppy + cLedFloppy,
|
---|
907 | cLedIde = 4,
|
---|
908 | iLedSata = iLedIde + cLedIde,
|
---|
909 | cLedSata = 30,
|
---|
910 | iLedScsi = iLedSata + cLedSata,
|
---|
911 | cLedScsi = 16,
|
---|
912 | iLedSas = iLedScsi + cLedScsi,
|
---|
913 | cLedSas = 8,
|
---|
914 | iLedUsb = iLedSas + cLedSas,
|
---|
915 | cLedUsb = 8,
|
---|
916 | iLedNvme = iLedUsb + cLedUsb,
|
---|
917 | cLedNvme = 30,
|
---|
918 | cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas + cLedUsb + cLedNvme
|
---|
919 | };
|
---|
920 | DeviceType_T maStorageDevType[cLedStorage];
|
---|
921 | PPDMLED mapStorageLeds[cLedStorage];
|
---|
922 | PPDMLED mapNetworkLeds[36]; /**< @todo adapt this to the maximum network card count */
|
---|
923 | PPDMLED mapSharedFolderLed;
|
---|
924 | PPDMLED mapUSBLed[2];
|
---|
925 | PPDMLED mapCrOglLed;
|
---|
926 |
|
---|
927 | MediumAttachmentMap mapMediumAttachments;
|
---|
928 |
|
---|
929 | /** List of attached USB storage devices. */
|
---|
930 | USBStorageDeviceList mUSBStorageDevices;
|
---|
931 |
|
---|
932 | /** Store for secret keys. */
|
---|
933 | SecretKeyStore * const m_pKeyStore;
|
---|
934 | /** Number of disks configured for encryption. */
|
---|
935 | unsigned m_cDisksEncrypted;
|
---|
936 | /** Number of disks which have the key in the map. */
|
---|
937 | unsigned m_cDisksPwProvided;
|
---|
938 |
|
---|
939 | /** Pointer to the key consumer -> provider (that's us) callbacks. */
|
---|
940 | struct MYPDMISECKEY : public PDMISECKEY
|
---|
941 | {
|
---|
942 | Console *pConsole;
|
---|
943 | } *mpIfSecKey;
|
---|
944 |
|
---|
945 | /** Pointer to the key helpers -> provider (that's us) callbacks. */
|
---|
946 | struct MYPDMISECKEYHLP : public PDMISECKEYHLP
|
---|
947 | {
|
---|
948 | Console *pConsole;
|
---|
949 | } *mpIfSecKeyHlp;
|
---|
950 |
|
---|
951 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
952 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
953 | Utf8Str maTAPDeviceName[8];
|
---|
954 | RTFILE maTapFD[8];
|
---|
955 | #endif
|
---|
956 |
|
---|
957 | bool mVMStateChangeCallbackDisabled;
|
---|
958 |
|
---|
959 | bool mfUseHostClipboard;
|
---|
960 |
|
---|
961 | /** Local machine state value. */
|
---|
962 | MachineState_T mMachineState;
|
---|
963 |
|
---|
964 | /** Machine uuid string. */
|
---|
965 | Bstr mstrUuid;
|
---|
966 |
|
---|
967 | /** Pointer to the progress object of a live cancelable task.
|
---|
968 | *
|
---|
969 | * This is currently only used by Console::Teleport(), but is intended to later
|
---|
970 | * be used by the live snapshot code path as well. Actions like
|
---|
971 | * Console::PowerDown, which automatically cancels out the running snapshot /
|
---|
972 | * teleportation operation, will cancel the teleportation / live snapshot
|
---|
973 | * operation before starting. */
|
---|
974 | ComPtr<IProgress> mptrCancelableProgress;
|
---|
975 |
|
---|
976 | ComPtr<IEventListener> mVmListener;
|
---|
977 |
|
---|
978 | friend class VMTask;
|
---|
979 | friend class ConsoleVRDPServer;
|
---|
980 | };
|
---|
981 |
|
---|
982 | #endif // !____H_CONSOLEIMPL
|
---|
983 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|