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