VirtualBox

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

Last change on this file since 28774 was 28764, checked in by vboxsync, 15 years ago

Main: Introduce a per controller setting to switch to the unbuffered async I/O interface (UseNewIo). Configurable through VBoxManage, default is still buffered

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.3 KB
Line 
1/* $Id: ConsoleImpl.h 28764 2010-04-26 16:12:49Z vboxsync $ */
2/** @file
3 * VBox Console COM Class definition
4 */
5
6/*
7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_CONSOLEIMPL
23#define ____H_CONSOLEIMPL
24
25#include "VirtualBoxBase.h"
26#include "SchemaDefs.h"
27
28class Guest;
29class Keyboard;
30class Mouse;
31class Display;
32class MachineDebugger;
33class TeleporterStateSrc;
34class OUSBDevice;
35class RemoteUSBDevice;
36class SharedFolder;
37class RemoteDisplayInfo;
38class AudioSniffer;
39class ConsoleVRDPServer;
40class VMMDev;
41class Progress;
42
43#include <VBox/vrdpapi.h>
44#include <VBox/pdmdrv.h>
45#ifdef VBOX_WITH_GUEST_PROPS
46# include <VBox/HostServices/GuestPropertySvc.h> /* For the property notification callback */
47#endif
48
49struct VUSBIRHCONFIG;
50typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
51
52#include <list>
53
54// defines
55///////////////////////////////////////////////////////////////////////////////
56
57/**
58 * Checks the availability of the underlying VM device driver corresponding
59 * to the COM interface (IKeyboard, IMouse, IDisplay, etc.). When the driver is
60 * not available (NULL), sets error info and returns returns E_ACCESSDENIED.
61 * The translatable error message is defined in null context.
62 *
63 * Intended to used only within Console children (i.e. Keyboard, Mouse,
64 * Display, etc.).
65 *
66 * @param drv driver pointer to check (compare it with NULL)
67 */
68#define CHECK_CONSOLE_DRV(drv) \
69 do { \
70 if (!(drv)) \
71 return setError(E_ACCESSDENIED, tr("The console is not powered up")); \
72 } while (0)
73
74// Console
75///////////////////////////////////////////////////////////////////////////////
76
77/** IConsole implementation class */
78class ATL_NO_VTABLE Console :
79 public VirtualBoxBaseWithChildrenNEXT,
80 public VirtualBoxSupportErrorInfoImpl<Console, IConsole>,
81 public VirtualBoxSupportTranslation<Console>,
82 VBOX_SCRIPTABLE_IMPL(IConsole)
83{
84 Q_OBJECT
85
86public:
87
88 DECLARE_NOT_AGGREGATABLE(Console)
89
90 DECLARE_PROTECT_FINAL_CONSTRUCT()
91
92 BEGIN_COM_MAP(Console)
93 COM_INTERFACE_ENTRY(ISupportErrorInfo)
94 COM_INTERFACE_ENTRY(IConsole)
95 COM_INTERFACE_ENTRY(IDispatch)
96 END_COM_MAP()
97
98 Console();
99 ~Console();
100
101 HRESULT FinalConstruct();
102 void FinalRelease();
103
104 // public initializers/uninitializers for internal purposes only
105 HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl);
106 void uninit();
107
108 // IConsole properties
109 STDMETHOD(COMGETTER(Machine))(IMachine **aMachine);
110 STDMETHOD(COMGETTER(State))(MachineState_T *aMachineState);
111 STDMETHOD(COMGETTER(Guest))(IGuest **aGuest);
112 STDMETHOD(COMGETTER(Keyboard))(IKeyboard **aKeyboard);
113 STDMETHOD(COMGETTER(Mouse))(IMouse **aMouse);
114 STDMETHOD(COMGETTER(Display))(IDisplay **aDisplay);
115 STDMETHOD(COMGETTER(Debugger))(IMachineDebugger **aDebugger);
116 STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IUSBDevice *, aUSBDevices));
117 STDMETHOD(COMGETTER(RemoteUSBDevices))(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices));
118 STDMETHOD(COMGETTER(RemoteDisplayInfo))(IRemoteDisplayInfo **aRemoteDisplayInfo);
119 STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
120
121 // IConsole methods
122 STDMETHOD(PowerUp)(IProgress **aProgress);
123 STDMETHOD(PowerUpPaused)(IProgress **aProgress);
124 STDMETHOD(PowerDown)(IProgress **aProgress);
125 STDMETHOD(Reset)();
126 STDMETHOD(Pause)();
127 STDMETHOD(Resume)();
128 STDMETHOD(PowerButton)();
129 STDMETHOD(SleepButton)();
130 STDMETHOD(GetPowerButtonHandled)(BOOL *aHandled);
131 STDMETHOD(GetGuestEnteredACPIMode)(BOOL *aEntered);
132 STDMETHOD(SaveState)(IProgress **aProgress);
133 STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
134 STDMETHOD(ForgetSavedState)(BOOL aRemove);
135 STDMETHOD(GetDeviceActivity)(DeviceType_T aDeviceType,
136 DeviceActivity_T *aDeviceActivity);
137 STDMETHOD(AttachUSBDevice)(IN_BSTR aId);
138 STDMETHOD(DetachUSBDevice)(IN_BSTR aId, IUSBDevice **aDevice);
139 STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IUSBDevice **aDevice);
140 STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IUSBDevice **aDevice);
141 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
142 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
143 STDMETHOD(TakeSnapshot)(IN_BSTR aName, IN_BSTR aDescription,
144 IProgress **aProgress);
145 STDMETHOD(DeleteSnapshot)(IN_BSTR aId, IProgress **aProgress);
146 STDMETHOD(RestoreSnapshot)(ISnapshot *aSnapshot, IProgress **aProgress);
147 STDMETHOD(Teleport)(IN_BSTR aHostname, ULONG aPort, IN_BSTR aPassword, ULONG aMaxDowntime, IProgress **aProgress);
148 STDMETHOD(RegisterCallback)(IConsoleCallback *aCallback);
149 STDMETHOD(UnregisterCallback)(IConsoleCallback *aCallback);
150
151 // public methods for internal purposes only
152
153 /*
154 * Note: the following methods do not increase refcount. intended to be
155 * called only by the VM execution thread.
156 */
157
158 Guest *getGuest() const { return mGuest; }
159 Keyboard *getKeyboard() const { return mKeyboard; }
160 Mouse *getMouse() const { return mMouse; }
161 Display *getDisplay() const { return mDisplay; }
162 MachineDebugger *getMachineDebugger() const { return mDebugger; }
163
164 const ComPtr<IMachine> &machine() const { return mMachine; }
165
166 /** Method is called only from ConsoleVRDPServer */
167 IVRDPServer *getVRDPServer() const { return mVRDPServer; }
168
169 ConsoleVRDPServer *consoleVRDPServer() const { return mConsoleVRDPServer; }
170
171 HRESULT updateMachineState(MachineState_T aMachineState);
172
173 // events from IInternalSessionControl
174 HRESULT onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter);
175 HRESULT onSerialPortChange(ISerialPort *aSerialPort);
176 HRESULT onParallelPortChange(IParallelPort *aParallelPort);
177 HRESULT onStorageControllerChange();
178 HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
179 HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
180 HRESULT onVRDPServerChange();
181 HRESULT onUSBControllerChange();
182 HRESULT onSharedFolderChange(BOOL aGlobal);
183 HRESULT onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
184 HRESULT onUSBDeviceDetach(IN_BSTR aId, IVirtualBoxErrorInfo *aError);
185 HRESULT getGuestProperty(IN_BSTR aKey, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
186 HRESULT setGuestProperty(IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags);
187 HRESULT enumerateGuestProperties(IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
188 VMMDev *getVMMDev() { return mVMMDev; }
189 AudioSniffer *getAudioSniffer() { return mAudioSniffer; }
190
191 int VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
192 void VRDPClientConnect(uint32_t u32ClientId);
193 void VRDPClientDisconnect(uint32_t u32ClientId, uint32_t fu32Intercepted);
194 void VRDPInterceptAudio(uint32_t u32ClientId);
195 void VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept);
196 void VRDPInterceptClipboard(uint32_t u32ClientId);
197
198 void processRemoteUSBDevices(uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList);
199
200 // callback callers (partly; for some events console callbacks are notified
201 // directly from IInternalSessionControl event handlers declared above)
202 void onMousePointerShapeChange(bool fVisible, bool fAlpha,
203 uint32_t xHot, uint32_t yHot,
204 uint32_t width, uint32_t height,
205 void *pShape);
206 void onMouseCapabilityChange(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor);
207 void onStateChange(MachineState_T aMachineState);
208 void onAdditionsStateChange();
209 void onAdditionsOutdated();
210 void onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock);
211 void onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
212 IVirtualBoxErrorInfo *aError);
213 void onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
214 HRESULT onShowWindow(BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId);
215 void onRemoteDisplayInfoChange();
216
217 static const PDMDRVREG DrvStatusReg;
218
219 void reportAuthLibraryError(const char *filename, int rc)
220 {
221 setError(E_FAIL, tr("Could not load the external authentication library '%s' (%Rrc)"), filename, rc);
222 }
223
224 static HRESULT handleUnexpectedExceptions(RT_SRC_POS_DECL);
225
226 static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
227 static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
228
229 // for VirtualBoxSupportErrorInfoImpl
230 static const wchar_t *getComponentName() { return L"Console"; }
231
232private:
233
234 /**
235 * Base template for AutoVMCaller and SaveVMPtr. Template arguments
236 * have the same meaning as arguments of Console::addVMCaller().
237 */
238 template <bool taQuiet = false, bool taAllowNullVM = false>
239 class AutoVMCallerBase
240 {
241 public:
242 AutoVMCallerBase(Console *aThat) : mThat(aThat), mRC(S_OK)
243 {
244 Assert(aThat);
245 mRC = aThat->addVMCaller(taQuiet, taAllowNullVM);
246 }
247 ~AutoVMCallerBase()
248 {
249 if (SUCCEEDED(mRC))
250 mThat->releaseVMCaller();
251 }
252 /** Decreases the number of callers before the instance is destroyed. */
253 void release()
254 {
255 AssertReturnVoid(SUCCEEDED(mRC));
256 mThat->releaseVMCaller();
257 mRC = E_FAIL;
258 }
259 /** Restores the number of callers after by #release(). #rc() must be
260 * rechecked to ensure the operation succeeded. */
261 void add()
262 {
263 AssertReturnVoid(!SUCCEEDED(mRC));
264 mRC = mThat->addVMCaller(taQuiet, taAllowNullVM);
265 }
266 /** Returns the result of Console::addVMCaller() */
267 HRESULT rc() const { return mRC; }
268 /** Shortcut to SUCCEEDED(rc()) */
269 bool isOk() const { return SUCCEEDED(mRC); }
270 protected:
271 Console *mThat;
272 HRESULT mRC;
273 private:
274 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(AutoVMCallerBase)
275 DECLARE_CLS_NEW_DELETE_NOOP(AutoVMCallerBase)
276 };
277
278 /**
279 * Helper class that protects sections of code using the mpVM pointer by
280 * automatically calling addVMCaller() on construction and
281 * releaseVMCaller() on destruction. Intended for Console methods dealing
282 * with mpVM. The usage pattern is:
283 * <code>
284 * AutoVMCaller autoVMCaller(this);
285 * if (FAILED(autoVMCaller.rc())) return autoVMCaller.rc();
286 * ...
287 * VMR3ReqCall (mpVM, ...
288 * </code>
289 *
290 * @note Temporarily locks the argument for writing.
291 *
292 * @sa SafeVMPtr, SafeVMPtrQuiet
293 */
294 typedef AutoVMCallerBase <false, false> AutoVMCaller;
295
296 /**
297 * Same as AutoVMCaller but doesn't set extended error info on failure.
298 *
299 * @note Temporarily locks the argument for writing.
300 */
301 typedef AutoVMCallerBase <true, false> AutoVMCallerQuiet;
302
303 /**
304 * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
305 * instead of assertion).
306 *
307 * @note Temporarily locks the argument for writing.
308 */
309 typedef AutoVMCallerBase <false, true> AutoVMCallerWeak;
310
311 /**
312 * Same as AutoVMCaller but doesn't set extended error info on failure
313 * and allows a null VM pointer (to trigger an error instead of
314 * assertion).
315 *
316 * @note Temporarily locks the argument for writing.
317 */
318 typedef AutoVMCallerBase <true, true> AutoVMCallerQuietWeak;
319
320 /**
321 * Base template for SaveVMPtr and SaveVMPtrQuiet.
322 */
323 template <bool taQuiet = false>
324 class SafeVMPtrBase : public AutoVMCallerBase <taQuiet, true>
325 {
326 typedef AutoVMCallerBase <taQuiet, true> Base;
327 public:
328 SafeVMPtrBase(Console *aThat) : Base(aThat), mpVM(NULL)
329 {
330 if (SUCCEEDED(Base::mRC))
331 mpVM = aThat->mpVM;
332 }
333 /** Smart SaveVMPtr to PVM cast operator */
334 operator PVM() const { return mpVM; }
335 /** Direct PVM access for printf()-like functions */
336 PVM raw() const { return mpVM; }
337 private:
338 PVM mpVM;
339 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(SafeVMPtrBase)
340 DECLARE_CLS_NEW_DELETE_NOOP(SafeVMPtrBase)
341 };
342
343public:
344
345 /**
346 * Helper class that safely manages the Console::mpVM pointer
347 * by calling addVMCaller() on construction and releaseVMCaller() on
348 * destruction. Intended for Console children. The usage pattern is:
349 * <code>
350 * Console::SaveVMPtr pVM(mParent);
351 * if (FAILED(pVM.rc())) return pVM.rc();
352 * ...
353 * VMR3ReqCall(pVM, ...
354 * ...
355 * printf("%p\n", pVM.raw());
356 * </code>
357 *
358 * @note Temporarily locks the argument for writing.
359 *
360 * @sa SafeVMPtrQuiet, AutoVMCaller
361 */
362 typedef SafeVMPtrBase <false> SafeVMPtr;
363
364 /**
365 * A deviation of SaveVMPtr that doesn't set the error info on failure.
366 * Intended for pieces of code that don't need to return the VM access
367 * failure to the caller. The usage pattern is:
368 * <code>
369 * Console::SaveVMPtrQuiet pVM(mParent);
370 * if (pVM.rc())
371 * VMR3ReqCall(pVM, ...
372 * return S_OK;
373 * </code>
374 *
375 * @note Temporarily locks the argument for writing.
376 *
377 * @sa SafeVMPtr, AutoVMCaller
378 */
379 typedef SafeVMPtrBase <true> SafeVMPtrQuiet;
380
381 class SharedFolderData
382 {
383 public:
384 SharedFolderData() {}
385 SharedFolderData(Bstr aHostPath, BOOL aWritable)
386 : mHostPath(aHostPath)
387 , mWritable(aWritable) {}
388 SharedFolderData(const SharedFolderData& aThat)
389 : mHostPath(aThat.mHostPath)
390 , mWritable(aThat.mWritable) {}
391 Bstr mHostPath;
392 BOOL mWritable;
393 };
394 typedef std::map <Bstr, ComObjPtr<SharedFolder> > SharedFolderMap;
395 typedef std::map <Bstr, SharedFolderData> SharedFolderDataMap;
396
397private:
398
399 typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
400 typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
401
402 HRESULT addVMCaller(bool aQuiet = false, bool aAllowNullVM = false);
403 void releaseVMCaller();
404
405 HRESULT consoleInitReleaseLog(const ComPtr<IMachine> aMachine);
406
407 HRESULT powerUp(IProgress **aProgress, bool aPaused);
408 HRESULT powerDown(Progress *aProgress = NULL);
409
410 HRESULT callTapSetupApplication(bool isStatic, RTFILE tapFD, Bstr &tapDevice,
411 Bstr &tapSetupApplication);
412#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
413 HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
414 HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
415#endif
416 HRESULT powerDownHostInterfaces();
417
418 HRESULT setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
419 HRESULT setMachineStateLocally(MachineState_T aMachineState)
420 {
421 return setMachineState(aMachineState, false /* aUpdateServer */);
422 }
423
424 HRESULT findSharedFolder(CBSTR aName,
425 ComObjPtr<SharedFolder> &aSharedFolder,
426 bool aSetError = false);
427
428 HRESULT fetchSharedFolders(BOOL aGlobal);
429 bool findOtherSharedFolder(IN_BSTR aName,
430 SharedFolderDataMap::const_iterator &aIt);
431
432 HRESULT createSharedFolder(CBSTR aName, SharedFolderData aData);
433 HRESULT removeSharedFolder(CBSTR aName);
434
435 static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole);
436
437 static int configMediumAttachment(PCFGMNODE pCtlInst,
438 const char *pcszDevice,
439 unsigned uInstance,
440 StorageBus_T enmBus,
441 IoBackendType_T enmIoBackend,
442 IMediumAttachment *pMediumAtt,
443 MachineState_T aMachineState,
444 HRESULT *phrc, bool fAttachDetach,
445 bool fForceUnmount, PVM pVM,
446 DeviceType_T *paLedDevType);
447 static int configMedium(PCFGMNODE pLunL0, bool fPassthrough,
448 DeviceType_T enmType, IoBackendType_T enmIoBackend,
449 IMedium *pMedium, MachineState_T aMachineState, HRESULT *phrc);
450 static DECLCALLBACK(int) reconfigureMediumAttachment(PVM pVM,
451 const char *pcszDevice,
452 unsigned uInstance,
453 StorageBus_T enmBus,
454 IoBackendType_T enmIoBackend,
455 IMediumAttachment *aMediumAtt,
456 MachineState_T aMachineState,
457 HRESULT *phrc);
458 static DECLCALLBACK(int) changeRemovableMedium(Console *pThis,
459 const char *pcszDevice,
460 unsigned uInstance,
461 StorageBus_T enmBus,
462 IoBackendType_T enmIoBackend,
463 IMediumAttachment *aMediumAtt,
464 bool fForce);
465
466 int configNetwork(const char *pszDevice, unsigned uInstance, unsigned uLun,
467 INetworkAdapter *aNetworkAdapter, PCFGMNODE pCfg,
468 PCFGMNODE pLunL0, PCFGMNODE pInst, bool fAttachDetach);
469
470 static DECLCALLBACK(int) configGuestProperties(void *pvConsole);
471 static DECLCALLBACK(int) configGuestControl(void *pvConsole);
472 static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
473 VMSTATE aOldState, void *aUser);
474 static DECLCALLBACK(int) unplugCpu(Console *pThis, unsigned uCpu);
475 static DECLCALLBACK(int) plugCpu(Console *pThis, unsigned uCpu);
476 HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce);
477 HRESULT doCPURemove(ULONG aCpu);
478 HRESULT doCPUAdd(ULONG aCpu);
479
480#ifdef VBOX_DYNAMIC_NET_ATTACH
481 HRESULT doNetworkAdapterChange(const char *pszDevice, unsigned uInstance,
482 unsigned uLun, INetworkAdapter *aNetworkAdapter);
483 static DECLCALLBACK(int) changeNetworkAttachment(Console *pThis, const char *pszDevice,
484 unsigned uInstance, unsigned uLun,
485 INetworkAdapter *aNetworkAdapter);
486#endif /* VBOX_DYNAMIC_NET_ATTACH */
487
488#ifdef VBOX_WITH_USB
489 HRESULT attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs);
490 HRESULT detachUSBDevice(USBDeviceList::iterator &aIt);
491
492 static DECLCALLBACK(int) usbAttachCallback(Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid,
493 bool aRemote, const char *aAddress, ULONG aMaskedIfs);
494 static DECLCALLBACK(int) usbDetachCallback(Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
495#endif
496
497 static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
498
499 static DECLCALLBACK(int) stateProgressCallback(PVM pVM, unsigned uPercent, void *pvUser);
500
501 static DECLCALLBACK(void) setVMErrorCallback(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
502 const char *pszFormat, va_list args);
503
504 static DECLCALLBACK(void) setVMRuntimeErrorCallbackF(PVM pVM, void *pvUser, uint32_t fFatal,
505 const char *pszErrorId,
506 const char *pszFormat, ...);
507 static DECLCALLBACK(void) setVMRuntimeErrorCallback(PVM pVM, void *pvUser, uint32_t fFatal,
508 const char *pszErrorId,
509 const char *pszFormat, va_list va);
510
511 HRESULT captureUSBDevices(PVM pVM);
512 void detachAllUSBDevices(bool aDone);
513
514 static DECLCALLBACK(int) powerUpThread(RTTHREAD Thread, void *pvUser);
515 static DECLCALLBACK(int) saveStateThread(RTTHREAD Thread, void *pvUser);
516 static DECLCALLBACK(int) powerDownThread(RTTHREAD Thread, void *pvUser);
517
518 static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
519 static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
520 static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
521 static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
522
523 int mcAudioRefs;
524 volatile uint32_t mcVRDPClients;
525 uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
526
527 static const char *sSSMConsoleUnit;
528 static uint32_t sSSMConsoleVer;
529
530 HRESULT loadDataFromSavedState();
531 int loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version);
532
533 static DECLCALLBACK(void) saveStateFileExec(PSSMHANDLE pSSM, void *pvUser);
534 static DECLCALLBACK(int) loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
535
536#ifdef VBOX_WITH_GUEST_PROPS
537 static DECLCALLBACK(int) doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
538 HRESULT doEnumerateGuestProperties(CBSTR aPatterns,
539 ComSafeArrayOut(BSTR, aNames),
540 ComSafeArrayOut(BSTR, aValues),
541 ComSafeArrayOut(ULONG64, aTimestamps),
542 ComSafeArrayOut(BSTR, aFlags));
543
544 bool enabledGuestPropertiesVRDP(void);
545 void updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
546 void updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId);
547#endif
548
549 /** @name Teleporter support
550 * @{ */
551 static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
552 HRESULT teleporterSrc(TeleporterStateSrc *pState);
553 HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
554 HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
555 int teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, Progress *pProgress);
556 static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
557 /** @} */
558
559 bool mSavedStateDataLoaded : 1;
560
561 const ComPtr<IMachine> mMachine;
562 const ComPtr<IInternalMachineControl> mControl;
563
564 const ComPtr <IVRDPServer> mVRDPServer;
565
566 ConsoleVRDPServer * const mConsoleVRDPServer;
567
568 const ComObjPtr<Guest> mGuest;
569 const ComObjPtr<Keyboard> mKeyboard;
570 const ComObjPtr<Mouse> mMouse;
571 const ComObjPtr<Display> mDisplay;
572 const ComObjPtr<MachineDebugger> mDebugger;
573 const ComObjPtr<RemoteDisplayInfo> mRemoteDisplayInfo;
574
575 USBDeviceList mUSBDevices;
576 RemoteUSBDeviceList mRemoteUSBDevices;
577
578 SharedFolderMap mSharedFolders;
579 SharedFolderDataMap mMachineSharedFolders;
580 SharedFolderDataMap mGlobalSharedFolders;
581
582 /** The VM instance handle. */
583 PVM mpVM;
584 /** Holds the number of "readonly" mpVM callers (users) */
585 uint32_t mVMCallers;
586 /** Semaphore posted when the number of mpVM callers drops to zero */
587 RTSEMEVENT mVMZeroCallersSem;
588 /** true when Console has entered the mpVM destruction phase */
589 bool mVMDestroying : 1;
590 /** true when power down is initiated by vmstateChangeCallback (EMT) */
591 bool mVMPoweredOff : 1;
592 /** true when vmstateChangeCallback shouldn't initiate a power down. */
593 bool mVMIsAlreadyPoweringOff : 1;
594
595 /** The current network attachment type in the VM.
596 * This doesn't have to match the network attachment type
597 * maintained in the NetworkAdapter. This is needed to
598 * change the network attachment dynamically.
599 */
600 NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount];
601
602 VMMDev * const mVMMDev;
603 AudioSniffer * const mAudioSniffer;
604
605 enum
606 {
607 iLedFloppy = 0,
608 cLedFloppy = 1,
609 iLedIde = iLedFloppy + cLedFloppy,
610 cLedIde = 4,
611 iLedSata = iLedIde + cLedIde,
612 cLedSata = 30,
613 iLedScsi = iLedSata + cLedSata,
614 cLedScsi = 16,
615 iLedSas = iLedScsi + cLedScsi,
616 cLedSas = 8,
617 cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi + cLedSas,
618 };
619 DeviceType_T maStorageDevType[cLedStorage];
620 PPDMLED mapStorageLeds[cLedStorage];
621 PPDMLED mapNetworkLeds[SchemaDefs::NetworkAdapterCount];
622 PPDMLED mapSharedFolderLed;
623 PPDMLED mapUSBLed[2];
624#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
625 Utf8Str maTAPDeviceName[8];
626 RTFILE maTapFD[8];
627#endif
628
629 bool mVMStateChangeCallbackDisabled;
630
631 /** Local machine state value. */
632 MachineState_T mMachineState;
633
634 /** Pointer to the progress object of a live cancelable task.
635 *
636 * This is currently only used by Console::Teleport(), but is intended to later
637 * be used by the live snapshot code path as well. Actions like
638 * Console::PowerDown, which automatically cancels out the running snapshot /
639 * teleportion operation, will cancel the teleportation / live snapshot
640 * operation before starting. */
641 ComObjPtr<Progress> mptrCancelableProgress;
642
643 typedef std::list <ComPtr<IConsoleCallback> > CallbackList;
644 CallbackList mCallbacks;
645
646 struct
647 {
648 /** OnMousePointerShapeChange() cache */
649 struct
650 {
651 bool valid;
652 bool visible;
653 bool alpha;
654 uint32_t xHot;
655 uint32_t yHot;
656 uint32_t width;
657 uint32_t height;
658 BYTE *shape;
659 size_t shapeSize;
660 }
661 mpsc;
662
663 /** OnMouseCapabilityChange() cache */
664 struct
665 {
666 bool valid;
667 BOOL supportsAbsolute;
668 BOOL supportsRelative;
669 BOOL needsHostCursor;
670 }
671 mcc;
672
673 /** OnKeyboardLedsChange() cache */
674 struct
675 {
676 bool valid;
677 bool numLock;
678 bool capsLock;
679 bool scrollLock;
680 }
681 klc;
682 }
683 mCallbackData;
684
685 friend struct VMTask;
686};
687
688#endif // !____H_CONSOLEIMPL
689/* 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