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