1 | /* $Id: ConsoleImpl.h 18348 2009-03-26 19:35:20Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VBox Console COM Class definition
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 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 |
|
---|
30 | class Guest;
|
---|
31 | class Keyboard;
|
---|
32 | class Mouse;
|
---|
33 | class Display;
|
---|
34 | class MachineDebugger;
|
---|
35 | class OUSBDevice;
|
---|
36 | class RemoteUSBDevice;
|
---|
37 | class SharedFolder;
|
---|
38 | class RemoteDisplayInfo;
|
---|
39 | class AudioSniffer;
|
---|
40 | class ConsoleVRDPServer;
|
---|
41 | class VMMDev;
|
---|
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 |
|
---|
49 | struct VUSBIRHCONFIG;
|
---|
50 | typedef 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 */
|
---|
78 | class ATL_NO_VTABLE Console :
|
---|
79 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
80 | public VirtualBoxSupportErrorInfoImpl <Console, IConsole>,
|
---|
81 | public VirtualBoxSupportTranslation <Console>,
|
---|
82 | public IConsole
|
---|
83 | {
|
---|
84 | Q_OBJECT
|
---|
85 |
|
---|
86 | public:
|
---|
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 | END_COM_MAP()
|
---|
96 |
|
---|
97 | NS_DECL_ISUPPORTS
|
---|
98 |
|
---|
99 | Console();
|
---|
100 | ~Console();
|
---|
101 |
|
---|
102 | HRESULT FinalConstruct();
|
---|
103 | void FinalRelease();
|
---|
104 |
|
---|
105 | // public initializers/uninitializers for internal purposes only
|
---|
106 | HRESULT init (IMachine *aMachine, IInternalMachineControl *aControl);
|
---|
107 | void uninit();
|
---|
108 |
|
---|
109 | // IConsole properties
|
---|
110 | STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
|
---|
111 | STDMETHOD(COMGETTER(State)) (MachineState_T *aMachineState);
|
---|
112 | STDMETHOD(COMGETTER(Guest)) (IGuest **aGuest);
|
---|
113 | STDMETHOD(COMGETTER(Keyboard)) (IKeyboard **aKeyboard);
|
---|
114 | STDMETHOD(COMGETTER(Mouse)) (IMouse **aMouse);
|
---|
115 | STDMETHOD(COMGETTER(Display)) (IDisplay **aDisplay);
|
---|
116 | STDMETHOD(COMGETTER(Debugger)) (IMachineDebugger **aDebugger);
|
---|
117 | STDMETHOD(COMGETTER(USBDevices)) (ComSafeArrayOut (IUSBDevice *, aUSBDevices));
|
---|
118 | STDMETHOD(COMGETTER(RemoteUSBDevices)) (ComSafeArrayOut (IHostUSBDevice *, aRemoteUSBDevices));
|
---|
119 | STDMETHOD(COMGETTER(RemoteDisplayInfo)) (IRemoteDisplayInfo **aRemoteDisplayInfo);
|
---|
120 | STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut (ISharedFolder *, aSharedFolders));
|
---|
121 |
|
---|
122 | // IConsole methods
|
---|
123 | STDMETHOD(PowerUp) (IProgress **aProgress);
|
---|
124 | STDMETHOD(PowerUpPaused) (IProgress **aProgress);
|
---|
125 | STDMETHOD(PowerDown)();
|
---|
126 | STDMETHOD(PowerDownAsync) (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(DiscardSavedState)();
|
---|
137 | STDMETHOD(GetDeviceActivity) (DeviceType_T aDeviceType,
|
---|
138 | DeviceActivity_T *aDeviceActivity);
|
---|
139 | STDMETHOD(AttachUSBDevice) (IN_GUID aId);
|
---|
140 | STDMETHOD(DetachUSBDevice) (IN_GUID aId, IUSBDevice **aDevice);
|
---|
141 | STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IUSBDevice **aDevice);
|
---|
142 | STDMETHOD(FindUSBDeviceById) (IN_GUID 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(DiscardSnapshot) (IN_GUID aId, IProgress **aProgress);
|
---|
148 | STDMETHOD(DiscardCurrentState) (IProgress **aProgress);
|
---|
149 | STDMETHOD(DiscardCurrentSnapshotAndState) (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 onDVDDriveChange();
|
---|
177 | HRESULT onFloppyDriveChange();
|
---|
178 | HRESULT onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter);
|
---|
179 | HRESULT onSerialPortChange (ISerialPort *aSerialPort);
|
---|
180 | HRESULT onParallelPortChange (IParallelPort *aParallelPort);
|
---|
181 | HRESULT onStorageControllerChange ();
|
---|
182 | HRESULT onVRDPServerChange();
|
---|
183 | HRESULT onUSBControllerChange();
|
---|
184 | HRESULT onSharedFolderChange (BOOL aGlobal);
|
---|
185 | HRESULT onUSBDeviceAttach (IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs);
|
---|
186 | HRESULT onUSBDeviceDetach (IN_GUID aId, IVirtualBoxErrorInfo *aError);
|
---|
187 | HRESULT getGuestProperty (IN_BSTR aKey, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
|
---|
188 | HRESULT setGuestProperty (IN_BSTR aKey, IN_BSTR aValue, IN_BSTR aFlags);
|
---|
189 | HRESULT enumerateGuestProperties (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
|
---|
190 | VMMDev *getVMMDev() { return mVMMDev; }
|
---|
191 | AudioSniffer *getAudioSniffer () { return mAudioSniffer; }
|
---|
192 |
|
---|
193 | int VRDPClientLogon (uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain);
|
---|
194 | void VRDPClientConnect (uint32_t u32ClientId);
|
---|
195 | void VRDPClientDisconnect (uint32_t u32ClientId, uint32_t fu32Intercepted);
|
---|
196 | void VRDPInterceptAudio (uint32_t u32ClientId);
|
---|
197 | void VRDPInterceptUSB (uint32_t u32ClientId, void **ppvIntercept);
|
---|
198 | void VRDPInterceptClipboard (uint32_t u32ClientId);
|
---|
199 |
|
---|
200 | void processRemoteUSBDevices (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList);
|
---|
201 |
|
---|
202 | // callback callers (partly; for some events console callbacks are notified
|
---|
203 | // directly from IInternalSessionControl event handlers declared above)
|
---|
204 | void onMousePointerShapeChange(bool fVisible, bool fAlpha,
|
---|
205 | uint32_t xHot, uint32_t yHot,
|
---|
206 | uint32_t width, uint32_t height,
|
---|
207 | void *pShape);
|
---|
208 | void onMouseCapabilityChange (BOOL supportsAbsolute, BOOL needsHostCursor);
|
---|
209 | void onStateChange (MachineState_T aMachineState);
|
---|
210 | void onAdditionsStateChange();
|
---|
211 | void onAdditionsOutdated();
|
---|
212 | void onKeyboardLedsChange (bool fNumLock, bool fCapsLock, bool fScrollLock);
|
---|
213 | void onUSBDeviceStateChange (IUSBDevice *aDevice, bool aAttached,
|
---|
214 | IVirtualBoxErrorInfo *aError);
|
---|
215 | void onRuntimeError (BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage);
|
---|
216 | HRESULT onShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId);
|
---|
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 | // for VirtualBoxSupportErrorInfoImpl
|
---|
226 | static const wchar_t *getComponentName() { return L"Console"; }
|
---|
227 |
|
---|
228 | private:
|
---|
229 |
|
---|
230 | /**
|
---|
231 | * Base template for AutoVMCaller and SaveVMPtr. Template arguments
|
---|
232 | * have the same meaning as arguments of Console::addVMCaller().
|
---|
233 | */
|
---|
234 | template <bool taQuiet = false, bool taAllowNullVM = false>
|
---|
235 | class AutoVMCallerBase
|
---|
236 | {
|
---|
237 | public:
|
---|
238 | AutoVMCallerBase (Console *aThat) : mThat (aThat), mRC (S_OK)
|
---|
239 | {
|
---|
240 | Assert (aThat);
|
---|
241 | mRC = aThat->addVMCaller (taQuiet, taAllowNullVM);
|
---|
242 | }
|
---|
243 | ~AutoVMCallerBase()
|
---|
244 | {
|
---|
245 | if (SUCCEEDED (mRC))
|
---|
246 | mThat->releaseVMCaller();
|
---|
247 | }
|
---|
248 | /** Decreases the number of callers before the instance is destroyed. */
|
---|
249 | void release()
|
---|
250 | {
|
---|
251 | AssertReturnVoid (SUCCEEDED (mRC));
|
---|
252 | mThat->releaseVMCaller();
|
---|
253 | mRC = E_FAIL;
|
---|
254 | }
|
---|
255 | /** Restores the number of callers after by #release(). #rc() must be
|
---|
256 | * rechecked to ensure the operation succeeded. */
|
---|
257 | void add()
|
---|
258 | {
|
---|
259 | AssertReturnVoid (!SUCCEEDED (mRC));
|
---|
260 | mRC = mThat->addVMCaller (taQuiet, taAllowNullVM);
|
---|
261 | }
|
---|
262 | /** Returns the result of Console::addVMCaller() */
|
---|
263 | HRESULT rc() const { return mRC; }
|
---|
264 | /** Shortcut to SUCCEEDED (rc()) */
|
---|
265 | bool isOk() const { return SUCCEEDED (mRC); }
|
---|
266 | protected:
|
---|
267 | Console *mThat;
|
---|
268 | HRESULT mRC;
|
---|
269 | private:
|
---|
270 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (AutoVMCallerBase)
|
---|
271 | DECLARE_CLS_NEW_DELETE_NOOP (AutoVMCallerBase)
|
---|
272 | };
|
---|
273 |
|
---|
274 | /**
|
---|
275 | * Helper class that protects sections of code using the mpVM pointer by
|
---|
276 | * automatically calling addVMCaller() on construction and
|
---|
277 | * releaseVMCaller() on destruction. Intended for Console methods dealing
|
---|
278 | * with mpVM. The usage pattern is:
|
---|
279 | * <code>
|
---|
280 | * AutoVMCaller autoVMCaller (this);
|
---|
281 | * CheckComRCReturnRC (autoVMCaller.rc());
|
---|
282 | * ...
|
---|
283 | * VMR3ReqCall (mpVM, ...
|
---|
284 | * </code>
|
---|
285 | *
|
---|
286 | * @note Temporarily locks the argument for writing.
|
---|
287 | *
|
---|
288 | * @sa SafeVMPtr, SafeVMPtrQuiet
|
---|
289 | */
|
---|
290 | typedef AutoVMCallerBase <false, false> AutoVMCaller;
|
---|
291 |
|
---|
292 | /**
|
---|
293 | * Same as AutoVMCaller but doesn't set extended error info on failure.
|
---|
294 | *
|
---|
295 | * @note Temporarily locks the argument for writing.
|
---|
296 | */
|
---|
297 | typedef AutoVMCallerBase <true, false> AutoVMCallerQuiet;
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Same as AutoVMCaller but allows a null VM pointer (to trigger an error
|
---|
301 | * instead of assertion).
|
---|
302 | *
|
---|
303 | * @note Temporarily locks the argument for writing.
|
---|
304 | */
|
---|
305 | typedef AutoVMCallerBase <false, true> AutoVMCallerWeak;
|
---|
306 |
|
---|
307 | /**
|
---|
308 | * Same as AutoVMCaller but doesn't set extended error info on failure
|
---|
309 | * and allows a null VM pointer (to trigger an error instead of
|
---|
310 | * assertion).
|
---|
311 | *
|
---|
312 | * @note Temporarily locks the argument for writing.
|
---|
313 | */
|
---|
314 | typedef AutoVMCallerBase <true, true> AutoVMCallerQuietWeak;
|
---|
315 |
|
---|
316 | /**
|
---|
317 | * Base template for SaveVMPtr and SaveVMPtrQuiet.
|
---|
318 | */
|
---|
319 | template <bool taQuiet = false>
|
---|
320 | class SafeVMPtrBase : public AutoVMCallerBase <taQuiet, true>
|
---|
321 | {
|
---|
322 | typedef AutoVMCallerBase <taQuiet, true> Base;
|
---|
323 | public:
|
---|
324 | SafeVMPtrBase (Console *aThat) : Base (aThat), mpVM (NULL)
|
---|
325 | {
|
---|
326 | if (SUCCEEDED (Base::mRC))
|
---|
327 | mpVM = aThat->mpVM;
|
---|
328 | }
|
---|
329 | /** Smart SaveVMPtr to PVM cast operator */
|
---|
330 | operator PVM() const { return mpVM; }
|
---|
331 | /** Direct PVM access for printf()-like functions */
|
---|
332 | PVM raw() const { return mpVM; }
|
---|
333 | private:
|
---|
334 | PVM mpVM;
|
---|
335 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (SafeVMPtrBase)
|
---|
336 | DECLARE_CLS_NEW_DELETE_NOOP (SafeVMPtrBase)
|
---|
337 | };
|
---|
338 |
|
---|
339 | public:
|
---|
340 |
|
---|
341 | /**
|
---|
342 | * Helper class that safely manages the Console::mpVM pointer
|
---|
343 | * by calling addVMCaller() on construction and releaseVMCaller() on
|
---|
344 | * destruction. Intended for Console children. The usage pattern is:
|
---|
345 | * <code>
|
---|
346 | * Console::SaveVMPtr pVM (mParent);
|
---|
347 | * CheckComRCReturnRC (pVM.rc());
|
---|
348 | * ...
|
---|
349 | * VMR3ReqCall (pVM, ...
|
---|
350 | * ...
|
---|
351 | * printf ("%p\n", pVM.raw());
|
---|
352 | * </code>
|
---|
353 | *
|
---|
354 | * @note Temporarily locks the argument for writing.
|
---|
355 | *
|
---|
356 | * @sa SafeVMPtrQuiet, AutoVMCaller
|
---|
357 | */
|
---|
358 | typedef SafeVMPtrBase <false> SafeVMPtr;
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * A deviation of SaveVMPtr that doesn't set the error info on failure.
|
---|
362 | * Intended for pieces of code that don't need to return the VM access
|
---|
363 | * failure to the caller. The usage pattern is:
|
---|
364 | * <code>
|
---|
365 | * Console::SaveVMPtrQuiet pVM (mParent);
|
---|
366 | * if (pVM.rc())
|
---|
367 | * VMR3ReqCall (pVM, ...
|
---|
368 | * return S_OK;
|
---|
369 | * </code>
|
---|
370 | *
|
---|
371 | * @note Temporarily locks the argument for writing.
|
---|
372 | *
|
---|
373 | * @sa SafeVMPtr, AutoVMCaller
|
---|
374 | */
|
---|
375 | typedef SafeVMPtrBase <true> SafeVMPtrQuiet;
|
---|
376 |
|
---|
377 | class SharedFolderData
|
---|
378 | {
|
---|
379 | public:
|
---|
380 | SharedFolderData() {}
|
---|
381 | SharedFolderData(Bstr aHostPath, BOOL aWritable)
|
---|
382 | : mHostPath (aHostPath)
|
---|
383 | , mWritable (aWritable) {}
|
---|
384 | SharedFolderData(const SharedFolderData& aThat)
|
---|
385 | : mHostPath (aThat.mHostPath)
|
---|
386 | , mWritable (aThat.mWritable) {}
|
---|
387 | Bstr mHostPath;
|
---|
388 | BOOL mWritable;
|
---|
389 | };
|
---|
390 | typedef std::map <Bstr, ComObjPtr <SharedFolder> > SharedFolderMap;
|
---|
391 | typedef std::map <Bstr, SharedFolderData> SharedFolderDataMap;
|
---|
392 |
|
---|
393 | private:
|
---|
394 |
|
---|
395 | typedef std::list <ComObjPtr <OUSBDevice> > USBDeviceList;
|
---|
396 | typedef std::list <ComObjPtr <RemoteUSBDevice> > RemoteUSBDeviceList;
|
---|
397 |
|
---|
398 | HRESULT addVMCaller (bool aQuiet = false, bool aAllowNullVM = false);
|
---|
399 | void releaseVMCaller();
|
---|
400 |
|
---|
401 | HRESULT consoleInitReleaseLog (const ComPtr <IMachine> aMachine);
|
---|
402 |
|
---|
403 | HRESULT powerUp (IProgress **aProgress, bool aPaused);
|
---|
404 | HRESULT powerDown (Progress *aProgress = NULL);
|
---|
405 |
|
---|
406 | HRESULT callTapSetupApplication(bool isStatic, RTFILE tapFD, Bstr &tapDevice,
|
---|
407 | Bstr &tapSetupApplication);
|
---|
408 | HRESULT attachToBridgedInterface(INetworkAdapter *networkAdapter);
|
---|
409 | HRESULT detachFromBridgedInterface(INetworkAdapter *networkAdapter);
|
---|
410 | HRESULT powerDownHostInterfaces();
|
---|
411 |
|
---|
412 | HRESULT setMachineState (MachineState_T aMachineState, bool aUpdateServer = true);
|
---|
413 | HRESULT setMachineStateLocally (MachineState_T aMachineState)
|
---|
414 | {
|
---|
415 | return setMachineState (aMachineState, false /* aUpdateServer */);
|
---|
416 | }
|
---|
417 |
|
---|
418 | HRESULT findSharedFolder (CBSTR aName,
|
---|
419 | ComObjPtr <SharedFolder> &aSharedFolder,
|
---|
420 | bool aSetError = false);
|
---|
421 |
|
---|
422 | HRESULT fetchSharedFolders (BOOL aGlobal);
|
---|
423 | bool findOtherSharedFolder (IN_BSTR aName,
|
---|
424 | SharedFolderDataMap::const_iterator &aIt);
|
---|
425 |
|
---|
426 | HRESULT createSharedFolder (CBSTR aName, SharedFolderData aData);
|
---|
427 | HRESULT removeSharedFolder (CBSTR aName);
|
---|
428 |
|
---|
429 | static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole);
|
---|
430 | static DECLCALLBACK(void) vmstateChangeCallback(PVM aVM, VMSTATE aState,
|
---|
431 | VMSTATE aOldState, void *aUser);
|
---|
432 | HRESULT doDriveChange (const char *pszDevice, unsigned uInstance,
|
---|
433 | unsigned uLun, DriveState_T eState,
|
---|
434 | DriveState_T *peState, const char *pszPath,
|
---|
435 | bool fPassthrough);
|
---|
436 | static DECLCALLBACK(int) changeDrive (Console *pThis, const char *pszDevice,
|
---|
437 | unsigned uInstance, unsigned uLun,
|
---|
438 | DriveState_T eState, DriveState_T *peState,
|
---|
439 | const char *pszPath, bool fPassthrough);
|
---|
440 |
|
---|
441 | #ifdef VBOX_WITH_USB
|
---|
442 | HRESULT attachUSBDevice (IUSBDevice *aHostDevice, ULONG aMaskedIfs);
|
---|
443 | HRESULT detachUSBDevice (USBDeviceList::iterator &aIt);
|
---|
444 |
|
---|
445 | static DECLCALLBACK(int)
|
---|
446 | usbAttachCallback (Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid,
|
---|
447 | bool aRemote, const char *aAddress, ULONG aMaskedIfs);
|
---|
448 | static DECLCALLBACK(int)
|
---|
449 | usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid);
|
---|
450 | #endif
|
---|
451 |
|
---|
452 | static DECLCALLBACK (int)
|
---|
453 | stateProgressCallback (PVM pVM, unsigned uPercent, void *pvUser);
|
---|
454 |
|
---|
455 | static DECLCALLBACK(void)
|
---|
456 | setVMErrorCallback (PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
|
---|
457 | const char *pszFormat, va_list args);
|
---|
458 |
|
---|
459 | static DECLCALLBACK(void)
|
---|
460 | setVMRuntimeErrorCallback (PVM pVM, void *pvUser, bool fFatal,
|
---|
461 | const char *pszErrorID,
|
---|
462 | const char *pszFormat, va_list args);
|
---|
463 |
|
---|
464 | HRESULT captureUSBDevices (PVM pVM);
|
---|
465 | void detachAllUSBDevices (bool aDone);
|
---|
466 |
|
---|
467 | static DECLCALLBACK (int) powerUpThread (RTTHREAD Thread, void *pvUser);
|
---|
468 | static DECLCALLBACK (int) saveStateThread (RTTHREAD Thread, void *pvUser);
|
---|
469 | static DECLCALLBACK (int) powerDownThread (RTTHREAD Thread, void *pvUser);
|
---|
470 |
|
---|
471 | static DECLCALLBACK(void *) drvStatus_QueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
472 | static DECLCALLBACK(void) drvStatus_UnitChanged(PPDMILEDCONNECTORS pInterface, unsigned iLUN);
|
---|
473 | static DECLCALLBACK(void) drvStatus_Destruct(PPDMDRVINS pDrvIns);
|
---|
474 | static DECLCALLBACK(int) drvStatus_Construct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
|
---|
475 |
|
---|
476 | int mcAudioRefs;
|
---|
477 | volatile uint32_t mcVRDPClients;
|
---|
478 | uint32_t mu32SingleRDPClientId; /* The id of a connected client in the single connection mode. */
|
---|
479 |
|
---|
480 | static const char *sSSMConsoleUnit;
|
---|
481 | static uint32_t sSSMConsoleVer;
|
---|
482 |
|
---|
483 | HRESULT loadDataFromSavedState();
|
---|
484 |
|
---|
485 | static DECLCALLBACK(void) saveStateFileExec (PSSMHANDLE pSSM, void *pvUser);
|
---|
486 | static DECLCALLBACK(int) loadStateFileExec (PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version);
|
---|
487 |
|
---|
488 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
489 | static DECLCALLBACK(int) doGuestPropNotification (void *pvExtension, uint32_t,
|
---|
490 | void *pvParms, uint32_t cbParms);
|
---|
491 | HRESULT doEnumerateGuestProperties (CBSTR aPatterns,
|
---|
492 | ComSafeArrayOut(BSTR, aNames),
|
---|
493 | ComSafeArrayOut(BSTR, aValues),
|
---|
494 | ComSafeArrayOut(ULONG64, aTimestamps),
|
---|
495 | ComSafeArrayOut(BSTR, aFlags));
|
---|
496 | #endif
|
---|
497 |
|
---|
498 | bool mSavedStateDataLoaded : 1;
|
---|
499 |
|
---|
500 | const ComPtr <IMachine> mMachine;
|
---|
501 | const ComPtr <IInternalMachineControl> mControl;
|
---|
502 |
|
---|
503 | const ComPtr <IVRDPServer> mVRDPServer;
|
---|
504 | const ComPtr <IDVDDrive> mDVDDrive;
|
---|
505 | const ComPtr <IFloppyDrive> mFloppyDrive;
|
---|
506 |
|
---|
507 | ConsoleVRDPServer * const mConsoleVRDPServer;
|
---|
508 |
|
---|
509 | const ComObjPtr <Guest> mGuest;
|
---|
510 | const ComObjPtr <Keyboard> mKeyboard;
|
---|
511 | const ComObjPtr <Mouse> mMouse;
|
---|
512 | const ComObjPtr <Display> mDisplay;
|
---|
513 | const ComObjPtr <MachineDebugger> mDebugger;
|
---|
514 | const ComObjPtr <RemoteDisplayInfo> mRemoteDisplayInfo;
|
---|
515 |
|
---|
516 | USBDeviceList mUSBDevices;
|
---|
517 | RemoteUSBDeviceList mRemoteUSBDevices;
|
---|
518 |
|
---|
519 | SharedFolderMap mSharedFolders;
|
---|
520 | SharedFolderDataMap mMachineSharedFolders;
|
---|
521 | SharedFolderDataMap mGlobalSharedFolders;
|
---|
522 |
|
---|
523 | /** The VM instance handle. */
|
---|
524 | PVM mpVM;
|
---|
525 | /** Holds the number of "readonly" mpVM callers (users) */
|
---|
526 | uint32_t mVMCallers;
|
---|
527 | /** Semaphore posted when the number of mpVM callers drops to zero */
|
---|
528 | RTSEMEVENT mVMZeroCallersSem;
|
---|
529 | /** true when Console has entered the mpVM destruction phase */
|
---|
530 | bool mVMDestroying : 1;
|
---|
531 | /** true when power down is initiated by vmstateChangeCallback (EMT) */
|
---|
532 | bool mVMPoweredOff : 1;
|
---|
533 |
|
---|
534 | /** The current DVD drive state in the VM.
|
---|
535 | * This does not have to match the state maintained in the DVD. */
|
---|
536 | DriveState_T meDVDState;
|
---|
537 | /** The current Floppy drive state in the VM.
|
---|
538 | * This does not have to match the state maintained in the Floppy. */
|
---|
539 | DriveState_T meFloppyState;
|
---|
540 |
|
---|
541 | VMMDev * const mVMMDev;
|
---|
542 | AudioSniffer * const mAudioSniffer;
|
---|
543 |
|
---|
544 | PPDMLED mapFDLeds[2];
|
---|
545 | PPDMLED mapIDELeds[4];
|
---|
546 | PPDMLED mapSATALeds[30];
|
---|
547 | PPDMLED mapSCSILeds[16];
|
---|
548 | PPDMLED mapNetworkLeds[8];
|
---|
549 | PPDMLED mapSharedFolderLed;
|
---|
550 | PPDMLED mapUSBLed[2];
|
---|
551 | #if !defined(VBOX_WITH_NETFLT) && defined(RT_OS_LINUX)
|
---|
552 | Utf8Str maTAPDeviceName[8];
|
---|
553 | RTFILE maTapFD[8];
|
---|
554 | #endif
|
---|
555 |
|
---|
556 | bool mVMStateChangeCallbackDisabled;
|
---|
557 |
|
---|
558 | /* Local machine state value */
|
---|
559 | MachineState_T mMachineState;
|
---|
560 |
|
---|
561 | typedef std::list <ComPtr <IConsoleCallback> > CallbackList;
|
---|
562 | CallbackList mCallbacks;
|
---|
563 |
|
---|
564 | struct
|
---|
565 | {
|
---|
566 | /** OnMousePointerShapeChange() cache */
|
---|
567 | struct
|
---|
568 | {
|
---|
569 | bool valid;
|
---|
570 | bool visible;
|
---|
571 | bool alpha;
|
---|
572 | uint32_t xHot;
|
---|
573 | uint32_t yHot;
|
---|
574 | uint32_t width;
|
---|
575 | uint32_t height;
|
---|
576 | BYTE *shape;
|
---|
577 | size_t shapeSize;
|
---|
578 | }
|
---|
579 | mpsc;
|
---|
580 |
|
---|
581 | /** OnMouseCapabilityChange() cache */
|
---|
582 | struct
|
---|
583 | {
|
---|
584 | bool valid;
|
---|
585 | BOOL supportsAbsolute;
|
---|
586 | BOOL needsHostCursor;
|
---|
587 | }
|
---|
588 | mcc;
|
---|
589 |
|
---|
590 | /** OnKeyboardLedsChange() cache */
|
---|
591 | struct
|
---|
592 | {
|
---|
593 | bool valid;
|
---|
594 | bool numLock;
|
---|
595 | bool capsLock;
|
---|
596 | bool scrollLock;
|
---|
597 | }
|
---|
598 | klc;
|
---|
599 | }
|
---|
600 | mCallbackData;
|
---|
601 |
|
---|
602 | friend struct VMTask;
|
---|
603 | };
|
---|
604 |
|
---|
605 | #endif // ____H_CONSOLEIMPL
|
---|
606 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|