VirtualBox

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

Last change on this file since 81429 was 81429, checked in by vboxsync, 5 years ago

Main/Console: forgotten change

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