VirtualBox

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

Last change on this file since 27823 was 27823, checked in by vboxsync, 15 years ago

More cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 41.7 KB
Line 
1/* $Id: MachineImpl.h 27823 2010-03-30 13:11:16Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class declaration
6 */
7
8/*
9 * Copyright (C) 2006-2010 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 "SnapshotImpl.h"
29#include "VRDPServerImpl.h"
30#include "MediumAttachmentImpl.h"
31#include "NetworkAdapterImpl.h"
32#include "AudioAdapterImpl.h"
33#include "SerialPortImpl.h"
34#include "ParallelPortImpl.h"
35#include "BIOSSettingsImpl.h"
36#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
37#include "VBox/settings.h"
38#ifdef VBOX_WITH_RESOURCE_USAGE_API
39#include "PerformanceImpl.h"
40#endif /* VBOX_WITH_RESOURCE_USAGE_API */
41
42// generated header
43#include "SchemaDefs.h"
44
45#include <VBox/types.h>
46
47#include <iprt/file.h>
48#include <iprt/thread.h>
49#include <iprt/time.h>
50
51#include <list>
52
53// defines
54////////////////////////////////////////////////////////////////////////////////
55
56// helper declarations
57////////////////////////////////////////////////////////////////////////////////
58
59class Progress;
60class Keyboard;
61class Mouse;
62class Display;
63class MachineDebugger;
64class USBController;
65class Snapshot;
66class SharedFolder;
67class HostUSBDevice;
68class StorageController;
69
70class SessionMachine;
71
72namespace settings
73{
74 class MachineConfigFile;
75 struct Snapshot;
76 struct Hardware;
77 struct Storage;
78 struct StorageController;
79 struct MachineRegistryEntry;
80}
81
82// Machine class
83////////////////////////////////////////////////////////////////////////////////
84
85class ATL_NO_VTABLE Machine :
86 public VirtualBoxBaseWithChildrenNEXT,
87 public VirtualBoxSupportErrorInfoImpl<Machine, IMachine>,
88 public VirtualBoxSupportTranslation<Machine>,
89 VBOX_SCRIPTABLE_IMPL(IMachine)
90{
91 Q_OBJECT
92
93public:
94
95 enum InitMode { Init_New, Init_Import, Init_Registered };
96
97 enum StateDependency
98 {
99 AnyStateDep = 0, MutableStateDep, MutableOrSavedStateDep
100 };
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 /** Guest properties have been modified and need saving since the
188 * machine was started, or there are transient properties which need
189 * deleting and the machine is being shut down. */
190 BOOL mGuestPropertiesModified;
191
192 RTFILE mHandleCfgFile;
193
194 Session mSession;
195
196 ComObjPtr<Snapshot> mFirstSnapshot;
197 ComObjPtr<Snapshot> mCurrentSnapshot;
198 };
199
200 /**
201 * Saved state data.
202 *
203 * It's actually only the state file path string, but it needs to be
204 * separate from Data, because Machine and SessionMachine instances
205 * share it, while SnapshotMachine does not.
206 *
207 * The data variable is |mSSData|.
208 */
209 struct SSData
210 {
211 Utf8Str mStateFilePath;
212 };
213
214 /**
215 * User changeable machine data.
216 *
217 * This data is common for all machine snapshots, i.e. it is shared
218 * by all SnapshotMachine instances associated with the given machine
219 * using the util::Backupable template through the |mUserData| variable.
220 *
221 * SessionMachine instances can alter this data and discard changes.
222 *
223 * @note There is no need to lock anything inside init() or uninit()
224 * methods, because they are always serialized (see AutoCaller).
225 */
226 struct UserData
227 {
228 UserData();
229 ~UserData();
230
231 Bstr mName;
232 BOOL mNameSync;
233 Bstr mDescription;
234 Bstr mOSTypeId;
235 Bstr mSnapshotFolder;
236 Bstr mSnapshotFolderFull;
237 BOOL mTeleporterEnabled;
238 ULONG mTeleporterPort;
239 Bstr mTeleporterAddress;
240 Bstr mTeleporterPassword;
241 BOOL mRTCUseUTC;
242 };
243
244 /**
245 * Hardware data.
246 *
247 * This data is unique for a machine and for every machine snapshot.
248 * Stored using the util::Backupable template in the |mHWData| variable.
249 *
250 * SessionMachine instances can alter this data and discard changes.
251 */
252 struct HWData
253 {
254 /**
255 * Data structure to hold information about a guest property.
256 */
257 struct GuestProperty {
258 /** Property name */
259 Utf8Str strName;
260 /** Property value */
261 Utf8Str strValue;
262 /** Property timestamp */
263 ULONG64 mTimestamp;
264 /** Property flags */
265 ULONG mFlags;
266 };
267
268 HWData();
269 ~HWData();
270
271 Bstr mHWVersion;
272 Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
273 ULONG mMemorySize;
274 ULONG mMemoryBalloonSize;
275 ULONG mVRAMSize;
276 ULONG mMonitorCount;
277 BOOL mHWVirtExEnabled;
278 BOOL mHWVirtExExclusive;
279 BOOL mHWVirtExNestedPagingEnabled;
280 BOOL mHWVirtExLargePagesEnabled;
281 BOOL mHWVirtExVPIDEnabled;
282 BOOL mAccelerate2DVideoEnabled;
283 BOOL mPAEEnabled;
284 BOOL mSyntheticCpu;
285 ULONG mCPUCount;
286 BOOL mCPUHotPlugEnabled;
287 BOOL mAccelerate3DEnabled;
288 BOOL mHpetEnabled;
289
290 BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
291
292 settings::CpuIdLeaf mCpuIdStdLeafs[10];
293 settings::CpuIdLeaf mCpuIdExtLeafs[10];
294
295 DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
296
297 typedef std::list< ComObjPtr<SharedFolder> > SharedFolderList;
298 SharedFolderList mSharedFolders;
299
300 ClipboardMode_T mClipboardMode;
301
302 typedef std::list<GuestProperty> GuestPropertyList;
303 GuestPropertyList mGuestProperties;
304 Utf8Str mGuestPropertyNotificationPatterns;
305
306 FirmwareType_T mFirmwareType;
307 KeyboardHidType_T mKeyboardHidType;
308 PointingHidType_T mPointingHidType;
309
310 IoMgrType_T mIoMgrType;
311 IoBackendType_T mIoBackendType;
312 BOOL mIoCacheEnabled;
313 ULONG mIoCacheSize;
314 ULONG mIoBandwidthMax;
315 };
316
317 /**
318 * Hard disk and other media data.
319 *
320 * The usage policy is the same as for HWData, but a separate structure
321 * is necessary because hard disk data requires different procedures when
322 * taking or discarding snapshots, etc.
323 *
324 * The data variable is |mMediaData|.
325 */
326 struct MediaData
327 {
328 MediaData();
329 ~MediaData();
330
331 typedef std::list< ComObjPtr<MediumAttachment> > AttachmentList;
332 AttachmentList mAttachments;
333 };
334
335 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine)
336
337 DECLARE_NOT_AGGREGATABLE(Machine)
338
339 DECLARE_PROTECT_FINAL_CONSTRUCT()
340
341 BEGIN_COM_MAP(Machine)
342 COM_INTERFACE_ENTRY(ISupportErrorInfo)
343 COM_INTERFACE_ENTRY(IMachine)
344 COM_INTERFACE_ENTRY(IDispatch)
345 END_COM_MAP()
346
347 DECLARE_EMPTY_CTOR_DTOR(Machine)
348
349 HRESULT FinalConstruct();
350 void FinalRelease();
351
352 // public initializer/uninitializer for internal purposes only
353 HRESULT init(VirtualBox *aParent,
354 const Utf8Str &strConfigFile,
355 InitMode aMode,
356 CBSTR aName = NULL,
357 GuestOSType *aOsType = NULL,
358 BOOL aOverride = FALSE,
359 BOOL aNameSync = TRUE,
360 const Guid *aId = NULL);
361 void uninit();
362
363protected:
364 HRESULT initDataAndChildObjects();
365 void uninitDataAndChildObjects();
366
367public:
368 // IMachine properties
369 STDMETHOD(COMGETTER(Parent))(IVirtualBox **aParent);
370 STDMETHOD(COMGETTER(Accessible))(BOOL *aAccessible);
371 STDMETHOD(COMGETTER(AccessError))(IVirtualBoxErrorInfo **aAccessError);
372 STDMETHOD(COMGETTER(Name))(BSTR *aName);
373 STDMETHOD(COMSETTER(Name))(IN_BSTR aName);
374 STDMETHOD(COMGETTER(Description))(BSTR *aDescription);
375 STDMETHOD(COMSETTER(Description))(IN_BSTR aDescription);
376 STDMETHOD(COMGETTER(Id))(BSTR *aId);
377 STDMETHOD(COMGETTER(OSTypeId))(BSTR *aOSTypeId);
378 STDMETHOD(COMSETTER(OSTypeId))(IN_BSTR aOSTypeId);
379 STDMETHOD(COMGETTER(HardwareVersion))(BSTR *aVersion);
380 STDMETHOD(COMSETTER(HardwareVersion))(IN_BSTR aVersion);
381 STDMETHOD(COMGETTER(HardwareUUID))(BSTR *aUUID);
382 STDMETHOD(COMSETTER(HardwareUUID))(IN_BSTR aUUID);
383 STDMETHOD(COMGETTER(MemorySize))(ULONG *memorySize);
384 STDMETHOD(COMSETTER(MemorySize))(ULONG memorySize);
385 STDMETHOD(COMGETTER(CPUCount))(ULONG *cpuCount);
386 STDMETHOD(COMSETTER(CPUCount))(ULONG cpuCount);
387 STDMETHOD(COMGETTER(CPUHotPlugEnabled))(BOOL *enabled);
388 STDMETHOD(COMSETTER(CPUHotPlugEnabled))(BOOL enabled);
389 STDMETHOD(COMGETTER(HpetEnabled))(BOOL *enabled);
390 STDMETHOD(COMSETTER(HpetEnabled))(BOOL enabled);
391 STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
392 STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
393 STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
394 STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
395 STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
396 STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
397 STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *enabled);
398 STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL enabled);
399 STDMETHOD(COMGETTER(Accelerate2DVideoEnabled))(BOOL *enabled);
400 STDMETHOD(COMSETTER(Accelerate2DVideoEnabled))(BOOL enabled);
401 STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
402 STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
403 STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
404 STDMETHOD(COMGETTER(MediumAttachments))(ComSafeArrayOut(IMediumAttachment *, aAttachments));
405 STDMETHOD(COMGETTER(VRDPServer))(IVRDPServer **vrdpServer);
406 STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
407 STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
408 STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
409 STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
410 STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
411 STDMETHOD(COMGETTER(SessionType))(BSTR *aSessionType);
412 STDMETHOD(COMGETTER(SessionPid))(ULONG *aSessionPid);
413 STDMETHOD(COMGETTER(State))(MachineState_T *machineState);
414 STDMETHOD(COMGETTER(LastStateChange))(LONG64 *aLastStateChange);
415 STDMETHOD(COMGETTER(StateFilePath))(BSTR *aStateFilePath);
416 STDMETHOD(COMGETTER(LogFolder))(BSTR *aLogFolder);
417 STDMETHOD(COMGETTER(CurrentSnapshot))(ISnapshot **aCurrentSnapshot);
418 STDMETHOD(COMGETTER(SnapshotCount))(ULONG *aSnapshotCount);
419 STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
420 STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
421 STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
422 STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
423 STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
424 STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
425 STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
426 STDMETHOD(COMGETTER(TeleporterEnabled))(BOOL *aEnabled);
427 STDMETHOD(COMSETTER(TeleporterEnabled))(BOOL aEnabled);
428 STDMETHOD(COMGETTER(TeleporterPort))(ULONG *aPort);
429 STDMETHOD(COMSETTER(TeleporterPort))(ULONG aPort);
430 STDMETHOD(COMGETTER(TeleporterAddress))(BSTR *aAddress);
431 STDMETHOD(COMSETTER(TeleporterAddress))(IN_BSTR aAddress);
432 STDMETHOD(COMGETTER(TeleporterPassword))(BSTR *aPassword);
433 STDMETHOD(COMSETTER(TeleporterPassword))(IN_BSTR aPassword);
434 STDMETHOD(COMGETTER(RTCUseUTC))(BOOL *aEnabled);
435 STDMETHOD(COMSETTER(RTCUseUTC))(BOOL aEnabled);
436 STDMETHOD(COMGETTER(FirmwareType)) (FirmwareType_T *aFirmware);
437 STDMETHOD(COMSETTER(FirmwareType)) (FirmwareType_T aFirmware);
438 STDMETHOD(COMGETTER(KeyboardHidType)) (KeyboardHidType_T *aKeyboardHidType);
439 STDMETHOD(COMSETTER(KeyboardHidType)) (KeyboardHidType_T aKeyboardHidType);
440 STDMETHOD(COMGETTER(PointingHidType)) (PointingHidType_T *aPointingHidType);
441 STDMETHOD(COMSETTER(PointingHidType)) (PointingHidType_T aPointingHidType);
442 STDMETHOD(COMGETTER(IoMgr)) (IoMgrType_T *aIoMgrType);
443 STDMETHOD(COMSETTER(IoMgr)) (IoMgrType_T aIoMgrType);
444 STDMETHOD(COMGETTER(IoBackend)) (IoBackendType_T *aIoBackendType);
445 STDMETHOD(COMSETTER(IoBackend)) (IoBackendType_T aIoBackendType);
446 STDMETHOD(COMGETTER(IoCacheEnabled)) (BOOL *aEnabled);
447 STDMETHOD(COMSETTER(IoCacheEnabled)) (BOOL aEnabled);
448 STDMETHOD(COMGETTER(IoCacheSize)) (ULONG *aIoCacheSize);
449 STDMETHOD(COMSETTER(IoCacheSize)) (ULONG aIoCacheSize);
450 STDMETHOD(COMGETTER(IoBandwidthMax)) (ULONG *aIoBandwidthMax);
451 STDMETHOD(COMSETTER(IoBandwidthMax)) (ULONG aIoBandwidthMax);
452
453 // IMachine methods
454 STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
455 STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
456 STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort,
457 LONG aDevice, DeviceType_T aType, IN_BSTR aId);
458 STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
459 STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
460 STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
461 LONG aDevice, IN_BSTR aId, BOOL aForce);
462 STDMETHOD(GetMedium)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice,
463 IMedium **aMedium);
464 STDMETHOD(GetSerialPort)(ULONG slot, ISerialPort **port);
465 STDMETHOD(GetParallelPort)(ULONG slot, IParallelPort **port);
466 STDMETHOD(GetNetworkAdapter)(ULONG slot, INetworkAdapter **adapter);
467 STDMETHOD(GetExtraDataKeys)(ComSafeArrayOut(BSTR, aKeys));
468 STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
469 STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
470 STDMETHOD(GetCPUProperty)(CPUPropertyType_T property, BOOL *aVal);
471 STDMETHOD(SetCPUProperty)(CPUPropertyType_T property, BOOL aVal);
472 STDMETHOD(GetCPUIDLeaf)(ULONG id, ULONG *aValEax, ULONG *aValEbx, ULONG *aValEcx, ULONG *aValEdx);
473 STDMETHOD(SetCPUIDLeaf)(ULONG id, ULONG aValEax, ULONG aValEbx, ULONG aValEcx, ULONG aValEdx);
474 STDMETHOD(RemoveCPUIDLeaf)(ULONG id);
475 STDMETHOD(RemoveAllCPUIDLeaves)();
476 STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
477 STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
478 STDMETHOD(SaveSettings)();
479 STDMETHOD(DiscardSettings)();
480 STDMETHOD(DeleteSettings)();
481 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription);
482 STDMETHOD(GetSnapshot)(IN_BSTR aId, ISnapshot **aSnapshot);
483 STDMETHOD(FindSnapshot)(IN_BSTR aName, ISnapshot **aSnapshot);
484 STDMETHOD(SetCurrentSnapshot)(IN_BSTR aId);
485 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
486 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
487 STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
488 STDMETHOD(ShowConsoleWindow)(ULONG64 *aWinId);
489 STDMETHOD(GetGuestProperty)(IN_BSTR aName, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
490 STDMETHOD(GetGuestPropertyValue)(IN_BSTR aName, BSTR *aValue);
491 STDMETHOD(GetGuestPropertyTimestamp)(IN_BSTR aName, ULONG64 *aTimestamp);
492 STDMETHOD(SetGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
493 STDMETHOD(SetGuestPropertyValue)(IN_BSTR aName, IN_BSTR aValue);
494 STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
495 STDMETHOD(GetMediumAttachmentsOfController)(IN_BSTR aName, ComSafeArrayOut(IMediumAttachment *, aAttachments));
496 STDMETHOD(GetMediumAttachment)(IN_BSTR aConstrollerName, LONG aControllerPort, LONG aDevice, IMediumAttachment **aAttachment);
497 STDMETHOD(AddStorageController)(IN_BSTR aName, StorageBus_T aConnectionType, IStorageController **controller);
498 STDMETHOD(RemoveStorageController(IN_BSTR aName));
499 STDMETHOD(GetStorageControllerByName(IN_BSTR aName, IStorageController **storageController));
500 STDMETHOD(GetStorageControllerByInstance(ULONG aInstance, IStorageController **storageController));
501 STDMETHOD(QuerySavedThumbnailSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
502 STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
503 STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
504 STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
505 STDMETHOD(HotPlugCPU(ULONG aCpu));
506 STDMETHOD(HotUnplugCPU(ULONG aCpu));
507 STDMETHOD(GetCPUStatus(ULONG aCpu, BOOL *aCpuAttached));
508 STDMETHOD(ReadLog(ULONG aIdx, ULONG64 aOffset, ULONG64 aSize, ComSafeArrayOut(BYTE, aData)));
509
510 // public methods only for internal purposes
511
512 /**
513 * Simple run-time type identification without having to enable C++ RTTI.
514 * The class IDs are defined in VirtualBoxBase.h.
515 * @return
516 */
517 virtual VBoxClsID getClassID() const
518 {
519 return clsidMachine;
520 }
521
522 /**
523 * Override of the default locking class to be used for validating lock
524 * order with the standard member lock handle.
525 */
526 virtual VBoxLockingClass getLockingClass() const
527 {
528 return LOCKCLASS_MACHINEOBJECT;
529 }
530
531 /// @todo (dmik) add lock and make non-inlined after revising classes
532 // that use it. Note: they should enter Machine lock to keep the returned
533 // information valid!
534 bool isRegistered() { return !!mData->mRegistered; }
535
536 // unsafe inline public methods for internal purposes only (ensure there is
537 // a caller and a read lock before calling them!)
538
539 /**
540 * Returns the VirtualBox object this machine belongs to.
541 *
542 * @note This method doesn't check this object's readiness. Intended to be
543 * used by ready Machine children (whose readiness is bound to the parent's
544 * one) or after doing addCaller() manually.
545 */
546 VirtualBox* getVirtualBox() const { return mParent; }
547
548 /**
549 * Returns this machine ID.
550 *
551 * @note This method doesn't check this object's readiness. Intended to be
552 * used by ready Machine children (whose readiness is bound to the parent's
553 * one) or after adding a caller manually.
554 */
555 const Guid& getId() const { return mData->mUuid; }
556
557 /**
558 * Returns the snapshot ID this machine represents or an empty UUID if this
559 * instance is not SnapshotMachine.
560 *
561 * @note This method doesn't check this object's readiness. Intended to be
562 * used by ready Machine children (whose readiness is bound to the parent's
563 * one) or after adding a caller manually.
564 */
565 inline const Guid& getSnapshotId() const;
566
567 /**
568 * Returns this machine's full settings file path.
569 *
570 * @note This method doesn't lock this object or check its readiness.
571 * Intended to be used only after doing addCaller() manually and locking it
572 * for reading.
573 */
574 const Utf8Str& getSettingsFileFull() const { return mData->m_strConfigFileFull; }
575
576 /**
577 * Returns this machine name.
578 *
579 * @note This method doesn't lock this object or check its readiness.
580 * Intended to be used only after doing addCaller() manually and locking it
581 * for reading.
582 */
583 const Bstr& getName() const { return mUserData->mName; }
584
585 enum
586 {
587 IsModified_MachineData = 0x0001,
588 IsModified_Storage = 0x0002,
589 IsModified_NetworkAdapters = 0x0008,
590 IsModified_SerialPorts = 0x0010,
591 IsModified_ParallelPorts = 0x0020,
592 IsModified_VRDPServer = 0x0040,
593 IsModified_AudioAdapter = 0x0080,
594 IsModified_USB = 0x0100,
595 IsModified_BIOS = 0x0200,
596 IsModified_SharedFolders = 0x0400
597 };
598
599 void setModified(uint32_t fl);
600
601 // callback handlers
602 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
603 virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
604 virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
605 virtual HRESULT onVRDPServerChange() { return S_OK; }
606 virtual HRESULT onUSBControllerChange() { return S_OK; }
607 virtual HRESULT onStorageControllerChange() { return S_OK; }
608 virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
609 virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
610 virtual HRESULT onSharedFolderChange() { return S_OK; }
611
612 HRESULT saveRegistryEntry(settings::MachineRegistryEntry &data);
613
614 int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
615 void calculateRelativePath(const Utf8Str &strPath, Utf8Str &aResult);
616
617 void getLogFolder(Utf8Str &aLogFolder);
618
619 HRESULT openSession(IInternalSessionControl *aControl);
620 HRESULT openRemoteSession(IInternalSessionControl *aControl,
621 IN_BSTR aType, IN_BSTR aEnvironment,
622 Progress *aProgress);
623 HRESULT openExistingSession(IInternalSessionControl *aControl);
624
625#if defined(RT_OS_WINDOWS)
626
627 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
628 ComPtr<IInternalSessionControl> *aControl = NULL,
629 HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
630 bool isSessionSpawning(RTPROCESS *aPID = NULL);
631
632 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
633 ComPtr<IInternalSessionControl> *aControl = NULL,
634 HANDLE *aIPCSem = NULL)
635 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
636
637#elif defined(RT_OS_OS2)
638
639 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
640 ComPtr<IInternalSessionControl> *aControl = NULL,
641 HMTX *aIPCSem = NULL, bool aAllowClosing = false);
642
643 bool isSessionSpawning(RTPROCESS *aPID = NULL);
644
645 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
646 ComPtr<IInternalSessionControl> *aControl = NULL,
647 HMTX *aIPCSem = NULL)
648 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
649
650#else
651
652 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
653 ComPtr<IInternalSessionControl> *aControl = NULL,
654 bool aAllowClosing = false);
655 bool isSessionSpawning();
656
657 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
658 ComPtr<IInternalSessionControl> *aControl = NULL)
659 { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
660
661#endif
662
663 bool checkForSpawnFailure();
664
665 HRESULT trySetRegistered(BOOL aRegistered);
666
667 HRESULT getSharedFolder(CBSTR aName,
668 ComObjPtr<SharedFolder> &aSharedFolder,
669 bool aSetError = false)
670 {
671 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
672 return findSharedFolder(aName, aSharedFolder, aSetError);
673 }
674
675 HRESULT addStateDependency(StateDependency aDepType = AnyStateDep,
676 MachineState_T *aState = NULL,
677 BOOL *aRegistered = NULL);
678 void releaseStateDependency();
679
680 // for VirtualBoxSupportErrorInfoImpl
681 static const wchar_t *getComponentName() { return L"Machine"; }
682
683protected:
684
685 HRESULT registeredInit();
686
687 HRESULT checkStateDependency(StateDependency aDepType);
688
689 Machine *getMachine();
690
691 void ensureNoStateDependencies();
692
693 virtual HRESULT setMachineState(MachineState_T aMachineState);
694
695 HRESULT findSharedFolder(CBSTR aName,
696 ComObjPtr<SharedFolder> &aSharedFolder,
697 bool aSetError = false);
698
699 HRESULT loadSettings(bool aRegistered);
700 HRESULT loadSnapshot(const settings::Snapshot &data,
701 const Guid &aCurSnapshotId,
702 Snapshot *aParentSnapshot);
703 HRESULT loadHardware(const settings::Hardware &data);
704 HRESULT loadStorageControllers(const settings::Storage &data,
705 bool aRegistered,
706 const Guid *aSnapshotId = NULL);
707 HRESULT loadStorageDevices(StorageController *aStorageController,
708 const settings::StorageController &data,
709 bool aRegistered,
710 const Guid *aSnapshotId = NULL);
711
712 HRESULT findSnapshot(const Guid &aId, ComObjPtr<Snapshot> &aSnapshot,
713 bool aSetError = false);
714 HRESULT findSnapshot(IN_BSTR aName, ComObjPtr<Snapshot> &aSnapshot,
715 bool aSetError = false);
716
717 HRESULT getStorageControllerByName(const Utf8Str &aName,
718 ComObjPtr<StorageController> &aStorageController,
719 bool aSetError = false);
720
721 HRESULT getMediumAttachmentsOfController(CBSTR aName,
722 MediaData::AttachmentList &aAttachments);
723
724 enum
725 {
726 /* flags for #saveSettings() */
727 SaveS_ResetCurStateModified = 0x01,
728 SaveS_InformCallbacksAnyway = 0x02,
729 SaveS_Force = 0x04,
730 /* flags for #saveStateSettings() */
731 SaveSTS_CurStateModified = 0x20,
732 SaveSTS_StateFilePath = 0x40,
733 SaveSTS_StateTimeStamp = 0x80,
734 };
735
736 HRESULT prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
737 HRESULT saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
738
739 HRESULT saveAllSnapshots();
740
741 HRESULT saveHardware(settings::Hardware &data);
742 HRESULT saveStorageControllers(settings::Storage &data);
743 HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController,
744 settings::StorageController &data);
745
746 HRESULT saveStateSettings(int aFlags);
747
748 HRESULT createImplicitDiffs(const Bstr &aFolder,
749 IProgress *aProgress,
750 ULONG aWeight,
751 bool aOnline,
752 bool *pfNeedsSaveSettings);
753 HRESULT deleteImplicitDiffs(bool *pfNeedsSaveSettings);
754
755 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
756 IN_BSTR aControllerName,
757 LONG aControllerPort,
758 LONG aDevice);
759 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
760 ComObjPtr<Medium> pMedium);
761 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
762 Guid &id);
763
764 void commitMedia(bool aOnline = false);
765 void rollbackMedia();
766
767 bool isInOwnDir(Utf8Str *aSettingsDir = NULL);
768
769 void rollback(bool aNotify);
770 void commit();
771 void copyFrom(Machine *aThat);
772
773#ifdef VBOX_WITH_GUEST_PROPS
774 HRESULT GetGuestPropertyFromService(IN_BSTR aName, BSTR *aValue,
775 ULONG64 *aTimestamp, BSTR *aFlags);
776 HRESULT GetGuestPropertyFromVM(IN_BSTR aName, BSTR *aValue,
777 ULONG64 *aTimestamp, BSTR *aFlags);
778 HRESULT SetGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
779 IN_BSTR aFlags);
780 HRESULT SetGuestPropertyToVM(IN_BSTR aName, IN_BSTR aValue,
781 IN_BSTR aFlags);
782 HRESULT EnumerateGuestPropertiesInService
783 (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
784 ComSafeArrayOut(BSTR, aValues),
785 ComSafeArrayOut(ULONG64, aTimestamps),
786 ComSafeArrayOut(BSTR, aFlags));
787 HRESULT EnumerateGuestPropertiesOnVM
788 (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
789 ComSafeArrayOut(BSTR, aValues),
790 ComSafeArrayOut(ULONG64, aTimestamps),
791 ComSafeArrayOut(BSTR, aFlags));
792#endif /* VBOX_WITH_GUEST_PROPS */
793
794#ifdef VBOX_WITH_RESOURCE_USAGE_API
795 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
796 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
797#endif /* VBOX_WITH_RESOURCE_USAGE_API */
798
799 Machine* const mPeer;
800
801 VirtualBox* const mParent;
802
803 uint32_t m_flModifications;
804
805 Shareable<Data> mData;
806 Shareable<SSData> mSSData;
807
808 Backupable<UserData> mUserData;
809 Backupable<HWData> mHWData;
810 Backupable<MediaData> mMediaData;
811
812 // the following fields need special backup/rollback/commit handling,
813 // so they cannot be a part of HWData
814
815 const ComObjPtr<VRDPServer> mVRDPServer;
816 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
817 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
818 const ComObjPtr<AudioAdapter> mAudioAdapter;
819 const ComObjPtr<USBController> mUSBController;
820 const ComObjPtr<BIOSSettings> mBIOSSettings;
821 const ComObjPtr<NetworkAdapter> mNetworkAdapters[SchemaDefs::NetworkAdapterCount];
822
823 typedef std::list< ComObjPtr<StorageController> > StorageControllerList;
824 Backupable<StorageControllerList> mStorageControllers;
825
826 friend class SessionMachine;
827 friend class SnapshotMachine;
828};
829
830// SessionMachine class
831////////////////////////////////////////////////////////////////////////////////
832
833/**
834 * @note Notes on locking objects of this class:
835 * SessionMachine shares some data with the primary Machine instance (pointed
836 * to by the |mPeer| member). In order to provide data consistency it also
837 * shares its lock handle. This means that whenever you lock a SessionMachine
838 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
839 * instance is also locked in the same lock mode. Keep it in mind.
840 */
841class ATL_NO_VTABLE SessionMachine :
842 public VirtualBoxSupportTranslation<SessionMachine>,
843 public Machine,
844 VBOX_SCRIPTABLE_IMPL(IInternalMachineControl)
845{
846public:
847
848 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SessionMachine)
849
850 DECLARE_NOT_AGGREGATABLE(SessionMachine)
851
852 DECLARE_PROTECT_FINAL_CONSTRUCT()
853
854 BEGIN_COM_MAP(SessionMachine)
855 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
856 COM_INTERFACE_ENTRY(ISupportErrorInfo)
857 COM_INTERFACE_ENTRY(IMachine)
858 COM_INTERFACE_ENTRY(IInternalMachineControl)
859 END_COM_MAP()
860
861 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
862
863 HRESULT FinalConstruct();
864 void FinalRelease();
865
866 // public initializer/uninitializer for internal purposes only
867 HRESULT init(Machine *aMachine);
868 void uninit() { uninit(Uninit::Unexpected); }
869
870 // util::Lockable interface
871 RWLockHandle *lockHandle() const;
872
873 // IInternalMachineControl methods
874 STDMETHOD(SetRemoveSavedState)(BOOL aRemove);
875 STDMETHOD(UpdateState)(MachineState_T machineState);
876 STDMETHOD(GetIPCId)(BSTR *id);
877 STDMETHOD(SetPowerUpInfo)(IVirtualBoxErrorInfo *aError);
878 STDMETHOD(RunUSBDeviceFilters)(IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
879 STDMETHOD(CaptureUSBDevice)(IN_BSTR aId);
880 STDMETHOD(DetachUSBDevice)(IN_BSTR aId, BOOL aDone);
881 STDMETHOD(AutoCaptureUSBDevices)();
882 STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
883 STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
884 STDMETHOD(BeginSavingState)(IProgress *aProgress, BSTR *aStateFilePath);
885 STDMETHOD(EndSavingState)(BOOL aSuccess);
886 STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
887 STDMETHOD(BeginTakingSnapshot)(IConsole *aInitiator,
888 IN_BSTR aName,
889 IN_BSTR aDescription,
890 IProgress *aConsoleProgress,
891 BOOL fTakingSnapshotOnline,
892 BSTR *aStateFilePath);
893 STDMETHOD(EndTakingSnapshot)(BOOL aSuccess);
894 STDMETHOD(DeleteSnapshot)(IConsole *aInitiator, IN_BSTR aId,
895 MachineState_T *aMachineState, IProgress **aProgress);
896 STDMETHOD(RestoreSnapshot)(IConsole *aInitiator,
897 ISnapshot *aSnapshot,
898 MachineState_T *aMachineState,
899 IProgress **aProgress);
900 STDMETHOD(PullGuestProperties)(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
901 ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
902 STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue,
903 ULONG64 aTimestamp, IN_BSTR aFlags);
904 STDMETHOD(LockMedia)() { return lockMedia(); }
905 STDMETHOD(UnlockMedia)() { unlockMedia(); return S_OK; }
906
907 // public methods only for internal purposes
908
909 /**
910 * Simple run-time type identification without having to enable C++ RTTI.
911 * The class IDs are defined in VirtualBoxBase.h.
912 * @return
913 */
914 virtual VBoxClsID getClassID() const
915 {
916 return clsidSessionMachine;
917 }
918
919 bool checkForDeath();
920
921 HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
922 HRESULT onStorageControllerChange();
923 HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
924 HRESULT onSerialPortChange(ISerialPort *serialPort);
925 HRESULT onParallelPortChange(IParallelPort *parallelPort);
926 HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
927 HRESULT onVRDPServerChange();
928 HRESULT onUSBControllerChange();
929 HRESULT onUSBDeviceAttach(IUSBDevice *aDevice,
930 IVirtualBoxErrorInfo *aError,
931 ULONG aMaskedIfs);
932 HRESULT onUSBDeviceDetach(IN_BSTR aId,
933 IVirtualBoxErrorInfo *aError);
934 HRESULT onSharedFolderChange();
935
936 bool hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
937
938private:
939
940 struct SnapshotData
941 {
942 SnapshotData() : mLastState(MachineState_Null) {}
943
944 MachineState_T mLastState;
945
946 // used when taking snapshot
947 ComObjPtr<Snapshot> mSnapshot;
948
949 // used when saving state
950 Guid mProgressId;
951 Utf8Str mStateFilePath;
952 };
953
954 struct Uninit
955 {
956 enum Reason { Unexpected, Abnormal, Normal };
957 };
958
959 struct SnapshotTask;
960 struct DeleteSnapshotTask;
961 struct RestoreSnapshotTask;
962
963 friend struct DeleteSnapshotTask;
964 friend struct RestoreSnapshotTask;
965
966 void uninit(Uninit::Reason aReason);
967
968 HRESULT endSavingState(BOOL aSuccess);
969
970 typedef std::map<ComObjPtr<Machine>, MachineState_T> AffectedMachines;
971
972 void deleteSnapshotHandler(DeleteSnapshotTask &aTask);
973 void restoreSnapshotHandler(RestoreSnapshotTask &aTask);
974
975 HRESULT lockMedia();
976 void unlockMedia();
977
978 HRESULT setMachineState(MachineState_T aMachineState);
979 HRESULT updateMachineStateOnClient();
980
981 HRESULT mRemoveSavedState;
982
983 SnapshotData mSnapshotData;
984
985 /** interprocess semaphore handle for this machine */
986#if defined(RT_OS_WINDOWS)
987 HANDLE mIPCSem;
988 Bstr mIPCSemName;
989 friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
990 ComPtr<IInternalSessionControl> *aControl,
991 HANDLE *aIPCSem, bool aAllowClosing);
992#elif defined(RT_OS_OS2)
993 HMTX mIPCSem;
994 Bstr mIPCSemName;
995 friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
996 ComPtr<IInternalSessionControl> *aControl,
997 HMTX *aIPCSem, bool aAllowClosing);
998#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
999 int mIPCSem;
1000# ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
1001 Bstr mIPCKey;
1002# endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */
1003#else
1004# error "Port me!"
1005#endif
1006
1007 static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
1008};
1009
1010// SnapshotMachine class
1011////////////////////////////////////////////////////////////////////////////////
1012
1013/**
1014 * @note Notes on locking objects of this class:
1015 * SnapshotMachine shares some data with the primary Machine instance (pointed
1016 * to by the |mPeer| member). In order to provide data consistency it also
1017 * shares its lock handle. This means that whenever you lock a SessionMachine
1018 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1019 * instance is also locked in the same lock mode. Keep it in mind.
1020 */
1021class ATL_NO_VTABLE SnapshotMachine :
1022 public VirtualBoxSupportTranslation<SnapshotMachine>,
1023 public Machine
1024{
1025public:
1026
1027 VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE(SnapshotMachine)
1028
1029 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1030
1031 DECLARE_PROTECT_FINAL_CONSTRUCT()
1032
1033 BEGIN_COM_MAP(SnapshotMachine)
1034 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1035 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1036 COM_INTERFACE_ENTRY(IMachine)
1037 END_COM_MAP()
1038
1039 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1040
1041 HRESULT FinalConstruct();
1042 void FinalRelease();
1043
1044 // public initializer/uninitializer for internal purposes only
1045 HRESULT init(SessionMachine *aSessionMachine,
1046 IN_GUID aSnapshotId,
1047 const Utf8Str &aStateFilePath);
1048 HRESULT init(Machine *aMachine,
1049 const settings::Hardware &hardware,
1050 const settings::Storage &storage,
1051 IN_GUID aSnapshotId,
1052 const Utf8Str &aStateFilePath);
1053 void uninit();
1054
1055 // util::Lockable interface
1056 RWLockHandle *lockHandle() const;
1057
1058 // public methods only for internal purposes
1059
1060 /**
1061 * Simple run-time type identification without having to enable C++ RTTI.
1062 * The class IDs are defined in VirtualBoxBase.h.
1063 * @return
1064 */
1065 virtual VBoxClsID getClassID() const
1066 {
1067 return clsidSnapshotMachine;
1068 }
1069
1070 HRESULT onSnapshotChange(Snapshot *aSnapshot);
1071
1072 // unsafe inline public methods for internal purposes only (ensure there is
1073 // a caller and a read lock before calling them!)
1074
1075 const Guid& getSnapshotId() const { return mSnapshotId; }
1076
1077private:
1078
1079 Guid mSnapshotId;
1080
1081 friend class Snapshot;
1082};
1083
1084// third party methods that depend on SnapshotMachine definiton
1085
1086inline const Guid &Machine::getSnapshotId() const
1087{
1088 return getClassID() != clsidSnapshotMachine
1089 ? Guid::Empty
1090 : static_cast<const SnapshotMachine*>(this)->getSnapshotId();
1091}
1092
1093
1094#endif // ____H_MACHINEIMPL
1095/* 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