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