VirtualBox

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

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

GuestControl,HGCM,VBoxService: Save/restore related optimizations and changes. bugref:9313

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.2 KB
Line 
1/* $Id: ConsoleImpl.h 75853 2018-11-30 19:26:42Z 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(void) i_vmstateChangeCallback(PUVM pUVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
743 static DECLCALLBACK(int) i_unplugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
744 static DECLCALLBACK(int) i_plugCpu(Console *pThis, PUVM pUVM, VMCPUID idCpu);
745 HRESULT i_doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce, PUVM pUVM);
746 HRESULT i_doCPURemove(ULONG aCpu, PUVM pUVM);
747 HRESULT i_doCPUAdd(ULONG aCpu, PUVM pUVM);
748
749 HRESULT i_doNetworkAdapterChange(PUVM pUVM, const char *pszDevice, unsigned uInstance,
750 unsigned uLun, INetworkAdapter *aNetworkAdapter);
751 static DECLCALLBACK(int) i_changeNetworkAttachment(Console *pThis, PUVM pUVM, const char *pszDevice,
752 unsigned uInstance, unsigned uLun,
753 INetworkAdapter *aNetworkAdapter);
754 static DECLCALLBACK(int) i_changeSerialPortAttachment(Console *pThis, PUVM pUVM,
755 ISerialPort *pSerialPort);
756
757 void i_changeClipboardMode(ClipboardMode_T aClipboardMode);
758 int i_changeDnDMode(DnDMode_T aDnDMode);
759
760#ifdef VBOX_WITH_USB
761 HRESULT i_attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs, const Utf8Str &aCaptureFilename);
762 HRESULT i_detachUSBDevice(const ComObjPtr<OUSBDevice> &aHostDevice);
763
764 static DECLCALLBACK(int) i_usbAttachCallback(Console *that, PUVM pUVM, IUSBDevice *aHostDevice, PCRTUUID aUuid,
765 const char *aBackend, const char *aAddress, void *pvRemoteBackend,
766 USBConnectionSpeed_T enmSpeed, ULONG aMaskedIfs,
767 const char *pszCaptureFilename);
768 static DECLCALLBACK(int) i_usbDetachCallback(Console *that, PUVM pUVM, PCRTUUID aUuid);
769#endif
770
771 static DECLCALLBACK(int) i_attachStorageDevice(Console *pThis,
772 PUVM pUVM,
773 const char *pcszDevice,
774 unsigned uInstance,
775 StorageBus_T enmBus,
776 bool fUseHostIOCache,
777 IMediumAttachment *aMediumAtt,
778 bool fSilent);
779 static DECLCALLBACK(int) i_detachStorageDevice(Console *pThis,
780 PUVM pUVM,
781 const char *pcszDevice,
782 unsigned uInstance,
783 StorageBus_T enmBus,
784 IMediumAttachment *aMediumAtt,
785 bool fSilent);
786 HRESULT i_doStorageDeviceAttach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
787 HRESULT i_doStorageDeviceDetach(IMediumAttachment *aMediumAttachment, PUVM pUVM, bool fSilent);
788
789 static DECLCALLBACK(int) i_stateProgressCallback(PUVM pUVM, unsigned uPercent, void *pvUser);
790
791 static DECLCALLBACK(void) i_genericVMSetErrorCallback(PUVM pUVM, void *pvUser, int rc, RT_SRC_POS_DECL,
792 const char *pszErrorFmt, va_list va);
793
794 void i_atVMRuntimeErrorCallbackF(uint32_t fFatal, const char *pszErrorId, const char *pszFormat, ...);
795 static DECLCALLBACK(void) i_atVMRuntimeErrorCallback(PUVM pUVM, void *pvUser, uint32_t fFatal,
796 const char *pszErrorId, const char *pszFormat, va_list va);
797
798 HRESULT i_captureUSBDevices(PUVM pUVM);
799 void i_detachAllUSBDevices(bool aDone);
800
801
802 static DECLCALLBACK(int) i_vmm2User_SaveState(PCVMM2USERMETHODS pThis, PUVM pUVM);
803 static DECLCALLBACK(void) i_vmm2User_NotifyEmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
804 static DECLCALLBACK(void) i_vmm2User_NotifyEmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu);
805 static DECLCALLBACK(void) i_vmm2User_NotifyPdmtInit(PCVMM2USERMETHODS pThis, PUVM pUVM);
806 static DECLCALLBACK(void) i_vmm2User_NotifyPdmtTerm(PCVMM2USERMETHODS pThis, PUVM pUVM);
807 static DECLCALLBACK(void) i_vmm2User_NotifyResetTurnedIntoPowerOff(PCVMM2USERMETHODS pThis, PUVM pUVM);
808 static DECLCALLBACK(void *) i_vmm2User_QueryGenericObject(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid);
809
810 static DECLCALLBACK(void *) i_drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
811 static DECLCALLBACK(void) i_drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
812 static DECLCALLBACK(int) i_drvStatus_MediumEjected(PPDMIMEDIANOTIFY pInterface, unsigned iLUN);
813 static DECLCALLBACK(void) i_drvStatus_Destruct(PPDMDRVINS pDrvIns);
814 static DECLCALLBACK(int) i_drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
815
816 static DECLCALLBACK(int) i_pdmIfSecKey_KeyRetain(PPDMISECKEY pInterface, const char *pszId, const uint8_t **ppbKey,
817 size_t *pcbKey);
818 static DECLCALLBACK(int) i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId);
819 static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRetain(PPDMISECKEY pInterface, const char *pszId, const char **ppszPassword);
820 static DECLCALLBACK(int) i_pdmIfSecKey_PasswordRelease(PPDMISECKEY pInterface, const char *pszId);
821
822 static DECLCALLBACK(int) i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface);
823
824 int mcAudioRefs;
825 volatile uint32_t mcVRDPClients;
826 uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
827 volatile bool mcGuestCredentialsProvided;
828
829 static const char *sSSMConsoleUnit;
830
831 HRESULT i_loadDataFromSavedState();
832 int i_loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
833
834 static DECLCALLBACK(void) i_saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
835 static DECLCALLBACK(int) i_loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
836
837#ifdef VBOX_WITH_GUEST_PROPS
838 static DECLCALLBACK(int) i_doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
839 HRESULT i_doEnumerateGuestProperties(const Utf8Str &aPatterns,
840 std::vector<Utf8Str> &aNames,
841 std::vector<Utf8Str> &aValues,
842 std::vector<LONG64> &aTimestamps,
843 std::vector<Utf8Str> &aFlags);
844
845 void i_guestPropertiesHandleVMReset(void);
846 bool i_guestPropertiesVRDPEnabled(void);
847 void i_guestPropertiesVRDPUpdateLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
848 void i_guestPropertiesVRDPUpdateActiveClient(uint32_t u32ClientId);
849 void i_guestPropertiesVRDPUpdateClientAttach(uint32_t u32ClientId, bool fAttached);
850 void i_guestPropertiesVRDPUpdateNameChange(uint32_t u32ClientId, const char *pszName);
851 void i_guestPropertiesVRDPUpdateIPAddrChange(uint32_t u32ClientId, const char *pszIPAddr);
852 void i_guestPropertiesVRDPUpdateLocationChange(uint32_t u32ClientId, const char *pszLocation);
853 void i_guestPropertiesVRDPUpdateOtherInfoChange(uint32_t u32ClientId, const char *pszOtherInfo);
854 void i_guestPropertiesVRDPUpdateDisconnect(uint32_t u32ClientId);
855#endif
856
857 bool i_isResetTurnedIntoPowerOff(void);
858
859 /** @name Disk encryption support
860 * @{ */
861 HRESULT i_consoleParseDiskEncryption(const char *psz, const char **ppszEnd);
862 HRESULT i_configureEncryptionForDisk(const Utf8Str &strId, unsigned *pcDisksConfigured);
863 HRESULT i_clearDiskEncryptionKeysOnAllAttachmentsWithKeyId(const Utf8Str &strId);
864 HRESULT i_initSecretKeyIfOnAllAttachments(void);
865 int i_consoleParseKeyValue(const char *psz, const char **ppszEnd,
866 char **ppszKey, char **ppszVal);
867 void i_removeSecretKeysOnSuspend();
868 /** @} */
869
870 /** @name Teleporter support
871 * @{ */
872 static DECLCALLBACK(int) i_teleporterSrcThreadWrapper(RTTHREAD hThreadSelf, void *pvUser);
873 HRESULT i_teleporterSrc(TeleporterStateSrc *pState);
874 HRESULT i_teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
875 HRESULT i_teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
876 HRESULT i_teleporterTrg(PUVM pUVM, IMachine *pMachine, Utf8Str *pErrorMsg, bool fStartPaused,
877 Progress *pProgress, bool *pfPowerOffOnFailure);
878 static DECLCALLBACK(int) i_teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
879 /** @} */
880
881 bool mSavedStateDataLoaded : 1;
882
883 const ComPtr<IMachine> mMachine;
884 const ComPtr<IInternalMachineControl> mControl;
885
886 const ComPtr<IVRDEServer> mVRDEServer;
887
888 ConsoleVRDPServer * const mConsoleVRDPServer;
889 bool mfVRDEChangeInProcess;
890 bool mfVRDEChangePending;
891 const ComObjPtr<Guest> mGuest;
892 const ComObjPtr<Keyboard> mKeyboard;
893 const ComObjPtr<Mouse> mMouse;
894 const ComObjPtr<Display> mDisplay;
895 const ComObjPtr<MachineDebugger> mDebugger;
896 const ComObjPtr<VRDEServerInfo> mVRDEServerInfo;
897 /** This can safely be used without holding any locks.
898 * An AutoCaller suffices to prevent it being destroy while in use and
899 * internally there is a lock providing the necessary serialization. */
900 const ComObjPtr<EventSource> mEventSource;
901#ifdef VBOX_WITH_EXTPACK
902 const ComObjPtr<ExtPackManager> mptrExtPackManager;
903#endif
904 const ComObjPtr<EmulatedUSB> mEmulatedUSB;
905
906 USBDeviceList mUSBDevices;
907 RemoteUSBDeviceList mRemoteUSBDevices;
908
909 SharedFolderDataMap m_mapGlobalSharedFolders;
910 SharedFolderDataMap m_mapMachineSharedFolders;
911 SharedFolderMap m_mapSharedFolders; // the console instances
912
913 /** The user mode VM handle. */
914 PUVM mpUVM;
915 /** Holds the number of "readonly" mpUVM callers (users). */
916 uint32_t mVMCallers;
917 /** Semaphore posted when the number of mpUVM callers drops to zero. */
918 RTSEMEVENT mVMZeroCallersSem;
919 /** true when Console has entered the mpUVM destruction phase. */
920 bool mVMDestroying : 1;
921 /** true when power down is initiated by vmstateChangeCallback (EMT). */
922 bool mVMPoweredOff : 1;
923 /** true when vmstateChangeCallback shouldn't initiate a power down. */
924 bool mVMIsAlreadyPoweringOff : 1;
925 /** true if we already showed the snapshot folder size warning. */
926 bool mfSnapshotFolderSizeWarningShown : 1;
927 /** true if we already showed the snapshot folder ext4/xfs bug warning. */
928 bool mfSnapshotFolderExt4WarningShown : 1;
929 /** true if we already listed the disk type of the snapshot folder. */
930 bool mfSnapshotFolderDiskTypeShown : 1;
931 /** true if a USB controller is available (i.e. USB devices can be attached). */
932 bool mfVMHasUsbController : 1;
933 /** true if the VM power off was caused by reset. */
934 bool mfPowerOffCausedByReset : 1;
935
936 /** Pointer to the VMM -> User (that's us) callbacks. */
937 struct MYVMM2USERMETHODS : public VMM2USERMETHODS
938 {
939 Console *pConsole;
940 /** The in-progress snapshot. */
941 ISnapshot *pISnapshot;
942 } *mpVmm2UserMethods;
943
944 /** The current network attachment type in the VM.
945 * This doesn't have to match the network attachment type maintained in the
946 * NetworkAdapter. This is needed to change the network attachment
947 * dynamically.
948 */
949 typedef std::vector<NetworkAttachmentType_T> NetworkAttachmentTypeVector;
950 NetworkAttachmentTypeVector meAttachmentType;
951
952 VMMDev * m_pVMMDev;
953 AudioVRDE * const mAudioVRDE;
954 Nvram * const mNvram;
955#ifdef VBOX_WITH_USB_CARDREADER
956 UsbCardReader * const mUsbCardReader;
957#endif
958 BusAssignmentManager* mBusMgr;
959
960 enum
961 {
962 iLedFloppy = 0,
963 cLedFloppy = 2,
964 iLedIde = iLedFloppy + cLedFloppy,
965 cLedIde = 4,
966 iLedSata = iLedIde + cLedIde,
967 cLedSata = 30,
968 iLedScsi = iLedSata + cLedSata,
969 cLedScsi = 16,
970 iLedSas = iLedScsi + cLedScsi,
971 cLedSas = 8,
972 iLedUsb = iLedSas + cLedSas,
973 cLedUsb = 8,
974 iLedNvme = iLedUsb + cLedUsb,
975 cLedNvme = 30,
976 cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas + cLedUsb + cLedNvme
977 };
978 DeviceType_T maStorageDevType[cLedStorage];
979 PPDMLED mapStorageLeds[cLedStorage];
980 PPDMLED mapNetworkLeds[36]; /**< @todo adapt this to the maximum network card count */
981 PPDMLED mapSharedFolderLed;
982 PPDMLED mapUSBLed[2];
983 PPDMLED mapCrOglLed;
984
985 MediumAttachmentMap mapMediumAttachments;
986
987 /** List of attached USB storage devices. */
988 USBStorageDeviceList mUSBStorageDevices;
989
990 /** Store for secret keys. */
991 SecretKeyStore * const m_pKeyStore;
992 /** Number of disks configured for encryption. */
993 unsigned m_cDisksEncrypted;
994 /** Number of disks which have the key in the map. */
995 unsigned m_cDisksPwProvided;
996
997 /** Current active port modes of the supported serial ports. */
998 PortMode_T m_aeSerialPortMode[4];
999
1000 /** Pointer to the key consumer -> provider (that's us) callbacks. */
1001 struct MYPDMISECKEY : public PDMISECKEY
1002 {
1003 Console *pConsole;
1004 } *mpIfSecKey;
1005
1006 /** Pointer to the key helpers -> provider (that's us) callbacks. */
1007 struct MYPDMISECKEYHLP : public PDMISECKEYHLP
1008 {
1009 Console *pConsole;
1010 } *mpIfSecKeyHlp;
1011
1012/* Note: FreeBSD needs this whether netflt is used or not. */
1013#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
1014 Utf8Str maTAPDeviceName[8];
1015 RTFILE maTapFD[8];
1016#endif
1017
1018 bool mVMStateChangeCallbackDisabled;
1019
1020 bool mfUseHostClipboard;
1021
1022 /** Local machine state value. */
1023 MachineState_T mMachineState;
1024
1025 /** Machine uuid string. */
1026 Bstr mstrUuid;
1027
1028 /** Pointer to the progress object of a live cancelable task.
1029 *
1030 * This is currently only used by Console::Teleport(), but is intended to later
1031 * be used by the live snapshot code path as well. Actions like
1032 * Console::PowerDown, which automatically cancels out the running snapshot /
1033 * teleportation operation, will cancel the teleportation / live snapshot
1034 * operation before starting. */
1035 ComPtr<IProgress> mptrCancelableProgress;
1036
1037 ComPtr<IEventListener> mVmListener;
1038
1039#ifdef VBOX_WITH_RECORDING
1040 struct Recording
1041 {
1042 Recording()
1043 : mpCtx(NULL)
1044# ifdef VBOX_WITH_AUDIO_RECORDING
1045 , mAudioRec(NULL)
1046# endif
1047 { }
1048
1049 /** The recording context. */
1050 RecordingContext *mpCtx;
1051# ifdef VBOX_WITH_AUDIO_RECORDING
1052 /** Pointer to capturing audio backend. */
1053 AudioVideoRec * const mAudioRec;
1054# endif
1055 } Recording;
1056#endif /* VBOX_WITH_RECORDING */
1057
1058 friend class VMTask;
1059 friend class ConsoleVRDPServer;
1060};
1061
1062#endif // !____H_CONSOLEIMPL
1063/* 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