VirtualBox

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

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

FreeBSD: Use the old TAP code when bridging to a TAP device and set the SharedMaxOnWire flag for a WLAN interface (contributed by Juergen Lock, thanks)

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