VirtualBox

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

Last change on this file since 73188 was 73003, checked in by vboxsync, 7 years ago

Main: Use setErrorBoth when we've got a VBox status code handy. (The COM status codes aren't too specfic and this may help us decode error messages and provide an alternative to strstr for API clients. setErrorBoth isn't new, btw.)

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