VirtualBox

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

最後變更 在這個檔案從24612是 24579,由 vboxsync 提交於 15 年 前

Main/Console: fix taking snapshots of a VM with several hard disk attachments, a
nd deal correctly with DVD/floppy drives. Plus a bit of cleanup/renaming.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 24.9 KB
 
1/* $Id: ConsoleImpl.h 24579 2009-11-11 13:50:27Z 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.alldomusa.eu.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, 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 const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType);
226 static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);
227
228 // for VirtualBoxSupportErrorInfoImpl
229 static const wchar_t *getComponentName() { return L"Console"; }
230
231private:
232
233 /**
234 * Base template for AutoVMCaller and SaveVMPtr. Template arguments
235 * have the same meaning as arguments of Console::addVMCaller().
236 */
237 template <bool taQuiet = false, bool taAllowNullVM = false>
238 class AutoVMCallerBase
239 {
240 public:
241 AutoVMCallerBase (Console *aThat) : mThat (aThat), mRC (S_OK)
242 {
243 Assert (aThat);
244 mRC = aThat->addVMCaller (taQuiet, taAllowNullVM);
245 }
246 ~AutoVMCallerBase()
247 {
248 if (SUCCEEDED (mRC))
249 mThat->releaseVMCaller();
250 }
251 /** Decreases the number of callers before the instance is destroyed. */
252 void release()
253 {
254 AssertReturnVoid (SUCCEEDED (mRC));
255 mThat->releaseVMCaller();
256 mRC = E_FAIL;
257 }
258 /** Restores the number of callers after by #release(). #rc() must be
259 * rechecked to ensure the operation succeeded. */
260 void add()
261 {
262 AssertReturnVoid (!SUCCEEDED (mRC));
263 mRC = mThat->addVMCaller (taQuiet, taAllowNullVM);
264 }
265 /** Returns the result of Console::addVMCaller() */
266 HRESULT rc() const { return mRC; }
267 /** Shortcut to SUCCEEDED (rc()) */
268 bool isOk() const { return SUCCEEDED (mRC); }
269 protected:
270 Console *mThat;
271 HRESULT mRC;
272 private:
273 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (AutoVMCallerBase)
274 DECLARE_CLS_NEW_DELETE_NOOP (AutoVMCallerBase)
275 };
276
277 /**
278 * Helper class that protects sections of code using the mpVM pointer by
279 * automatically calling addVMCaller() on construction and
280 * releaseVMCaller() on destruction. Intended for Console methods dealing
281 * with mpVM. The usage pattern is:
282 * <code>
283 * AutoVMCaller autoVMCaller (this);
284 * CheckComRCReturnRC (autoVMCaller.rc());
285 * ...
286 * VMR3ReqCall (mpVM, ...
287 * </code>
288 *
289 * @note Temporarily locks the argument for writing.
290 *
291 * @sa SafeVMPtr, SafeVMPtrQuiet
292 */
293 typedef AutoVMCallerBase <false, false> AutoVMCaller;
294
295 /**
296 * Same as AutoVMCaller but doesn't set extended error info on failure.
297 *
298 * @note Temporarily locks the argument for writing.
299 */
300 typedef AutoVMCallerBase <true, false> AutoVMCallerQuiet;
301
302 /**
303 * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
304 * instead of assertion).
305 *
306 * @note Temporarily locks the argument for writing.
307 */
308 typedef AutoVMCallerBase <false, true> AutoVMCallerWeak;
309
310 /**
311 * Same as AutoVMCaller but doesn't set extended error info on failure
312 * and allows a null VM pointer (to trigger an error instead of
313 * assertion).
314 *
315 * @note Temporarily locks the argument for writing.
316 */
317 typedef AutoVMCallerBase <true, true> AutoVMCallerQuietWeak;
318
319 /**
320 * Base template for SaveVMPtr and SaveVMPtrQuiet.
321 */
322 template <bool taQuiet = false>
323 class SafeVMPtrBase : public AutoVMCallerBase <taQuiet, true>
324 {
325 typedef AutoVMCallerBase <taQuiet, true> Base;
326 public:
327 SafeVMPtrBase (Console *aThat) : Base (aThat), mpVM (NULL)
328 {
329 if (SUCCEEDED (Base::mRC))
330 mpVM = aThat->mpVM;
331 }
332 /** Smart SaveVMPtr to PVM cast operator */
333 operator PVM() const { return mpVM; }
334 /** Direct PVM access for printf()-like functions */
335 PVM raw() const { return mpVM; }
336 private:
337 PVM mpVM;
338 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (SafeVMPtrBase)
339 DECLARE_CLS_NEW_DELETE_NOOP (SafeVMPtrBase)
340 };
341
342public:
343
344 /**
345 * Helper class that safely manages the Console::mpVM pointer
346 * by calling addVMCaller() on construction and releaseVMCaller() on
347 * destruction. Intended for Console children. The usage pattern is:
348 * <code>
349 * Console::SaveVMPtr pVM (mParent);
350 * CheckComRCReturnRC (pVM.rc());
351 * ...
352 * VMR3ReqCall (pVM, ...
353 * ...
354 * printf ("%p\n", pVM.raw());
355 * </code>
356 *
357 * @note Temporarily locks the argument for writing.
358 *
359 * @sa SafeVMPtrQuiet, AutoVMCaller
360 */
361 typedef SafeVMPtrBase <false> SafeVMPtr;
362
363 /**
364 * A deviation of SaveVMPtr that doesn't set the error info on failure.
365 * Intended for pieces of code that don't need to return the VM access
366 * failure to the caller. The usage pattern is:
367 * <code>
368 * Console::SaveVMPtrQuiet pVM (mParent);
369 * if (pVM.rc())
370 * VMR3ReqCall (pVM, ...
371 * return S_OK;
372 * </code>
373 *
374 * @note Temporarily locks the argument for writing.
375 *
376 * @sa SafeVMPtr, AutoVMCaller
377 */
378 typedef SafeVMPtrBase <true> SafeVMPtrQuiet;
379
380 class SharedFolderData
381 {
382 public:
383 SharedFolderData() {}
384 SharedFolderData(Bstr aHostPath, BOOL aWritable)
385 : mHostPath (aHostPath)
386 , mWritable (aWritable) {}
387 SharedFolderData(const SharedFolderData& aThat)
388 : mHostPath (aThat.mHostPath)
389 , mWritable (aThat.mWritable) {}
390 Bstr mHostPath;
391 BOOL mWritable;
392 };
393 typedef std::map <Bstr, ComObjPtr<SharedFolder> > SharedFolderMap;
394 typedef std::map <Bstr, SharedFolderData> SharedFolderDataMap;
395
396private:
397
398 typedef std::list <ComObjPtr<OUSBDevice> > USBDeviceList;
399 typedef std::list <ComObjPtr<RemoteUSBDevice> > RemoteUSBDeviceList;
400
401 HRESULT addVMCaller (bool aQuiet = false, bool aAllowNullVM = false);
402 void releaseVMCaller();
403
404 HRESULT consoleInitReleaseLog (const ComPtr<IMachine> aMachine);
405
406 HRESULT powerUp (IProgress **aProgress, bool aPaused);
407 HRESULT powerDown (Progress *aProgress = NULL);
408
409 HRESULT callTapSetupApplication(bool isStatic, RTFILE tapFD, Bstr &tapDevice,
410 Bstr &tapSetupApplication);
411#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
412 HRESULT attachToTapInterface(INetworkAdapter *networkAdapter);
413 HRESULT detachFromTapInterface(INetworkAdapter *networkAdapter);
414#endif
415 HRESULT powerDownHostInterfaces();
416
417 HRESULT setMachineState(MachineState_T aMachineState, bool aUpdateServer = true);
418 HRESULT setMachineStateLocally(MachineState_T aMachineState)
419 {
420 return setMachineState (aMachineState, false /* aUpdateServer */);
421 }
422
423 HRESULT findSharedFolder (CBSTR aName,
424 ComObjPtr<SharedFolder> &aSharedFolder,
425 bool aSetError = false);
426
427 HRESULT fetchSharedFolders (BOOL aGlobal);
428 bool findOtherSharedFolder (IN_BSTR aName,
429 SharedFolderDataMap::const_iterator &aIt);
430
431 HRESULT createSharedFolder (CBSTR aName, SharedFolderData aData);
432 HRESULT removeSharedFolder (CBSTR aName);
433
434 static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole);
435 static DECLCALLBACK(int) configGuestProperties(void *pvConsole);
436 static int configNetwork(Console *pThis, const char *pszDevice,
437 unsigned uInstance, unsigned uLun,
438 INetworkAdapter *aNetworkAdapter,
439 PCFGMNODE pCfg, PCFGMNODE pLunL0,
440 PCFGMNODE pInst, bool fAttachDetach);
441 static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
442 VMSTATE aOldState, void *aUser);
443 static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice,
444 unsigned uInstance, unsigned uLun,
445 bool fHostDrive, const char *pszPath,
446 const char *pszFormat, bool fPassthrough,
447 bool fForce);
448 HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce);
449
450#ifdef VBOX_DYNAMIC_NET_ATTACH
451 HRESULT doNetworkAdapterChange (const char *pszDevice, unsigned uInstance,
452 unsigned uLun, INetworkAdapter *aNetworkAdapter);
453 static DECLCALLBACK(int) changeNetworkAttachment (Console *pThis, const char *pszDevice,
454 unsigned uInstance, unsigned uLun,
455 INetworkAdapter *aNetworkAdapter);
456#endif /* VBOX_DYNAMIC_NET_ATTACH */
457
458#ifdef VBOX_WITH_USB
459 HRESULT attachUSBDevice (IUSBDevice *aHostDevice, ULONG aMaskedIfs);
460 HRESULT detachUSBDevice (USBDeviceList::iterator &aIt);
461
462 static DECLCALLBACK(int) usbAttachCallback (Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid,
463 bool aRemote, const char *aAddress, ULONG aMaskedIfs);
464 static DECLCALLBACK(int) usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
465#endif
466
467 static DECLCALLBACK(int) fntTakeSnapshotWorker(RTTHREAD Thread, void *pvUser);
468
469 static DECLCALLBACK(int) stateProgressCallback(PVM pVM, unsigned uPercent, void *pvUser);
470
471 static DECLCALLBACK(void) setVMErrorCallback(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
472 const char *pszFormat, va_list args);
473
474 static DECLCALLBACK(void) setVMRuntimeErrorCallbackF (PVM pVM, void *pvUser, uint32_t fFatal,
475 const char *pszErrorId,
476 const char *pszFormat, ...);
477 static DECLCALLBACK(void) setVMRuntimeErrorCallback (PVM pVM, void *pvUser, uint32_t fFatal,
478 const char *pszErrorId,
479 const char *pszFormat, va_list va);
480
481 HRESULT captureUSBDevices (PVM pVM);
482 void detachAllUSBDevices (bool aDone);
483
484 static DECLCALLBACK (int) powerUpThread (RTTHREAD Thread, void *pvUser);
485 static DECLCALLBACK (int) saveStateThread (RTTHREAD Thread, void *pvUser);
486 static DECLCALLBACK (int) powerDownThread (RTTHREAD Thread, void *pvUser);
487
488 static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
489 static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
490 static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
491 static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle, uint32_t fFlags);
492
493 int mcAudioRefs;
494 volatile uint32_t mcVRDPClients;
495 uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
496
497 static const char *sSSMConsoleUnit;
498 static uint32_t sSSMConsoleVer;
499
500 HRESULT loadDataFromSavedState();
501 int loadStateFileExecInternal (PSSMHANDLE pSSM, uint32_t u32Version);
502
503 static DECLCALLBACK(void) saveStateFileExec (PSSMHANDLE pSSM, void *pvUser);
504 static DECLCALLBACK(int) loadStateFileExec (PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
505
506#ifdef VBOX_WITH_GUEST_PROPS
507 static DECLCALLBACK(int) doGuestPropNotification (void *pvExtension, uint32_t,
508 void *pvParms, uint32_t cbParms);
509 HRESULT doEnumerateGuestProperties (CBSTR aPatterns,
510 ComSafeArrayOut(BSTR, aNames),
511 ComSafeArrayOut(BSTR, aValues),
512 ComSafeArrayOut(ULONG64, aTimestamps),
513 ComSafeArrayOut(BSTR, aFlags));
514
515 bool enabledGuestPropertiesVRDP (void);
516 void updateGuestPropertiesVRDPLogon (uint32_t u32ClientId, const char *pszUser, const char *pszDomain);
517 void updateGuestPropertiesVRDPDisconnect (uint32_t u32ClientId);
518#endif
519
520 /** @name Teleporter support
521 * @{ */
522 static DECLCALLBACK(int) teleporterSrcThreadWrapper(RTTHREAD hThread, void *pvUser);
523 HRESULT teleporterSrc(TeleporterStateSrc *pState);
524 HRESULT teleporterSrcReadACK(TeleporterStateSrc *pState, const char *pszWhich, const char *pszNAckMsg = NULL);
525 HRESULT teleporterSrcSubmitCommand(TeleporterStateSrc *pState, const char *pszCommand, bool fWaitForAck = true);
526 int teleporterTrg(PVM pVM, IMachine *pMachine, bool fStartPaused, Progress *pProgress);
527 static DECLCALLBACK(int) teleporterTrgServeConnection(RTSOCKET Sock, void *pvUser);
528 /** @} */
529
530 bool mSavedStateDataLoaded : 1;
531
532 const ComPtr<IMachine> mMachine;
533 const ComPtr<IInternalMachineControl> mControl;
534
535 const ComPtr <IVRDPServer> mVRDPServer;
536
537 ConsoleVRDPServer * const mConsoleVRDPServer;
538
539 const ComObjPtr<Guest> mGuest;
540 const ComObjPtr<Keyboard> mKeyboard;
541 const ComObjPtr<Mouse> mMouse;
542 const ComObjPtr<Display> mDisplay;
543 const ComObjPtr<MachineDebugger> mDebugger;
544 const ComObjPtr<RemoteDisplayInfo> mRemoteDisplayInfo;
545
546 USBDeviceList mUSBDevices;
547 RemoteUSBDeviceList mRemoteUSBDevices;
548
549 SharedFolderMap mSharedFolders;
550 SharedFolderDataMap mMachineSharedFolders;
551 SharedFolderDataMap mGlobalSharedFolders;
552
553 /** The VM instance handle. */
554 PVM mpVM;
555 /** Holds the number of "readonly" mpVM callers (users) */
556 uint32_t mVMCallers;
557 /** Semaphore posted when the number of mpVM callers drops to zero */
558 RTSEMEVENT mVMZeroCallersSem;
559 /** true when Console has entered the mpVM destruction phase */
560 bool mVMDestroying : 1;
561 /** true when power down is initiated by vmstateChangeCallback (EMT) */
562 bool mVMPoweredOff : 1;
563
564 /** The current network attachment type in the VM.
565 * This doesn't have to match the network attachment type
566 * maintained in the NetworkAdapter. This is needed to
567 * change the network attachment dynamically.
568 */
569 NetworkAttachmentType_T meAttachmentType[SchemaDefs::NetworkAdapterCount];
570
571 VMMDev * const mVMMDev;
572 AudioSniffer * const mAudioSniffer;
573
574 PPDMLED mapFDLeds[2];
575 PPDMLED mapIDELeds[4];
576 PPDMLED mapSATALeds[30];
577 PPDMLED mapSCSILeds[16];
578 PPDMLED mapNetworkLeds[SchemaDefs::NetworkAdapterCount];
579 PPDMLED mapSharedFolderLed;
580 PPDMLED mapUSBLed[2];
581#if !defined(VBOX_WITH_NETFLT) && (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
582 Utf8Str maTAPDeviceName[8];
583 RTFILE maTapFD[8];
584#endif
585
586 bool mVMStateChangeCallbackDisabled;
587
588 /** Local machine state value. */
589 MachineState_T mMachineState;
590
591 /** Pointer to the progress object of a live cancelable task.
592 *
593 * This is currently only used by Console::Teleport(), but is intended to later
594 * be used by the live snapshot code path as well. Actions like
595 * Console::PowerDown, which automatically cancels out the running snapshot /
596 * teleportion operation, will cancel the teleportation / live snapshot
597 * operation before starting. */
598 ComObjPtr<Progress> mptrCancelableProgress;
599
600 typedef std::list <ComPtr<IConsoleCallback> > CallbackList;
601 CallbackList mCallbacks;
602
603 struct
604 {
605 /** OnMousePointerShapeChange() cache */
606 struct
607 {
608 bool valid;
609 bool visible;
610 bool alpha;
611 uint32_t xHot;
612 uint32_t yHot;
613 uint32_t width;
614 uint32_t height;
615 BYTE *shape;
616 size_t shapeSize;
617 }
618 mpsc;
619
620 /** OnMouseCapabilityChange() cache */
621 struct
622 {
623 bool valid;
624 BOOL supportsAbsolute;
625 BOOL needsHostCursor;
626 }
627 mcc;
628
629 /** OnKeyboardLedsChange() cache */
630 struct
631 {
632 bool valid;
633 bool numLock;
634 bool capsLock;
635 bool scrollLock;
636 }
637 klc;
638 }
639 mCallbackData;
640
641 friend struct VMTask;
642};
643
644#endif // !____H_CONSOLEIMPL
645/* vi: set tabstop=4 shiftwidth=4 expandtab: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette