VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

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