VirtualBox

source: vbox/trunk/src/VBox/Main/include/ConsoleImpl.h@ 76402

Last change on this file since 76402 was 75955, checked in by vboxsync, 6 years ago

Main: Load VBoxGuestPropSvc from the VMMDev driver.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette