VirtualBox

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

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

Main/GuestProperties: cleaned up and fixed a problem with accessibility of properties after a VM shutdown

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 42.0 KB
Line 
1/* $Id: MachineImpl.h 27818 2010-03-30 11:50:21Z 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 mStatisticsUpdateInterval;
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(StatisticsUpdateInterval))(ULONG *statisticsUpdateInterval);
395 STDMETHOD(COMSETTER(StatisticsUpdateInterval))(ULONG statisticsUpdateInterval);
396 STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
397 STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
398 STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
399 STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
400 STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *enabled);
401 STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL enabled);
402 STDMETHOD(COMGETTER(Accelerate2DVideoEnabled))(BOOL *enabled);
403 STDMETHOD(COMSETTER(Accelerate2DVideoEnabled))(BOOL enabled);
404 STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
405 STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
406 STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
407 STDMETHOD(COMGETTER(MediumAttachments))(ComSafeArrayOut(IMediumAttachment *, aAttachments));
408 STDMETHOD(COMGETTER(VRDPServer))(IVRDPServer **vrdpServer);
409 STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
410 STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
411 STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
412 STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
413 STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
414 STDMETHOD(COMGETTER(SessionType))(BSTR *aSessionType);
415 STDMETHOD(COMGETTER(SessionPid))(ULONG *aSessionPid);
416 STDMETHOD(COMGETTER(State))(MachineState_T *machineState);
417 STDMETHOD(COMGETTER(LastStateChange))(LONG64 *aLastStateChange);
418 STDMETHOD(COMGETTER(StateFilePath))(BSTR *aStateFilePath);
419 STDMETHOD(COMGETTER(LogFolder))(BSTR *aLogFolder);
420 STDMETHOD(COMGETTER(CurrentSnapshot))(ISnapshot **aCurrentSnapshot);
421 STDMETHOD(COMGETTER(SnapshotCount))(ULONG *aSnapshotCount);
422 STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
423 STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
424 STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
425 STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
426 STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
427 STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
428 STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
429 STDMETHOD(COMGETTER(TeleporterEnabled))(BOOL *aEnabled);
430 STDMETHOD(COMSETTER(TeleporterEnabled))(BOOL aEnabled);
431 STDMETHOD(COMGETTER(TeleporterPort))(ULONG *aPort);
432 STDMETHOD(COMSETTER(TeleporterPort))(ULONG aPort);
433 STDMETHOD(COMGETTER(TeleporterAddress))(BSTR *aAddress);
434 STDMETHOD(COMSETTER(TeleporterAddress))(IN_BSTR aAddress);
435 STDMETHOD(COMGETTER(TeleporterPassword))(BSTR *aPassword);
436 STDMETHOD(COMSETTER(TeleporterPassword))(IN_BSTR aPassword);
437 STDMETHOD(COMGETTER(RTCUseUTC))(BOOL *aEnabled);
438 STDMETHOD(COMSETTER(RTCUseUTC))(BOOL aEnabled);
439 STDMETHOD(COMGETTER(FirmwareType)) (FirmwareType_T *aFirmware);
440 STDMETHOD(COMSETTER(FirmwareType)) (FirmwareType_T aFirmware);
441 STDMETHOD(COMGETTER(KeyboardHidType)) (KeyboardHidType_T *aKeyboardHidType);
442 STDMETHOD(COMSETTER(KeyboardHidType)) (KeyboardHidType_T aKeyboardHidType);
443 STDMETHOD(COMGETTER(PointingHidType)) (PointingHidType_T *aPointingHidType);
444 STDMETHOD(COMSETTER(PointingHidType)) (PointingHidType_T aPointingHidType);
445 STDMETHOD(COMGETTER(IoMgr)) (IoMgrType_T *aIoMgrType);
446 STDMETHOD(COMSETTER(IoMgr)) (IoMgrType_T aIoMgrType);
447 STDMETHOD(COMGETTER(IoBackend)) (IoBackendType_T *aIoBackendType);
448 STDMETHOD(COMSETTER(IoBackend)) (IoBackendType_T aIoBackendType);
449 STDMETHOD(COMGETTER(IoCacheEnabled)) (BOOL *aEnabled);
450 STDMETHOD(COMSETTER(IoCacheEnabled)) (BOOL aEnabled);
451 STDMETHOD(COMGETTER(IoCacheSize)) (ULONG *aIoCacheSize);
452 STDMETHOD(COMSETTER(IoCacheSize)) (ULONG aIoCacheSize);
453 STDMETHOD(COMGETTER(IoBandwidthMax)) (ULONG *aIoBandwidthMax);
454 STDMETHOD(COMSETTER(IoBandwidthMax)) (ULONG aIoBandwidthMax);
455
456 // IMachine methods
457 STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
458 STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
459 STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort,
460 LONG aDevice, DeviceType_T aType, IN_BSTR aId);
461 STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
462 STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
463 STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
464 LONG aDevice, IN_BSTR aId, BOOL aForce);
465 STDMETHOD(GetMedium)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice,
466 IMedium **aMedium);
467 STDMETHOD(GetSerialPort)(ULONG slot, ISerialPort **port);
468 STDMETHOD(GetParallelPort)(ULONG slot, IParallelPort **port);
469 STDMETHOD(GetNetworkAdapter)(ULONG slot, INetworkAdapter **adapter);
470 STDMETHOD(GetExtraDataKeys)(ComSafeArrayOut(BSTR, aKeys));
471 STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
472 STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
473 STDMETHOD(GetCPUProperty)(CPUPropertyType_T property, BOOL *aVal);
474 STDMETHOD(SetCPUProperty)(CPUPropertyType_T property, BOOL aVal);
475 STDMETHOD(GetCPUIDLeaf)(ULONG id, ULONG *aValEax, ULONG *aValEbx, ULONG *aValEcx, ULONG *aValEdx);
476 STDMETHOD(SetCPUIDLeaf)(ULONG id, ULONG aValEax, ULONG aValEbx, ULONG aValEcx, ULONG aValEdx);
477 STDMETHOD(RemoveCPUIDLeaf)(ULONG id);
478 STDMETHOD(RemoveAllCPUIDLeaves)();
479 STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
480 STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
481 STDMETHOD(SaveSettings)();
482 STDMETHOD(DiscardSettings)();
483 STDMETHOD(DeleteSettings)();
484 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription);
485 STDMETHOD(GetSnapshot)(IN_BSTR aId, ISnapshot **aSnapshot);
486 STDMETHOD(FindSnapshot)(IN_BSTR aName, ISnapshot **aSnapshot);
487 STDMETHOD(SetCurrentSnapshot)(IN_BSTR aId);
488 STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable);
489 STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
490 STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
491 STDMETHOD(ShowConsoleWindow)(ULONG64 *aWinId);
492 STDMETHOD(GetGuestProperty)(IN_BSTR aName, BSTR *aValue, ULONG64 *aTimestamp, BSTR *aFlags);
493 STDMETHOD(GetGuestPropertyValue)(IN_BSTR aName, BSTR *aValue);
494 STDMETHOD(GetGuestPropertyTimestamp)(IN_BSTR aName, ULONG64 *aTimestamp);
495 STDMETHOD(SetGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
496 STDMETHOD(SetGuestPropertyValue)(IN_BSTR aName, IN_BSTR aValue);
497 STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(ULONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
498 STDMETHOD(GetMediumAttachmentsOfController)(IN_BSTR aName, ComSafeArrayOut(IMediumAttachment *, aAttachments));
499 STDMETHOD(GetMediumAttachment)(IN_BSTR aConstrollerName, LONG aControllerPort, LONG aDevice, IMediumAttachment **aAttachment);
500 STDMETHOD(AddStorageController)(IN_BSTR aName, StorageBus_T aConnectionType, IStorageController **controller);
501 STDMETHOD(RemoveStorageController(IN_BSTR aName));
502 STDMETHOD(GetStorageControllerByName(IN_BSTR aName, IStorageController **storageController));
503 STDMETHOD(GetStorageControllerByInstance(ULONG aInstance, IStorageController **storageController));
504 STDMETHOD(QuerySavedThumbnailSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
505 STDMETHOD(ReadSavedThumbnailToArray)(BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
506 STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
507 STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
508 STDMETHOD(HotPlugCPU(ULONG aCpu));
509 STDMETHOD(HotUnplugCPU(ULONG aCpu));
510 STDMETHOD(GetCPUStatus(ULONG aCpu, BOOL *aCpuAttached));
511 STDMETHOD(ReadLog(ULONG aIdx, ULONG64 aOffset, ULONG64 aSize, ComSafeArrayOut(BYTE, aData)));
512
513 // public methods only for internal purposes
514
515 /**
516 * Simple run-time type identification without having to enable C++ RTTI.
517 * The class IDs are defined in VirtualBoxBase.h.
518 * @return
519 */
520 virtual VBoxClsID getClassID() const
521 {
522 return clsidMachine;
523 }
524
525 /**
526 * Override of the default locking class to be used for validating lock
527 * order with the standard member lock handle.
528 */
529 virtual VBoxLockingClass getLockingClass() const
530 {
531 return LOCKCLASS_MACHINEOBJECT;
532 }
533
534 /// @todo (dmik) add lock and make non-inlined after revising classes
535 // that use it. Note: they should enter Machine lock to keep the returned
536 // information valid!
537 bool isRegistered() { return !!mData->mRegistered; }
538
539 // unsafe inline public methods for internal purposes only (ensure there is
540 // a caller and a read lock before calling them!)
541
542 /**
543 * Returns the VirtualBox object this machine belongs to.
544 *
545 * @note This method doesn't check this object's readiness. Intended to be
546 * used by ready Machine children (whose readiness is bound to the parent's
547 * one) or after doing addCaller() manually.
548 */
549 VirtualBox* getVirtualBox() const { return mParent; }
550
551 /**
552 * Returns this machine ID.
553 *
554 * @note This method doesn't check this object's readiness. Intended to be
555 * used by ready Machine children (whose readiness is bound to the parent's
556 * one) or after adding a caller manually.
557 */
558 const Guid& getId() const { return mData->mUuid; }
559
560 /**
561 * Returns the snapshot ID this machine represents or an empty UUID if this
562 * instance is not SnapshotMachine.
563 *
564 * @note This method doesn't check this object's readiness. Intended to be
565 * used by ready Machine children (whose readiness is bound to the parent's
566 * one) or after adding a caller manually.
567 */
568 inline const Guid& getSnapshotId() const;
569
570 /**
571 * Returns this machine's full settings file path.
572 *
573 * @note This method doesn't lock this object or check its readiness.
574 * Intended to be used only after doing addCaller() manually and locking it
575 * for reading.
576 */
577 const Utf8Str& getSettingsFileFull() const { return mData->m_strConfigFileFull; }
578
579 /**
580 * Returns this machine name.
581 *
582 * @note This method doesn't lock this object or check its readiness.
583 * Intended to be used only after doing addCaller() manually and locking it
584 * for reading.
585 */
586 const Bstr& getName() const { return mUserData->mName; }
587
588 enum
589 {
590 IsModified_MachineData = 0x0001,
591 IsModified_Storage = 0x0002,
592 IsModified_NetworkAdapters = 0x0008,
593 IsModified_SerialPorts = 0x0010,
594 IsModified_ParallelPorts = 0x0020,
595 IsModified_VRDPServer = 0x0040,
596 IsModified_AudioAdapter = 0x0080,
597 IsModified_USB = 0x0100,
598 IsModified_BIOS = 0x0200,
599 IsModified_SharedFolders = 0x0400
600 };
601
602 void setModified(uint32_t fl);
603
604 // callback handlers
605 virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
606 virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
607 virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
608 virtual HRESULT onVRDPServerChange() { return S_OK; }
609 virtual HRESULT onUSBControllerChange() { return S_OK; }
610 virtual HRESULT onStorageControllerChange() { return S_OK; }
611 virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
612 virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
613 virtual HRESULT onSharedFolderChange() { return S_OK; }
614
615 HRESULT saveRegistryEntry(settings::MachineRegistryEntry &data);
616
617 int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
618 void calculateRelativePath(const Utf8Str &strPath, Utf8Str &aResult);
619
620 void getLogFolder(Utf8Str &aLogFolder);
621
622 HRESULT openSession(IInternalSessionControl *aControl);
623 HRESULT openRemoteSession(IInternalSessionControl *aControl,
624 IN_BSTR aType, IN_BSTR aEnvironment,
625 Progress *aProgress);
626 HRESULT openExistingSession(IInternalSessionControl *aControl);
627
628#if defined(RT_OS_WINDOWS)
629
630 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
631 ComPtr<IInternalSessionControl> *aControl = NULL,
632 HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
633 bool isSessionSpawning(RTPROCESS *aPID = NULL);
634
635 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
636 ComPtr<IInternalSessionControl> *aControl = NULL,
637 HANDLE *aIPCSem = NULL)
638 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
639
640#elif defined(RT_OS_OS2)
641
642 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
643 ComPtr<IInternalSessionControl> *aControl = NULL,
644 HMTX *aIPCSem = NULL, bool aAllowClosing = false);
645
646 bool isSessionSpawning(RTPROCESS *aPID = NULL);
647
648 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
649 ComPtr<IInternalSessionControl> *aControl = NULL,
650 HMTX *aIPCSem = NULL)
651 { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
652
653#else
654
655 bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
656 ComPtr<IInternalSessionControl> *aControl = NULL,
657 bool aAllowClosing = false);
658 bool isSessionSpawning();
659
660 bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
661 ComPtr<IInternalSessionControl> *aControl = NULL)
662 { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
663
664#endif
665
666 bool checkForSpawnFailure();
667
668 HRESULT trySetRegistered(BOOL aRegistered);
669
670 HRESULT getSharedFolder(CBSTR aName,
671 ComObjPtr<SharedFolder> &aSharedFolder,
672 bool aSetError = false)
673 {
674 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
675 return findSharedFolder(aName, aSharedFolder, aSetError);
676 }
677
678 HRESULT addStateDependency(StateDependency aDepType = AnyStateDep,
679 MachineState_T *aState = NULL,
680 BOOL *aRegistered = NULL);
681 void releaseStateDependency();
682
683 // for VirtualBoxSupportErrorInfoImpl
684 static const wchar_t *getComponentName() { return L"Machine"; }
685
686protected:
687
688 HRESULT registeredInit();
689
690 HRESULT checkStateDependency(StateDependency aDepType);
691
692 Machine *getMachine();
693
694 void ensureNoStateDependencies();
695
696 virtual HRESULT setMachineState(MachineState_T aMachineState);
697
698 HRESULT findSharedFolder(CBSTR aName,
699 ComObjPtr<SharedFolder> &aSharedFolder,
700 bool aSetError = false);
701
702 HRESULT loadSettings(bool aRegistered);
703 HRESULT loadSnapshot(const settings::Snapshot &data,
704 const Guid &aCurSnapshotId,
705 Snapshot *aParentSnapshot);
706 HRESULT loadHardware(const settings::Hardware &data);
707 HRESULT loadStorageControllers(const settings::Storage &data,
708 bool aRegistered,
709 const Guid *aSnapshotId = NULL);
710 HRESULT loadStorageDevices(StorageController *aStorageController,
711 const settings::StorageController &data,
712 bool aRegistered,
713 const Guid *aSnapshotId = NULL);
714
715 HRESULT findSnapshot(const Guid &aId, ComObjPtr<Snapshot> &aSnapshot,
716 bool aSetError = false);
717 HRESULT findSnapshot(IN_BSTR aName, ComObjPtr<Snapshot> &aSnapshot,
718 bool aSetError = false);
719
720 HRESULT getStorageControllerByName(const Utf8Str &aName,
721 ComObjPtr<StorageController> &aStorageController,
722 bool aSetError = false);
723
724 HRESULT getMediumAttachmentsOfController(CBSTR aName,
725 MediaData::AttachmentList &aAttachments);
726
727 enum
728 {
729 /* flags for #saveSettings() */
730 SaveS_ResetCurStateModified = 0x01,
731 SaveS_InformCallbacksAnyway = 0x02,
732 SaveS_Force = 0x04,
733 /* flags for #saveStateSettings() */
734 SaveSTS_CurStateModified = 0x20,
735 SaveSTS_StateFilePath = 0x40,
736 SaveSTS_StateTimeStamp = 0x80,
737 };
738
739 HRESULT prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
740 HRESULT saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
741
742 HRESULT saveAllSnapshots();
743
744 HRESULT saveHardware(settings::Hardware &data);
745 HRESULT saveStorageControllers(settings::Storage &data);
746 HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController,
747 settings::StorageController &data);
748
749 HRESULT saveStateSettings(int aFlags);
750
751 HRESULT createImplicitDiffs(const Bstr &aFolder,
752 IProgress *aProgress,
753 ULONG aWeight,
754 bool aOnline,
755 bool *pfNeedsSaveSettings);
756 HRESULT deleteImplicitDiffs(bool *pfNeedsSaveSettings);
757
758 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
759 IN_BSTR aControllerName,
760 LONG aControllerPort,
761 LONG aDevice);
762 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
763 ComObjPtr<Medium> pMedium);
764 MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
765 Guid &id);
766
767 void commitMedia(bool aOnline = false);
768 void rollbackMedia();
769
770 bool isInOwnDir(Utf8Str *aSettingsDir = NULL);
771
772 void rollback(bool aNotify);
773 void commit();
774 void copyFrom(Machine *aThat);
775
776#ifdef VBOX_WITH_GUEST_PROPS
777 HRESULT GetGuestPropertyFromService(IN_BSTR aName, BSTR *aValue,
778 ULONG64 *aTimestamp, BSTR *aFlags);
779 HRESULT GetGuestPropertyFromVM(IN_BSTR aName, BSTR *aValue,
780 ULONG64 *aTimestamp, BSTR *aFlags);
781 HRESULT SetGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
782 IN_BSTR aFlags);
783 HRESULT SetGuestPropertyToVM(IN_BSTR aName, IN_BSTR aValue,
784 IN_BSTR aFlags);
785 HRESULT EnumerateGuestPropertiesInService
786 (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
787 ComSafeArrayOut(BSTR, aValues),
788 ComSafeArrayOut(ULONG64, aTimestamps),
789 ComSafeArrayOut(BSTR, aFlags));
790 HRESULT EnumerateGuestPropertiesOnVM
791 (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
792 ComSafeArrayOut(BSTR, aValues),
793 ComSafeArrayOut(ULONG64, aTimestamps),
794 ComSafeArrayOut(BSTR, aFlags));
795#endif /* VBOX_WITH_GUEST_PROPS */
796
797#ifdef VBOX_WITH_RESOURCE_USAGE_API
798 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
799 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
800#endif /* VBOX_WITH_RESOURCE_USAGE_API */
801
802 Machine* const mPeer;
803
804 VirtualBox* const mParent;
805
806 uint32_t m_flModifications;
807
808 Shareable<Data> mData;
809 Shareable<SSData> mSSData;
810
811 Backupable<UserData> mUserData;
812 Backupable<HWData> mHWData;
813 Backupable<MediaData> mMediaData;
814
815 // the following fields need special backup/rollback/commit handling,
816 // so they cannot be a part of HWData
817
818 const ComObjPtr<VRDPServer> mVRDPServer;
819 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
820 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
821 const ComObjPtr<AudioAdapter> mAudioAdapter;
822 const ComObjPtr<USBController> mUSBController;
823 const ComObjPtr<BIOSSettings> mBIOSSettings;
824 const ComObjPtr<NetworkAdapter> mNetworkAdapters[SchemaDefs::NetworkAdapterCount];
825
826 typedef std::list< ComObjPtr<StorageController> > StorageControllerList;
827 Backupable<StorageControllerList> mStorageControllers;
828
829 friend class SessionMachine;
830 friend class SnapshotMachine;
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.

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