1 | /* $Id: ConsoleImpl.h 98266 2023-01-24 09:46:42Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Console COM Class definition
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2005-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef MAIN_INCLUDED_ConsoleImpl_h
|
---|
29 | #define MAIN_INCLUDED_ConsoleImpl_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include "VirtualBoxBase.h"
|
---|
35 | #include "VBox/com/array.h"
|
---|
36 | #include "EventImpl.h"
|
---|
37 | #include "SecretKeyStore.h"
|
---|
38 | #include "ConsoleWrap.h"
|
---|
39 | #ifdef VBOX_WITH_RECORDING
|
---|
40 | # include "Recording.h"
|
---|
41 | #endif
|
---|
42 | #ifdef VBOX_WITH_CLOUD_NET
|
---|
43 | #include "CloudGateway.h"
|
---|
44 | #endif /* VBOX_WITH_CLOUD_NET */
|
---|
45 |
|
---|
46 | class Guest;
|
---|
47 | class Keyboard;
|
---|
48 | class Mouse;
|
---|
49 | class Display;
|
---|
50 | class MachineDebugger;
|
---|
51 | class TeleporterStateSrc;
|
---|
52 | class OUSBDevice;
|
---|
53 | class RemoteUSBDevice;
|
---|
54 | class SharedFolder;
|
---|
55 | class VRDEServerInfo;
|
---|
56 | class EmulatedUSB;
|
---|
57 | class AudioVRDE;
|
---|
58 | #ifdef VBOX_WITH_AUDIO_RECORDING
|
---|
59 | class AudioVideoRec;
|
---|
60 | #endif
|
---|
61 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
62 | class UsbCardReader;
|
---|
63 | #endif
|
---|
64 | class ConsoleVRDPServer;
|
---|
65 | class VMMDev;
|
---|
66 | class Progress;
|
---|
67 | class BusAssignmentManager;
|
---|
68 | COM_STRUCT_OR_CLASS(IEventListener);
|
---|
69 | #ifdef VBOX_WITH_EXTPACK
|
---|
70 | class ExtPackManager;
|
---|
71 | #endif
|
---|
72 | class VMMDevMouseInterface;
|
---|
73 | class DisplayMouseInterface;
|
---|
74 | class VMPowerUpTask;
|
---|
75 | class VMPowerDownTask;
|
---|
76 | class NvramStore;
|
---|
77 |
|
---|
78 | #include <iprt/uuid.h>
|
---|
79 | #include <iprt/log.h>
|
---|
80 | #include <iprt/memsafer.h>
|
---|
81 | #include <VBox/RemoteDesktop/VRDE.h>
|
---|
82 | #include <VBox/vmm/pdmdrv.h>
|
---|
83 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
84 | # include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
|
---|
85 | #endif
|
---|
86 | #ifdef VBOX_WITH_USB
|
---|
87 | # include <VBox/vrdpusb.h>
|
---|
88 | #endif
|
---|
89 | #include <VBox/VBoxCryptoIf.h>
|
---|
90 |
|
---|
91 | #if defined(VBOX_WITH_GUEST_PROPS) || defined(VBOX_WITH_SHARED_CLIPBOARD) \
|
---|
92 | || defined(VBOX_WITH_DRAG_AND_DROP)
|
---|
93 | # include "HGCM.h" /** @todo It should be possible to register a service
|
---|
94 | * extension using a VMMDev callback. */
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | struct VUSBIRHCONFIG;
|
---|
98 | typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
|
---|
99 |
|
---|
100 | #include <list>
|
---|
101 | #include <vector>
|
---|
102 |
|
---|
103 | // defines
|
---|
104 | ///////////////////////////////////////////////////////////////////////////////
|
---|
105 |
|
---|
106 | /**
|
---|
107 | * Checks the availability of the underlying VM device driver corresponding
|
---|
108 | * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
|
---|
109 | * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
|
---|
110 | * The translatable error message is defined in null context.
|
---|
111 | *
|
---|
112 | * Intended to used only within Console children (i.e. Keyboard, Mouse,
|
---|
113 | * Display, etc.).
|
---|
114 | *
|
---|
115 | * @param drv driver pointer to check (compare it with NULL)
|
---|
116 | */
|
---|
117 | #define CHECK_CONSOLE_DRV(drv) \
|
---|
118 | do { \
|
---|
119 | if (!!(drv)) {} \
|
---|
120 | else return setError(E_ACCESSDENIED, Console::tr("The console is not powered up (%Rfn)"), __FUNCTION__); \
|
---|
121 | } while (0)
|
---|
122 |
|
---|
123 | // Console
|
---|
124 | ///////////////////////////////////////////////////////////////////////////////
|
---|
125 |
|
---|
126 | class ConsoleMouseInterface
|
---|
127 | {
|
---|
128 | public:
|
---|
129 | virtual ~ConsoleMouseInterface() { }
|
---|
130 | virtual VMMDevMouseInterface *i_getVMMDevMouseInterface(){return NULL;}
|
---|
131 | virtual DisplayMouseInterface *i_getDisplayMouseInterface(){return NULL;}
|
---|
132 | virtual void i_onMouseCapabilityChange(BOOL supportsAbsolute,
|
---|
133 | BOOL supportsRelative,
|
---|
134 | BOOL supportsTouchScreen,
|
---|
135 | BOOL supportsTouchPad,
|
---|
136 | BOOL needsHostCursor)
|
---|
137 | {
|
---|
138 | RT_NOREF(supportsAbsolute, supportsRelative, supportsTouchScreen, supportsTouchPad, needsHostCursor);
|
---|
139 | }
|
---|
140 | };
|
---|
141 |
|
---|
142 | /** IConsole implementation class */
|
---|
143 | class ATL_NO_VTABLE Console :
|
---|
144 | public ConsoleWrap,
|
---|
145 | public ConsoleMouseInterface
|
---|
146 | {
|
---|
147 |
|
---|
148 | public:
|
---|
149 |
|
---|
150 | DECLARE_COMMON_CLASS_METHODS(Console)
|
---|
151 |
|
---|
152 | HRESULT FinalConstruct();
|
---|
153 | void FinalRelease();
|
---|
154 |
|
---|
155 | // public initializers/uninitializers for internal purposes only
|
---|
156 | HRESULT initWithMachine(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType);
|
---|
157 | void uninit();
|
---|
158 |
|
---|
159 |
|
---|
160 | // public methods for internal purposes only
|
---|
161 |
|
---|
162 | /*
|
---|
163 | * Note: the following methods do not increase refcount. intended to be
|
---|
164 | * called only by the VM execution thread.
|
---|
165 | */
|
---|
166 |
|
---|
167 | PCVMMR3VTABLE i_getVMMVTable() const RT_NOEXCEPT { return mpVMM; }
|
---|
168 | Guest *i_getGuest() const { return mGuest; }
|
---|
169 | Keyboard *i_getKeyboard() const { return mKeyboard; }
|
---|
170 | Mouse *i_getMouse() const { return mMouse; }
|
---|
171 | Display *i_getDisplay() const { return mDisplay; }
|
---|
172 | MachineDebugger *i_getMachineDebugger() const { return mDebugger; }
|
---|
173 | #ifdef VBOX_WITH_AUDIO_VRDE
|
---|
174 | AudioVRDE *i_getAudioVRDE() const { return mAudioVRDE; }
|
---|
175 | #endif
|
---|
176 | #ifdef VBOX_WITH_RECORDING
|
---|
177 | int i_recordingCreate(void);
|
---|
178 | void i_recordingDestroy(void);
|
---|
179 | int i_recordingEnable(BOOL fEnable, util::AutoWriteLock *pAutoLock);
|
---|
180 | int i_recordingGetSettings(settings::RecordingSettings &recording);
|
---|
181 | int i_recordingStart(util::AutoWriteLock *pAutoLock = NULL);
|
---|
182 | int i_recordingStop(util::AutoWriteLock *pAutoLock = NULL);
|
---|
183 | # ifdef VBOX_WITH_AUDIO_RECORDING
|
---|
184 | AudioVideoRec *i_recordingGetAudioDrv(void) const { return mRecording.mAudioRec; }
|
---|
185 | # endif
|
---|
186 | RecordingContext *i_recordingGetContext(void) { return &mRecording.mCtx; }
|
---|
187 | # ifdef VBOX_WITH_AUDIO_RECORDING
|
---|
188 | HRESULT i_recordingSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs);
|
---|
189 | # endif
|
---|
190 | #endif
|
---|
191 |
|
---|
192 | const ComPtr<IMachine> &i_machine() const { return mMachine; }
|
---|
193 | const Bstr &i_getId() const { return mstrUuid; }
|
---|
194 |
|
---|
195 | bool i_useHostClipboard() { return mfUseHostClipboard; }
|
---|
196 |
|
---|
197 | /** Method is called only from ConsoleVRDPServer */
|
---|
198 | IVRDEServer *i_getVRDEServer() const { return mVRDEServer; }
|
---|
199 |
|
---|
200 | ConsoleVRDPServer *i_consoleVRDPServer() const { return mConsoleVRDPServer; }
|
---|
201 |
|
---|
202 | HRESULT i_updateMachineState(MachineState_T aMachineState);
|
---|
203 | HRESULT i_getNominalState(MachineState_T &aNominalState);
|
---|
204 | Utf8Str i_getAudioAdapterDeviceName(IAudioAdapter *aAudioAdapter);
|
---|
205 |
|
---|
206 | // events from IInternalSessionControl
|
---|
207 | HRESULT i_onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
|
---|
208 | HRESULT i_onAudioAdapterChange(IAudioAdapter *aAudioAdapter);
|
---|
209 | HRESULT i_onHostAudioDeviceChange(IHostAudioDevice *aDevice, BOOL aNew, AudioDeviceState_T aState,
|
---|
210 | IVirtualBoxErrorInfo *aErrInfo);
|
---|
211 | HRESULT i_onSerialPortChange(ISerialPort *aSerialPort);
|
---|
212 | HRESULT i_onParallelPortChange(IParallelPort *aParallelPort);
|
---|
213 | HRESULT i_onStorageControllerChange(const com::Guid& aMachineId, const com::Utf8Str& aControllerName);
|
---|
214 | HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
|
---|
215 | HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
|
---|
216 | HRESULT i_onCPUExecutionCapChange(ULONG aExecutionCap);
|
---|
217 | HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
|
---|
218 | HRESULT i_onClipboardFileTransferModeChange(bool aEnabled);
|
---|
219 | HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
|
---|
220 | HRESULT i_onVRDEServerChange(BOOL aRestart);
|
---|
221 | HRESULT i_onRecordingChange(BOOL fEnable);
|
---|
222 | HRESULT i_onUSBControllerChange();
|
---|
223 | HRESULT i_onSharedFolderChange(BOOL aGlobal);
|
---|
224 | HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs,
|
---|
225 | const Utf8Str &aCaptureFilename);
|
---|
226 | HRESULT i_onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
|
---|
227 | HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
|
---|
228 | HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
|
---|
229 | HRESULT i_onExtraDataChange(const Bstr &aMachineId, const Bstr &aKey, const Bstr &aVal);
|
---|
230 | HRESULT i_onGuestDebugControlChange(IGuestDebugControl *aGuestDebugControl);
|
---|
231 |
|
---|
232 | HRESULT i_getGuestProperty(const Utf8Str &aName, Utf8Str *aValue, LONG64 *aTimestamp, Utf8Str *aFlags);
|
---|
233 | HRESULT i_setGuestProperty(const Utf8Str &aName, const Utf8Str &aValue, const Utf8Str &aFlags);
|
---|
234 | HRESULT i_deleteGuestProperty(const Utf8Str &aName);
|
---|
235 | HRESULT i_enumerateGuestProperties(const Utf8Str &aPatterns,
|
---|
236 | std::vector<Utf8Str> &aNames,
|
---|
237 | std::vector<Utf8Str> &aValues,
|
---|
238 | std::vector<LONG64> &aTimestamps,
|
---|
239 | std::vector<Utf8Str> &aFlags);
|
---|
240 | HRESULT i_onlineMergeMedium(IMediumAttachment *aMediumAttachment,
|
---|
241 | ULONG aSourceIdx, ULONG aTargetIdx,
|
---|
242 | IProgress *aProgress);
|
---|
243 | HRESULT i_reconfigureMediumAttachments(const std::vector<ComPtr<IMediumAttachment> > &aAttachments);
|
---|
244 | HRESULT i_onVMProcessPriorityChange(VMProcPriority_T priority);
|
---|
245 | int i_hgcmLoadService(const char *pszServiceLibrary, const char *pszServiceName);
|
---|
246 | VMMDev *i_getVMMDev() { return m_pVMMDev; }
|
---|
247 |
|
---|
248 | #ifdef VBOX_WITH_EXTPACK
|
---|
249 | ExtPackManager *i_getExtPackManager();
|
---|
250 | #endif
|
---|
251 | EventSource *i_getEventSource() { return mEventSource; }
|
---|
252 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
253 | UsbCardReader *i_getUsbCardReader() { return mUsbCardReader; }
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | int i_VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
|
---|
257 | void i_VRDPClientStatusChange(uint32_t u32ClientId, const char *pszStatus);
|
---|
258 | void i_VRDPClientConnect(uint32_t u32ClientId);
|
---|
259 | void i_VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
|
---|
260 | void i_VRDPInterceptAudio(uint32_t u32ClientId);
|
---|
261 | void i_VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
|
---|
262 | void i_VRDPInterceptClipboard(uint32_t u32ClientId);
|
---|
263 |
|
---|
264 | void i_processRemoteUSBDevices(uint32_t u32ClientId, VRDEUSBDEVICEDESC *pDevList, uint32_t cbDevList, bool fDescExt);
|
---|
265 | void i_reportVmStatistics(ULONG aValidStats, ULONG aCpuUser,
|
---|
266 | ULONG aCpuKernel, ULONG aCpuIdle,
|
---|
267 | ULONG aMemTotal, ULONG aMemFree,
|
---|
268 | ULONG aMemBalloon, ULONG aMemShared,
|
---|
269 | ULONG aMemCache, ULONG aPageTotal,
|
---|
270 | ULONG aAllocVMM, ULONG aFreeVMM,
|
---|
271 | ULONG aBalloonedVMM, ULONG aSharedVMM,
|
---|
272 | ULONG aVmNetRx, ULONG aVmNetTx)
|
---|
273 | {
|
---|
274 | mControl->ReportVmStatistics(aValidStats, aCpuUser, aCpuKernel, aCpuIdle,
|
---|
275 | aMemTotal, aMemFree, aMemBalloon, aMemShared,
|
---|
276 | aMemCache, aPageTotal, aAllocVMM, aFreeVMM,
|
---|
277 | aBalloonedVMM, aSharedVMM, aVmNetRx, aVmNetTx);
|
---|
278 | }
|
---|
279 | void i_enableVMMStatistics(BOOL aEnable);
|
---|
280 |
|
---|
281 | HRESULT i_pause(Reason_T aReason);
|
---|
282 | HRESULT i_resume(Reason_T aReason, AutoWriteLock &alock);
|
---|
283 | HRESULT i_saveState(Reason_T aReason, const ComPtr<IProgress> &aProgress,
|
---|
284 | const ComPtr<ISnapshot> &aSnapshot,
|
---|
285 | const Utf8Str &aStateFilePath, bool fPauseVM, bool &fLeftPaused);
|
---|
286 | HRESULT i_cancelSaveState();
|
---|
287 |
|
---|
288 | // callback callers (partly; for some events console callbacks are notified
|
---|
289 | // directly from IInternalSessionControl event handlers declared above)
|
---|
290 | void i_onMousePointerShapeChange(bool fVisible, bool fAlpha,
|
---|
291 | uint32_t xHot, uint32_t yHot,
|
---|
292 | uint32_t width, uint32_t height,
|
---|
293 | const uint8_t *pu8Shape,
|
---|
294 | uint32_t cbShape);
|
---|
295 | void i_onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative,
|
---|
296 | BOOL supportsTouchScreen, BOOL supportsTouchPad,
|
---|
297 | BOOL needsHostCursor);
|
---|
298 | void i_onStateChange(MachineState_T aMachineState);
|
---|
299 | void i_onAdditionsStateChange();
|
---|
300 | void i_onAdditionsOutdated();
|
---|
301 | void i_onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
|
---|
302 | void i_onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
|
---|
303 | IVirtualBoxErrorInfo *aError);
|
---|
304 | void i_onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
|
---|
305 | HRESULT i_onShowWindow(BOOL aCheck, BOOL *aCanShow, LONG64 *aWinId);
|
---|
306 | void i_onVRDEServerInfoChange();
|
---|
307 | HRESULT i_sendACPIMonitorHotPlugEvent();
|
---|
308 |
|
---|
309 | static const PDMDRVREG DrvStatusReg;
|
---|
310 |
|
---|
311 | static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcsz, ...);
|
---|
312 | static HRESULT i_setErrorStaticBoth(HRESULT aResultCode, int vrc, const char *pcsz, ...);
|
---|
313 | HRESULT i_setInvalidMachineStateError();
|
---|
314 |
|
---|
315 | static const char *i_storageControllerTypeToStr(StorageControllerType_T enmCtrlType);
|
---|
316 | static HRESULT i_storageBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
|
---|
317 | // Called from event listener
|
---|
318 | HRESULT i_onNATRedirectRuleChanged(ULONG ulInstance, BOOL aNatRuleRemove,
|
---|
319 | NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
|
---|
320 | HRESULT i_onNATDnsChanged();
|
---|
321 |
|
---|
322 | // Mouse interface
|
---|
323 | VMMDevMouseInterface *i_getVMMDevMouseInterface();
|
---|
324 | DisplayMouseInterface *i_getDisplayMouseInterface();
|
---|
325 |
|
---|
326 | EmulatedUSB *i_getEmulatedUSB(void) { return mEmulatedUSB; }
|
---|
327 |
|
---|
328 | /**
|
---|
329 | * Sets the disk encryption keys.
|
---|
330 | *
|
---|
331 | * @returns COM status code.
|
---|
332 | * @param strCfg The config for the disks.
|
---|
333 | *
|
---|
334 | * @note One line in the config string contains all required data for one disk.
|
---|
335 | * The format for one disk is some sort of comma separated value using
|
---|
336 | * key=value pairs.
|
---|
337 | * There are two keys defined at the moment:
|
---|
338 | * - uuid: The uuid of the base image the key is for (with or without)
|
---|
339 | * the curly braces.
|
---|
340 | * - dek: The data encryption key in base64 encoding
|
---|
341 | */
|
---|
342 | HRESULT i_setDiskEncryptionKeys(const Utf8Str &strCfg);
|
---|
343 |
|
---|
344 | int i_retainCryptoIf(PCVBOXCRYPTOIF *ppCryptoIf);
|
---|
345 | int i_releaseCryptoIf(PCVBOXCRYPTOIF pCryptoIf);
|
---|
346 | HRESULT i_unloadCryptoIfModule(void);
|
---|
347 |
|
---|
348 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
349 | // VMMDev needs:
|
---|
350 | HRESULT i_pullGuestProperties(ComSafeArrayOut(BSTR, names), ComSafeArrayOut(BSTR, values),
|
---|
351 | ComSafeArrayOut(LONG64, timestamps), ComSafeArrayOut(BSTR, flags));
|
---|
352 | static DECLCALLBACK(int) i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
|
---|
353 | #endif
|
---|
354 |
|
---|
355 | private:
|
---|
356 |
|
---|
357 | // wrapped IConsole properties
|
---|
358 | HRESULT getMachine(ComPtr<IMachine> &aMachine);
|
---|
359 | HRESULT getState(MachineState_T *aState);
|
---|
360 | HRESULT getGuest(ComPtr<IGuest> &aGuest);
|
---|
361 | HRESULT getKeyboard(ComPtr<IKeyboard> &aKeyboard);
|
---|
362 | HRESULT getMouse(ComPtr<IMouse> &aMouse);
|
---|
363 | HRESULT getDisplay(ComPtr<IDisplay> &aDisplay);
|
---|
364 | HRESULT getDebugger(ComPtr<IMachineDebugger> &aDebugger);
|
---|
365 | HRESULT getUSBDevices(std::vector<ComPtr<IUSBDevice> > &aUSBDevices);
|
---|
366 | HRESULT getRemoteUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aRemoteUSBDevices);
|
---|
367 | HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
|
---|
368 | HRESULT getVRDEServerInfo(ComPtr<IVRDEServerInfo> &aVRDEServerInfo);
|
---|
369 | HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
|
---|
370 | HRESULT getAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttachedPCIDevices);
|
---|
371 | HRESULT getUseHostClipboard(BOOL *aUseHostClipboard);
|
---|
372 | HRESULT setUseHostClipboard(BOOL aUseHostClipboard);
|
---|
373 | HRESULT getEmulatedUSB(ComPtr<IEmulatedUSB> &aEmulatedUSB);
|
---|
374 |
|
---|
375 | // wrapped IConsole methods
|
---|
376 | HRESULT powerUp(ComPtr<IProgress> &aProgress);
|
---|
377 | HRESULT powerUpPaused(ComPtr<IProgress> &aProgress);
|
---|
378 | HRESULT powerDown(ComPtr<IProgress> &aProgress);
|
---|
379 | HRESULT reset();
|
---|
380 | HRESULT pause();
|
---|
381 | HRESULT resume();
|
---|
382 | HRESULT powerButton();
|
---|
383 | HRESULT sleepButton();
|
---|
384 | HRESULT getPowerButtonHandled(BOOL *aHandled);
|
---|
385 | HRESULT getGuestEnteredACPIMode(BOOL *aEntered);
|
---|
386 | HRESULT getDeviceActivity(const std::vector<DeviceType_T> &aType,
|
---|
387 | std::vector<DeviceActivity_T> &aActivity);
|
---|
388 | HRESULT attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
|
---|
389 | HRESULT detachUSBDevice(const com::Guid &aId,
|
---|
390 | ComPtr<IUSBDevice> &aDevice);
|
---|
391 | HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
|
---|
392 | ComPtr<IUSBDevice> &aDevice);
|
---|
393 | HRESULT findUSBDeviceById(const com::Guid &aId,
|
---|
394 | ComPtr<IUSBDevice> &aDevice);
|
---|
395 | HRESULT createSharedFolder(const com::Utf8Str &aName,
|
---|
396 | const com::Utf8Str &aHostPath,
|
---|
397 | BOOL aWritable,
|
---|
398 | BOOL aAutomount,
|
---|
399 | const com::Utf8Str &aAutoMountPoint);
|
---|
400 | HRESULT removeSharedFolder(const com::Utf8Str &aName);
|
---|
401 | HRESULT teleport(const com::Utf8Str &aHostname,
|
---|
402 | ULONG aTcpport,
|
---|
403 | const com::Utf8Str &aPassword,
|
---|
404 | ULONG aMaxDowntime,
|
---|
405 | ComPtr<IProgress> &aProgress);
|
---|
406 | HRESULT addEncryptionPassword(const com::Utf8Str &aId, const com::Utf8Str &aPassword,
|
---|
407 | BOOL aClearOnSuspend);
|
---|
408 | HRESULT addEncryptionPasswords(const std::vector<com::Utf8Str> &aIds, const std::vector<com::Utf8Str> &aPasswords,
|
---|
409 | BOOL aClearOnSuspend);
|
---|
410 | HRESULT removeEncryptionPassword(const com::Utf8Str &aId);
|
---|
411 | HRESULT clearAllEncryptionPasswords();
|
---|
412 |
|
---|
413 | void notifyNatDnsChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, ULONG ulInstanceMax);
|
---|
414 | Utf8Str VRDPServerErrorToMsg(int vrc);
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Base template for AutoVMCaller and SafeVMPtr. Template arguments
|
---|
418 | * have the same meaning as arguments of Console::addVMCaller().
|
---|
419 | */
|
---|
420 | template <bool taQuiet = false, bool taAllowNullVM = false>
|
---|
421 | class AutoVMCallerBase
|
---|
422 | {
|
---|
423 | public:
|
---|
424 | AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(E_FAIL)
|
---|
425 | {
|
---|
426 | Assert(aThat);
|
---|
427 | mRC = aThat->i_addVMCaller(taQuiet, taAllowNullVM);
|
---|
428 | }
|
---|
429 | ~AutoVMCallerBase()
|
---|
430 | {
|
---|
431 | doRelease();
|
---|
432 | }
|
---|
433 | /** Decreases the number of callers before the instance is destroyed. */
|
---|
434 | void releaseCaller()
|
---|
435 | {
|
---|
436 | Assert(SUCCEEDED(mRC));
|
---|
437 | doRelease();
|
---|
438 | }
|
---|
439 | /** Restores the number of callers after by #release(). #hrc() must be
|
---|
440 | * rechecked to ensure the operation succeeded. */
|
---|
441 | void addYY()
|
---|
442 | {
|
---|
443 | AssertReturnVoid(!SUCCEEDED(mRC));
|
---|
444 | mRC = mThat->i_addVMCaller(taQuiet, taAllowNullVM);
|
---|
445 | }
|
---|
446 | /** Returns the result of Console::addVMCaller() */
|
---|
447 | HRESULT hrc() const { return mRC; }
|
---|
448 | /** Shortcut to SUCCEEDED(hrc()) */
|
---|
449 | bool isOk() const { return SUCCEEDED(mRC); }
|
---|
450 | protected:
|
---|
451 | Console *mThat;
|
---|
452 | void doRelease()
|
---|
453 | {
|
---|
454 | if (SUCCEEDED(mRC))
|
---|
455 | {
|
---|
456 | mThat->i_releaseVMCaller();
|
---|
457 | mRC = E_FAIL;
|
---|
458 | }
|
---|
459 | }
|
---|
460 | private:
|
---|
461 | HRESULT mRC; /* Whether the caller was added. */
|
---|
462 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase);
|
---|
463 | };
|
---|
464 |
|
---|
465 | #if 0
|
---|
466 | /**
|
---|
467 | * Helper class that protects sections of code using the mpUVM pointer by
|
---|
468 | * automatically calling addVMCaller() on construction and
|
---|
469 | * releaseVMCaller() on destruction. Intended for Console methods dealing
|
---|
470 | * with mpUVM. The usage pattern is:
|
---|
471 | * <code>
|
---|
472 | * AutoVMCaller autoVMCaller(this);
|
---|
473 | * if (FAILED(autoVMCaller.hrc())) return autoVMCaller.hrc();
|
---|
474 | * ...
|
---|
475 | * VMR3ReqCall (mpUVM, ...
|
---|
476 | * </code>
|
---|
477 | *
|
---|
478 | * @note Temporarily locks the argument for writing.
|
---|
479 | *
|
---|
480 | * @sa SafeVMPtr, SafeVMPtrQuiet
|
---|
481 | * @note Obsolete, use SafeVMPtr
|
---|
482 | */
|
---|
483 | typedef AutoVMCallerBase<false, false> AutoVMCaller;
|
---|
484 | #endif
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Same as AutoVMCaller but doesn't set extended error info on failure.
|
---|
488 | *
|
---|
489 | * @note Temporarily locks the argument for writing.
|
---|
490 | * @note Obsolete, use SafeVMPtrQuiet
|
---|
491 | */
|
---|
492 | typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
|
---|
493 |
|
---|
494 | /**
|
---|
495 | * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
|
---|
496 | * instead of assertion).
|
---|
497 | *
|
---|
498 | * @note Temporarily locks the argument for writing.
|
---|
499 | * @note Obsolete, use SafeVMPtr
|
---|
500 | */
|
---|
501 | typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
|
---|
502 |
|
---|
503 | /**
|
---|
504 | * Same as AutoVMCaller but doesn't set extended error info on failure
|
---|
505 | * and allows a null VM pointer (to trigger an error instead of
|
---|
506 | * assertion).
|
---|
507 | *
|
---|
508 | * @note Temporarily locks the argument for writing.
|
---|
509 | * @note Obsolete, use SafeVMPtrQuiet
|
---|
510 | */
|
---|
511 | typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Base template for SafeVMPtr and SafeVMPtrQuiet.
|
---|
515 | */
|
---|
516 | template<bool taQuiet = false>
|
---|
517 | class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
|
---|
518 | {
|
---|
519 | typedef AutoVMCallerBase<taQuiet, true> Base;
|
---|
520 | public:
|
---|
521 | SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(E_FAIL), mpUVM(NULL), mpVMM(NULL)
|
---|
522 | {
|
---|
523 | if (Base::isOk())
|
---|
524 | mRC = aThat->i_safeVMPtrRetainer(&mpUVM, &mpVMM, taQuiet);
|
---|
525 | }
|
---|
526 | ~SafeVMPtrBase()
|
---|
527 | {
|
---|
528 | doRelease();
|
---|
529 | }
|
---|
530 | /** Direct PUVM access. */
|
---|
531 | PUVM rawUVM() const { return mpUVM; }
|
---|
532 | /** Direct PCVMMR3VTABLE access. */
|
---|
533 | PCVMMR3VTABLE vtable() const { return mpVMM; }
|
---|
534 | /** Release the handles. */
|
---|
535 | void release()
|
---|
536 | {
|
---|
537 | Assert(SUCCEEDED(mRC));
|
---|
538 | doRelease();
|
---|
539 | }
|
---|
540 |
|
---|
541 | /** The combined result of Console::addVMCaller() and Console::safeVMPtrRetainer */
|
---|
542 | HRESULT hrc() const { return Base::isOk() ? mRC : Base::hrc(); }
|
---|
543 | /** Shortcut to SUCCEEDED(hrc()) */
|
---|
544 | bool isOk() const { return SUCCEEDED(mRC) && Base::isOk(); }
|
---|
545 |
|
---|
546 | private:
|
---|
547 | void doRelease()
|
---|
548 | {
|
---|
549 | if (SUCCEEDED(mRC))
|
---|
550 | {
|
---|
551 | Base::mThat->i_safeVMPtrReleaser(&mpUVM);
|
---|
552 | mRC = E_FAIL;
|
---|
553 | }
|
---|
554 | Base::doRelease();
|
---|
555 | }
|
---|
556 | HRESULT mRC; /* Whether the VM ptr was retained. */
|
---|
557 | PUVM mpUVM;
|
---|
558 | PCVMMR3VTABLE mpVMM;
|
---|
559 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase);
|
---|
560 | };
|
---|
561 |
|
---|
562 | public:
|
---|
563 |
|
---|
564 | /*
|
---|
565 | * Helper class that safely manages the Console::mpUVM pointer
|
---|
566 | * by calling addVMCaller() on construction and releaseVMCaller() on
|
---|
567 | * destruction. Intended for Console children. The usage pattern is:
|
---|
568 | * <code>
|
---|
569 | * Console::SafeVMPtr ptrVM(mParent);
|
---|
570 | * if (!ptrVM.isOk())
|
---|
571 | * return ptrVM.hrc();
|
---|
572 | * ...
|
---|
573 | * VMR3ReqCall(ptrVM.rawUVM(), ...
|
---|
574 | * ...
|
---|
575 | * printf("%p\n", ptrVM.rawUVM());
|
---|
576 | * </code>
|
---|
577 | *
|
---|
578 | * @note Temporarily locks the argument for writing.
|
---|
579 | *
|
---|
580 | * @sa SafeVMPtrQuiet, AutoVMCaller
|
---|
581 | */
|
---|
582 | typedef SafeVMPtrBase<false> SafeVMPtr;
|
---|
583 |
|
---|
584 | /**
|
---|
585 | * A deviation of SafeVMPtr that doesn't set the error info on failure.
|
---|
586 | * Intended for pieces of code that don't need to return the VM access
|
---|
587 | * failure to the caller. The usage pattern is:
|
---|
588 | * <code>
|
---|
589 | * Console::SafeVMPtrQuiet pVM(mParent);
|
---|
590 | * if (pVM.hrc())
|
---|
591 | * VMR3ReqCall(pVM, ...
|
---|
592 | * return S_OK;
|
---|
593 | * </code>
|
---|
594 | *
|
---|
595 | * @note Temporarily locks the argument for writing.
|
---|
596 | *
|
---|
597 | * @sa SafeVMPtr, AutoVMCaller
|
---|
598 | */
|
---|
599 | typedef SafeVMPtrBase<true> SafeVMPtrQuiet;
|
---|
600 |
|
---|
601 | class SharedFolderData
|
---|
602 | {
|
---|
603 | public:
|
---|
604 | SharedFolderData()
|
---|
605 | { }
|
---|
606 |
|
---|
607 | SharedFolderData(const Utf8Str &aHostPath,
|
---|
608 | bool aWritable,
|
---|
609 | bool aAutoMount,
|
---|
610 | const Utf8Str &aAutoMountPoint)
|
---|
611 | : m_strHostPath(aHostPath)
|
---|
612 | , m_fWritable(aWritable)
|
---|
613 | , m_fAutoMount(aAutoMount)
|
---|
614 | , m_strAutoMountPoint(aAutoMountPoint)
|
---|
615 | { }
|
---|
616 |
|
---|
617 | /** Copy constructor. */
|
---|
618 | SharedFolderData(const SharedFolderData& aThat)
|
---|
619 | : m_strHostPath(aThat.m_strHostPath)
|
---|
620 | , m_fWritable(aThat.m_fWritable)
|
---|
621 | , m_fAutoMount(aThat.m_fAutoMount)
|
---|
622 | , m_strAutoMountPoint(aThat.m_strAutoMountPoint)
|
---|
623 | { }
|
---|
624 |
|
---|
625 | /** Copy assignment operator. */
|
---|
626 | SharedFolderData &operator=(SharedFolderData const &a_rThat) RT_NOEXCEPT
|
---|
627 | {
|
---|
628 | m_strHostPath = a_rThat.m_strHostPath;
|
---|
629 | m_fWritable = a_rThat.m_fWritable;
|
---|
630 | m_fAutoMount = a_rThat.m_fAutoMount;
|
---|
631 | m_strAutoMountPoint = a_rThat.m_strAutoMountPoint;
|
---|
632 |
|
---|
633 | return *this;
|
---|
634 | }
|
---|
635 |
|
---|
636 | Utf8Str m_strHostPath;
|
---|
637 | bool m_fWritable;
|
---|
638 | bool m_fAutoMount;
|
---|
639 | Utf8Str m_strAutoMountPoint;
|
---|
640 | };
|
---|
641 |
|
---|
642 | /**
|
---|
643 | * Class for managing emulated USB MSDs.
|
---|
644 | */
|
---|
645 | class USBStorageDevice
|
---|
646 | {
|
---|
647 | public:
|
---|
648 | USBStorageDevice()
|
---|
649 | { }
|
---|
650 | /** The UUID associated with the USB device. */
|
---|
651 | RTUUID mUuid;
|
---|
652 | /** Port of the storage device. */
|
---|
653 | LONG iPort;
|
---|
654 | };
|
---|
655 |
|
---|
656 | typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
|
---|
657 | typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
|
---|
658 | typedef std::map<Utf8Str, ComPtr<IMediumAttachment> > MediumAttachmentMap;
|
---|
659 | typedef std::list<USBStorageDevice> USBStorageDeviceList;
|
---|
660 |
|
---|
661 | static void i_powerUpThreadTask(VMPowerUpTask *pTask);
|
---|
662 | static void i_powerDownThreadTask(VMPowerDownTask *pTask);
|
---|
663 |
|
---|
664 | private:
|
---|
665 |
|
---|
666 | typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
|
---|
667 | typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
|
---|
668 |
|
---|
669 | HRESULT i_loadVMM(void) RT_NOEXCEPT;
|
---|
670 | HRESULT i_addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
|
---|
671 | void i_releaseVMCaller();
|
---|
672 | HRESULT i_safeVMPtrRetainer(PUVM *a_ppUVM, PCVMMR3VTABLE *a_ppVMM, bool aQuiet) RT_NOEXCEPT;
|
---|
673 | void i_safeVMPtrReleaser(PUVM *a_ppUVM);
|
---|
674 |
|
---|
675 | HRESULT i_consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
|
---|
676 |
|
---|
677 | HRESULT i_powerUp(IProgress **aProgress, bool aPaused);
|
---|
678 | HRESULT i_powerDown(IProgress *aProgress = NULL);
|
---|
679 |
|
---|
680 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
681 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
682 | HRESULT i_attachToTapInterface(INetworkAdapter *networkAdapter);
|
---|
683 | HRESULT i_detachFromTapInterface(INetworkAdapter *networkAdapter);
|
---|
684 | #endif
|
---|
685 | HRESULT i_powerDownHostInterfaces();
|
---|
686 |
|
---|
687 | HRESULT i_setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
|
---|
688 | HRESULT i_setMachineStateLocally(MachineState_T aMachineState)
|
---|
689 | {
|
---|
690 | return i_setMachineState(aMachineState, false /* aUpdateServer */);
|
---|
691 | }
|
---|
692 |
|
---|
693 | HRESULT i_findSharedFolder(const Utf8Str &strName,
|
---|
694 | ComObjPtr<SharedFolder> &aSharedFolder,
|
---|
695 | bool aSetError = false);
|
---|
696 |
|
---|
697 | HRESULT i_fetchSharedFolders(BOOL aGlobal);
|
---|
698 | bool i_findOtherSharedFolder(const Utf8Str &straName,
|
---|
699 | SharedFolderDataMap::const_iterator &aIt);
|
---|
700 |
|
---|
701 | HRESULT i_createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
|
---|
702 | HRESULT i_removeSharedFolder(const Utf8Str &strName);
|
---|
703 |
|
---|
704 | HRESULT i_suspendBeforeConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock, bool *pfResume);
|
---|
705 | void i_resumeAfterConfigChange(PUVM pUVM, PCVMMR3VTABLE pVMM);
|
---|
706 |
|
---|
707 | static DECLCALLBACK(int) i_configConstructor(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, void *pvConsole);
|
---|
708 | void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const char *pcszValue);
|
---|
709 | void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue);
|
---|
710 | void InsertConfigString(PCFGMNODE pNode, const char *pcszName, const Bstr &rBstrValue);
|
---|
711 | void InsertConfigStringF(PCFGMNODE pNode, const char *pcszName, const char *pszFormat, ...);
|
---|
712 | void InsertConfigPassword(PCFGMNODE pNode, const char *pcszName, const Utf8Str &rStrValue);
|
---|
713 | void InsertConfigBytes(PCFGMNODE pNode, const char *pcszName, const void *pvBytes, size_t cbBytes);
|
---|
714 | void InsertConfigInteger(PCFGMNODE pNode, const char *pcszName, uint64_t u64Integer);
|
---|
715 | void InsertConfigNode(PCFGMNODE pNode, const char *pcszName, PCFGMNODE *ppChild);
|
---|
716 | void InsertConfigNodeF(PCFGMNODE pNode, PCFGMNODE *ppChild, const char *pszNameFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
|
---|
717 | void RemoveConfigValue(PCFGMNODE pNode, const char *pcszName);
|
---|
718 | int SetBiosDiskInfo(ComPtr<IMachine> pMachine, PCFGMNODE pCfg, PCFGMNODE pBiosCfg,
|
---|
719 | Bstr controllerName, const char * const s_apszBiosConfig[4]);
|
---|
720 | void i_configAudioDriver(IVirtualBox *pVirtualBox, IMachine *pMachine, PCFGMNODE pLUN, const char *pszDriverName,
|
---|
721 | bool fAudioEnabledIn, bool fAudioEnabledOut);
|
---|
722 | int i_configConstructorInner(PUVM pUVM, PVM pVM, PCVMMR3VTABLE pVMM, AutoWriteLock *pAlock);
|
---|
723 | int i_configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
724 | int i_configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
|
---|
725 |
|
---|
726 | int i_configGraphicsController(PCFGMNODE pDevices,
|
---|
727 | const GraphicsControllerType_T graphicsController,
|
---|
728 | BusAssignmentManager *pBusMgr,
|
---|
729 | const ComPtr<IMachine> &ptrMachine,
|
---|
730 | const ComPtr<IGraphicsAdapter> &ptrGraphicsAdapter,
|
---|
731 | const ComPtr<IBIOSSettings> &ptrBiosSettings,
|
---|
732 | bool fHMEnabled);
|
---|
733 | int i_checkMediumLocation(IMedium *pMedium, bool *pfUseHostIOCache);
|
---|
734 | int i_unmountMediumFromGuest(PUVM pUVM, PCVMMR3VTABLE pVMM, StorageBus_T enmBus, DeviceType_T enmDevType,
|
---|
735 | const char *pcszDevice, unsigned uInstance, unsigned uLUN,
|
---|
736 | bool fForceUnmount) RT_NOEXCEPT;
|
---|
737 | int i_removeMediumDriverFromVm(PCFGMNODE pCtlInst,
|
---|
738 | const char *pcszDevice,
|
---|
739 | unsigned uInstance,
|
---|
740 | unsigned uLUN,
|
---|
741 | StorageBus_T enmBus,
|
---|
742 | bool fAttachDetach,
|
---|
743 | bool fHotplug,
|
---|
744 | bool fForceUnmount,
|
---|
745 | PUVM pUVM,
|
---|
746 | PCVMMR3VTABLE pVMM,
|
---|
747 | DeviceType_T enmDevType,
|
---|
748 | PCFGMNODE *ppLunL0);
|
---|
749 | int i_configMediumAttachment(const char *pcszDevice,
|
---|
750 | unsigned uInstance,
|
---|
751 | StorageBus_T enmBus,
|
---|
752 | bool fUseHostIOCache,
|
---|
753 | bool fBuiltinIoCache,
|
---|
754 | bool fInsertDiskIntegrityDrv,
|
---|
755 | bool fSetupMerge,
|
---|
756 | unsigned uMergeSource,
|
---|
757 | unsigned uMergeTarget,
|
---|
758 | IMediumAttachment *pMediumAtt,
|
---|
759 | MachineState_T aMachineState,
|
---|
760 | HRESULT *phrc,
|
---|
761 | bool fAttachDetach,
|
---|
762 | bool fForceUnmount,
|
---|
763 | bool fHotplug,
|
---|
764 | PUVM pUVM,
|
---|
765 | PCVMMR3VTABLE pVMM,
|
---|
766 | DeviceType_T *paLedDevType,
|
---|
767 | PCFGMNODE *ppLunL0);
|
---|
768 | int i_configMedium(PCFGMNODE pLunL0,
|
---|
769 | bool fPassthrough,
|
---|
770 | DeviceType_T enmType,
|
---|
771 | bool fUseHostIOCache,
|
---|
772 | bool fBuiltinIoCache,
|
---|
773 | bool fInsertDiskIntegrityDrv,
|
---|
774 | bool fSetupMerge,
|
---|
775 | unsigned uMergeSource,
|
---|
776 | unsigned uMergeTarget,
|
---|
777 | const char *pcszBwGroup,
|
---|
778 | bool fDiscard,
|
---|
779 | bool fNonRotational,
|
---|
780 | ComPtr<IMedium> ptrMedium,
|
---|
781 | MachineState_T aMachineState,
|
---|
782 | HRESULT *phrc);
|
---|
783 | int i_configMediumProperties(PCFGMNODE pCur, IMedium *pMedium, bool *pfHostIP, bool *pfEncrypted);
|
---|
784 | static DECLCALLBACK(int) i_reconfigureMediumAttachment(Console *pThis,
|
---|
785 | PUVM pUVM,
|
---|
786 | PCVMMR3VTABLE pVMM,
|
---|
787 | const char *pcszDevice,
|
---|
788 | unsigned uInstance,
|
---|
789 | StorageBus_T enmBus,
|
---|
790 | bool fUseHostIOCache,
|
---|
791 | bool fBuiltinIoCache,
|
---|
792 | bool fInsertDiskIntegrityDrv,
|
---|
793 | bool fSetupMerge,
|
---|
794 | unsigned uMergeSource,
|
---|
795 | unsigned uMergeTarget,
|
---|
796 | IMediumAttachment *aMediumAtt,
|
---|
797 | MachineState_T aMachineState,
|
---|
798 | HRESULT *phrc);
|
---|
799 | static DECLCALLBACK(int) i_changeRemovableMedium(Console *pThis,
|
---|
800 | PUVM pUVM,
|
---|
801 | PCVMMR3VTABLE pVMM,
|
---|
802 | const char *pcszDevice,
|
---|
803 | unsigned uInstance,
|
---|
804 | StorageBus_T enmBus,
|
---|
805 | bool fUseHostIOCache,
|
---|
806 | IMediumAttachment *aMediumAtt,
|
---|
807 | bool fForce);
|
---|
808 |
|
---|
809 | HRESULT i_attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
|
---|
810 | struct LEDSET;
|
---|
811 | typedef struct LEDSET *PLEDSET;
|
---|
812 | PPDMLED volatile *i_getLedSet(uint32_t iLedSet);
|
---|
813 | void i_setLedType(DeviceType_T *penmSubTypeEntry, DeviceType_T enmNewType);
|
---|
814 | HRESULT i_refreshLedTypeArrays(AutoReadLock *pReadLock);
|
---|
815 | uint32_t i_allocateDriverLeds(uint32_t cLeds, uint32_t fTypes, DeviceType_T **ppSubTypes);
|
---|
816 | void i_attachStatusDriver(PCFGMNODE pCtlInst, DeviceType_T enmType, uint32_t cLeds = 1);
|
---|
817 | void i_attachStatusDriver(PCFGMNODE pCtlInst, uint32_t fTypes, uint32_t cLeds, DeviceType_T **ppaSubTypes,
|
---|
818 | Console::MediumAttachmentMap *pmapMediumAttachments,
|
---|
819 | const char *pcszDevice, unsigned uInstance);
|
---|
820 |
|
---|
821 | int i_configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun, INetworkAdapter *aNetworkAdapter,
|
---|
822 | PCFGMNODE pCfg, PCFGMNODE pLunL0, PCFGMNODE pInst, bool fAttachDetach, bool fIgnoreConnectFailure,
|
---|
823 | PUVM pUVM, PCVMMR3VTABLE pVMM);
|
---|
824 | int i_configProxy(ComPtr<IVirtualBox> virtualBox, PCFGMNODE pCfg, const char *pcszPrefix, const com::Utf8Str &strIpAddr);
|
---|
825 |
|
---|
826 | int i_configSerialPort(PCFGMNODE pInst, PortMode_T ePortMode, const char *pszPath, bool fServer);
|
---|
827 | static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, PCVMMR3VTABLE pVMM, VMSTATE enmState,
|
---|
828 | VMSTATE enmOldState, void *pvUser);
|
---|
829 | static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu);
|
---|
830 | static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, VMCPUID idCpu);
|
---|
831 | HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM, PCVMMR3VTABLE pVMM);
|
---|
832 | HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM);
|
---|
833 | HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM, PCVMMR3VTABLE pVMM);
|
---|
834 |
|
---|
835 | HRESULT i_doNetworkAdapterChange(PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice, unsigned uInstance,
|
---|
836 | unsigned uLun, INetworkAdapter *aNetworkAdapter);
|
---|
837 | static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, const char *pszDevice,
|
---|
838 | unsigned uInstance, unsigned uLun, INetworkAdapter *aNetworkAdapter);
|
---|
839 | static DECLCALLBACK(int) i_changeSerialPortAttachment(Console *pThis, PUVM pUVM, PCVMMR3VTABLE pVMM, ISerialPort *pSerialPort);
|
---|
840 |
|
---|
841 | int i_changeClipboardMode(ClipboardMode_T aClipboardMode);
|
---|
842 | int i_changeClipboardFileTransferMode(bool aEnabled);
|
---|
843 | int i_changeDnDMode(DnDMode_T aDnDMode);
|
---|
844 |
|
---|
845 | #ifdef VBOX_WITH_USB
|
---|
846 | HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename);
|
---|
847 | HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
|
---|
848 |
|
---|
849 | static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, IUSBDevice *aHostDevice,
|
---|
850 | PCRTUUID aUuid, const char *aBackend, const char *aAddress,
|
---|
851 | PCFGMNODE pRemoteCfg, USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
|
---|
852 | const char *pszCaptureFilename);
|
---|
853 | static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCVMMR3VTABLE pVMM, PCRTUUID aUuid);
|
---|
854 | static DECLCALLBACK(PREMOTEUSBCALLBACK) i_usbQueryRemoteUsbBackend(void *pvUser, PCRTUUID pUuid, uint32_t idClient);
|
---|
855 |
|
---|
856 | /** Interface for the VRDP USB proxy backend to query for a device remote callback table. */
|
---|
857 | REMOTEUSBIF mRemoteUsbIf;
|
---|
858 | #endif
|
---|
859 |
|
---|
860 | static DECLCALLBACK(int) i_attachStorageDevice(Console *pThis,
|
---|
861 | PUVM pUVM,
|
---|
862 | PCVMMR3VTABLE pVMM,
|
---|
863 | const char *pcszDevice,
|
---|
864 | unsigned uInstance,
|
---|
865 | StorageBus_T enmBus,
|
---|
866 | bool fUseHostIOCache,
|
---|
867 | IMediumAttachment *aMediumAtt,
|
---|
868 | bool fSilent);
|
---|
869 | static DECLCALLBACK(int) i_detachStorageDevice(Console *pThis,
|
---|
870 | PUVM pUVM,
|
---|
871 | PCVMMR3VTABLE pVMM,
|
---|
872 | const char *pcszDevice,
|
---|
873 | unsigned uInstance,
|
---|
874 | StorageBus_T enmBus,
|
---|
875 | IMediumAttachment *aMediumAtt,
|
---|
876 | bool fSilent);
|
---|
877 | HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent);
|
---|
878 | HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, PCVMMR3VTABLE pVMM, bool fSilent);
|
---|
879 |
|
---|
880 | static DECLCALLBACK(int) i_stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
|
---|
881 |
|
---|
882 | static DECLCALLBACK(void) i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int vrc, RT_SRC_POS_DECL,
|
---|
883 | const char *pszErrorFmt, va_list va);
|
---|
884 |
|
---|
885 | void i_atVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
|
---|
886 | static DECLCALLBACK(void) i_atVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
|
---|
887 | const char *pszErrorId, const char *pszFormat, va_list va);
|
---|
888 |
|
---|
889 | HRESULT i_captureUSBDevices(PUVM pUVM);
|
---|
890 | void i_detachAllUSBDevices(bool aDone);
|
---|
891 |
|
---|
892 |
|
---|
893 | static DECLCALLBACK(int) i_vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
894 | static DECLCALLBACK(void) i_vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
895 | static DECLCALLBACK(void) i_vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
|
---|
896 | static DECLCALLBACK(void) i_vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
897 | static DECLCALLBACK(void) i_vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
898 | static DECLCALLBACK(void) i_vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
|
---|
899 | static DECLCALLBACK(void *) i_vmm2User_QueryGenericObject(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid);
|
---|
900 |
|
---|
901 | static DECLCALLBACK(void *) i_drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
902 | static DECLCALLBACK(void) i_drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
|
---|
903 | static DECLCALLBACK(int) i_drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
|
---|
904 | static DECLCALLBACK(void) i_drvStatus_Destruct(PPDMDRVINS pDrvIns);
|
---|
905 | static DECLCALLBACK(int) i_drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
906 |
|
---|
907 | static DECLCALLBACK(int) i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey,
|
---|
908 | size_t *pcbKey);
|
---|
909 | static DECLCALLBACK(int) i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId);
|
---|
910 | static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRetain(PPDMISECKEY pInterface, const char *pszId, const char **ppszPassword);
|
---|
911 | static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRelease(PPDMISECKEY pInterface, const char *pszId);
|
---|
912 |
|
---|
913 | static DECLCALLBACK(int) i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface);
|
---|
914 |
|
---|
915 | int mcAudioRefs;
|
---|
916 | volatile uint32_t mcVRDPClients;
|
---|
917 | uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
|
---|
918 | volatile bool mcGuestCredentialsProvided;
|
---|
919 |
|
---|
920 | static const char *sSSMConsoleUnit;
|
---|
921 |
|
---|
922 | HRESULT i_loadDataFromSavedState();
|
---|
923 | int i_loadStateFileExecInternal(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t u32Version);
|
---|
924 |
|
---|
925 | static DECLCALLBACK(int) i_saveStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser);
|
---|
926 | static DECLCALLBACK(int) i_loadStateFileExec(PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, void *pvUser,
|
---|
927 | uint32_t uVersion, uint32_t uPass);
|
---|
928 |
|
---|
929 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
930 | HRESULT i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
|
---|
931 | std::vector<Utf8Str> &aNames,
|
---|
932 | std::vector<Utf8Str> &aValues,
|
---|
933 | std::vector<LONG64> &aTimestamps,
|
---|
934 | std::vector<Utf8Str> &aFlags);
|
---|
935 |
|
---|
936 | void i_guestPropertiesHandleVMReset(void);
|
---|
937 | bool i_guestPropertiesVRDPEnabled(void);
|
---|
938 | void i_guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
|
---|
939 | void i_guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
|
---|
940 | void i_guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
|
---|
941 | void i_guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
|
---|
942 | void i_guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
|
---|
943 | void i_guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
|
---|
944 | void i_guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
|
---|
945 | void i_guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
|
---|
946 | #endif
|
---|
947 |
|
---|
948 | /** @name Disk encryption support
|
---|
949 | * @{ */
|
---|
950 | HRESULT i_consoleParseDiskEncryption(const char *psz, const char **ppszEnd);
|
---|
951 | HRESULT i_configureEncryptionForDisk(const Utf8Str &strId, unsigned *pcDisksConfigured);
|
---|
952 | HRESULT i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(const Utf8Str &strId);
|
---|
953 | HRESULT i_initSecretKeyIfOnAllAttachments(void);
|
---|
954 | int i_consoleParseKeyValue(const char *psz, const char **ppszEnd,
|
---|
955 | char **ppszKey, char **ppszVal);
|
---|
956 | void i_removeSecretKeysOnSuspend();
|
---|
957 | /** @} */
|
---|
958 |
|
---|
959 | /** @name Teleporter support
|
---|
960 | * @{ */
|
---|
961 | static DECLCALLBACK(int) i_teleporterSrcThreadWrapper(RTTHREAD hThreadSelf, void *pvUser);
|
---|
962 | HRESULT i_teleporterSrc(TeleporterStateSrc *pState);
|
---|
963 | HRESULT i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
|
---|
964 | HRESULT i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
|
---|
965 | HRESULT i_teleporterTrg(PUVM pUVM, PCVMMR3VTABLE pVMM, IMachine *pMachine, Utf8Str *pErrorMsg,
|
---|
966 | bool fStartPaused, Progress *pProgress, bool *pfPowerOffOnFailure);
|
---|
967 | static DECLCALLBACK(int) i_teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
|
---|
968 | /** @} */
|
---|
969 |
|
---|
970 | #ifdef VBOX_WITH_FULL_VM_ENCRYPTION
|
---|
971 | /** @name Encrypted log interface
|
---|
972 | * @{ */
|
---|
973 | static DECLCALLBACK(int) i_logEncryptedOpen(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename, uint32_t fFlags);
|
---|
974 | static DECLCALLBACK(int) i_logEncryptedClose(PCRTLOGOUTPUTIF pIf, void *pvUser);
|
---|
975 | static DECLCALLBACK(int) i_logEncryptedDelete(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilename);
|
---|
976 | static DECLCALLBACK(int) i_logEncryptedRename(PCRTLOGOUTPUTIF pIf, void *pvUser, const char *pszFilenameOld,
|
---|
977 | const char *pszFilenameNew, uint32_t fFlags);
|
---|
978 | static DECLCALLBACK(int) i_logEncryptedQuerySize(PCRTLOGOUTPUTIF pIf, void *pvUser, uint64_t *pcbSize);
|
---|
979 | static DECLCALLBACK(int) i_logEncryptedWrite(PCRTLOGOUTPUTIF pIf, void *pvUser, const void *pvBuf,
|
---|
980 | size_t cbWrite, size_t *pcbWritten);
|
---|
981 | static DECLCALLBACK(int) i_logEncryptedFlush(PCRTLOGOUTPUTIF pIf, void *pvUser);
|
---|
982 | /** @} */
|
---|
983 | #endif
|
---|
984 |
|
---|
985 | bool mSavedStateDataLoaded : 1;
|
---|
986 |
|
---|
987 | const ComPtr<IMachine> mMachine;
|
---|
988 | const ComPtr<IInternalMachineControl> mControl;
|
---|
989 |
|
---|
990 | const ComPtr<IVRDEServer> mVRDEServer;
|
---|
991 |
|
---|
992 | ConsoleVRDPServer * const mConsoleVRDPServer;
|
---|
993 | bool mfVRDEChangeInProcess;
|
---|
994 | bool mfVRDEChangePending;
|
---|
995 | const ComObjPtr<Guest> mGuest;
|
---|
996 | const ComObjPtr<Keyboard> mKeyboard;
|
---|
997 | const ComObjPtr<Mouse> mMouse;
|
---|
998 | const ComObjPtr<Display> mDisplay;
|
---|
999 | const ComObjPtr<MachineDebugger> mDebugger;
|
---|
1000 | const ComObjPtr<VRDEServerInfo> mVRDEServerInfo;
|
---|
1001 | /** This can safely be used without holding any locks.
|
---|
1002 | * An AutoCaller suffices to prevent it being destroy while in use and
|
---|
1003 | * internally there is a lock providing the necessary serialization. */
|
---|
1004 | const ComObjPtr<EventSource> mEventSource;
|
---|
1005 | #ifdef VBOX_WITH_EXTPACK
|
---|
1006 | const ComObjPtr<ExtPackManager> mptrExtPackManager;
|
---|
1007 | #endif
|
---|
1008 | const ComObjPtr<EmulatedUSB> mEmulatedUSB;
|
---|
1009 | const ComObjPtr<NvramStore> mptrNvramStore;
|
---|
1010 |
|
---|
1011 | USBDeviceList mUSBDevices;
|
---|
1012 | RemoteUSBDeviceList mRemoteUSBDevices;
|
---|
1013 |
|
---|
1014 | SharedFolderDataMap m_mapGlobalSharedFolders;
|
---|
1015 | SharedFolderDataMap m_mapMachineSharedFolders;
|
---|
1016 | SharedFolderMap m_mapSharedFolders; // the console instances
|
---|
1017 |
|
---|
1018 | /** VMM loader handle. */
|
---|
1019 | RTLDRMOD mhModVMM;
|
---|
1020 | /** The VMM vtable. */
|
---|
1021 | PCVMMR3VTABLE mpVMM;
|
---|
1022 | /** The user mode VM handle. */
|
---|
1023 | PUVM mpUVM;
|
---|
1024 | /** Holds the number of "readonly" mpUVM callers (users). */
|
---|
1025 | uint32_t mVMCallers;
|
---|
1026 | /** Semaphore posted when the number of mpUVM callers drops to zero. */
|
---|
1027 | RTSEMEVENT mVMZeroCallersSem;
|
---|
1028 | /** true when Console has entered the mpUVM destruction phase. */
|
---|
1029 | bool mVMDestroying : 1;
|
---|
1030 | /** true when power down is initiated by vmstateChangeCallback (EMT). */
|
---|
1031 | bool mVMPoweredOff : 1;
|
---|
1032 | /** true when vmstateChangeCallback shouldn't initiate a power down. */
|
---|
1033 | bool mVMIsAlreadyPoweringOff : 1;
|
---|
1034 | /** true if we already showed the snapshot folder size warning. */
|
---|
1035 | bool mfSnapshotFolderSizeWarningShown : 1;
|
---|
1036 | /** true if we already showed the snapshot folder ext4/xfs bug warning. */
|
---|
1037 | bool mfSnapshotFolderExt4WarningShown : 1;
|
---|
1038 | /** true if we already listed the disk type of the snapshot folder. */
|
---|
1039 | bool mfSnapshotFolderDiskTypeShown : 1;
|
---|
1040 | /** true if a USB controller is available (i.e. USB devices can be attached). */
|
---|
1041 | bool mfVMHasUsbController : 1;
|
---|
1042 | /** Shadow of the VBoxInternal2/TurnResetIntoPowerOff extra data setting.
|
---|
1043 | * This is initialized by Console::i_configConstructorInner(). */
|
---|
1044 | bool mfTurnResetIntoPowerOff : 1;
|
---|
1045 | /** true if the VM power off was caused by reset. */
|
---|
1046 | bool mfPowerOffCausedByReset : 1;
|
---|
1047 |
|
---|
1048 | /** Pointer to the VMM -> User (that's us) callbacks. */
|
---|
1049 | struct MYVMM2USERMETHODS : public VMM2USERMETHODS
|
---|
1050 | {
|
---|
1051 | Console *pConsole;
|
---|
1052 | /** The in-progress snapshot. */
|
---|
1053 | ISnapshot *pISnapshot;
|
---|
1054 | } *mpVmm2UserMethods;
|
---|
1055 |
|
---|
1056 | /** The current network attachment type in the VM.
|
---|
1057 | * This doesn't have to match the network attachment type maintained in the
|
---|
1058 | * NetworkAdapter. This is needed to change the network attachment
|
---|
1059 | * dynamically.
|
---|
1060 | */
|
---|
1061 | typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
|
---|
1062 | NetworkAttachmentTypeVector meAttachmentType;
|
---|
1063 |
|
---|
1064 | VMMDev * m_pVMMDev;
|
---|
1065 | AudioVRDE * const mAudioVRDE;
|
---|
1066 | #ifdef VBOX_WITH_USB_CARDREADER
|
---|
1067 | UsbCardReader * const mUsbCardReader;
|
---|
1068 | #endif
|
---|
1069 | BusAssignmentManager* mBusMgr;
|
---|
1070 |
|
---|
1071 | /** @name LEDs and their management
|
---|
1072 | * @{ */
|
---|
1073 | /** Read/write lock separating LED allocations and per-type data construction
|
---|
1074 | * (write) from queries (read). */
|
---|
1075 | RWLockHandle mLedLock;
|
---|
1076 | /** LED configuration generation. This is increased whenever a new set is
|
---|
1077 | * allocated or a sub-device type changes. */
|
---|
1078 | uint32_t muLedGen;
|
---|
1079 | /** The LED configuration generation which maLedTypes was constructed for. */
|
---|
1080 | uint32_t muLedTypeGen;
|
---|
1081 | /** Number of LED sets in use in maLedSets. */
|
---|
1082 | uint32_t mcLedSets;
|
---|
1083 | /** LED sets. */
|
---|
1084 | struct LEDSET
|
---|
1085 | {
|
---|
1086 | /** Bitmask of possible DeviceType_T values (e.g. RT_BIT_32(DeviceType_Network)). */
|
---|
1087 | uint32_t fTypes;
|
---|
1088 | /** Number of LEDs. */
|
---|
1089 | uint32_t cLeds;
|
---|
1090 | /** Array of PDMLED pointers. The pointers in the array can be changed at any
|
---|
1091 | * time by Console::i_drvStatus_UnitChanged(). */
|
---|
1092 | PPDMLED volatile *papLeds;
|
---|
1093 | /** Optionally, device types for each individual LED. Runs parallel to papLeds. */
|
---|
1094 | DeviceType_T *paSubTypes;
|
---|
1095 | } maLedSets[32];
|
---|
1096 | /** LEDs data organized by DeviceType_T.
|
---|
1097 | * This is reconstructed by Console::i_refreshLedTypeArrays() when
|
---|
1098 | * Console::getDeviceActivity is called and mLedTypeGen doesn't match
|
---|
1099 | * muLedGen. */
|
---|
1100 | struct
|
---|
1101 | {
|
---|
1102 | /** Number of possibly valid entries in pappLeds. */
|
---|
1103 | uint32_t cLeds;
|
---|
1104 | /** Number of allocated entries. */
|
---|
1105 | uint32_t cAllocated;
|
---|
1106 | /** Array of pointer to LEDSET::papLed entries.
|
---|
1107 | * The indirection is due to Console::i_drvStatus_UnitChanged() only knowing
|
---|
1108 | * about the LEDSET::papLeds. */
|
---|
1109 | PPDMLED volatile **pappLeds;
|
---|
1110 | } maLedTypes[DeviceType_End];
|
---|
1111 | /** @} */
|
---|
1112 |
|
---|
1113 | MediumAttachmentMap mapMediumAttachments;
|
---|
1114 |
|
---|
1115 | /** List of attached USB storage devices. */
|
---|
1116 | USBStorageDeviceList mUSBStorageDevices;
|
---|
1117 |
|
---|
1118 | /** Store for secret keys. */
|
---|
1119 | SecretKeyStore * const m_pKeyStore;
|
---|
1120 | /** Number of disks configured for encryption. */
|
---|
1121 | unsigned m_cDisksEncrypted;
|
---|
1122 | /** Number of disks which have the key in the map. */
|
---|
1123 | unsigned m_cDisksPwProvided;
|
---|
1124 |
|
---|
1125 | /** Current active port modes of the supported serial ports. */
|
---|
1126 | PortMode_T m_aeSerialPortMode[4];
|
---|
1127 |
|
---|
1128 | /** Pointer to the key consumer -> provider (that's us) callbacks. */
|
---|
1129 | struct MYPDMISECKEY : public PDMISECKEY
|
---|
1130 | {
|
---|
1131 | Console *pConsole;
|
---|
1132 | } *mpIfSecKey;
|
---|
1133 |
|
---|
1134 | /** Pointer to the key helpers -> provider (that's us) callbacks. */
|
---|
1135 | struct MYPDMISECKEYHLP : public PDMISECKEYHLP
|
---|
1136 | {
|
---|
1137 | Console *pConsole;
|
---|
1138 | } *mpIfSecKeyHlp;
|
---|
1139 |
|
---|
1140 | /* Note: FreeBSD needs this whether netflt is used or not. */
|
---|
1141 | #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
|
---|
1142 | Utf8Str maTAPDeviceName[8];
|
---|
1143 | RTFILE maTapFD[8];
|
---|
1144 | #endif
|
---|
1145 |
|
---|
1146 | bool mVMStateChangeCallbackDisabled;
|
---|
1147 |
|
---|
1148 | bool mfUseHostClipboard;
|
---|
1149 |
|
---|
1150 | /** Local machine state value. */
|
---|
1151 | MachineState_T mMachineState;
|
---|
1152 |
|
---|
1153 | /** Machine uuid string. */
|
---|
1154 | Bstr mstrUuid;
|
---|
1155 |
|
---|
1156 | /** @name Members related to the cryptographic support interface.
|
---|
1157 | * @{ */
|
---|
1158 | /** The loaded module handle if loaded. */
|
---|
1159 | RTLDRMOD mhLdrModCrypto;
|
---|
1160 | /** Reference counter tracking how many users of the cryptographic support
|
---|
1161 | * are there currently. */
|
---|
1162 | volatile uint32_t mcRefsCrypto;
|
---|
1163 | /** Pointer to the cryptographic support interface. */
|
---|
1164 | PCVBOXCRYPTOIF mpCryptoIf;
|
---|
1165 | /** @} */
|
---|
1166 |
|
---|
1167 | #ifdef VBOX_WITH_FULL_VM_ENCRYPTION
|
---|
1168 | /** Flag whether the log is encrypted. */
|
---|
1169 | bool m_fEncryptedLog;
|
---|
1170 | /** The file handle of the encrypted log. */
|
---|
1171 | RTVFSFILE m_hVfsFileLog;
|
---|
1172 | /** The logging output interface for encrypted logs. */
|
---|
1173 | RTLOGOUTPUTIF m_LogOutputIf;
|
---|
1174 | /** The log file key ID. */
|
---|
1175 | Utf8Str m_strLogKeyId;
|
---|
1176 | /** The log file key store. */
|
---|
1177 | Utf8Str m_strLogKeyStore;
|
---|
1178 | #endif
|
---|
1179 |
|
---|
1180 | #ifdef VBOX_WITH_DRAG_AND_DROP
|
---|
1181 | HGCMSVCEXTHANDLE m_hHgcmSvcExtDragAndDrop;
|
---|
1182 | #endif
|
---|
1183 |
|
---|
1184 | /** Pointer to the progress object of a live cancelable task.
|
---|
1185 | *
|
---|
1186 | * This is currently only used by Console::Teleport(), but is intended to later
|
---|
1187 | * be used by the live snapshot code path as well. Actions like
|
---|
1188 | * Console::PowerDown, which automatically cancels out the running snapshot /
|
---|
1189 | * teleportation operation, will cancel the teleportation / live snapshot
|
---|
1190 | * operation before starting. */
|
---|
1191 | ComPtr<IProgress> mptrCancelableProgress;
|
---|
1192 |
|
---|
1193 | ComPtr<IEventListener> mVmListener;
|
---|
1194 |
|
---|
1195 | #ifdef VBOX_WITH_RECORDING
|
---|
1196 | struct Recording
|
---|
1197 | {
|
---|
1198 | Recording()
|
---|
1199 | # ifdef VBOX_WITH_AUDIO_RECORDING
|
---|
1200 | : mAudioRec(NULL)
|
---|
1201 | # endif
|
---|
1202 | { }
|
---|
1203 |
|
---|
1204 | /** The recording context. */
|
---|
1205 | RecordingContext mCtx;
|
---|
1206 | # ifdef VBOX_WITH_AUDIO_RECORDING
|
---|
1207 | /** Pointer to capturing audio backend. */
|
---|
1208 | AudioVideoRec * const mAudioRec;
|
---|
1209 | # endif
|
---|
1210 | } mRecording;
|
---|
1211 | #endif /* VBOX_WITH_RECORDING */
|
---|
1212 |
|
---|
1213 | #ifdef VBOX_WITH_CLOUD_NET
|
---|
1214 | GatewayInfo mGateway;
|
---|
1215 | #endif /* VBOX_WITH_CLOUD_NET */
|
---|
1216 |
|
---|
1217 | friend class VMTask;
|
---|
1218 | friend class ConsoleVRDPServer;
|
---|
1219 | };
|
---|
1220 |
|
---|
1221 | #endif /* !MAIN_INCLUDED_ConsoleImpl_h */
|
---|
1222 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|