VirtualBox

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

最後變更 在這個檔案從22173是 22173,由 vboxsync 提交於 16 年 前

Main: the big XML settings rework. Move XML reading/writing out of interface implementation code into separate layer so it can handle individual settings versions in the future.

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

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