VirtualBox

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

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

Main: bugref:6913: Added OnStorageControllerChanged to IVirtualBox events and fixed generation the medium events

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