1 | /* $Id: MachineImpl.h 11683 2008-08-26 17:40:41Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class declaration
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2007 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_MACHINEIMPL
|
---|
25 | #define ____H_MACHINEIMPL
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 | #include "ProgressImpl.h"
|
---|
29 | #include "SnapshotImpl.h"
|
---|
30 | #include "VRDPServerImpl.h"
|
---|
31 | #include "DVDDriveImpl.h"
|
---|
32 | #include "FloppyDriveImpl.h"
|
---|
33 | #include "HardDiskAttachmentImpl.h"
|
---|
34 | #include "Collection.h"
|
---|
35 | #include "NetworkAdapterImpl.h"
|
---|
36 | #include "AudioAdapterImpl.h"
|
---|
37 | #include "SerialPortImpl.h"
|
---|
38 | #include "ParallelPortImpl.h"
|
---|
39 | #include "BIOSSettingsImpl.h"
|
---|
40 | #include "SATAControllerImpl.h"
|
---|
41 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
42 | #include "PerformanceImpl.h"
|
---|
43 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
44 |
|
---|
45 | // generated header
|
---|
46 | #include "SchemaDefs.h"
|
---|
47 |
|
---|
48 | #include <VBox/types.h>
|
---|
49 |
|
---|
50 | #include <iprt/file.h>
|
---|
51 | #include <iprt/thread.h>
|
---|
52 | #include <iprt/time.h>
|
---|
53 |
|
---|
54 | #include <list>
|
---|
55 |
|
---|
56 | // defines
|
---|
57 | ////////////////////////////////////////////////////////////////////////////////
|
---|
58 |
|
---|
59 | // helper declarations
|
---|
60 | ////////////////////////////////////////////////////////////////////////////////
|
---|
61 |
|
---|
62 | class VirtualBox;
|
---|
63 | class Progress;
|
---|
64 | class CombinedProgress;
|
---|
65 | class Keyboard;
|
---|
66 | class Mouse;
|
---|
67 | class Display;
|
---|
68 | class MachineDebugger;
|
---|
69 | class USBController;
|
---|
70 | class Snapshot;
|
---|
71 | class SharedFolder;
|
---|
72 | class HostUSBDevice;
|
---|
73 |
|
---|
74 | class SessionMachine;
|
---|
75 |
|
---|
76 | // Machine class
|
---|
77 | ////////////////////////////////////////////////////////////////////////////////
|
---|
78 |
|
---|
79 | class ATL_NO_VTABLE Machine :
|
---|
80 | public VirtualBoxBaseWithChildrenNEXT,
|
---|
81 | public VirtualBoxSupportErrorInfoImpl <Machine, IMachine>,
|
---|
82 | public VirtualBoxSupportTranslation <Machine>,
|
---|
83 | public IMachine
|
---|
84 | {
|
---|
85 | Q_OBJECT
|
---|
86 |
|
---|
87 | public:
|
---|
88 |
|
---|
89 | /**
|
---|
90 | * Internal machine data.
|
---|
91 | *
|
---|
92 | * Only one instance of this data exists per every machine --
|
---|
93 | * it is shared by the Machine, SessionMachine and all SnapshotMachine
|
---|
94 | * instances associated with the given machine using the util::Shareable
|
---|
95 | * template through the mData variable.
|
---|
96 | *
|
---|
97 | * @note |const| members are persistent during lifetime so can be
|
---|
98 | * accessed without locking.
|
---|
99 | *
|
---|
100 | * @note There is no need to lock anything inside init() or uninit()
|
---|
101 | * methods, because they are always serialized (see AutoCaller).
|
---|
102 | */
|
---|
103 | struct Data
|
---|
104 | {
|
---|
105 | /**
|
---|
106 | * Data structure to hold information about sessions opened for the
|
---|
107 | * given machine.
|
---|
108 | */
|
---|
109 | struct Session
|
---|
110 | {
|
---|
111 | /** Control of the direct session opened by openSession() */
|
---|
112 | ComPtr <IInternalSessionControl> mDirectControl;
|
---|
113 |
|
---|
114 | typedef std::list <ComPtr <IInternalSessionControl> > RemoteControlList;
|
---|
115 |
|
---|
116 | /** list of controls of all opened remote sessions */
|
---|
117 | RemoteControlList mRemoteControls;
|
---|
118 |
|
---|
119 | /** openRemoteSession() and OnSessionEnd() progress indicator */
|
---|
120 | ComObjPtr <Progress> mProgress;
|
---|
121 |
|
---|
122 | /**
|
---|
123 | * PID of the session object that must be passed to openSession()
|
---|
124 | * to finalize the openRemoteSession() request
|
---|
125 | * (i.e., PID of the process created by openRemoteSession())
|
---|
126 | */
|
---|
127 | RTPROCESS mPid;
|
---|
128 |
|
---|
129 | /** Current session state */
|
---|
130 | SessionState_T mState;
|
---|
131 |
|
---|
132 | /** Session type string (for indirect sessions) */
|
---|
133 | Bstr mType;
|
---|
134 |
|
---|
135 | /** Sesison machine object */
|
---|
136 | ComObjPtr <SessionMachine> mMachine;
|
---|
137 | };
|
---|
138 |
|
---|
139 | Data();
|
---|
140 | ~Data();
|
---|
141 |
|
---|
142 | const Guid mUuid;
|
---|
143 | BOOL mRegistered;
|
---|
144 |
|
---|
145 | Bstr mConfigFile;
|
---|
146 | Bstr mConfigFileFull;
|
---|
147 |
|
---|
148 | Utf8Str mSettingsFileVersion;
|
---|
149 |
|
---|
150 | BOOL mAccessible;
|
---|
151 | com::ErrorInfo mAccessError;
|
---|
152 |
|
---|
153 | MachineState_T mMachineState;
|
---|
154 | RTTIMESPEC mLastStateChange;
|
---|
155 |
|
---|
156 | /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
|
---|
157 | uint32_t mMachineStateDeps;
|
---|
158 | RTSEMEVENTMULTI mMachineStateDepsSem;
|
---|
159 | uint32_t mMachineStateChangePending;
|
---|
160 |
|
---|
161 | BOOL mCurrentStateModified;
|
---|
162 |
|
---|
163 | RTFILE mHandleCfgFile;
|
---|
164 |
|
---|
165 | Session mSession;
|
---|
166 |
|
---|
167 | ComObjPtr <Snapshot> mFirstSnapshot;
|
---|
168 | ComObjPtr <Snapshot> mCurrentSnapshot;
|
---|
169 |
|
---|
170 | };
|
---|
171 |
|
---|
172 | /**
|
---|
173 | * Saved state data.
|
---|
174 | *
|
---|
175 | * It's actually only the state file path string, but it needs to be
|
---|
176 | * separate from Data, because Machine and SessionMachine instances
|
---|
177 | * share it, while SnapshotMachine does not.
|
---|
178 | *
|
---|
179 | * The data variable is |mSSData|.
|
---|
180 | */
|
---|
181 | struct SSData
|
---|
182 | {
|
---|
183 | Bstr mStateFilePath;
|
---|
184 | };
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * User changeable machine data.
|
---|
188 | *
|
---|
189 | * This data is common for all machine snapshots, i.e. it is shared
|
---|
190 | * by all SnapshotMachine instances associated with the given machine
|
---|
191 | * using the util::Backupable template through the |mUserData| variable.
|
---|
192 | *
|
---|
193 | * SessionMachine instances can alter this data and discard changes.
|
---|
194 | *
|
---|
195 | * @note There is no need to lock anything inside init() or uninit()
|
---|
196 | * methods, because they are always serialized (see AutoCaller).
|
---|
197 | */
|
---|
198 | struct UserData
|
---|
199 | {
|
---|
200 | UserData();
|
---|
201 | ~UserData();
|
---|
202 |
|
---|
203 | bool operator== (const UserData &that) const
|
---|
204 | {
|
---|
205 | return this == &that ||
|
---|
206 | (mName == that.mName &&
|
---|
207 | mNameSync == that.mNameSync &&
|
---|
208 | mDescription == that.mDescription &&
|
---|
209 | mOSTypeId == that.mOSTypeId &&
|
---|
210 | mSnapshotFolderFull == that.mSnapshotFolderFull);
|
---|
211 | }
|
---|
212 |
|
---|
213 | Bstr mName;
|
---|
214 | BOOL mNameSync;
|
---|
215 | Bstr mDescription;
|
---|
216 | Bstr mOSTypeId;
|
---|
217 | Bstr mSnapshotFolder;
|
---|
218 | Bstr mSnapshotFolderFull;
|
---|
219 | };
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Hardware data.
|
---|
223 | *
|
---|
224 | * This data is unique for a machine and for every machine snapshot.
|
---|
225 | * Stored using the util::Backupable template in the |mHWData| variable.
|
---|
226 | *
|
---|
227 | * SessionMachine instances can alter this data and discard changes.
|
---|
228 | */
|
---|
229 | struct HWData
|
---|
230 | {
|
---|
231 | /**
|
---|
232 | * Data structure to hold information about a guest property.
|
---|
233 | */
|
---|
234 | struct GuestProperty {
|
---|
235 | /** Property name */
|
---|
236 | Bstr mName;
|
---|
237 | /** Property value */
|
---|
238 | Bstr mValue;
|
---|
239 | /** Property timestamp */
|
---|
240 | ULONG64 mTimestamp;
|
---|
241 | /** Property flags */
|
---|
242 | Bstr mFlags;
|
---|
243 | };
|
---|
244 |
|
---|
245 | HWData();
|
---|
246 | ~HWData();
|
---|
247 |
|
---|
248 | bool operator== (const HWData &that) const;
|
---|
249 |
|
---|
250 | ULONG mMemorySize;
|
---|
251 | ULONG mMemoryBalloonSize;
|
---|
252 | ULONG mStatisticsUpdateInterval;
|
---|
253 | ULONG mVRAMSize;
|
---|
254 | ULONG mMonitorCount;
|
---|
255 | TSBool_T mHWVirtExEnabled;
|
---|
256 | BOOL mHWVirtExNestedPagingEnabled;
|
---|
257 | BOOL mPAEEnabled;
|
---|
258 |
|
---|
259 | DeviceType_T mBootOrder [SchemaDefs::MaxBootPosition];
|
---|
260 |
|
---|
261 | typedef std::list <ComObjPtr <SharedFolder> > SharedFolderList;
|
---|
262 | SharedFolderList mSharedFolders;
|
---|
263 | ClipboardMode_T mClipboardMode;
|
---|
264 | typedef std::list <GuestProperty> GuestPropertyList;
|
---|
265 | GuestPropertyList mGuestProperties;
|
---|
266 | BOOL mPropertyServiceActive;
|
---|
267 | };
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Hard disk data.
|
---|
271 | *
|
---|
272 | * The usage policy is the same as for HWData, but a separate structure
|
---|
273 | * is necessarym because hard disk data requires different procedures when
|
---|
274 | * taking or discarding snapshots, etc.
|
---|
275 | *
|
---|
276 | * The data variable is |mHWData|.
|
---|
277 | */
|
---|
278 | struct HDData
|
---|
279 | {
|
---|
280 | HDData();
|
---|
281 | ~HDData();
|
---|
282 |
|
---|
283 | bool operator== (const HDData &that) const;
|
---|
284 |
|
---|
285 | typedef std::list <ComObjPtr <HardDiskAttachment> > HDAttachmentList;
|
---|
286 | HDAttachmentList mHDAttachments;
|
---|
287 |
|
---|
288 | /**
|
---|
289 | * Right after Machine::fixupHardDisks(true): |true| if hard disks
|
---|
290 | * were actually changed, |false| otherwise
|
---|
291 | */
|
---|
292 | bool mHDAttachmentsChanged;
|
---|
293 | };
|
---|
294 |
|
---|
295 | enum StateDependency
|
---|
296 | {
|
---|
297 | AnyStateDep = 0, MutableStateDep, MutableOrSavedStateDep
|
---|
298 | };
|
---|
299 |
|
---|
300 | /**
|
---|
301 | * Helper class that safely manages the machine state dependency by
|
---|
302 | * calling Machine::addStateDependency() on construction and
|
---|
303 | * Machine::releaseStateDependency() on destruction. Intended for Machine
|
---|
304 | * children. The usage pattern is:
|
---|
305 | *
|
---|
306 | * @code
|
---|
307 | * AutoCaller autoCaller (this);
|
---|
308 | * CheckComRCReturnRC (autoCaller.rc());
|
---|
309 | *
|
---|
310 | * Machine::AutoStateDependency <MutableStateDep> adep (mParent);
|
---|
311 | * CheckComRCReturnRC (stateDep.rc());
|
---|
312 | * ...
|
---|
313 | * // code that depends on the particular machine state
|
---|
314 | * ...
|
---|
315 | * @endcode
|
---|
316 | *
|
---|
317 | * Note that it is more convenient to use the following individual
|
---|
318 | * shortcut classes instead of using this template directly:
|
---|
319 | * AutoAnyStateDependency, AutoMutableStateDependency and
|
---|
320 | * AutoMutableOrSavedStateDependency. The usage pattern is exactly the
|
---|
321 | * same as above except that there is no need to specify the template
|
---|
322 | * argument because it is already done by the shortcut class.
|
---|
323 | *
|
---|
324 | * @param taDepType Dependecy type to manage.
|
---|
325 | */
|
---|
326 | template <StateDependency taDepType = AnyStateDep>
|
---|
327 | class AutoStateDependency
|
---|
328 | {
|
---|
329 | public:
|
---|
330 |
|
---|
331 | AutoStateDependency (Machine *aThat)
|
---|
332 | : mThat (aThat), mRC (S_OK)
|
---|
333 | , mMachineState (MachineState_Null)
|
---|
334 | , mRegistered (FALSE)
|
---|
335 | {
|
---|
336 | Assert (aThat);
|
---|
337 | mRC = aThat->addStateDependency (taDepType, &mMachineState,
|
---|
338 | &mRegistered);
|
---|
339 | }
|
---|
340 | ~AutoStateDependency()
|
---|
341 | {
|
---|
342 | if (SUCCEEDED (mRC))
|
---|
343 | mThat->releaseStateDependency();
|
---|
344 | }
|
---|
345 |
|
---|
346 | /** Decreases the number of dependencies before the instance is
|
---|
347 | * destroyed. Note that will reset #rc() to E_FAIL. */
|
---|
348 | void release()
|
---|
349 | {
|
---|
350 | AssertReturnVoid (SUCCEEDED (mRC));
|
---|
351 | mThat->releaseStateDependency();
|
---|
352 | mRC = E_FAIL;
|
---|
353 | }
|
---|
354 |
|
---|
355 | /** Restores the number of callers after by #release(). #rc() will be
|
---|
356 | * reset to the result of calling addStateDependency() and must be
|
---|
357 | * rechecked to ensure the operation succeeded. */
|
---|
358 | void add()
|
---|
359 | {
|
---|
360 | AssertReturnVoid (!SUCCEEDED (mRC));
|
---|
361 | mRC = mThat->addStateDependency (taDepType, &mMachineState,
|
---|
362 | &mRegistered);
|
---|
363 | }
|
---|
364 |
|
---|
365 | /** Returns the result of Machine::addStateDependency(). */
|
---|
366 | HRESULT rc() const { return mRC; }
|
---|
367 |
|
---|
368 | /** Shortcut to SUCCEEDED (rc()). */
|
---|
369 | bool isOk() const { return SUCCEEDED (mRC); }
|
---|
370 |
|
---|
371 | /** Returns the machine state value as returned by
|
---|
372 | * Machine::addStateDependency(). */
|
---|
373 | MachineState_T machineState() const { return mMachineState; }
|
---|
374 |
|
---|
375 | /** Returns the machine state value as returned by
|
---|
376 | * Machine::addStateDependency(). */
|
---|
377 | BOOL machineRegistered() const { return mRegistered; }
|
---|
378 |
|
---|
379 | protected:
|
---|
380 |
|
---|
381 | Machine *mThat;
|
---|
382 | HRESULT mRC;
|
---|
383 | MachineState_T mMachineState;
|
---|
384 | BOOL mRegistered;
|
---|
385 |
|
---|
386 | private:
|
---|
387 |
|
---|
388 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP (AutoStateDependency)
|
---|
389 | DECLARE_CLS_NEW_DELETE_NOOP (AutoStateDependency)
|
---|
390 | };
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Shortcut to AutoStateDependency <AnyStateDep>.
|
---|
394 | * See AutoStateDependency to get the usage pattern.
|
---|
395 | *
|
---|
396 | * Accepts any machine state and guarantees the state won't change before
|
---|
397 | * this object is destroyed. If the machine state cannot be protected (as
|
---|
398 | * a result of the state change currently in progress), this instance's
|
---|
399 | * #rc() method will indicate a failure, and the caller is not allowed to
|
---|
400 | * rely on any particular machine state and should return the failed
|
---|
401 | * result code to the upper level.
|
---|
402 | */
|
---|
403 | typedef AutoStateDependency <AnyStateDep> AutoAnyStateDependency;
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Shortcut to AutoStateDependency <MutableStateDep>.
|
---|
407 | * See AutoStateDependency to get the usage pattern.
|
---|
408 | *
|
---|
409 | * Succeeds only if the machine state is in one of the mutable states, and
|
---|
410 | * guarantees the given mutable state won't change before this object is
|
---|
411 | * destroyed. If the machine is not mutable, this instance's #rc() method
|
---|
412 | * will indicate a failure, and the caller is not allowed to rely on any
|
---|
413 | * particular machine state and should return the failed result code to
|
---|
414 | * the upper level.
|
---|
415 | *
|
---|
416 | * Intended to be used within all setter methods of IMachine
|
---|
417 | * children objects (DVDDrive, NetworkAdapter, AudioAdapter, etc.) to
|
---|
418 | * provide data protection and consistency.
|
---|
419 | */
|
---|
420 | typedef AutoStateDependency <MutableStateDep> AutoMutableStateDependency;
|
---|
421 |
|
---|
422 | /**
|
---|
423 | * Shortcut to AutoStateDependency <MutableOrSavedStateDep>.
|
---|
424 | * See AutoStateDependency to get the usage pattern.
|
---|
425 | *
|
---|
426 | * Succeeds only if the machine state is in one of the mutable states, or
|
---|
427 | * if the machine is in the Saved state, and guarantees the given mutable
|
---|
428 | * state won't change before this object is destroyed. If the machine is
|
---|
429 | * not mutable, this instance's #rc() method will indicate a failure, and
|
---|
430 | * the caller is not allowed to rely on any particular machine state and
|
---|
431 | * should return the failed result code to the upper level.
|
---|
432 | *
|
---|
433 | * Intended to be used within setter methods of IMachine
|
---|
434 | * children objects that may also operate on Saved machines.
|
---|
435 | */
|
---|
436 | typedef AutoStateDependency <MutableOrSavedStateDep> AutoMutableOrSavedStateDependency;
|
---|
437 |
|
---|
438 |
|
---|
439 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Machine)
|
---|
440 |
|
---|
441 | DECLARE_NOT_AGGREGATABLE(Machine)
|
---|
442 |
|
---|
443 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
444 |
|
---|
445 | BEGIN_COM_MAP(Machine)
|
---|
446 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
447 | COM_INTERFACE_ENTRY(IMachine)
|
---|
448 | END_COM_MAP()
|
---|
449 |
|
---|
450 | NS_DECL_ISUPPORTS
|
---|
451 |
|
---|
452 | DECLARE_EMPTY_CTOR_DTOR (Machine)
|
---|
453 |
|
---|
454 | HRESULT FinalConstruct();
|
---|
455 | void FinalRelease();
|
---|
456 |
|
---|
457 | enum InitMode { Init_New, Init_Existing, Init_Registered };
|
---|
458 |
|
---|
459 | // public initializer/uninitializer for internal purposes only
|
---|
460 | HRESULT init (VirtualBox *aParent, const BSTR aConfigFile,
|
---|
461 | InitMode aMode, const BSTR aName = NULL,
|
---|
462 | BOOL aNameSync = TRUE, const Guid *aId = NULL);
|
---|
463 | void uninit();
|
---|
464 |
|
---|
465 | // IMachine properties
|
---|
466 | STDMETHOD(COMGETTER(Parent))(IVirtualBox **aParent);
|
---|
467 | STDMETHOD(COMGETTER(Accessible)) (BOOL *aAccessible);
|
---|
468 | STDMETHOD(COMGETTER(AccessError)) (IVirtualBoxErrorInfo **aAccessError);
|
---|
469 | STDMETHOD(COMGETTER(Name))(BSTR *aName);
|
---|
470 | STDMETHOD(COMSETTER(Name))(INPTR BSTR aName);
|
---|
471 | STDMETHOD(COMGETTER(Description))(BSTR *aDescription);
|
---|
472 | STDMETHOD(COMSETTER(Description))(INPTR BSTR aDescription);
|
---|
473 | STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT aId);
|
---|
474 | STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
|
---|
475 | STDMETHOD(COMSETTER(OSTypeId)) (INPTR BSTR aOSTypeId);
|
---|
476 | STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
|
---|
477 | STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
|
---|
478 | STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
|
---|
479 | STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
|
---|
480 | STDMETHOD(COMGETTER(StatisticsUpdateInterval))(ULONG *statisticsUpdateInterval);
|
---|
481 | STDMETHOD(COMSETTER(StatisticsUpdateInterval))(ULONG statisticsUpdateInterval);
|
---|
482 | STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
|
---|
483 | STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
|
---|
484 | STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
|
---|
485 | STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
|
---|
486 | STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
|
---|
487 | STDMETHOD(COMGETTER(HWVirtExEnabled))(TSBool_T *enabled);
|
---|
488 | STDMETHOD(COMSETTER(HWVirtExEnabled))(TSBool_T enabled);
|
---|
489 | STDMETHOD(COMGETTER(HWVirtExNestedPagingEnabled))(BOOL *enabled);
|
---|
490 | STDMETHOD(COMSETTER(HWVirtExNestedPagingEnabled))(BOOL enabled);
|
---|
491 | STDMETHOD(COMGETTER(PAEEnabled))(BOOL *enabled);
|
---|
492 | STDMETHOD(COMSETTER(PAEEnabled))(BOOL enabled);
|
---|
493 | STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
|
---|
494 | STDMETHOD(COMSETTER(SnapshotFolder))(INPTR BSTR aSavedStateFolder);
|
---|
495 | STDMETHOD(COMGETTER(HardDiskAttachments))(IHardDiskAttachmentCollection **attachments);
|
---|
496 | STDMETHOD(COMGETTER(VRDPServer))(IVRDPServer **vrdpServer);
|
---|
497 | STDMETHOD(COMGETTER(DVDDrive))(IDVDDrive **dvdDrive);
|
---|
498 | STDMETHOD(COMGETTER(FloppyDrive))(IFloppyDrive **floppyDrive);
|
---|
499 | STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
|
---|
500 | STDMETHOD(COMGETTER(USBController)) (IUSBController * *aUSBController);
|
---|
501 | STDMETHOD(COMGETTER(SATAController)) (ISATAController **aSATAController);
|
---|
502 | STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aFilePath);
|
---|
503 | STDMETHOD(COMGETTER(SettingsFileVersion)) (BSTR *aSettingsFileVersion);
|
---|
504 | STDMETHOD(COMGETTER(SettingsModified)) (BOOL *aModified);
|
---|
505 | STDMETHOD(COMGETTER(SessionState)) (SessionState_T *aSessionState);
|
---|
506 | STDMETHOD(COMGETTER(SessionType)) (BSTR *aSessionType);
|
---|
507 | STDMETHOD(COMGETTER(SessionPid)) (ULONG *aSessionPid);
|
---|
508 | STDMETHOD(COMGETTER(State)) (MachineState_T *machineState);
|
---|
509 | STDMETHOD(COMGETTER(LastStateChange)) (LONG64 *aLastStateChange);
|
---|
510 | STDMETHOD(COMGETTER(StateFilePath)) (BSTR *aStateFilePath);
|
---|
511 | STDMETHOD(COMGETTER(LogFolder)) (BSTR *aLogFolder);
|
---|
512 | STDMETHOD(COMGETTER(CurrentSnapshot)) (ISnapshot **aCurrentSnapshot);
|
---|
513 | STDMETHOD(COMGETTER(SnapshotCount)) (ULONG *aSnapshotCount);
|
---|
514 | STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
|
---|
515 | STDMETHOD(COMGETTER(SharedFolders)) (ISharedFolderCollection **aSharedFolders);
|
---|
516 | STDMETHOD(COMGETTER(ClipboardMode)) (ClipboardMode_T *aClipboardMode);
|
---|
517 | STDMETHOD(COMSETTER(ClipboardMode)) (ClipboardMode_T aClipboardMode);
|
---|
518 |
|
---|
519 | // IMachine methods
|
---|
520 | STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
|
---|
521 | STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
|
---|
522 | STDMETHOD(AttachHardDisk)(INPTR GUIDPARAM aId, StorageBus_T aBus, LONG aChannel, LONG aDevice);
|
---|
523 | STDMETHOD(GetHardDisk)(StorageBus_T aBus, LONG aChannel, LONG aDevice, IHardDisk **aHardDisk);
|
---|
524 | STDMETHOD(DetachHardDisk) (StorageBus_T aBus, LONG aChannel, LONG aDevice);
|
---|
525 | STDMETHOD(GetSerialPort) (ULONG slot, ISerialPort **port);
|
---|
526 | STDMETHOD(GetParallelPort) (ULONG slot, IParallelPort **port);
|
---|
527 | STDMETHOD(GetNetworkAdapter) (ULONG slot, INetworkAdapter **adapter);
|
---|
528 | STDMETHOD(GetNextExtraDataKey)(INPTR BSTR aKey, BSTR *aNextKey, BSTR *aNextValue);
|
---|
529 | STDMETHOD(GetExtraData)(INPTR BSTR aKey, BSTR *aValue);
|
---|
530 | STDMETHOD(SetExtraData)(INPTR BSTR aKey, INPTR BSTR aValue);
|
---|
531 | STDMETHOD(SaveSettings)();
|
---|
532 | STDMETHOD(SaveSettingsWithBackup) (BSTR *aBakFileName);
|
---|
533 | STDMETHOD(DiscardSettings)();
|
---|
534 | STDMETHOD(DeleteSettings)();
|
---|
535 | STDMETHOD(GetSnapshot) (INPTR GUIDPARAM aId, ISnapshot **aSnapshot);
|
---|
536 | STDMETHOD(FindSnapshot) (INPTR BSTR aName, ISnapshot **aSnapshot);
|
---|
537 | STDMETHOD(SetCurrentSnapshot) (INPTR GUIDPARAM aId);
|
---|
538 | STDMETHOD(CreateSharedFolder) (INPTR BSTR aName, INPTR BSTR aHostPath, BOOL aWritable);
|
---|
539 | STDMETHOD(RemoveSharedFolder) (INPTR BSTR aName);
|
---|
540 | STDMETHOD(CanShowConsoleWindow) (BOOL *aCanShow);
|
---|
541 | STDMETHOD(ShowConsoleWindow) (ULONG64 *aWinId);
|
---|
542 | STDMETHOD(GetGuestProperty) (INPTR BSTR aName, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
|
---|
543 | STDMETHOD(GetGuestPropertyValue) (INPTR BSTR aName, BSTR *aValue);
|
---|
544 | STDMETHOD(GetGuestPropertyTimestamp) (INPTR BSTR aName, ULONG64 *aTimestamp);
|
---|
545 | STDMETHOD(SetGuestProperty) (INPTR BSTR aName, INPTR BSTR aValue, INPTR BSTR aFlags);
|
---|
546 | STDMETHOD(SetGuestPropertyValue) (INPTR BSTR aName, INPTR BSTR aValue);
|
---|
547 | STDMETHOD(EnumerateGuestProperties) (INPTR BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
|
---|
548 |
|
---|
549 | // public methods only for internal purposes
|
---|
550 |
|
---|
551 | /// @todo (dmik) add lock and make non-inlined after revising classes
|
---|
552 | // that use it. Note: they should enter Machine lock to keep the returned
|
---|
553 | // information valid!
|
---|
554 | bool isRegistered() { return !!mData->mRegistered; }
|
---|
555 |
|
---|
556 | ComObjPtr <SessionMachine> sessionMachine();
|
---|
557 |
|
---|
558 | /**
|
---|
559 | * Returns the VirtualBox object this machine belongs to.
|
---|
560 | *
|
---|
561 | * @note This method doesn't check this object's readiness as it is
|
---|
562 | * intended to be used only by Machine children where it is guaranteed
|
---|
563 | * that this object still exists in memory.
|
---|
564 | */
|
---|
565 | const ComObjPtr <VirtualBox, ComWeakRef> &virtualBox() const { return mParent; }
|
---|
566 |
|
---|
567 | /**
|
---|
568 | * Returns this machine's name.
|
---|
569 | *
|
---|
570 | * @note This method doesn't check this object's readiness as it is
|
---|
571 | * intended to be used only after adding a caller to this object (that
|
---|
572 | * guarantees that the object is ready or at least limited).
|
---|
573 | */
|
---|
574 | const Guid &uuid() const { return mData->mUuid; }
|
---|
575 |
|
---|
576 | /**
|
---|
577 | * Returns this machine's full settings file path.
|
---|
578 | *
|
---|
579 | * @note This method doesn't lock this object or check its readiness as
|
---|
580 | * it is intended to be used only after adding a caller to this object
|
---|
581 | * (that guarantees that the object is ready) and locking it for reading.
|
---|
582 | */
|
---|
583 | const Bstr &settingsFileFull() const { return mData->mConfigFileFull; }
|
---|
584 |
|
---|
585 | /**
|
---|
586 | * Returns this machine's name.
|
---|
587 | *
|
---|
588 | * @note This method doesn't lock this object or check its readiness as
|
---|
589 | * it is intended to be used only after adding a caller to this object
|
---|
590 | * (that guarantees that the object is ready) and locking it for reading.
|
---|
591 | */
|
---|
592 | const Bstr &name() const { return mUserData->mName; }
|
---|
593 |
|
---|
594 | // callback handlers
|
---|
595 | virtual HRESULT onDVDDriveChange() { return S_OK; }
|
---|
596 | virtual HRESULT onFloppyDriveChange() { return S_OK; }
|
---|
597 | virtual HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter) { return S_OK; }
|
---|
598 | virtual HRESULT onSerialPortChange(ISerialPort *serialPort) { return S_OK; }
|
---|
599 | virtual HRESULT onParallelPortChange(IParallelPort *ParallelPort) { return S_OK; }
|
---|
600 | virtual HRESULT onVRDPServerChange() { return S_OK; }
|
---|
601 | virtual HRESULT onUSBControllerChange() { return S_OK; }
|
---|
602 | virtual HRESULT onSATAControllerChange() { return S_OK; }
|
---|
603 | virtual HRESULT onSharedFolderChange() { return S_OK; }
|
---|
604 |
|
---|
605 | HRESULT saveRegistryEntry (settings::Key &aEntryNode);
|
---|
606 |
|
---|
607 | int calculateFullPath (const char *aPath, Utf8Str &aResult);
|
---|
608 | void calculateRelativePath (const char *aPath, Utf8Str &aResult);
|
---|
609 |
|
---|
610 | void getLogFolder (Utf8Str &aLogFolder);
|
---|
611 |
|
---|
612 | bool isDVDImageUsed (const Guid &aId, ResourceUsage_T aUsage);
|
---|
613 | bool isFloppyImageUsed (const Guid &aId, ResourceUsage_T aUsage);
|
---|
614 |
|
---|
615 | HRESULT openSession (IInternalSessionControl *aControl);
|
---|
616 | HRESULT openRemoteSession (IInternalSessionControl *aControl,
|
---|
617 | INPTR BSTR aType, INPTR BSTR aEnvironment,
|
---|
618 | Progress *aProgress);
|
---|
619 | HRESULT openExistingSession (IInternalSessionControl *aControl);
|
---|
620 |
|
---|
621 | HRESULT trySetRegistered (BOOL aRegistered);
|
---|
622 |
|
---|
623 | HRESULT getSharedFolder (const BSTR aName,
|
---|
624 | ComObjPtr <SharedFolder> &aSharedFolder,
|
---|
625 | bool aSetError = false)
|
---|
626 | {
|
---|
627 | AutoWriteLock alock (this);
|
---|
628 | return findSharedFolder (aName, aSharedFolder, aSetError);
|
---|
629 | }
|
---|
630 |
|
---|
631 | HRESULT addStateDependency (StateDependency aDepType = AnyStateDep,
|
---|
632 | MachineState_T *aState = NULL,
|
---|
633 | BOOL *aRegistered = NULL);
|
---|
634 | void releaseStateDependency();
|
---|
635 |
|
---|
636 | // for VirtualBoxSupportErrorInfoImpl
|
---|
637 | static const wchar_t *getComponentName() { return L"Machine"; }
|
---|
638 |
|
---|
639 | protected:
|
---|
640 |
|
---|
641 | enum InstanceType { IsMachine, IsSessionMachine, IsSnapshotMachine };
|
---|
642 |
|
---|
643 | HRESULT registeredInit();
|
---|
644 |
|
---|
645 | HRESULT checkStateDependency (StateDependency aDepType);
|
---|
646 |
|
---|
647 | inline Machine *machine();
|
---|
648 |
|
---|
649 | HRESULT initDataAndChildObjects();
|
---|
650 | void uninitDataAndChildObjects();
|
---|
651 |
|
---|
652 | void ensureNoStateDependencies (AutoWriteLock &aLock);
|
---|
653 |
|
---|
654 | virtual HRESULT setMachineState (MachineState_T aMachineState);
|
---|
655 |
|
---|
656 | HRESULT findSharedFolder (const BSTR aName,
|
---|
657 | ComObjPtr <SharedFolder> &aSharedFolder,
|
---|
658 | bool aSetError = false);
|
---|
659 |
|
---|
660 | HRESULT loadSettings (bool aRegistered);
|
---|
661 | HRESULT loadSnapshot (const settings::Key &aNode, const Guid &aCurSnapshotId,
|
---|
662 | Snapshot *aParentSnapshot);
|
---|
663 | HRESULT loadHardware (const settings::Key &aNode);
|
---|
664 | HRESULT loadHardDisks (const settings::Key &aNode, bool aRegistered,
|
---|
665 | const Guid *aSnapshotId = NULL);
|
---|
666 |
|
---|
667 | HRESULT findSnapshotNode (Snapshot *aSnapshot, settings::Key &aMachineNode,
|
---|
668 | settings::Key *aSnapshotsNode,
|
---|
669 | settings::Key *aSnapshotNode);
|
---|
670 |
|
---|
671 | HRESULT findSnapshot (const Guid &aId, ComObjPtr <Snapshot> &aSnapshot,
|
---|
672 | bool aSetError = false);
|
---|
673 | HRESULT findSnapshot (const BSTR aName, ComObjPtr <Snapshot> &aSnapshot,
|
---|
674 | bool aSetError = false);
|
---|
675 |
|
---|
676 | HRESULT findHardDiskAttachment (const ComObjPtr <HardDisk> &aHd,
|
---|
677 | ComObjPtr <Machine> *aMachine,
|
---|
678 | ComObjPtr <Snapshot> *aSnapshot,
|
---|
679 | ComObjPtr <HardDiskAttachment> *aHda);
|
---|
680 |
|
---|
681 | HRESULT prepareSaveSettings (bool &aRenamed, bool &aNew);
|
---|
682 | HRESULT saveSettings (bool aMarkCurStateAsModified = true,
|
---|
683 | bool aInformCallbacksAnyway = false);
|
---|
684 |
|
---|
685 | enum
|
---|
686 | {
|
---|
687 | // ops for #saveSnapshotSettings()
|
---|
688 | SaveSS_NoOp = 0x00, SaveSS_AddOp = 0x01,
|
---|
689 | SaveSS_UpdateAttrsOp = 0x02, SaveSS_UpdateAllOp = 0x03,
|
---|
690 | SaveSS_OpMask = 0xF,
|
---|
691 | // flags for #saveSnapshotSettings()
|
---|
692 | SaveSS_UpdateCurStateModified = 0x40,
|
---|
693 | SaveSS_UpdateCurrentId = 0x80,
|
---|
694 | // flags for #saveStateSettings()
|
---|
695 | SaveSTS_CurStateModified = 0x20,
|
---|
696 | SaveSTS_StateFilePath = 0x40,
|
---|
697 | SaveSTS_StateTimeStamp = 0x80,
|
---|
698 | };
|
---|
699 |
|
---|
700 | HRESULT saveSnapshotSettings (Snapshot *aSnapshot, int aOpFlags);
|
---|
701 | HRESULT saveSnapshotSettingsWorker (settings::Key &aMachineNode,
|
---|
702 | Snapshot *aSnapshot, int aOpFlags);
|
---|
703 |
|
---|
704 | HRESULT saveSnapshot (settings::Key &aNode, Snapshot *aSnapshot, bool aAttrsOnly);
|
---|
705 | HRESULT saveHardware (settings::Key &aNode);
|
---|
706 | HRESULT saveHardDisks (settings::Key &aNode);
|
---|
707 |
|
---|
708 | HRESULT saveStateSettings (int aFlags);
|
---|
709 |
|
---|
710 | HRESULT wipeOutImmutableDiffs();
|
---|
711 |
|
---|
712 | HRESULT fixupHardDisks (bool aCommit);
|
---|
713 |
|
---|
714 | HRESULT createSnapshotDiffs (const Guid *aSnapshotId,
|
---|
715 | const Bstr &aFolder,
|
---|
716 | const ComObjPtr <Progress> &aProgress,
|
---|
717 | bool aOnline);
|
---|
718 | HRESULT deleteSnapshotDiffs (const ComObjPtr <Snapshot> &aSnapshot);
|
---|
719 |
|
---|
720 | HRESULT lockConfig();
|
---|
721 | HRESULT unlockConfig();
|
---|
722 |
|
---|
723 | /** @note This method is not thread safe */
|
---|
724 | BOOL isConfigLocked()
|
---|
725 | {
|
---|
726 | return !!mData && mData->mHandleCfgFile != NIL_RTFILE;
|
---|
727 | }
|
---|
728 |
|
---|
729 | bool isInOwnDir (Utf8Str *aSettingsDir = NULL);
|
---|
730 |
|
---|
731 | bool isModified();
|
---|
732 | bool isReallyModified (bool aIgnoreUserData = false);
|
---|
733 | void rollback (bool aNotify);
|
---|
734 | HRESULT commit();
|
---|
735 | void copyFrom (Machine *aThat);
|
---|
736 |
|
---|
737 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
738 | void registerMetrics (PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
|
---|
739 | void unregisterMetrics (PerformanceCollector *aCollector, Machine *aMachine);
|
---|
740 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
741 |
|
---|
742 | const InstanceType mType;
|
---|
743 |
|
---|
744 | const ComObjPtr <Machine, ComWeakRef> mPeer;
|
---|
745 |
|
---|
746 | const ComObjPtr <VirtualBox, ComWeakRef> mParent;
|
---|
747 |
|
---|
748 | Shareable <Data> mData;
|
---|
749 | Shareable <SSData> mSSData;
|
---|
750 |
|
---|
751 | Backupable <UserData> mUserData;
|
---|
752 | Backupable <HWData> mHWData;
|
---|
753 | Backupable <HDData> mHDData;
|
---|
754 |
|
---|
755 | // the following fields need special backup/rollback/commit handling,
|
---|
756 | // so they cannot be a part of HWData
|
---|
757 |
|
---|
758 | const ComObjPtr <VRDPServer> mVRDPServer;
|
---|
759 | const ComObjPtr <DVDDrive> mDVDDrive;
|
---|
760 | const ComObjPtr <FloppyDrive> mFloppyDrive;
|
---|
761 | const ComObjPtr <SerialPort>
|
---|
762 | mSerialPorts [SchemaDefs::SerialPortCount];
|
---|
763 | const ComObjPtr <ParallelPort>
|
---|
764 | mParallelPorts [SchemaDefs::ParallelPortCount];
|
---|
765 | const ComObjPtr <AudioAdapter> mAudioAdapter;
|
---|
766 | const ComObjPtr <USBController> mUSBController;
|
---|
767 | const ComObjPtr <SATAController> mSATAController;
|
---|
768 | const ComObjPtr <BIOSSettings> mBIOSSettings;
|
---|
769 | const ComObjPtr <NetworkAdapter>
|
---|
770 | mNetworkAdapters [SchemaDefs::NetworkAdapterCount];
|
---|
771 |
|
---|
772 | friend class SessionMachine;
|
---|
773 | friend class SnapshotMachine;
|
---|
774 | };
|
---|
775 |
|
---|
776 | // SessionMachine class
|
---|
777 | ////////////////////////////////////////////////////////////////////////////////
|
---|
778 |
|
---|
779 | /**
|
---|
780 | * @note Notes on locking objects of this class:
|
---|
781 | * SessionMachine shares some data with the primary Machine instance (pointed
|
---|
782 | * to by the |mPeer| member). In order to provide data consistency it also
|
---|
783 | * shares its lock handle. This means that whenever you lock a SessionMachine
|
---|
784 | * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
|
---|
785 | * instance is also locked in the same lock mode. Keep it in mind.
|
---|
786 | */
|
---|
787 | class ATL_NO_VTABLE SessionMachine :
|
---|
788 | public VirtualBoxSupportTranslation <SessionMachine>,
|
---|
789 | public Machine,
|
---|
790 | public IInternalMachineControl
|
---|
791 | {
|
---|
792 | public:
|
---|
793 |
|
---|
794 | VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SessionMachine)
|
---|
795 |
|
---|
796 | DECLARE_NOT_AGGREGATABLE(SessionMachine)
|
---|
797 |
|
---|
798 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
799 |
|
---|
800 | BEGIN_COM_MAP(SessionMachine)
|
---|
801 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
802 | COM_INTERFACE_ENTRY(IMachine)
|
---|
803 | COM_INTERFACE_ENTRY(IInternalMachineControl)
|
---|
804 | END_COM_MAP()
|
---|
805 |
|
---|
806 | NS_DECL_ISUPPORTS
|
---|
807 |
|
---|
808 | DECLARE_EMPTY_CTOR_DTOR (SessionMachine)
|
---|
809 |
|
---|
810 | HRESULT FinalConstruct();
|
---|
811 | void FinalRelease();
|
---|
812 |
|
---|
813 | // public initializer/uninitializer for internal purposes only
|
---|
814 | HRESULT init (Machine *aMachine);
|
---|
815 | void uninit() { uninit (Uninit::Unexpected); }
|
---|
816 |
|
---|
817 | // util::Lockable interface
|
---|
818 | RWLockHandle *lockHandle() const;
|
---|
819 |
|
---|
820 | // IInternalMachineControl methods
|
---|
821 | STDMETHOD(UpdateState)(MachineState_T machineState);
|
---|
822 | STDMETHOD(GetIPCId)(BSTR *id);
|
---|
823 | STDMETHOD(RunUSBDeviceFilters) (IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
|
---|
824 | STDMETHOD(CaptureUSBDevice) (INPTR GUIDPARAM aId);
|
---|
825 | STDMETHOD(DetachUSBDevice) (INPTR GUIDPARAM aId, BOOL aDone);
|
---|
826 | STDMETHOD(AutoCaptureUSBDevices)();
|
---|
827 | STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
|
---|
828 | STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
|
---|
829 | STDMETHOD(BeginSavingState) (IProgress *aProgress, BSTR *aStateFilePath);
|
---|
830 | STDMETHOD(EndSavingState) (BOOL aSuccess);
|
---|
831 | STDMETHOD(AdoptSavedState) (INPTR BSTR aSavedStateFile);
|
---|
832 | STDMETHOD(BeginTakingSnapshot) (IConsole *aInitiator,
|
---|
833 | INPTR BSTR aName, INPTR BSTR aDescription,
|
---|
834 | IProgress *aProgress, BSTR *aStateFilePath,
|
---|
835 | IProgress **aServerProgress);
|
---|
836 | STDMETHOD(EndTakingSnapshot) (BOOL aSuccess);
|
---|
837 | STDMETHOD(DiscardSnapshot) (IConsole *aInitiator, INPTR GUIDPARAM aId,
|
---|
838 | MachineState_T *aMachineState, IProgress **aProgress);
|
---|
839 | STDMETHOD(DiscardCurrentState) (
|
---|
840 | IConsole *aInitiator, MachineState_T *aMachineState, IProgress **aProgress);
|
---|
841 | STDMETHOD(DiscardCurrentSnapshotAndState) (
|
---|
842 | IConsole *aInitiator, MachineState_T *aMachineState, IProgress **aProgress);
|
---|
843 | STDMETHOD(PullGuestProperties) (ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
|
---|
844 | ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
|
---|
845 | STDMETHOD(PushGuestProperties) (ComSafeArrayIn(INPTR BSTR, aNames), ComSafeArrayIn(INPTR BSTR, aValues),
|
---|
846 | ComSafeArrayIn(ULONG64, aTimestamps), ComSafeArrayIn(INPTR BSTR, aFlags));
|
---|
847 |
|
---|
848 | // public methods only for internal purposes
|
---|
849 |
|
---|
850 | bool checkForDeath();
|
---|
851 |
|
---|
852 | #if defined (RT_OS_WINDOWS)
|
---|
853 | HANDLE ipcSem() { return mIPCSem; }
|
---|
854 | #elif defined (RT_OS_OS2)
|
---|
855 | HMTX ipcSem() { return mIPCSem; }
|
---|
856 | #endif
|
---|
857 |
|
---|
858 | HRESULT onDVDDriveChange();
|
---|
859 | HRESULT onFloppyDriveChange();
|
---|
860 | HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter);
|
---|
861 | HRESULT onSerialPortChange(ISerialPort *serialPort);
|
---|
862 | HRESULT onParallelPortChange(IParallelPort *parallelPort);
|
---|
863 | HRESULT onVRDPServerChange();
|
---|
864 | HRESULT onUSBControllerChange();
|
---|
865 | HRESULT onUSBDeviceAttach (IUSBDevice *aDevice,
|
---|
866 | IVirtualBoxErrorInfo *aError,
|
---|
867 | ULONG aMaskedIfs);
|
---|
868 | HRESULT onUSBDeviceDetach (INPTR GUIDPARAM aId,
|
---|
869 | IVirtualBoxErrorInfo *aError);
|
---|
870 | HRESULT onSharedFolderChange();
|
---|
871 |
|
---|
872 | bool hasMatchingUSBFilter (const ComObjPtr <HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
|
---|
873 |
|
---|
874 | private:
|
---|
875 |
|
---|
876 | struct SnapshotData
|
---|
877 | {
|
---|
878 | SnapshotData() : mLastState (MachineState_Null) {}
|
---|
879 |
|
---|
880 | MachineState_T mLastState;
|
---|
881 |
|
---|
882 | // used when taking snapshot
|
---|
883 | ComObjPtr <Snapshot> mSnapshot;
|
---|
884 | ComObjPtr <Progress> mServerProgress;
|
---|
885 | ComObjPtr <CombinedProgress> mCombinedProgress;
|
---|
886 |
|
---|
887 | // used when saving state
|
---|
888 | Guid mProgressId;
|
---|
889 | Bstr mStateFilePath;
|
---|
890 | };
|
---|
891 |
|
---|
892 | struct Uninit {
|
---|
893 | enum Reason { Unexpected, Abnormal, Normal };
|
---|
894 | };
|
---|
895 |
|
---|
896 | struct Task;
|
---|
897 | struct TakeSnapshotTask;
|
---|
898 | struct DiscardSnapshotTask;
|
---|
899 | struct DiscardCurrentStateTask;
|
---|
900 |
|
---|
901 | friend struct TakeSnapshotTask;
|
---|
902 | friend struct DiscardSnapshotTask;
|
---|
903 | friend struct DiscardCurrentStateTask;
|
---|
904 |
|
---|
905 | void uninit (Uninit::Reason aReason);
|
---|
906 |
|
---|
907 | HRESULT endSavingState (BOOL aSuccess);
|
---|
908 | HRESULT endTakingSnapshot (BOOL aSuccess);
|
---|
909 |
|
---|
910 | typedef std::map <ComObjPtr <Machine>, MachineState_T> AffectedMachines;
|
---|
911 |
|
---|
912 | void takeSnapshotHandler (TakeSnapshotTask &aTask);
|
---|
913 | void discardSnapshotHandler (DiscardSnapshotTask &aTask);
|
---|
914 | void discardCurrentStateHandler (DiscardCurrentStateTask &aTask);
|
---|
915 |
|
---|
916 | HRESULT setMachineState (MachineState_T aMachineState);
|
---|
917 | HRESULT updateMachineStateOnClient();
|
---|
918 |
|
---|
919 | SnapshotData mSnapshotData;
|
---|
920 |
|
---|
921 | /** interprocess semaphore handle (id) for this machine */
|
---|
922 | #if defined(RT_OS_WINDOWS)
|
---|
923 | HANDLE mIPCSem;
|
---|
924 | Bstr mIPCSemName;
|
---|
925 | #elif defined(RT_OS_OS2)
|
---|
926 | HMTX mIPCSem;
|
---|
927 | Bstr mIPCSemName;
|
---|
928 | #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
|
---|
929 | int mIPCSem;
|
---|
930 | #else
|
---|
931 | # error "Port me!"
|
---|
932 | #endif
|
---|
933 |
|
---|
934 | static DECLCALLBACK(int) taskHandler (RTTHREAD thread, void *pvUser);
|
---|
935 | };
|
---|
936 |
|
---|
937 | // SnapshotMachine class
|
---|
938 | ////////////////////////////////////////////////////////////////////////////////
|
---|
939 |
|
---|
940 | /**
|
---|
941 | * @note Notes on locking objects of this class:
|
---|
942 | * SnapshotMachine shares some data with the primary Machine instance (pointed
|
---|
943 | * to by the |mPeer| member). In order to provide data consistency it also
|
---|
944 | * shares its lock handle. This means that whenever you lock a SessionMachine
|
---|
945 | * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
|
---|
946 | * instance is also locked in the same lock mode. Keep it in mind.
|
---|
947 | */
|
---|
948 | class ATL_NO_VTABLE SnapshotMachine :
|
---|
949 | public VirtualBoxSupportTranslation <SnapshotMachine>,
|
---|
950 | public Machine
|
---|
951 | {
|
---|
952 | public:
|
---|
953 |
|
---|
954 | VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SnapshotMachine)
|
---|
955 |
|
---|
956 | DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
|
---|
957 |
|
---|
958 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
959 |
|
---|
960 | BEGIN_COM_MAP(SnapshotMachine)
|
---|
961 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
962 | COM_INTERFACE_ENTRY(IMachine)
|
---|
963 | END_COM_MAP()
|
---|
964 |
|
---|
965 | NS_DECL_ISUPPORTS
|
---|
966 |
|
---|
967 | DECLARE_EMPTY_CTOR_DTOR (SnapshotMachine)
|
---|
968 |
|
---|
969 | HRESULT FinalConstruct();
|
---|
970 | void FinalRelease();
|
---|
971 |
|
---|
972 | // public initializer/uninitializer for internal purposes only
|
---|
973 | HRESULT init (SessionMachine *aSessionMachine,
|
---|
974 | INPTR GUIDPARAM aSnapshotId, INPTR BSTR aStateFilePath);
|
---|
975 | HRESULT init (Machine *aMachine,
|
---|
976 | const settings::Key &aHWNode, const settings::Key &aHDAsNode,
|
---|
977 | INPTR GUIDPARAM aSnapshotId, INPTR BSTR aStateFilePath);
|
---|
978 | void uninit();
|
---|
979 |
|
---|
980 | // util::Lockable interface
|
---|
981 | RWLockHandle *lockHandle() const;
|
---|
982 |
|
---|
983 | // public methods only for internal purposes
|
---|
984 |
|
---|
985 | HRESULT onSnapshotChange (Snapshot *aSnapshot);
|
---|
986 |
|
---|
987 | private:
|
---|
988 |
|
---|
989 | Guid mSnapshotId;
|
---|
990 |
|
---|
991 | friend class Snapshot;
|
---|
992 | };
|
---|
993 |
|
---|
994 | ////////////////////////////////////////////////////////////////////////////////
|
---|
995 |
|
---|
996 | /**
|
---|
997 | * Returns a pointer to the Machine object for this machine that acts like a
|
---|
998 | * parent for complex machine data objects such as shared folders, etc.
|
---|
999 | *
|
---|
1000 | * For primary Machine objects and for SnapshotMachine objects, returns this
|
---|
1001 | * object's pointer itself. For SessoinMachine objects, returns the peer
|
---|
1002 | * (primary) machine pointer.
|
---|
1003 | */
|
---|
1004 | inline Machine *Machine::machine()
|
---|
1005 | {
|
---|
1006 | if (mType == IsSessionMachine)
|
---|
1007 | return mPeer;
|
---|
1008 | return this;
|
---|
1009 | }
|
---|
1010 |
|
---|
1011 | COM_DECL_READONLY_ENUM_AND_COLLECTION (Machine)
|
---|
1012 |
|
---|
1013 | #endif // ____H_MACHINEIMPL
|
---|