VirtualBox

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

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

ConsoleImpl: Implemented VBOX_E_DONT_CALL_AGAIN for IConsoleCallback.

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