VirtualBox

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

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

Main/Recording: compile fixes when VBOX_WITH_AUDIO_RECORDING is unset

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.3 KB
Line 
1/* $Id: ConsoleImpl.h 75527 2018-11-16 17:14:58Z 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 * @þaram 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
305private:
306
307 // wraped IConsole properties
308 HRESULT getMachine(ComPtr<IMachine> &aMachine);
309 HRESULT getState(MachineState_T *aState);
310 HRESULT getGuest(ComPtr<IGuest> &aGuest);
311 HRESULT getKeyboard(ComPtr<IKeyboard> &aKeyboard);
312 HRESULT getMouse(ComPtr<IMouse> &aMouse);
313 HRESULT getDisplay(ComPtr<IDisplay> &aDisplay);
314 HRESULT getDebugger(ComPtr<IMachineDebugger> &aDebugger);
315 HRESULT getUSBDevices(std::vector<ComPtr<IUSBDevice> > &aUSBDevices);
316 HRESULT getRemoteUSBDevices(std::vector<ComPtr<IHostUSBDevice> > &aRemoteUSBDevices);
317 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
318 HRESULT getVRDEServerInfo(ComPtr<IVRDEServerInfo> &aVRDEServerInfo);
319 HRESULT getEventSource(ComPtr<IEventSource> &aEventSource);
320 HRESULT getAttachedPCIDevices(std::vector<ComPtr<IPCIDeviceAttachment> > &aAttachedPCIDevices);
321 HRESULT getUseHostClipboard(BOOL *aUseHostClipboard);
322 HRESULT setUseHostClipboard(BOOL aUseHostClipboard);
323 HRESULT getEmulatedUSB(ComPtr<IEmulatedUSB> &aEmulatedUSB);
324
325 // wraped IConsole methods
326 HRESULT powerUp(ComPtr<IProgress> &aProgress);
327 HRESULT powerUpPaused(ComPtr<IProgress> &aProgress);
328 HRESULT powerDown(ComPtr<IProgress> &aProgress);
329 HRESULT reset();
330 HRESULT pause();
331 HRESULT resume();
332 HRESULT powerButton();
333 HRESULT sleepButton();
334 HRESULT getPowerButtonHandled(BOOL *aHandled);
335 HRESULT getGuestEnteredACPIMode(BOOL *aEntered);
336 HRESULT getDeviceActivity(const std::vector<DeviceType_T> &aType,
337 std::vector<DeviceActivity_T> &aActivity);
338 HRESULT attachUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
339 HRESULT detachUSBDevice(const com::Guid &aId,
340 ComPtr<IUSBDevice> &aDevice);
341 HRESULT findUSBDeviceByAddress(const com::Utf8Str &aName,
342 ComPtr<IUSBDevice> &aDevice);
343 HRESULT findUSBDeviceById(const com::Guid &aId,
344 ComPtr<IUSBDevice> &aDevice);
345 HRESULT createSharedFolder(const com::Utf8Str &aName,
346 const com::Utf8Str &aHostPath,
347 BOOL aWritable,
348 BOOL aAutomount,
349 const com::Utf8Str &aAutoMountPoint);
350 HRESULT removeSharedFolder(const com::Utf8Str &aName);
351 HRESULT teleport(const com::Utf8Str &aHostname,
352 ULONG aTcpport,
353 const com::Utf8Str &aPassword,
354 ULONG aMaxDowntime,
355 ComPtr<IProgress> &aProgress);
356 HRESULT addDiskEncryptionPassword(const com::Utf8Str &aId, const com::Utf8Str &aPassword,
357 BOOL aClearOnSuspend);
358 HRESULT addDiskEncryptionPasswords(const std::vector<com::Utf8Str> &aIds, const std::vector<com::Utf8Str> &aPasswords,
359 BOOL aClearOnSuspend);
360 HRESULT removeDiskEncryptionPassword(const com::Utf8Str &aId);
361 HRESULT clearAllDiskEncryptionPasswords();
362
363 void notifyNatDnsChange(PUVM pUVM, const char *pszDevice, ULONG ulInstanceMax);
364 Utf8Str VRDPServerErrorToMsg(int vrc);
365
366 /**
367 * Base template for AutoVMCaller and SafeVMPtr. Template arguments
368 * have the same meaning as arguments of Console::addVMCaller().
369 */
370 template <bool taQuiet = false, bool taAllowNullVM = false>
371 class AutoVMCallerBase
372 {
373 public:
374 AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(E_FAIL)
375 {
376 Assert(aThat);
377 mRC = aThat->i_addVMCaller(taQuiet, taAllowNullVM);
378 }
379 ~AutoVMCallerBase()
380 {
381 doRelease();
382 }
383 /** Decreases the number of callers before the instance is destroyed. */
384 void releaseCaller()
385 {
386 Assert(SUCCEEDED(mRC));
387 doRelease();
388 }
389 /** Restores the number of callers after by #release(). #rc() must be
390 * rechecked to ensure the operation succeeded. */
391 void addYY()
392 {
393 AssertReturnVoid(!SUCCEEDED(mRC));
394 mRC = mThat->i_addVMCaller(taQuiet, taAllowNullVM);
395 }
396 /** Returns the result of Console::addVMCaller() */
397 HRESULT rc() const { return mRC; }
398 /** Shortcut to SUCCEEDED(rc()) */
399 bool isOk() const { return SUCCEEDED(mRC); }
400 protected:
401 Console *mThat;
402 void doRelease()
403 {
404 if (SUCCEEDED(mRC))
405 {
406 mThat->i_releaseVMCaller();
407 mRC = E_FAIL;
408 }
409 }
410 private:
411 HRESULT mRC; /* Whether the caller was added. */
412 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase);
413 };
414
415#if 0
416 /**
417 * Helper class that protects sections of code using the mpUVM pointer by
418 * automatically calling addVMCaller() on construction and
419 * releaseVMCaller() on destruction. Intended for Console methods dealing
420 * with mpUVM. The usage pattern is:
421 * <code>
422 * AutoVMCaller autoVMCaller(this);
423 * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
424 * ...
425 * VMR3ReqCall (mpUVM, ...
426 * </code>
427 *
428 * @note Temporarily locks the argument for writing.
429 *
430 * @sa SafeVMPtr, SafeVMPtrQuiet
431 * @note Obsolete, use SafeVMPtr
432 */
433 typedef AutoVMCallerBase<false, false> AutoVMCaller;
434#endif
435
436 /**
437 * Same as AutoVMCaller but doesn't set extended error info on failure.
438 *
439 * @note Temporarily locks the argument for writing.
440 * @note Obsolete, use SafeVMPtrQuiet
441 */
442 typedef AutoVMCallerBase<true, false> AutoVMCallerQuiet;
443
444 /**
445 * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
446 * instead of assertion).
447 *
448 * @note Temporarily locks the argument for writing.
449 * @note Obsolete, use SafeVMPtr
450 */
451 typedef AutoVMCallerBase<false, true> AutoVMCallerWeak;
452
453 /**
454 * Same as AutoVMCaller but doesn't set extended error info on failure
455 * and allows a null VM pointer (to trigger an error instead of
456 * assertion).
457 *
458 * @note Temporarily locks the argument for writing.
459 * @note Obsolete, use SafeVMPtrQuiet
460 */
461 typedef AutoVMCallerBase<true, true> AutoVMCallerQuietWeak;
462
463 /**
464 * Base template for SafeVMPtr and SafeVMPtrQuiet.
465 */
466 template<bool taQuiet = false>
467 class SafeVMPtrBase : public AutoVMCallerBase<taQuiet, true>
468 {
469 typedef AutoVMCallerBase<taQuiet, true> Base;
470 public:
471 SafeVMPtrBase(Console *aThat) : Base(aThat), mRC(E_FAIL), mpUVM(NULL)
472 {
473 if (Base::isOk())
474 mRC = aThat->i_safeVMPtrRetainer(&mpUVM, taQuiet);
475 }
476 ~SafeVMPtrBase()
477 {
478 doRelease();
479 }
480 /** Direct PUVM access. */
481 PUVM rawUVM() const { return mpUVM; }
482 /** Release the handles. */
483 void release()
484 {
485 Assert(SUCCEEDED(mRC));
486 doRelease();
487 }
488
489 /** The combined result of Console::addVMCaller() and Console::safeVMPtrRetainer */
490 HRESULT rc() const { return Base::isOk()? mRC: Base::rc(); }
491 /** Shortcut to SUCCEEDED(rc()) */
492 bool isOk() const { return SUCCEEDED(mRC) && Base::isOk(); }
493
494 private:
495 void doRelease()
496 {
497 if (SUCCEEDED(mRC))
498 {
499 Base::mThat->i_safeVMPtrReleaser(&mpUVM);
500 mRC = E_FAIL;
501 }
502 Base::doRelease();
503 }
504 HRESULT mRC; /* Whether the VM ptr was retained. */
505 PUVM mpUVM;
506 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase);
507 };
508
509public:
510
511 /*
512 * Helper class that safely manages the Console::mpUVM pointer
513 * by calling addVMCaller() on construction and releaseVMCaller() on
514 * destruction. Intended for Console children. The usage pattern is:
515 * <code>
516 * Console::SafeVMPtr ptrVM(mParent);
517 * if (!ptrVM.isOk())
518 * return ptrVM.rc();
519 * ...
520 * VMR3ReqCall(ptrVM.rawUVM(), ...
521 * ...
522 * printf("%p\n", ptrVM.rawUVM());
523 * </code>
524 *
525 * @note Temporarily locks the argument for writing.
526 *
527 * @sa SafeVMPtrQuiet, AutoVMCaller
528 */
529 typedef SafeVMPtrBase<false> SafeVMPtr;
530
531 /**
532 * A deviation of SafeVMPtr that doesn't set the error info on failure.
533 * Intended for pieces of code that don't need to return the VM access
534 * failure to the caller. The usage pattern is:
535 * <code>
536 * Console::SafeVMPtrQuiet pVM(mParent);
537 * if (pVM.rc())
538 * VMR3ReqCall(pVM, ...
539 * return S_OK;
540 * </code>
541 *
542 * @note Temporarily locks the argument for writing.
543 *
544 * @sa SafeVMPtr, AutoVMCaller
545 */
546 typedef SafeVMPtrBase<true> SafeVMPtrQuiet;
547
548 class SharedFolderData
549 {
550 public:
551 SharedFolderData()
552 { }
553
554 SharedFolderData(const Utf8Str &aHostPath,
555 bool aWritable,
556 bool aAutoMount,
557 const Utf8Str &aAutoMountPoint)
558 : m_strHostPath(aHostPath)
559 , m_fWritable(aWritable)
560 , m_fAutoMount(aAutoMount)
561 , m_strAutoMountPoint(aAutoMountPoint)
562 { }
563
564 // copy constructor
565 SharedFolderData(const SharedFolderData& aThat)
566 : m_strHostPath(aThat.m_strHostPath)
567 , m_fWritable(aThat.m_fWritable)
568 , m_fAutoMount(aThat.m_fAutoMount)
569 , m_strAutoMountPoint(aThat.m_strAutoMountPoint)
570 { }
571
572 Utf8Str m_strHostPath;
573 bool m_fWritable;
574 bool m_fAutoMount;
575 Utf8Str m_strAutoMountPoint;
576 };
577
578 /**
579 * Class for managing emulated USB MSDs.
580 */
581 class USBStorageDevice
582 {
583 public:
584 USBStorageDevice()
585 { }
586 /** The UUID associated with the USB device. */
587 RTUUID mUuid;
588 /** Port of the storage device. */
589 LONG iPort;
590 };
591
592 typedef std::map<Utf8Str, ComObjPtr<SharedFolder> > SharedFolderMap;
593 typedef std::map<Utf8Str, SharedFolderData> SharedFolderDataMap;
594 typedef std::map<Utf8Str, ComPtr<IMediumAttachment> > MediumAttachmentMap;
595 typedef std::list <USBStorageDevice> USBStorageDeviceList;
596
597 static void i_powerUpThreadTask(VMPowerUpTask *pTask);
598 static void i_powerDownThreadTask(VMPowerDownTask *pTask);
599
600private:
601
602 typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
603 typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
604
605 HRESULT i_addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
606 void i_releaseVMCaller();
607 HRESULT i_safeVMPtrRetainer(PUVM *a_ppUVM, bool aQuiet);
608 void i_safeVMPtrReleaser(PUVM *a_ppUVM);
609
610 HRESULT i_consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
611
612 HRESULT i_powerUp(IProgress **aProgress, bool aPaused);
613 HRESULT i_powerDown(IProgress *aProgress = NULL);
614
615/* Note: FreeBSD needs this whether netflt is used or not. */
616#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
617 HRESULT i_attachToTapInterface(INetworkAdapter *networkAdapter);
618 HRESULT i_detachFromTapInterface(INetworkAdapter *networkAdapter);
619#endif
620 HRESULT i_powerDownHostInterfaces();
621
622 HRESULT i_setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
623 HRESULT i_setMachineStateLocally(MachineState_T aMachineState)
624 {
625 return i_setMachineState(aMachineState, false /* aUpdateServer */);
626 }
627
628 HRESULT i_findSharedFolder(const Utf8Str &strName,
629 ComObjPtr<SharedFolder> &aSharedFolder,
630 bool aSetError = false);
631
632 HRESULT i_fetchSharedFolders(BOOL aGlobal);
633 bool i_findOtherSharedFolder(const Utf8Str &straName,
634 SharedFolderDataMap::const_iterator &aIt);
635
636 HRESULT i_createSharedFolder(const Utf8Str &strName, const SharedFolderData &aData);
637 HRESULT i_removeSharedFolder(const Utf8Str &strName);
638
639 HRESULT i_suspendBeforeConfigChange(PUVM pUVM, AutoWriteLock *pAlock, bool *pfResume);
640 void i_resumeAfterConfigChange(PUVM pUVM);
641
642 uint32_t i_getAudioDriverValU32(IVirtualBox *pVirtualBox, IMachine *pMachine,
643 const char *pszDriverName, const char *pszValue, uint32_t uDefault);
644
645 static DECLCALLBACK(int) i_configConstructor(PUVM pUVM, PVM pVM, void *pvConsole);
646 int i_configAudioDriver(IAudioAdapter *pAudioAdapter, IVirtualBox *pVirtualBox, IMachine *pMachine,
647 PCFGMNODE pLUN, const char *pszDriverName);
648 int i_configConstructorInner(PUVM pUVM, PVM pVM, AutoWriteLock *pAlock);
649 int i_configCfgmOverlay(PCFGMNODE pRoot, IVirtualBox *pVirtualBox, IMachine *pMachine);
650 int i_configDumpAPISettingsTweaks(IVirtualBox *pVirtualBox, IMachine *pMachine);
651
652 int i_configGraphicsController(PCFGMNODE pDevices,
653 const GraphicsControllerType_T graphicsController,
654 BusAssignmentManager *pBusMgr,
655 const ComPtr<IMachine> &ptrMachine,
656 const ComPtr<IBIOSSettings> &ptrBiosSettings,
657 bool fHMEnabled);
658 int i_checkMediumLocation(IMedium *pMedium, bool *pfUseHostIOCache);
659 int i_unmountMediumFromGuest(PUVM pUVM, StorageBus_T enmBus, DeviceType_T enmDevType,
660 const char *pcszDevice, unsigned uInstance, unsigned uLUN,
661 bool fForceUnmount);
662 int i_removeMediumDriverFromVm(PCFGMNODE pCtlInst,
663 const char *pcszDevice,
664 unsigned uInstance,
665 unsigned uLUN,
666 StorageBus_T enmBus,
667 bool fAttachDetach,
668 bool fHotplug,
669 bool fForceUnmount,
670 PUVM pUVM,
671 DeviceType_T enmDevType,
672 PCFGMNODE *ppLunL0);
673 int i_configMediumAttachment(const char *pcszDevice,
674 unsigned uInstance,
675 StorageBus_T enmBus,
676 bool fUseHostIOCache,
677 bool fBuiltinIoCache,
678 bool fInsertDiskIntegrityDrv,
679 bool fSetupMerge,
680 unsigned uMergeSource,
681 unsigned uMergeTarget,
682 IMediumAttachment *pMediumAtt,
683 MachineState_T aMachineState,
684 HRESULT *phrc,
685 bool fAttachDetach,
686 bool fForceUnmount,
687 bool fHotplug,
688 PUVM pUVM,
689 DeviceType_T *paLedDevType,
690 PCFGMNODE *ppLunL0);
691 int i_configMedium(PCFGMNODE pLunL0,
692 bool fPassthrough,
693 DeviceType_T enmType,
694 bool fUseHostIOCache,
695 bool fBuiltinIoCache,
696 bool fInsertDiskIntegrityDrv,
697 bool fSetupMerge,
698 unsigned uMergeSource,
699 unsigned uMergeTarget,
700 const char *pcszBwGroup,
701 bool fDiscard,
702 bool fNonRotational,
703 IMedium *pMedium,
704 MachineState_T aMachineState,
705 HRESULT *phrc);
706 int i_configMediumProperties(PCFGMNODE pCur, IMedium *pMedium, bool *pfHostIP, bool *pfEncrypted);
707 static DECLCALLBACK(int) i_reconfigureMediumAttachment(Console *pThis,
708 PUVM pUVM,
709 const char *pcszDevice,
710 unsigned uInstance,
711 StorageBus_T enmBus,
712 bool fUseHostIOCache,
713 bool fBuiltinIoCache,
714 bool fInsertDiskIntegrityDrv,
715 bool fSetupMerge,
716 unsigned uMergeSource,
717 unsigned uMergeTarget,
718 IMediumAttachment *aMediumAtt,
719 MachineState_T aMachineState,
720 HRESULT *phrc);
721 static DECLCALLBACK(int) i_changeRemovableMedium(Console *pThis,
722 PUVM pUVM,
723 const char *pcszDevice,
724 unsigned uInstance,
725 StorageBus_T enmBus,
726 bool fUseHostIOCache,
727 IMediumAttachment *aMediumAtt,
728 bool fForce);
729
730 HRESULT i_attachRawPCIDevices(PUVM pUVM, BusAssignmentManager *BusMgr, PCFGMNODE pDevices);
731 void i_attachStatusDriver(PCFGMNODE pCtlInst, PPDMLED *papLeds,
732 uint64_t uFirst, uint64_t uLast,
733 Console::MediumAttachmentMap *pmapMediumAttachments,
734 const char *pcszDevice, unsigned uInstance);
735
736 int i_configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
737 INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
738 PCFGMNODE pLunL0, PCFGMNODE pInst,
739 bool fAttachDetach, bool fIgnoreConnectFailure);
740 int i_configSerialPort(PCFGMNODE pInst, PortMode_T ePortMode, const char *pszPath, bool fServer);
741 static DECLCALLBACK(int) i_configGuestProperties(void *pvConsole);
742 static DECLCALLBACK(int) i_configGuestControl(void *pvConsole);
743 static DECLCALLBACK(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
744 static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
745 static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
746 HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
747 HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM);
748 HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM);
749
750 HRESULT i_doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
751 unsigned uLun, INetworkAdapter *aNetworkAdapter);
752 static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
753 unsigned uInstance, unsigned uLun,
754 INetworkAdapter *aNetworkAdapter);
755 static DECLCALLBACK(int) i_changeSerialPortAttachment(Console *pThis, PUVM pUVM,
756 ISerialPort *pSerialPort);
757
758 void i_changeClipboardMode(ClipboardMode_T aClipboardMode);
759 int i_changeDnDMode(DnDMode_T aDnDMode);
760
761#ifdef VBOX_WITH_USB
762 HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename);
763 HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
764
765 static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
766 const char *aBackend, const char *aAddress, void *pvRemoteBackend,
767 USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
768 const char *pszCaptureFilename);
769 static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
770#endif
771
772 static DECLCALLBACK(int) i_attachStorageDevice(Console *pThis,
773 PUVM pUVM,
774 const char *pcszDevice,
775 unsigned uInstance,
776 StorageBus_T enmBus,
777 bool fUseHostIOCache,
778 IMediumAttachment *aMediumAtt,
779 bool fSilent);
780 static DECLCALLBACK(int) i_detachStorageDevice(Console *pThis,
781 PUVM pUVM,
782 const char *pcszDevice,
783 unsigned uInstance,
784 StorageBus_T enmBus,
785 IMediumAttachment *aMediumAtt,
786 bool fSilent);
787 HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
788 HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
789
790 static DECLCALLBACK(int) i_stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
791
792 static DECLCALLBACK(void) i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
793 const char *pszErrorFmt, va_list va);
794
795 void i_atVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
796 static DECLCALLBACK(void) i_atVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
797 const char *pszErrorId, const char *pszFormat, va_list va);
798
799 HRESULT i_captureUSBDevices(PUVM pUVM);
800 void i_detachAllUSBDevices(bool aDone);
801
802
803 static DECLCALLBACK(int) i_vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
804 static DECLCALLBACK(void) i_vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
805 static DECLCALLBACK(void) i_vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
806 static DECLCALLBACK(void) i_vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
807 static DECLCALLBACK(void) i_vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
808 static DECLCALLBACK(void) i_vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
809 static DECLCALLBACK(void *) i_vmm2User_QueryGenericObject(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid);
810
811 static DECLCALLBACK(void *) i_drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
812 static DECLCALLBACK(void) i_drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
813 static DECLCALLBACK(int) i_drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
814 static DECLCALLBACK(void) i_drvStatus_Destruct(PPDMDRVINS pDrvIns);
815 static DECLCALLBACK(int) i_drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
816
817 static DECLCALLBACK(int) i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey,
818 size_t *pcbKey);
819 static DECLCALLBACK(int) i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId);
820 static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRetain(PPDMISECKEY pInterface, const char *pszId, const char **ppszPassword);
821 static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRelease(PPDMISECKEY pInterface, const char *pszId);
822
823 static DECLCALLBACK(int) i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface);
824
825 int mcAudioRefs;
826 volatile uint32_t mcVRDPClients;
827 uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
828 volatile bool mcGuestCredentialsProvided;
829
830 static const char *sSSMConsoleUnit;
831
832 HRESULT i_loadDataFromSavedState();
833 int i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
834
835 static DECLCALLBACK(void) i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
836 static DECLCALLBACK(int) i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
837
838#ifdef VBOX_WITH_GUEST_PROPS
839 static DECLCALLBACK(int) i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
840 HRESULT i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
841 std::vector<Utf8Str> &aNames,
842 std::vector<Utf8Str> &aValues,
843 std::vector<LONG64> &aTimestamps,
844 std::vector<Utf8Str> &aFlags);
845
846 void i_guestPropertiesHandleVMReset(void);
847 bool i_guestPropertiesVRDPEnabled(void);
848 void i_guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
849 void i_guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
850 void i_guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
851 void i_guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
852 void i_guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
853 void i_guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
854 void i_guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
855 void i_guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
856#endif
857
858 bool i_isResetTurnedIntoPowerOff(void);
859
860 /** @name Disk encryption support
861 * @{ */
862 HRESULT i_consoleParseDiskEncryption(const char *psz, const char **ppszEnd);
863 HRESULT i_configureEncryptionForDisk(const Utf8Str &strId, unsigned *pcDisksConfigured);
864 HRESULT i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(const Utf8Str &strId);
865 HRESULT i_initSecretKeyIfOnAllAttachments(void);
866 int i_consoleParseKeyValue(const char *psz, const char **ppszEnd,
867 char **ppszKey, char **ppszVal);
868 void i_removeSecretKeysOnSuspend();
869 /** @} */
870
871 /** @name Teleporter support
872 * @{ */
873 static DECLCALLBACK(int) i_teleporterSrcThreadWrapper(RTTHREAD hThreadSelf, void *pvUser);
874 HRESULT i_teleporterSrc(TeleporterStateSrc *pState);
875 HRESULT i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
876 HRESULT i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
877 HRESULT i_teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
878 Progress *pProgress, bool *pfPowerOffOnFailure);
879 static DECLCALLBACK(int) i_teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
880 /** @} */
881
882 bool mSavedStateDataLoaded : 1;
883
884 const ComPtr<IMachine> mMachine;
885 const ComPtr<IInternalMachineControl> mControl;
886
887 const ComPtr<IVRDEServer> mVRDEServer;
888
889 ConsoleVRDPServer * const mConsoleVRDPServer;
890 bool mfVRDEChangeInProcess;
891 bool mfVRDEChangePending;
892 const ComObjPtr<Guest> mGuest;
893 const ComObjPtr<Keyboard> mKeyboard;
894 const ComObjPtr<Mouse> mMouse;
895 const ComObjPtr<Display> mDisplay;
896 const ComObjPtr<MachineDebugger> mDebugger;
897 const ComObjPtr<VRDEServerInfo> mVRDEServerInfo;
898 /** This can safely be used without holding any locks.
899 * An AutoCaller suffices to prevent it being destroy while in use and
900 * internally there is a lock providing the necessary serialization. */
901 const ComObjPtr<EventSource> mEventSource;
902#ifdef VBOX_WITH_EXTPACK
903 const ComObjPtr<ExtPackManager> mptrExtPackManager;
904#endif
905 const ComObjPtr<EmulatedUSB> mEmulatedUSB;
906
907 USBDeviceList mUSBDevices;
908 RemoteUSBDeviceList mRemoteUSBDevices;
909
910 SharedFolderDataMap m_mapGlobalSharedFolders;
911 SharedFolderDataMap m_mapMachineSharedFolders;
912 SharedFolderMap m_mapSharedFolders; // the console instances
913
914 /** The user mode VM handle. */
915 PUVM mpUVM;
916 /** Holds the number of "readonly" mpUVM callers (users). */
917 uint32_t mVMCallers;
918 /** Semaphore posted when the number of mpUVM callers drops to zero. */
919 RTSEMEVENT mVMZeroCallersSem;
920 /** true when Console has entered the mpUVM destruction phase. */
921 bool mVMDestroying : 1;
922 /** true when power down is initiated by vmstateChangeCallback (EMT). */
923 bool mVMPoweredOff : 1;
924 /** true when vmstateChangeCallback shouldn't initiate a power down. */
925 bool mVMIsAlreadyPoweringOff : 1;
926 /** true if we already showed the snapshot folder size warning. */
927 bool mfSnapshotFolderSizeWarningShown : 1;
928 /** true if we already showed the snapshot folder ext4/xfs bug warning. */
929 bool mfSnapshotFolderExt4WarningShown : 1;
930 /** true if we already listed the disk type of the snapshot folder. */
931 bool mfSnapshotFolderDiskTypeShown : 1;
932 /** true if a USB controller is available (i.e. USB devices can be attached). */
933 bool mfVMHasUsbController : 1;
934 /** true if the VM power off was caused by reset. */
935 bool mfPowerOffCausedByReset : 1;
936
937 /** Pointer to the VMM -> User (that's us) callbacks. */
938 struct MYVMM2USERMETHODS : public VMM2USERMETHODS
939 {
940 Console *pConsole;
941 /** The in-progress snapshot. */
942 ISnapshot *pISnapshot;
943 } *mpVmm2UserMethods;
944
945 /** The current network attachment type in the VM.
946 * This doesn't have to match the network attachment type maintained in the
947 * NetworkAdapter. This is needed to change the network attachment
948 * dynamically.
949 */
950 typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
951 NetworkAttachmentTypeVector meAttachmentType;
952
953 VMMDev * m_pVMMDev;
954 AudioVRDE * const mAudioVRDE;
955 Nvram * const mNvram;
956#ifdef VBOX_WITH_USB_CARDREADER
957 UsbCardReader * const mUsbCardReader;
958#endif
959 BusAssignmentManager* mBusMgr;
960
961 enum
962 {
963 iLedFloppy = 0,
964 cLedFloppy = 2,
965 iLedIde = iLedFloppy + cLedFloppy,
966 cLedIde = 4,
967 iLedSata = iLedIde + cLedIde,
968 cLedSata = 30,
969 iLedScsi = iLedSata + cLedSata,
970 cLedScsi = 16,
971 iLedSas = iLedScsi + cLedScsi,
972 cLedSas = 8,
973 iLedUsb = iLedSas + cLedSas,
974 cLedUsb = 8,
975 iLedNvme = iLedUsb + cLedUsb,
976 cLedNvme = 30,
977 cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas + cLedUsb + cLedNvme
978 };
979 DeviceType_T maStorageDevType[cLedStorage];
980 PPDMLED mapStorageLeds[cLedStorage];
981 PPDMLED mapNetworkLeds[36]; /**< @todo adapt this to the maximum network card count */
982 PPDMLED mapSharedFolderLed;
983 PPDMLED mapUSBLed[2];
984 PPDMLED mapCrOglLed;
985
986 MediumAttachmentMap mapMediumAttachments;
987
988 /** List of attached USB storage devices. */
989 USBStorageDeviceList mUSBStorageDevices;
990
991 /** Store for secret keys. */
992 SecretKeyStore * const m_pKeyStore;
993 /** Number of disks configured for encryption. */
994 unsigned m_cDisksEncrypted;
995 /** Number of disks which have the key in the map. */
996 unsigned m_cDisksPwProvided;
997
998 /** Current active port modes of the supported serial ports. */
999 PortMode_T m_aeSerialPortMode[4];
1000
1001 /** Pointer to the key consumer -> provider (that's us) callbacks. */
1002 struct MYPDMISECKEY : public PDMISECKEY
1003 {
1004 Console *pConsole;
1005 } *mpIfSecKey;
1006
1007 /** Pointer to the key helpers -> provider (that's us) callbacks. */
1008 struct MYPDMISECKEYHLP : public PDMISECKEYHLP
1009 {
1010 Console *pConsole;
1011 } *mpIfSecKeyHlp;
1012
1013/* Note: FreeBSD needs this whether netflt is used or not. */
1014#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
1015 Utf8Str maTAPDeviceName[8];
1016 RTFILE maTapFD[8];
1017#endif
1018
1019 bool mVMStateChangeCallbackDisabled;
1020
1021 bool mfUseHostClipboard;
1022
1023 /** Local machine state value. */
1024 MachineState_T mMachineState;
1025
1026 /** Machine uuid string. */
1027 Bstr mstrUuid;
1028
1029 /** Pointer to the progress object of a live cancelable task.
1030 *
1031 * This is currently only used by Console::Teleport(), but is intended to later
1032 * be used by the live snapshot code path as well. Actions like
1033 * Console::PowerDown, which automatically cancels out the running snapshot /
1034 * teleportation operation, will cancel the teleportation / live snapshot
1035 * operation before starting. */
1036 ComPtr<IProgress> mptrCancelableProgress;
1037
1038 ComPtr<IEventListener> mVmListener;
1039
1040#ifdef VBOX_WITH_RECORDING
1041 struct Recording
1042 {
1043 Recording()
1044 : mpCtx(NULL)
1045# ifdef VBOX_WITH_AUDIO_RECORDING
1046 , mAudioRec(NULL)
1047# endif
1048 { }
1049
1050 /** The recording context. */
1051 RecordingContext *mpCtx;
1052# ifdef VBOX_WITH_AUDIO_RECORDING
1053 /** Pointer to capturing audio backend. */
1054 AudioVideoRec * const mAudioRec;
1055# endif
1056 } Recording;
1057#endif /* VBOX_WITH_RECORDING */
1058
1059 friend class VMTask;
1060 friend class ConsoleVRDPServer;
1061};
1062
1063#endif // !____H_CONSOLEIMPL
1064/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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