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