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