VirtualBox

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

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

Main: VC++ 19.2 adjustments. bugref:8489

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette