VirtualBox

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

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

Guest Control: Update (Main, registering host service, bugfixes).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 KB
Line 
1/* $Id: ConsoleImpl.h 27788 2010-03-29 12:42:22Z vboxsync $ */
2/** @file
3 * VBox Console COM Class definition
4 */
5
6/*
7 * Copyright (C) 2006-2009 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 static DECLCALLBACK(int) configGuestProperties(void *pvConsole);
437 static DECLCALLBACK(int) configGuestControl(void *pvConsole);
438 static int configNetwork(Console *pThis, const char *pszDevice,
439 unsigned uInstance, unsigned uLun,
440 INetworkAdapter *aNetworkAdapter,
441 PCFGMNODE pCfg, PCFGMNODE pLunL0,
442 PCFGMNODE pInst, bool fAttachDetach);
443 static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
444 VMSTATE aOldState, void *aUser);
445 static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice,
446 unsigned uInstance, unsigned uLun,
447 bool fHostDrive, const char *pszPath,
448 const char *pszFormat, bool fPassthrough,
449 bool fForce);
450 static DECLCALLBACK(int) unplugCpu (Console *pThis, unsigned uCpu);
451 static DECLCALLBACK(int) plugCpu (Console *pThis, unsigned uCpu);
452 HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce);
453 HRESULT doCPURemove(ULONG aCpu);
454 HRESULT doCPUAdd(ULONG aCpu);
455
456#ifdef VBOX_DYNAMIC_NET_ATTACH
457 HRESULT doNetworkAdapterChange (const char *pszDevice, unsigned uInstance,
458 unsigned uLun, INetworkAdapter *aNetworkAdapter);
459 static DECLCALLBACK(int) changeNetworkAttachment (Console *pThis, const char *pszDevice,
460 unsigned uInstance, unsigned uLun,
461 INetworkAdapter *aNetworkAdapter);
462#endif /* VBOX_DYNAMIC_NET_ATTACH */
463
464#ifdef VBOX_WITH_USB
465 HRESULT attachUSBDevice (IUSBDevice *aHostDevice, ULONG aMaskedIfs);
466 HRESULT detachUSBDevice (USBDeviceList::iterator &aIt);
467
468 static DECLCALLBACK(int) usbAttachCallback (Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid,
469 bool aRemote, const char *aAddress, ULONG aMaskedIfs);
470 static DECLCALLBACK(int) usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
471#endif
472
473 static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
474
475 static DECLCALLBACK(int) stateProgressCallback(PVM pVM, unsigned uPercent, void *pvUser);
476
477 static DECLCALLBACK(void) setVMErrorCallback(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
478 const char *pszFormat, va_list args);
479
480 static DECLCALLBACK(void) setVMRuntimeErrorCallbackF (PVM pVM, void *pvUser, uint32_t fFatal,
481 const char *pszErrorId,
482 const char *pszFormat, ...);
483 static DECLCALLBACK(void) setVMRuntimeErrorCallback (PVM pVM, void *pvUser, uint32_t fFatal,
484 const char *pszErrorId,
485 const char *pszFormat, va_list va);
486
487 HRESULT captureUSBDevices (PVM pVM);
488 void detachAllUSBDevices (bool aDone);
489
490 static DECLCALLBACK (int) powerUpThread (RTTHREAD Thread, void *pvUser);
491 static DECLCALLBACK (int) saveStateThread (RTTHREAD Thread, void *pvUser);
492 static DECLCALLBACK (int) powerDownThread (RTTHREAD Thread, void *pvUser);
493
494 static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, const char *pszIID);
495 static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
496 static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
497 static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
498
499 int mcAudioRefs;
500 volatile uint32_t mcVRDPClients;
501 uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
502
503 static const char *sSSMConsoleUnit;
504 static uint32_t sSSMConsoleVer;
505
506 HRESULT loadDataFromSavedState();
507 int loadStateFileExecInternal (PSSMHANDLE pSSM, uint32_t u32Version);
508
509 static DECLCALLBACK(void) saveStateFileExec (PSSMHANDLE pSSM, void *pvUser);
510 static DECLCALLBACK(int) loadStateFileExec (PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
511
512#ifdef VBOX_WITH_GUEST_PROPS
513 static DECLCALLBACK(int) doGuestPropNotification(void *pvExtension, uint32_t, void *pvParms, uint32_t cbParms);
514 HRESULT doEnumerateGuestProperties(CBSTR aPatterns,
515 ComSafeArrayOut(BSTR, aNames),
516 ComSafeArrayOut(BSTR, aValues),
517 ComSafeArrayOut(ULONG64, aTimestamps),
518 ComSafeArrayOut(BSTR, aFlags));
519
520 bool enabledGuestPropertiesVRDP (void);
521 void updateGuestPropertiesVRDPLogon (uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
522 void updateGuestPropertiesVRDPDisconnect (uint32_t u32ClientId);
523#endif
524
525 /** @name Teleporter support
526 * @{ */
527 static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
528 HRESULT teleporterSrc(TeleporterStateSrc *pState);
529 HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
530 HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
531 int teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, Progress *pProgress);
532 static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
533 /** @} */
534
535 bool mSavedStateDataLoaded : 1;
536
537 const ComPtr<IMachine> mMachine;
538 const ComPtr<IInternalMachineControl> mControl;
539
540 const ComPtr <IVRDPServer> mVRDPServer;
541
542 ConsoleVRDPServer * const mConsoleVRDPServer;
543
544 const ComObjPtr<Guest> mGuest;
545 const ComObjPtr<Keyboard> mKeyboard;
546 const ComObjPtr<Mouse> mMouse;
547 const ComObjPtr<Display> mDisplay;
548 const ComObjPtr<MachineDebugger> mDebugger;
549 const ComObjPtr<RemoteDisplayInfo> mRemoteDisplayInfo;
550
551 USBDeviceList mUSBDevices;
552 RemoteUSBDeviceList mRemoteUSBDevices;
553
554 SharedFolderMap mSharedFolders;
555 SharedFolderDataMap mMachineSharedFolders;
556 SharedFolderDataMap mGlobalSharedFolders;
557
558 /** The VM instance handle. */
559 PVM mpVM;
560 /** Holds the number of "readonly" mpVM callers (users) */
561 uint32_t mVMCallers;
562 /** Semaphore posted when the number of mpVM callers drops to zero */
563 RTSEMEVENT mVMZeroCallersSem;
564 /** true when Console has entered the mpVM destruction phase */
565 bool mVMDestroying : 1;
566 /** true when power down is initiated by vmstateChangeCallback (EMT) */
567 bool mVMPoweredOff : 1;
568 /** true when vmstateChangeCallback shouldn't initiate a power down. */
569 bool mVMIsAlreadyPoweringOff : 1;
570
571 /** The current network attachment type in the VM.
572 * This doesn't have to match the network attachment type
573 * maintained in the NetworkAdapter. This is needed to
574 * change the network attachment dynamically.
575 */
576 NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount];
577
578 VMMDev * const mVMMDev;
579 AudioSniffer * const mAudioSniffer;
580
581 enum
582 {
583 iLedFloppy = 0,
584 cLedFloppy = 1,
585 iLedIde = iLedFloppy + cLedFloppy,
586 cLedIde = 4,
587 iLedSata = iLedIde + cLedIde,
588 cLedSata = 30,
589 iLedScsi = iLedSata + cLedSata,
590 cLedScsi = 16,
591 cLedStorage = cLedFloppy + cLedIde + cLedSata + cLedScsi,
592 };
593 DeviceType_T maStorageDevType[cLedStorage];
594 PPDMLED mapStorageLeds[cLedStorage];
595 PPDMLED mapNetworkLeds[SchemaDefs::NetworkAdapterCount];
596 PPDMLED mapSharedFolderLed;
597 PPDMLED mapUSBLed[2];
598#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
599 Utf8Str maTAPDeviceName[8];
600 RTFILE maTapFD[8];
601#endif
602
603 bool mVMStateChangeCallbackDisabled;
604
605 /** Local machine state value. */
606 MachineState_T mMachineState;
607
608 /** Pointer to the progress object of a live cancelable task.
609 *
610 * This is currently only used by Console::Teleport(), but is intended to later
611 * be used by the live snapshot code path as well. Actions like
612 * Console::PowerDown, which automatically cancels out the running snapshot /
613 * teleportion operation, will cancel the teleportation / live snapshot
614 * operation before starting. */
615 ComObjPtr<Progress> mptrCancelableProgress;
616
617 typedef std::list <ComPtr<IConsoleCallback> > CallbackList;
618 CallbackList mCallbacks;
619
620 struct
621 {
622 /** OnMousePointerShapeChange() cache */
623 struct
624 {
625 bool valid;
626 bool visible;
627 bool alpha;
628 uint32_t xHot;
629 uint32_t yHot;
630 uint32_t width;
631 uint32_t height;
632 BYTE *shape;
633 size_t shapeSize;
634 }
635 mpsc;
636
637 /** OnMouseCapabilityChange() cache */
638 struct
639 {
640 bool valid;
641 BOOL supportsAbsolute;
642 BOOL supportsRelative;
643 BOOL needsHostCursor;
644 }
645 mcc;
646
647 /** OnKeyboardLedsChange() cache */
648 struct
649 {
650 bool valid;
651 bool numLock;
652 bool capsLock;
653 bool scrollLock;
654 }
655 klc;
656 }
657 mCallbackData;
658
659 friend struct VMTask;
660};
661
662#endif // !____H_CONSOLEIMPL
663/* 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