VirtualBox

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

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

Main,VBoxManage,FE/Qt: Extended the createSharedFolder and ISharedFolder methods with a mount poit parameter/attribute for use when auto-mounting. This is especially useful for Windows and OS/2 guests which operates with drive letters. The change has not yet trickled down to the guest interface and VBoxService.

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