VirtualBox

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

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

metrics update

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

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