VirtualBox

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

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

Main: Use MAIN_INCLUDED_ and MAIN_INCLUDED_SRC_ as header guard prefixes with scm.

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