VirtualBox

source: vbox/trunk/src/VBox/Main/include/MachineImpl.h@ 21968

Last change on this file since 21968 was 21961, checked in by vboxsync, 16 years ago

NetworkAttachment: trigger the network attachment change only when AttachTo* API are called

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

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