VirtualBox

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

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

Audio/Main: Implemented feeding the pre-buffering, buffer size and period size (all in ms) values on a per-driver level from extra data into CFGM.

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

© 2023 Oracle
ContactPrivacy policyTerms of Use