VirtualBox

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

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

VideoRec/Main: Condensed code for enabling / disabling video (audio) recording at VM startup and onVideoCaptureChange handler.

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