1 | /* $Id: MachineImpl.h 37485 2011-06-16 08:37:49Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2011 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_MACHINEIMPL
|
---|
19 | #define ____H_MACHINEIMPL
|
---|
20 |
|
---|
21 | #include "VirtualBoxBase.h"
|
---|
22 | #include "SnapshotImpl.h"
|
---|
23 | #include "ProgressImpl.h"
|
---|
24 | #include "VRDEServerImpl.h"
|
---|
25 | #include "MediumAttachmentImpl.h"
|
---|
26 | #include "PciDeviceAttachmentImpl.h"
|
---|
27 | #include "MediumLock.h"
|
---|
28 | #include "NetworkAdapterImpl.h"
|
---|
29 | #include "AudioAdapterImpl.h"
|
---|
30 | #include "SerialPortImpl.h"
|
---|
31 | #include "ParallelPortImpl.h"
|
---|
32 | #include "BIOSSettingsImpl.h"
|
---|
33 | #include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
|
---|
34 | #include "BandwidthControlImpl.h"
|
---|
35 | #include "BandwidthGroupImpl.h"
|
---|
36 | #include "VBox/settings.h"
|
---|
37 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
38 | #include "Performance.h"
|
---|
39 | #include "PerformanceImpl.h"
|
---|
40 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
41 |
|
---|
42 | // generated header
|
---|
43 | #include "SchemaDefs.h"
|
---|
44 |
|
---|
45 | #include "VBox/com/ErrorInfo.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 |
|
---|
59 | class Progress;
|
---|
60 | class ProgressProxy;
|
---|
61 | class Keyboard;
|
---|
62 | class Mouse;
|
---|
63 | class Display;
|
---|
64 | class MachineDebugger;
|
---|
65 | class USBController;
|
---|
66 | class Snapshot;
|
---|
67 | class SharedFolder;
|
---|
68 | class HostUSBDevice;
|
---|
69 | class StorageController;
|
---|
70 |
|
---|
71 | class SessionMachine;
|
---|
72 |
|
---|
73 | namespace 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 |
|
---|
86 | class ATL_NO_VTABLE Machine :
|
---|
87 | public VirtualBoxBase,
|
---|
88 | VBOX_SCRIPTABLE_IMPL(IMachine)
|
---|
89 | {
|
---|
90 | Q_OBJECT
|
---|
91 |
|
---|
92 | public:
|
---|
93 |
|
---|
94 | enum StateDependency
|
---|
95 | {
|
---|
96 | AnyStateDep = 0, MutableStateDep, MutableOrSavedStateDep
|
---|
97 | };
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Internal machine data.
|
---|
101 | *
|
---|
102 | * Only one instance of this data exists per every machine -- it is shared
|
---|
103 | * by the Machine, SessionMachine and all SnapshotMachine instances
|
---|
104 | * associated with the given machine using the util::Shareable template
|
---|
105 | * through the mData variable.
|
---|
106 | *
|
---|
107 | * @note |const| members are persistent during lifetime so can be
|
---|
108 | * accessed without locking.
|
---|
109 | *
|
---|
110 | * @note There is no need to lock anything inside init() or uninit()
|
---|
111 | * methods, because they are always serialized (see AutoCaller).
|
---|
112 | */
|
---|
113 | struct Data
|
---|
114 | {
|
---|
115 | /**
|
---|
116 | * Data structure to hold information about sessions opened for the
|
---|
117 | * given machine.
|
---|
118 | */
|
---|
119 | struct Session
|
---|
120 | {
|
---|
121 | /** Control of the direct session opened by lockMachine() */
|
---|
122 | ComPtr<IInternalSessionControl> mDirectControl;
|
---|
123 |
|
---|
124 | typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
|
---|
125 |
|
---|
126 | /** list of controls of all opened remote sessions */
|
---|
127 | RemoteControlList mRemoteControls;
|
---|
128 |
|
---|
129 | /** launchVMProcess() and OnSessionEnd() progress indicator */
|
---|
130 | ComObjPtr<ProgressProxy> mProgress;
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * PID of the session object that must be passed to openSession()
|
---|
134 | * to finalize the launchVMProcess() request (i.e., PID of the
|
---|
135 | * process created by launchVMProcess())
|
---|
136 | */
|
---|
137 | RTPROCESS mPid;
|
---|
138 |
|
---|
139 | /** Current session state */
|
---|
140 | SessionState_T mState;
|
---|
141 |
|
---|
142 | /** Session type string (for indirect sessions) */
|
---|
143 | Bstr mType;
|
---|
144 |
|
---|
145 | /** Session machine object */
|
---|
146 | ComObjPtr<SessionMachine> mMachine;
|
---|
147 |
|
---|
148 | /** Medium object lock collection. */
|
---|
149 | MediumLockListMap mLockedMedia;
|
---|
150 | };
|
---|
151 |
|
---|
152 | Data();
|
---|
153 | ~Data();
|
---|
154 |
|
---|
155 | const Guid mUuid;
|
---|
156 | BOOL mRegistered;
|
---|
157 |
|
---|
158 | Utf8Str m_strConfigFile;
|
---|
159 | Utf8Str m_strConfigFileFull;
|
---|
160 |
|
---|
161 | // machine settings XML file
|
---|
162 | settings::MachineConfigFile *pMachineConfigFile;
|
---|
163 | uint32_t flModifications;
|
---|
164 |
|
---|
165 | BOOL mAccessible;
|
---|
166 | com::ErrorInfo mAccessError;
|
---|
167 |
|
---|
168 | MachineState_T mMachineState;
|
---|
169 | RTTIMESPEC mLastStateChange;
|
---|
170 |
|
---|
171 | /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
|
---|
172 | uint32_t mMachineStateDeps;
|
---|
173 | RTSEMEVENTMULTI mMachineStateDepsSem;
|
---|
174 | uint32_t mMachineStateChangePending;
|
---|
175 |
|
---|
176 | BOOL mCurrentStateModified;
|
---|
177 | /** Guest properties have been modified and need saving since the
|
---|
178 | * machine was started, or there are transient properties which need
|
---|
179 | * deleting and the machine is being shut down. */
|
---|
180 | BOOL mGuestPropertiesModified;
|
---|
181 |
|
---|
182 | Session mSession;
|
---|
183 |
|
---|
184 | ComObjPtr<Snapshot> mFirstSnapshot;
|
---|
185 | ComObjPtr<Snapshot> mCurrentSnapshot;
|
---|
186 |
|
---|
187 | // list of files to delete in Delete(); this list is filled by Unregister()
|
---|
188 | std::list<Utf8Str> llFilesToDelete;
|
---|
189 | };
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * Saved state data.
|
---|
193 | *
|
---|
194 | * It's actually only the state file path string, but it needs to be
|
---|
195 | * separate from Data, because Machine and SessionMachine instances
|
---|
196 | * share it, while SnapshotMachine does not.
|
---|
197 | *
|
---|
198 | * The data variable is |mSSData|.
|
---|
199 | */
|
---|
200 | struct SSData
|
---|
201 | {
|
---|
202 | Utf8Str strStateFilePath;
|
---|
203 | };
|
---|
204 |
|
---|
205 | /**
|
---|
206 | * User changeable machine data.
|
---|
207 | *
|
---|
208 | * This data is common for all machine snapshots, i.e. it is shared
|
---|
209 | * by all SnapshotMachine instances associated with the given machine
|
---|
210 | * using the util::Backupable template through the |mUserData| variable.
|
---|
211 | *
|
---|
212 | * SessionMachine instances can alter this data and discard changes.
|
---|
213 | *
|
---|
214 | * @note There is no need to lock anything inside init() or uninit()
|
---|
215 | * methods, because they are always serialized (see AutoCaller).
|
---|
216 | */
|
---|
217 | struct UserData
|
---|
218 | {
|
---|
219 | settings::MachineUserData s;
|
---|
220 | };
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * Hardware data.
|
---|
224 | *
|
---|
225 | * This data is unique for a machine and for every machine snapshot.
|
---|
226 | * Stored using the util::Backupable template in the |mHWData| variable.
|
---|
227 | *
|
---|
228 | * SessionMachine instances can alter this data and discard changes.
|
---|
229 | */
|
---|
230 | struct HWData
|
---|
231 | {
|
---|
232 | /**
|
---|
233 | * Data structure to hold information about a guest property.
|
---|
234 | */
|
---|
235 | struct GuestProperty {
|
---|
236 | /** Property name */
|
---|
237 | Utf8Str strName;
|
---|
238 | /** Property value */
|
---|
239 | Utf8Str strValue;
|
---|
240 | /** Property timestamp */
|
---|
241 | LONG64 mTimestamp;
|
---|
242 | /** Property flags */
|
---|
243 | ULONG mFlags;
|
---|
244 | };
|
---|
245 |
|
---|
246 | HWData();
|
---|
247 | ~HWData();
|
---|
248 |
|
---|
249 | Bstr mHWVersion;
|
---|
250 | Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
|
---|
251 | ULONG mMemorySize;
|
---|
252 | ULONG mMemoryBalloonSize;
|
---|
253 | BOOL mPageFusionEnabled;
|
---|
254 | ULONG mVRAMSize;
|
---|
255 | ULONG mMonitorCount;
|
---|
256 | BOOL mHWVirtExEnabled;
|
---|
257 | BOOL mHWVirtExExclusive;
|
---|
258 | BOOL mHWVirtExNestedPagingEnabled;
|
---|
259 | BOOL mHWVirtExLargePagesEnabled;
|
---|
260 | BOOL mHWVirtExVPIDEnabled;
|
---|
261 | BOOL mHWVirtExForceEnabled;
|
---|
262 | BOOL mAccelerate2DVideoEnabled;
|
---|
263 | BOOL mPAEEnabled;
|
---|
264 | BOOL mSyntheticCpu;
|
---|
265 | ULONG mCPUCount;
|
---|
266 | BOOL mCPUHotPlugEnabled;
|
---|
267 | ULONG mCpuExecutionCap;
|
---|
268 | BOOL mAccelerate3DEnabled;
|
---|
269 | BOOL mHpetEnabled;
|
---|
270 |
|
---|
271 | BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
|
---|
272 |
|
---|
273 | settings::CpuIdLeaf mCpuIdStdLeafs[10];
|
---|
274 | settings::CpuIdLeaf mCpuIdExtLeafs[10];
|
---|
275 |
|
---|
276 | DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
|
---|
277 |
|
---|
278 | typedef std::list< ComObjPtr<SharedFolder> > SharedFolderList;
|
---|
279 | SharedFolderList mSharedFolders;
|
---|
280 |
|
---|
281 | ClipboardMode_T mClipboardMode;
|
---|
282 |
|
---|
283 | typedef std::list<GuestProperty> GuestPropertyList;
|
---|
284 | GuestPropertyList mGuestProperties;
|
---|
285 | Utf8Str mGuestPropertyNotificationPatterns;
|
---|
286 |
|
---|
287 | FirmwareType_T mFirmwareType;
|
---|
288 | KeyboardHidType_T mKeyboardHidType;
|
---|
289 | PointingHidType_T mPointingHidType;
|
---|
290 | ChipsetType_T mChipsetType;
|
---|
291 |
|
---|
292 | BOOL mIoCacheEnabled;
|
---|
293 | ULONG mIoCacheSize;
|
---|
294 |
|
---|
295 | typedef std::list< ComObjPtr<PciDeviceAttachment> > PciDeviceAssignmentList;
|
---|
296 | PciDeviceAssignmentList mPciDeviceAssignments;
|
---|
297 | };
|
---|
298 |
|
---|
299 | /**
|
---|
300 | * Hard disk and other media data.
|
---|
301 | *
|
---|
302 | * The usage policy is the same as for HWData, but a separate structure
|
---|
303 | * is necessary because hard disk data requires different procedures when
|
---|
304 | * taking or deleting snapshots, etc.
|
---|
305 | *
|
---|
306 | * The data variable is |mMediaData|.
|
---|
307 | */
|
---|
308 | struct MediaData
|
---|
309 | {
|
---|
310 | MediaData();
|
---|
311 | ~MediaData();
|
---|
312 |
|
---|
313 | typedef std::list< ComObjPtr<MediumAttachment> > AttachmentList;
|
---|
314 | AttachmentList mAttachments;
|
---|
315 | };
|
---|
316 |
|
---|
317 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Machine, IMachine)
|
---|
318 |
|
---|
319 | DECLARE_NOT_AGGREGATABLE(Machine)
|
---|
320 |
|
---|
321 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
322 |
|
---|
323 | BEGIN_COM_MAP(Machine)
|
---|
324 | VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
|
---|
325 | END_COM_MAP()
|
---|
326 |
|
---|
327 | DECLARE_EMPTY_CTOR_DTOR(Machine)
|
---|
328 |
|
---|
329 | HRESULT FinalConstruct();
|
---|
330 | void FinalRelease();
|
---|
331 |
|
---|
332 | // public initializer/uninitializer for internal purposes only:
|
---|
333 |
|
---|
334 | // initializer for creating a new, empty machine
|
---|
335 | HRESULT init(VirtualBox *aParent,
|
---|
336 | const Utf8Str &strConfigFile,
|
---|
337 | const Utf8Str &strName,
|
---|
338 | GuestOSType *aOsType,
|
---|
339 | const Guid &aId,
|
---|
340 | bool fForceOverwrite);
|
---|
341 |
|
---|
342 | // initializer for loading existing machine XML (either registered or not)
|
---|
343 | HRESULT init(VirtualBox *aParent,
|
---|
344 | const Utf8Str &strConfigFile,
|
---|
345 | const Guid *aId);
|
---|
346 |
|
---|
347 | // initializer for machine config in memory (OVF import)
|
---|
348 | HRESULT init(VirtualBox *aParent,
|
---|
349 | const Utf8Str &strName,
|
---|
350 | const settings::MachineConfigFile &config);
|
---|
351 |
|
---|
352 | void uninit();
|
---|
353 |
|
---|
354 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
355 | // Needed from VirtualBox, for the delayed metrics cleanup.
|
---|
356 | void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
|
---|
357 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
358 |
|
---|
359 | protected:
|
---|
360 | HRESULT initImpl(VirtualBox *aParent,
|
---|
361 | const Utf8Str &strConfigFile);
|
---|
362 | HRESULT initDataAndChildObjects();
|
---|
363 | HRESULT registeredInit();
|
---|
364 | HRESULT tryCreateMachineConfigFile(bool fForceOverwrite);
|
---|
365 | void uninitDataAndChildObjects();
|
---|
366 |
|
---|
367 | public:
|
---|
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(CPUExecutionCap))(ULONG *aExecutionCap);
|
---|
390 | STDMETHOD(COMSETTER(CPUExecutionCap))(ULONG aExecutionCap);
|
---|
391 | STDMETHOD(COMGETTER(HpetEnabled))(BOOL *enabled);
|
---|
392 | STDMETHOD(COMSETTER(HpetEnabled))(BOOL enabled);
|
---|
393 | STDMETHOD(COMGETTER(MemoryBalloonSize))(ULONG *memoryBalloonSize);
|
---|
394 | STDMETHOD(COMSETTER(MemoryBalloonSize))(ULONG memoryBalloonSize);
|
---|
395 | STDMETHOD(COMGETTER(PageFusionEnabled))(BOOL *enabled);
|
---|
396 | STDMETHOD(COMSETTER(PageFusionEnabled))(BOOL enabled);
|
---|
397 | STDMETHOD(COMGETTER(VRAMSize))(ULONG *memorySize);
|
---|
398 | STDMETHOD(COMSETTER(VRAMSize))(ULONG memorySize);
|
---|
399 | STDMETHOD(COMGETTER(MonitorCount))(ULONG *monitorCount);
|
---|
400 | STDMETHOD(COMSETTER(MonitorCount))(ULONG monitorCount);
|
---|
401 | STDMETHOD(COMGETTER(Accelerate3DEnabled))(BOOL *enabled);
|
---|
402 | STDMETHOD(COMSETTER(Accelerate3DEnabled))(BOOL enabled);
|
---|
403 | STDMETHOD(COMGETTER(Accelerate2DVideoEnabled))(BOOL *enabled);
|
---|
404 | STDMETHOD(COMSETTER(Accelerate2DVideoEnabled))(BOOL enabled);
|
---|
405 | STDMETHOD(COMGETTER(BIOSSettings))(IBIOSSettings **biosSettings);
|
---|
406 | STDMETHOD(COMGETTER(SnapshotFolder))(BSTR *aSavedStateFolder);
|
---|
407 | STDMETHOD(COMSETTER(SnapshotFolder))(IN_BSTR aSavedStateFolder);
|
---|
408 | STDMETHOD(COMGETTER(MediumAttachments))(ComSafeArrayOut(IMediumAttachment *, aAttachments));
|
---|
409 | STDMETHOD(COMGETTER(VRDEServer))(IVRDEServer **vrdeServer);
|
---|
410 | STDMETHOD(COMGETTER(AudioAdapter))(IAudioAdapter **audioAdapter);
|
---|
411 | STDMETHOD(COMGETTER(USBController))(IUSBController * *aUSBController);
|
---|
412 | STDMETHOD(COMGETTER(SettingsFilePath))(BSTR *aFilePath);
|
---|
413 | STDMETHOD(COMGETTER(SettingsModified))(BOOL *aModified);
|
---|
414 | STDMETHOD(COMGETTER(SessionState))(SessionState_T *aSessionState);
|
---|
415 | STDMETHOD(COMGETTER(SessionType))(BSTR *aSessionType);
|
---|
416 | STDMETHOD(COMGETTER(SessionPid))(ULONG *aSessionPid);
|
---|
417 | STDMETHOD(COMGETTER(State))(MachineState_T *machineState);
|
---|
418 | STDMETHOD(COMGETTER(LastStateChange))(LONG64 *aLastStateChange);
|
---|
419 | STDMETHOD(COMGETTER(StateFilePath))(BSTR *aStateFilePath);
|
---|
420 | STDMETHOD(COMGETTER(LogFolder))(BSTR *aLogFolder);
|
---|
421 | STDMETHOD(COMGETTER(CurrentSnapshot))(ISnapshot **aCurrentSnapshot);
|
---|
422 | STDMETHOD(COMGETTER(SnapshotCount))(ULONG *aSnapshotCount);
|
---|
423 | STDMETHOD(COMGETTER(CurrentStateModified))(BOOL *aCurrentStateModified);
|
---|
424 | STDMETHOD(COMGETTER(SharedFolders))(ComSafeArrayOut(ISharedFolder *, aSharedFolders));
|
---|
425 | STDMETHOD(COMGETTER(ClipboardMode))(ClipboardMode_T *aClipboardMode);
|
---|
426 | STDMETHOD(COMSETTER(ClipboardMode))(ClipboardMode_T aClipboardMode);
|
---|
427 | STDMETHOD(COMGETTER(GuestPropertyNotificationPatterns))(BSTR *aPattern);
|
---|
428 | STDMETHOD(COMSETTER(GuestPropertyNotificationPatterns))(IN_BSTR aPattern);
|
---|
429 | STDMETHOD(COMGETTER(StorageControllers))(ComSafeArrayOut(IStorageController *, aStorageControllers));
|
---|
430 | STDMETHOD(COMGETTER(TeleporterEnabled))(BOOL *aEnabled);
|
---|
431 | STDMETHOD(COMSETTER(TeleporterEnabled))(BOOL aEnabled);
|
---|
432 | STDMETHOD(COMGETTER(TeleporterPort))(ULONG *aPort);
|
---|
433 | STDMETHOD(COMSETTER(TeleporterPort))(ULONG aPort);
|
---|
434 | STDMETHOD(COMGETTER(TeleporterAddress))(BSTR *aAddress);
|
---|
435 | STDMETHOD(COMSETTER(TeleporterAddress))(IN_BSTR aAddress);
|
---|
436 | STDMETHOD(COMGETTER(TeleporterPassword))(BSTR *aPassword);
|
---|
437 | STDMETHOD(COMSETTER(TeleporterPassword))(IN_BSTR aPassword);
|
---|
438 | STDMETHOD(COMGETTER(FaultToleranceState))(FaultToleranceState_T *aEnabled);
|
---|
439 | STDMETHOD(COMSETTER(FaultToleranceState))(FaultToleranceState_T aEnabled);
|
---|
440 | STDMETHOD(COMGETTER(FaultToleranceAddress))(BSTR *aAddress);
|
---|
441 | STDMETHOD(COMSETTER(FaultToleranceAddress))(IN_BSTR aAddress);
|
---|
442 | STDMETHOD(COMGETTER(FaultTolerancePort))(ULONG *aPort);
|
---|
443 | STDMETHOD(COMSETTER(FaultTolerancePort))(ULONG aPort);
|
---|
444 | STDMETHOD(COMGETTER(FaultTolerancePassword))(BSTR *aPassword);
|
---|
445 | STDMETHOD(COMSETTER(FaultTolerancePassword))(IN_BSTR aPassword);
|
---|
446 | STDMETHOD(COMGETTER(FaultToleranceSyncInterval))(ULONG *aInterval);
|
---|
447 | STDMETHOD(COMSETTER(FaultToleranceSyncInterval))(ULONG aInterval);
|
---|
448 | STDMETHOD(COMGETTER(RTCUseUTC))(BOOL *aEnabled);
|
---|
449 | STDMETHOD(COMSETTER(RTCUseUTC))(BOOL aEnabled);
|
---|
450 | STDMETHOD(COMGETTER(FirmwareType)) (FirmwareType_T *aFirmware);
|
---|
451 | STDMETHOD(COMSETTER(FirmwareType)) (FirmwareType_T aFirmware);
|
---|
452 | STDMETHOD(COMGETTER(KeyboardHidType)) (KeyboardHidType_T *aKeyboardHidType);
|
---|
453 | STDMETHOD(COMSETTER(KeyboardHidType)) (KeyboardHidType_T aKeyboardHidType);
|
---|
454 | STDMETHOD(COMGETTER(PointingHidType)) (PointingHidType_T *aPointingHidType);
|
---|
455 | STDMETHOD(COMSETTER(PointingHidType)) (PointingHidType_T aPointingHidType);
|
---|
456 | STDMETHOD(COMGETTER(ChipsetType)) (ChipsetType_T *aChipsetType);
|
---|
457 | STDMETHOD(COMSETTER(ChipsetType)) (ChipsetType_T aChipsetType);
|
---|
458 | STDMETHOD(COMGETTER(IoCacheEnabled)) (BOOL *aEnabled);
|
---|
459 | STDMETHOD(COMSETTER(IoCacheEnabled)) (BOOL aEnabled);
|
---|
460 | STDMETHOD(COMGETTER(IoCacheSize)) (ULONG *aIoCacheSize);
|
---|
461 | STDMETHOD(COMSETTER(IoCacheSize)) (ULONG aIoCacheSize);
|
---|
462 | STDMETHOD(COMGETTER(PciDeviceAssignments))(ComSafeArrayOut(IPciDeviceAttachment *, aAssignments));
|
---|
463 | STDMETHOD(COMGETTER(BandwidthControl))(IBandwidthControl **aBandwidthControl);
|
---|
464 |
|
---|
465 | // IMachine methods
|
---|
466 | STDMETHOD(LockMachine)(ISession *aSession, LockType_T lockType);
|
---|
467 | STDMETHOD(LaunchVMProcess)(ISession *aSession, IN_BSTR aType, IN_BSTR aEnvironment, IProgress **aProgress);
|
---|
468 |
|
---|
469 | STDMETHOD(SetBootOrder)(ULONG aPosition, DeviceType_T aDevice);
|
---|
470 | STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice);
|
---|
471 | STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort,
|
---|
472 | LONG aDevice, DeviceType_T aType, IMedium *aMedium);
|
---|
473 | STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice);
|
---|
474 | STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough);
|
---|
475 | STDMETHOD(SetBandwidthGroupForDevice)(IN_BSTR aControllerName, LONG aControllerPort,
|
---|
476 | LONG aDevice, IBandwidthGroup *aBandwidthGroup);
|
---|
477 | STDMETHOD(MountMedium)(IN_BSTR aControllerName, LONG aControllerPort,
|
---|
478 | LONG aDevice, IMedium *aMedium, BOOL aForce);
|
---|
479 | STDMETHOD(GetMedium)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice,
|
---|
480 | IMedium **aMedium);
|
---|
481 | STDMETHOD(GetSerialPort)(ULONG slot, ISerialPort **port);
|
---|
482 | STDMETHOD(GetParallelPort)(ULONG slot, IParallelPort **port);
|
---|
483 | STDMETHOD(GetNetworkAdapter)(ULONG slot, INetworkAdapter **adapter);
|
---|
484 | STDMETHOD(GetExtraDataKeys)(ComSafeArrayOut(BSTR, aKeys));
|
---|
485 | STDMETHOD(GetExtraData)(IN_BSTR aKey, BSTR *aValue);
|
---|
486 | STDMETHOD(SetExtraData)(IN_BSTR aKey, IN_BSTR aValue);
|
---|
487 | STDMETHOD(GetCPUProperty)(CPUPropertyType_T property, BOOL *aVal);
|
---|
488 | STDMETHOD(SetCPUProperty)(CPUPropertyType_T property, BOOL aVal);
|
---|
489 | STDMETHOD(GetCPUIDLeaf)(ULONG id, ULONG *aValEax, ULONG *aValEbx, ULONG *aValEcx, ULONG *aValEdx);
|
---|
490 | STDMETHOD(SetCPUIDLeaf)(ULONG id, ULONG aValEax, ULONG aValEbx, ULONG aValEcx, ULONG aValEdx);
|
---|
491 | STDMETHOD(RemoveCPUIDLeaf)(ULONG id);
|
---|
492 | STDMETHOD(RemoveAllCPUIDLeaves)();
|
---|
493 | STDMETHOD(GetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL *aVal);
|
---|
494 | STDMETHOD(SetHWVirtExProperty)(HWVirtExPropertyType_T property, BOOL aVal);
|
---|
495 | STDMETHOD(SaveSettings)();
|
---|
496 | STDMETHOD(DiscardSettings)();
|
---|
497 | STDMETHOD(Unregister)(CleanupMode_T cleanupMode, ComSafeArrayOut(IMedium*, aMedia));
|
---|
498 | STDMETHOD(Delete)(ComSafeArrayIn(IMedium*, aMedia), IProgress **aProgress);
|
---|
499 | STDMETHOD(Export)(IAppliance *aAppliance, IN_BSTR location, IVirtualSystemDescription **aDescription);
|
---|
500 | STDMETHOD(FindSnapshot)(IN_BSTR aNameOrId, ISnapshot **aSnapshot);
|
---|
501 | STDMETHOD(CreateSharedFolder)(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable, BOOL aAutoMount);
|
---|
502 | STDMETHOD(RemoveSharedFolder)(IN_BSTR aName);
|
---|
503 | STDMETHOD(CanShowConsoleWindow)(BOOL *aCanShow);
|
---|
504 | STDMETHOD(ShowConsoleWindow)(LONG64 *aWinId);
|
---|
505 | STDMETHOD(GetGuestProperty)(IN_BSTR aName, BSTR *aValue, LONG64 *aTimestamp, BSTR *aFlags);
|
---|
506 | STDMETHOD(GetGuestPropertyValue)(IN_BSTR aName, BSTR *aValue);
|
---|
507 | STDMETHOD(GetGuestPropertyTimestamp)(IN_BSTR aName, LONG64 *aTimestamp);
|
---|
508 | STDMETHOD(SetGuestProperty)(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags);
|
---|
509 | STDMETHOD(SetGuestPropertyValue)(IN_BSTR aName, IN_BSTR aValue);
|
---|
510 | STDMETHOD(EnumerateGuestProperties)(IN_BSTR aPattern, ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues), ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
|
---|
511 | STDMETHOD(GetMediumAttachmentsOfController)(IN_BSTR aName, ComSafeArrayOut(IMediumAttachment *, aAttachments));
|
---|
512 | STDMETHOD(GetMediumAttachment)(IN_BSTR aConstrollerName, LONG aControllerPort, LONG aDevice, IMediumAttachment **aAttachment);
|
---|
513 | STDMETHOD(AddStorageController)(IN_BSTR aName, StorageBus_T aConnectionType, IStorageController **controller);
|
---|
514 | STDMETHOD(RemoveStorageController(IN_BSTR aName));
|
---|
515 | STDMETHOD(GetStorageControllerByName(IN_BSTR aName, IStorageController **storageController));
|
---|
516 | STDMETHOD(GetStorageControllerByInstance(ULONG aInstance, IStorageController **storageController));
|
---|
517 | STDMETHOD(SetStorageControllerBootable)(IN_BSTR aName, BOOL fBootable);
|
---|
518 | STDMETHOD(QuerySavedGuestSize)(ULONG aScreenId, ULONG *puWidth, ULONG *puHeight);
|
---|
519 | STDMETHOD(QuerySavedThumbnailSize)(ULONG aScreenId, ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
|
---|
520 | STDMETHOD(ReadSavedThumbnailToArray)(ULONG aScreenId, BOOL aBGR, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
|
---|
521 | STDMETHOD(ReadSavedThumbnailPNGToArray)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
|
---|
522 | STDMETHOD(QuerySavedScreenshotPNGSize)(ULONG aScreenId, ULONG *aSize, ULONG *aWidth, ULONG *aHeight);
|
---|
523 | STDMETHOD(ReadSavedScreenshotPNGToArray)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ComSafeArrayOut(BYTE, aData));
|
---|
524 | STDMETHOD(HotPlugCPU(ULONG aCpu));
|
---|
525 | STDMETHOD(HotUnplugCPU(ULONG aCpu));
|
---|
526 | STDMETHOD(GetCPUStatus(ULONG aCpu, BOOL *aCpuAttached));
|
---|
527 | STDMETHOD(QueryLogFilename(ULONG aIdx, BSTR *aName));
|
---|
528 | STDMETHOD(ReadLog(ULONG aIdx, LONG64 aOffset, LONG64 aSize, ComSafeArrayOut(BYTE, aData)));
|
---|
529 | STDMETHOD(AttachHostPciDevice(LONG hostAddress, LONG desiredGuestAddress, BOOL tryToUnbind));
|
---|
530 | STDMETHOD(DetachHostPciDevice(LONG hostAddress));
|
---|
531 | STDMETHOD(CloneTo(IMachine *aTarget, CloneMode_T mode, BOOL aFullClone, IProgress **aProgress));
|
---|
532 | // public methods only for internal purposes
|
---|
533 |
|
---|
534 | virtual bool isSnapshotMachine() const
|
---|
535 | {
|
---|
536 | return false;
|
---|
537 | }
|
---|
538 |
|
---|
539 | virtual bool isSessionMachine() const
|
---|
540 | {
|
---|
541 | return false;
|
---|
542 | }
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Override of the default locking class to be used for validating lock
|
---|
546 | * order with the standard member lock handle.
|
---|
547 | */
|
---|
548 | virtual VBoxLockingClass getLockingClass() const
|
---|
549 | {
|
---|
550 | return LOCKCLASS_MACHINEOBJECT;
|
---|
551 | }
|
---|
552 |
|
---|
553 | /// @todo (dmik) add lock and make non-inlined after revising classes
|
---|
554 | // that use it. Note: they should enter Machine lock to keep the returned
|
---|
555 | // information valid!
|
---|
556 | bool isRegistered() { return !!mData->mRegistered; }
|
---|
557 |
|
---|
558 | // unsafe inline public methods for internal purposes only (ensure there is
|
---|
559 | // a caller and a read lock before calling them!)
|
---|
560 |
|
---|
561 | /**
|
---|
562 | * Returns the VirtualBox object this machine belongs to.
|
---|
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 doing addCaller() manually.
|
---|
567 | */
|
---|
568 | VirtualBox* getVirtualBox() const { return mParent; }
|
---|
569 |
|
---|
570 | /**
|
---|
571 | * Returns this machine ID.
|
---|
572 | *
|
---|
573 | * @note This method doesn't check this object's readiness. Intended to be
|
---|
574 | * used by ready Machine children (whose readiness is bound to the parent's
|
---|
575 | * one) or after adding a caller manually.
|
---|
576 | */
|
---|
577 | const Guid& getId() const { return mData->mUuid; }
|
---|
578 |
|
---|
579 | /**
|
---|
580 | * Returns the snapshot ID this machine represents or an empty UUID if this
|
---|
581 | * instance is not SnapshotMachine.
|
---|
582 | *
|
---|
583 | * @note This method doesn't check this object's readiness. Intended to be
|
---|
584 | * used by ready Machine children (whose readiness is bound to the parent's
|
---|
585 | * one) or after adding a caller manually.
|
---|
586 | */
|
---|
587 | inline const Guid& getSnapshotId() const;
|
---|
588 |
|
---|
589 | /**
|
---|
590 | * Returns this machine's full settings file path.
|
---|
591 | *
|
---|
592 | * @note This method doesn't lock this object or check its readiness.
|
---|
593 | * Intended to be used only after doing addCaller() manually and locking it
|
---|
594 | * for reading.
|
---|
595 | */
|
---|
596 | const Utf8Str& getSettingsFileFull() const { return mData->m_strConfigFileFull; }
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * Returns this machine name.
|
---|
600 | *
|
---|
601 | * @note This method doesn't lock this object or check its readiness.
|
---|
602 | * Intended to be used only after doing addCaller() manually and locking it
|
---|
603 | * for reading.
|
---|
604 | */
|
---|
605 | const Utf8Str& getName() const { return mUserData->s.strName; }
|
---|
606 |
|
---|
607 | enum
|
---|
608 | {
|
---|
609 | IsModified_MachineData = 0x0001,
|
---|
610 | IsModified_Storage = 0x0002,
|
---|
611 | IsModified_NetworkAdapters = 0x0008,
|
---|
612 | IsModified_SerialPorts = 0x0010,
|
---|
613 | IsModified_ParallelPorts = 0x0020,
|
---|
614 | IsModified_VRDEServer = 0x0040,
|
---|
615 | IsModified_AudioAdapter = 0x0080,
|
---|
616 | IsModified_USB = 0x0100,
|
---|
617 | IsModified_BIOS = 0x0200,
|
---|
618 | IsModified_SharedFolders = 0x0400,
|
---|
619 | IsModified_Snapshots = 0x0800,
|
---|
620 | IsModified_BandwidthControl = 0x1000
|
---|
621 | };
|
---|
622 |
|
---|
623 | void setModified(uint32_t fl);
|
---|
624 | void setModifiedLock(uint32_t fl);
|
---|
625 |
|
---|
626 | // callback handlers
|
---|
627 | virtual HRESULT onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
|
---|
628 | virtual HRESULT onNATRedirectRuleChange(ULONG /* slot */, BOOL /* fRemove */ , IN_BSTR /* name */,
|
---|
629 | NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */, IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
|
---|
630 | virtual HRESULT onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
|
---|
631 | virtual HRESULT onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
|
---|
632 | virtual HRESULT onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
|
---|
633 | virtual HRESULT onUSBControllerChange() { return S_OK; }
|
---|
634 | virtual HRESULT onStorageControllerChange() { return S_OK; }
|
---|
635 | virtual HRESULT onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
|
---|
636 | virtual HRESULT onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
|
---|
637 | virtual HRESULT onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
|
---|
638 | virtual HRESULT onSharedFolderChange() { return S_OK; }
|
---|
639 | virtual HRESULT onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
|
---|
640 | virtual HRESULT onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */) { return S_OK; }
|
---|
641 |
|
---|
642 | HRESULT saveRegistryEntry(settings::MachineRegistryEntry &data);
|
---|
643 |
|
---|
644 | int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
|
---|
645 | void copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
|
---|
646 |
|
---|
647 | void getLogFolder(Utf8Str &aLogFolder);
|
---|
648 | Utf8Str queryLogFilename(ULONG idx);
|
---|
649 |
|
---|
650 | void composeSavedStateFilename(Utf8Str &strStateFilePath);
|
---|
651 |
|
---|
652 | HRESULT launchVMProcess(IInternalSessionControl *aControl,
|
---|
653 | const Utf8Str &strType,
|
---|
654 | const Utf8Str &strEnvironment,
|
---|
655 | ProgressProxy *aProgress);
|
---|
656 |
|
---|
657 | HRESULT getDirectControl(ComPtr<IInternalSessionControl> *directControl)
|
---|
658 | {
|
---|
659 | HRESULT rc;
|
---|
660 | *directControl = mData->mSession.mDirectControl;
|
---|
661 |
|
---|
662 | if (!*directControl)
|
---|
663 | rc = E_ACCESSDENIED;
|
---|
664 | else
|
---|
665 | rc = S_OK;
|
---|
666 |
|
---|
667 | return rc;
|
---|
668 | }
|
---|
669 |
|
---|
670 | #if defined(RT_OS_WINDOWS)
|
---|
671 |
|
---|
672 | bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
|
---|
673 | ComPtr<IInternalSessionControl> *aControl = NULL,
|
---|
674 | HANDLE *aIPCSem = NULL, bool aAllowClosing = false);
|
---|
675 | bool isSessionSpawning(RTPROCESS *aPID = NULL);
|
---|
676 |
|
---|
677 | bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
|
---|
678 | ComPtr<IInternalSessionControl> *aControl = NULL,
|
---|
679 | HANDLE *aIPCSem = NULL)
|
---|
680 | { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
|
---|
681 |
|
---|
682 | #elif defined(RT_OS_OS2)
|
---|
683 |
|
---|
684 | bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
|
---|
685 | ComPtr<IInternalSessionControl> *aControl = NULL,
|
---|
686 | HMTX *aIPCSem = NULL, bool aAllowClosing = false);
|
---|
687 |
|
---|
688 | bool isSessionSpawning(RTPROCESS *aPID = NULL);
|
---|
689 |
|
---|
690 | bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
|
---|
691 | ComPtr<IInternalSessionControl> *aControl = NULL,
|
---|
692 | HMTX *aIPCSem = NULL)
|
---|
693 | { return isSessionOpen(aMachine, aControl, aIPCSem, true /* aAllowClosing */); }
|
---|
694 |
|
---|
695 | #else
|
---|
696 |
|
---|
697 | bool isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
|
---|
698 | ComPtr<IInternalSessionControl> *aControl = NULL,
|
---|
699 | bool aAllowClosing = false);
|
---|
700 | bool isSessionSpawning();
|
---|
701 |
|
---|
702 | bool isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
|
---|
703 | ComPtr<IInternalSessionControl> *aControl = NULL)
|
---|
704 | { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
|
---|
705 |
|
---|
706 | #endif
|
---|
707 |
|
---|
708 | bool checkForSpawnFailure();
|
---|
709 |
|
---|
710 | HRESULT prepareRegister();
|
---|
711 |
|
---|
712 | HRESULT getSharedFolder(CBSTR aName,
|
---|
713 | ComObjPtr<SharedFolder> &aSharedFolder,
|
---|
714 | bool aSetError = false)
|
---|
715 | {
|
---|
716 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
717 | return findSharedFolder(aName, aSharedFolder, aSetError);
|
---|
718 | }
|
---|
719 |
|
---|
720 | HRESULT addStateDependency(StateDependency aDepType = AnyStateDep,
|
---|
721 | MachineState_T *aState = NULL,
|
---|
722 | BOOL *aRegistered = NULL);
|
---|
723 | void releaseStateDependency();
|
---|
724 |
|
---|
725 | HRESULT getBandwidthGroup(const Utf8Str &strBandwidthGroup,
|
---|
726 | ComObjPtr<BandwidthGroup> &pBandwidthGroup,
|
---|
727 | bool fSetError = false)
|
---|
728 | {
|
---|
729 | return mBandwidthControl->getBandwidthGroupByName(strBandwidthGroup,
|
---|
730 | pBandwidthGroup,
|
---|
731 | fSetError);
|
---|
732 | }
|
---|
733 |
|
---|
734 | protected:
|
---|
735 |
|
---|
736 | HRESULT checkStateDependency(StateDependency aDepType);
|
---|
737 |
|
---|
738 | Machine *getMachine();
|
---|
739 |
|
---|
740 | void ensureNoStateDependencies();
|
---|
741 |
|
---|
742 | virtual HRESULT setMachineState(MachineState_T aMachineState);
|
---|
743 |
|
---|
744 | HRESULT findSharedFolder(const Utf8Str &aName,
|
---|
745 | ComObjPtr<SharedFolder> &aSharedFolder,
|
---|
746 | bool aSetError = false);
|
---|
747 |
|
---|
748 | HRESULT loadSettings(bool aRegistered);
|
---|
749 | HRESULT loadMachineDataFromSettings(const settings::MachineConfigFile &config,
|
---|
750 | const Guid *puuidRegistry);
|
---|
751 | HRESULT loadSnapshot(const settings::Snapshot &data,
|
---|
752 | const Guid &aCurSnapshotId,
|
---|
753 | Snapshot *aParentSnapshot);
|
---|
754 | HRESULT loadHardware(const settings::Hardware &data);
|
---|
755 | HRESULT loadStorageControllers(const settings::Storage &data,
|
---|
756 | const Guid *puuidRegistry,
|
---|
757 | const Guid *puuidSnapshot);
|
---|
758 | HRESULT loadStorageDevices(StorageController *aStorageController,
|
---|
759 | const settings::StorageController &data,
|
---|
760 | const Guid *puuidRegistry,
|
---|
761 | const Guid *puuidSnapshot);
|
---|
762 |
|
---|
763 | HRESULT findSnapshotById(const Guid &aId,
|
---|
764 | ComObjPtr<Snapshot> &aSnapshot,
|
---|
765 | bool aSetError = false);
|
---|
766 | HRESULT findSnapshotByName(const Utf8Str &strName,
|
---|
767 | ComObjPtr<Snapshot> &aSnapshot,
|
---|
768 | bool aSetError = false);
|
---|
769 |
|
---|
770 | HRESULT getStorageControllerByName(const Utf8Str &aName,
|
---|
771 | ComObjPtr<StorageController> &aStorageController,
|
---|
772 | bool aSetError = false);
|
---|
773 |
|
---|
774 | HRESULT getMediumAttachmentsOfController(CBSTR aName,
|
---|
775 | MediaData::AttachmentList &aAttachments);
|
---|
776 |
|
---|
777 | enum
|
---|
778 | {
|
---|
779 | /* flags for #saveSettings() */
|
---|
780 | SaveS_ResetCurStateModified = 0x01,
|
---|
781 | SaveS_InformCallbacksAnyway = 0x02,
|
---|
782 | SaveS_Force = 0x04,
|
---|
783 | /* flags for #saveStateSettings() */
|
---|
784 | SaveSTS_CurStateModified = 0x20,
|
---|
785 | SaveSTS_StateFilePath = 0x40,
|
---|
786 | SaveSTS_StateTimeStamp = 0x80
|
---|
787 | };
|
---|
788 |
|
---|
789 | HRESULT prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
|
---|
790 | HRESULT saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
|
---|
791 |
|
---|
792 | void copyMachineDataToSettings(settings::MachineConfigFile &config);
|
---|
793 | HRESULT saveAllSnapshots(settings::MachineConfigFile &config);
|
---|
794 | HRESULT saveHardware(settings::Hardware &data);
|
---|
795 | HRESULT saveStorageControllers(settings::Storage &data);
|
---|
796 | HRESULT saveStorageDevices(ComObjPtr<StorageController> aStorageController,
|
---|
797 | settings::StorageController &data);
|
---|
798 | HRESULT saveStateSettings(int aFlags);
|
---|
799 |
|
---|
800 | void addMediumToRegistry(ComObjPtr<Medium> &pMedium,
|
---|
801 | GuidList &llRegistriesThatNeedSaving,
|
---|
802 | Guid *puuid);
|
---|
803 |
|
---|
804 | HRESULT createImplicitDiffs(IProgress *aProgress,
|
---|
805 | ULONG aWeight,
|
---|
806 | bool aOnline,
|
---|
807 | GuidList *pllRegistriesThatNeedSaving);
|
---|
808 | HRESULT deleteImplicitDiffs(GuidList *pllRegistriesThatNeedSaving);
|
---|
809 |
|
---|
810 | MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
|
---|
811 | IN_BSTR aControllerName,
|
---|
812 | LONG aControllerPort,
|
---|
813 | LONG aDevice);
|
---|
814 | MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
|
---|
815 | ComObjPtr<Medium> pMedium);
|
---|
816 | MediumAttachment* findAttachment(const MediaData::AttachmentList &ll,
|
---|
817 | Guid &id);
|
---|
818 |
|
---|
819 | HRESULT detachDevice(MediumAttachment *pAttach,
|
---|
820 | AutoWriteLock &writeLock,
|
---|
821 | Snapshot *pSnapshot,
|
---|
822 | GuidList *pllRegistriesThatNeedSaving);
|
---|
823 | HRESULT detachAllMedia(AutoWriteLock &writeLock,
|
---|
824 | Snapshot *pSnapshot,
|
---|
825 | CleanupMode_T cleanupMode,
|
---|
826 | MediaList &llMedia);
|
---|
827 |
|
---|
828 | void commitMedia(bool aOnline = false);
|
---|
829 | void rollbackMedia();
|
---|
830 |
|
---|
831 | bool isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
|
---|
832 |
|
---|
833 | void rollback(bool aNotify);
|
---|
834 | void commit();
|
---|
835 | void copyFrom(Machine *aThat);
|
---|
836 | bool isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
|
---|
837 |
|
---|
838 | struct DeleteTask;
|
---|
839 | static DECLCALLBACK(int) deleteThread(RTTHREAD Thread, void *pvUser);
|
---|
840 | HRESULT deleteTaskWorker(DeleteTask &task);
|
---|
841 |
|
---|
842 | struct CloneVMTask;
|
---|
843 | HRESULT cloneCreateMachineList(const ComPtr<ISnapshot> &pSnapshot, RTCList< ComObjPtr<Machine> > &machineList) const;
|
---|
844 | settings::Snapshot cloneFindSnapshot(settings::MachineConfigFile *pMCF, const settings::SnapshotsList &snl, const Guid &id) const;
|
---|
845 | void cloneUpdateStorageLists(settings::StorageControllersList &sc, const Bstr &bstrOldId, const Bstr &bstrNewId) const;
|
---|
846 | void cloneUpdateSnapshotStorageLists(settings::SnapshotsList &sl, const Bstr &bstrOldId, const Bstr &bstrNewId) const;
|
---|
847 | void cloneUpdateStateFile(settings::SnapshotsList &snl, const Guid &id, const Utf8Str &strFile) const;
|
---|
848 | static int cloneCopyStateFileProgress(unsigned uPercentage, void *pvUser);
|
---|
849 |
|
---|
850 | static DECLCALLBACK(int) cloneVMThread(RTTHREAD Thread, void *pvUser);
|
---|
851 | HRESULT cloneVMTaskWorker(CloneVMTask *pTask);
|
---|
852 |
|
---|
853 | #ifdef VBOX_WITH_GUEST_PROPS
|
---|
854 | HRESULT getGuestPropertyFromService(IN_BSTR aName, BSTR *aValue,
|
---|
855 | LONG64 *aTimestamp, BSTR *aFlags) const;
|
---|
856 | HRESULT getGuestPropertyFromVM(IN_BSTR aName, BSTR *aValue,
|
---|
857 | LONG64 *aTimestamp, BSTR *aFlags) const;
|
---|
858 | HRESULT setGuestPropertyToService(IN_BSTR aName, IN_BSTR aValue,
|
---|
859 | IN_BSTR aFlags);
|
---|
860 | HRESULT setGuestPropertyToVM(IN_BSTR aName, IN_BSTR aValue,
|
---|
861 | IN_BSTR aFlags);
|
---|
862 | HRESULT enumerateGuestPropertiesInService
|
---|
863 | (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
|
---|
864 | ComSafeArrayOut(BSTR, aValues),
|
---|
865 | ComSafeArrayOut(LONG64, aTimestamps),
|
---|
866 | ComSafeArrayOut(BSTR, aFlags));
|
---|
867 | HRESULT enumerateGuestPropertiesOnVM
|
---|
868 | (IN_BSTR aPatterns, ComSafeArrayOut(BSTR, aNames),
|
---|
869 | ComSafeArrayOut(BSTR, aValues),
|
---|
870 | ComSafeArrayOut(LONG64, aTimestamps),
|
---|
871 | ComSafeArrayOut(BSTR, aFlags));
|
---|
872 | #endif /* VBOX_WITH_GUEST_PROPS */
|
---|
873 |
|
---|
874 | #ifdef VBOX_WITH_RESOURCE_USAGE_API
|
---|
875 | void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
|
---|
876 |
|
---|
877 | pm::CollectorGuest *mCollectorGuest;
|
---|
878 | #endif /* VBOX_WITH_RESOURCE_USAGE_API */
|
---|
879 |
|
---|
880 | Machine* const mPeer;
|
---|
881 |
|
---|
882 | VirtualBox * const mParent;
|
---|
883 |
|
---|
884 | Shareable<Data> mData;
|
---|
885 | Shareable<SSData> mSSData;
|
---|
886 |
|
---|
887 | Backupable<UserData> mUserData;
|
---|
888 | Backupable<HWData> mHWData;
|
---|
889 | Backupable<MediaData> mMediaData;
|
---|
890 |
|
---|
891 | // the following fields need special backup/rollback/commit handling,
|
---|
892 | // so they cannot be a part of HWData
|
---|
893 |
|
---|
894 | const ComObjPtr<VRDEServer> mVRDEServer;
|
---|
895 | const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
|
---|
896 | const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
|
---|
897 | const ComObjPtr<AudioAdapter> mAudioAdapter;
|
---|
898 | const ComObjPtr<USBController> mUSBController;
|
---|
899 | const ComObjPtr<BIOSSettings> mBIOSSettings;
|
---|
900 | const ComObjPtr<NetworkAdapter> mNetworkAdapters[SchemaDefs::NetworkAdapterCount];
|
---|
901 | const ComObjPtr<BandwidthControl> mBandwidthControl;
|
---|
902 |
|
---|
903 | typedef std::list< ComObjPtr<StorageController> > StorageControllerList;
|
---|
904 | Backupable<StorageControllerList> mStorageControllers;
|
---|
905 |
|
---|
906 | friend class SessionMachine;
|
---|
907 | friend class SnapshotMachine;
|
---|
908 | friend class Appliance;
|
---|
909 | friend class VirtualBox;
|
---|
910 | };
|
---|
911 |
|
---|
912 | // SessionMachine class
|
---|
913 | ////////////////////////////////////////////////////////////////////////////////
|
---|
914 |
|
---|
915 | /**
|
---|
916 | * @note Notes on locking objects of this class:
|
---|
917 | * SessionMachine shares some data with the primary Machine instance (pointed
|
---|
918 | * to by the |mPeer| member). In order to provide data consistency it also
|
---|
919 | * shares its lock handle. This means that whenever you lock a SessionMachine
|
---|
920 | * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
|
---|
921 | * instance is also locked in the same lock mode. Keep it in mind.
|
---|
922 | */
|
---|
923 | class ATL_NO_VTABLE SessionMachine :
|
---|
924 | public Machine,
|
---|
925 | VBOX_SCRIPTABLE_IMPL(IInternalMachineControl)
|
---|
926 | {
|
---|
927 | public:
|
---|
928 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
|
---|
929 |
|
---|
930 | DECLARE_NOT_AGGREGATABLE(SessionMachine)
|
---|
931 |
|
---|
932 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
933 |
|
---|
934 | BEGIN_COM_MAP(SessionMachine)
|
---|
935 | VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
|
---|
936 | COM_INTERFACE_ENTRY(IInternalMachineControl)
|
---|
937 | END_COM_MAP()
|
---|
938 |
|
---|
939 | DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
|
---|
940 |
|
---|
941 | HRESULT FinalConstruct();
|
---|
942 | void FinalRelease();
|
---|
943 |
|
---|
944 | // public initializer/uninitializer for internal purposes only
|
---|
945 | HRESULT init(Machine *aMachine);
|
---|
946 | void uninit() { uninit(Uninit::Unexpected); }
|
---|
947 |
|
---|
948 | // util::Lockable interface
|
---|
949 | RWLockHandle *lockHandle() const;
|
---|
950 |
|
---|
951 | // IInternalMachineControl methods
|
---|
952 | STDMETHOD(SetRemoveSavedStateFile)(BOOL aRemove);
|
---|
953 | STDMETHOD(UpdateState)(MachineState_T machineState);
|
---|
954 | STDMETHOD(GetIPCId)(BSTR *id);
|
---|
955 | STDMETHOD(BeginPowerUp)(IProgress *aProgress);
|
---|
956 | STDMETHOD(EndPowerUp)(LONG iResult);
|
---|
957 | STDMETHOD(BeginPoweringDown)(IProgress **aProgress);
|
---|
958 | STDMETHOD(EndPoweringDown)(LONG aResult, IN_BSTR aErrMsg);
|
---|
959 | STDMETHOD(RunUSBDeviceFilters)(IUSBDevice *aUSBDevice, BOOL *aMatched, ULONG *aMaskedIfs);
|
---|
960 | STDMETHOD(CaptureUSBDevice)(IN_BSTR aId);
|
---|
961 | STDMETHOD(DetachUSBDevice)(IN_BSTR aId, BOOL aDone);
|
---|
962 | STDMETHOD(AutoCaptureUSBDevices)();
|
---|
963 | STDMETHOD(DetachAllUSBDevices)(BOOL aDone);
|
---|
964 | STDMETHOD(OnSessionEnd)(ISession *aSession, IProgress **aProgress);
|
---|
965 | STDMETHOD(BeginSavingState)(IProgress **aProgress, BSTR *aStateFilePath);
|
---|
966 | STDMETHOD(EndSavingState)(LONG aResult, IN_BSTR aErrMsg);
|
---|
967 | STDMETHOD(AdoptSavedState)(IN_BSTR aSavedStateFile);
|
---|
968 | STDMETHOD(BeginTakingSnapshot)(IConsole *aInitiator,
|
---|
969 | IN_BSTR aName,
|
---|
970 | IN_BSTR aDescription,
|
---|
971 | IProgress *aConsoleProgress,
|
---|
972 | BOOL fTakingSnapshotOnline,
|
---|
973 | BSTR *aStateFilePath);
|
---|
974 | STDMETHOD(EndTakingSnapshot)(BOOL aSuccess);
|
---|
975 | STDMETHOD(DeleteSnapshot)(IConsole *aInitiator, IN_BSTR aId,
|
---|
976 | BOOL fDeleteAllChildren,
|
---|
977 | MachineState_T *aMachineState, IProgress **aProgress);
|
---|
978 | STDMETHOD(FinishOnlineMergeMedium)(IMediumAttachment *aMediumAttachment,
|
---|
979 | IMedium *aSource, IMedium *aTarget,
|
---|
980 | BOOL fMergeForward,
|
---|
981 | IMedium *pParentForTarget,
|
---|
982 | ComSafeArrayIn(IMedium *, aChildrenToReparent));
|
---|
983 | STDMETHOD(RestoreSnapshot)(IConsole *aInitiator,
|
---|
984 | ISnapshot *aSnapshot,
|
---|
985 | MachineState_T *aMachineState,
|
---|
986 | IProgress **aProgress);
|
---|
987 | STDMETHOD(PullGuestProperties)(ComSafeArrayOut(BSTR, aNames), ComSafeArrayOut(BSTR, aValues),
|
---|
988 | ComSafeArrayOut(LONG64, aTimestamps), ComSafeArrayOut(BSTR, aFlags));
|
---|
989 | STDMETHOD(PushGuestProperty)(IN_BSTR aName, IN_BSTR aValue,
|
---|
990 | LONG64 aTimestamp, IN_BSTR aFlags);
|
---|
991 | STDMETHOD(LockMedia)() { return lockMedia(); }
|
---|
992 | STDMETHOD(UnlockMedia)() { unlockMedia(); return S_OK; }
|
---|
993 |
|
---|
994 | // public methods only for internal purposes
|
---|
995 |
|
---|
996 | virtual bool isSessionMachine() const
|
---|
997 | {
|
---|
998 | return true;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | bool checkForDeath();
|
---|
1002 |
|
---|
1003 | HRESULT onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
|
---|
1004 | HRESULT onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
|
---|
1005 | NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort, IN_BSTR aGuestIp, LONG aGuestPort);
|
---|
1006 | HRESULT onStorageControllerChange();
|
---|
1007 | HRESULT onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
|
---|
1008 | HRESULT onSerialPortChange(ISerialPort *serialPort);
|
---|
1009 | HRESULT onParallelPortChange(IParallelPort *parallelPort);
|
---|
1010 | HRESULT onCPUChange(ULONG aCPU, BOOL aRemove);
|
---|
1011 | HRESULT onCPUExecutionCapChange(ULONG aCpuExecutionCap);
|
---|
1012 | HRESULT onVRDEServerChange(BOOL aRestart);
|
---|
1013 | HRESULT onUSBControllerChange();
|
---|
1014 | HRESULT onUSBDeviceAttach(IUSBDevice *aDevice,
|
---|
1015 | IVirtualBoxErrorInfo *aError,
|
---|
1016 | ULONG aMaskedIfs);
|
---|
1017 | HRESULT onUSBDeviceDetach(IN_BSTR aId,
|
---|
1018 | IVirtualBoxErrorInfo *aError);
|
---|
1019 | HRESULT onSharedFolderChange();
|
---|
1020 | HRESULT onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
|
---|
1021 | HRESULT onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove);
|
---|
1022 |
|
---|
1023 | bool hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
|
---|
1024 |
|
---|
1025 | private:
|
---|
1026 |
|
---|
1027 | struct ConsoleTaskData
|
---|
1028 | {
|
---|
1029 | ConsoleTaskData()
|
---|
1030 | : mLastState(MachineState_Null)
|
---|
1031 | { }
|
---|
1032 |
|
---|
1033 | MachineState_T mLastState;
|
---|
1034 | ComObjPtr<Progress> mProgress;
|
---|
1035 |
|
---|
1036 | // used when taking snapshot
|
---|
1037 | ComObjPtr<Snapshot> mSnapshot;
|
---|
1038 |
|
---|
1039 | // used when saving state (either as part of a snapshot or separate)
|
---|
1040 | Utf8Str strStateFilePath;
|
---|
1041 | };
|
---|
1042 |
|
---|
1043 | struct Uninit
|
---|
1044 | {
|
---|
1045 | enum Reason { Unexpected, Abnormal, Normal };
|
---|
1046 | };
|
---|
1047 |
|
---|
1048 | struct SnapshotTask;
|
---|
1049 | struct DeleteSnapshotTask;
|
---|
1050 | struct RestoreSnapshotTask;
|
---|
1051 |
|
---|
1052 | friend struct DeleteSnapshotTask;
|
---|
1053 | friend struct RestoreSnapshotTask;
|
---|
1054 |
|
---|
1055 | void uninit(Uninit::Reason aReason);
|
---|
1056 |
|
---|
1057 | HRESULT endSavingState(HRESULT aRC, const Utf8Str &aErrMsg);
|
---|
1058 | void releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
|
---|
1059 |
|
---|
1060 | void deleteSnapshotHandler(DeleteSnapshotTask &aTask);
|
---|
1061 | void restoreSnapshotHandler(RestoreSnapshotTask &aTask);
|
---|
1062 |
|
---|
1063 | HRESULT prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
|
---|
1064 | const Guid &machineId,
|
---|
1065 | const Guid &snapshotId,
|
---|
1066 | bool fOnlineMergePossible,
|
---|
1067 | MediumLockList *aVMMALockList,
|
---|
1068 | ComObjPtr<Medium> &aSource,
|
---|
1069 | ComObjPtr<Medium> &aTarget,
|
---|
1070 | bool &fMergeForward,
|
---|
1071 | ComObjPtr<Medium> &pParentForTarget,
|
---|
1072 | MediaList &aChildrenToReparent,
|
---|
1073 | bool &fNeedOnlineMerge,
|
---|
1074 | MediumLockList * &aMediumLockList);
|
---|
1075 | void cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
|
---|
1076 | const ComObjPtr<Medium> &aSource,
|
---|
1077 | const MediaList &aChildrenToReparent,
|
---|
1078 | bool fNeedsOnlineMerge,
|
---|
1079 | MediumLockList *aMediumLockList,
|
---|
1080 | const Guid &aMediumId,
|
---|
1081 | const Guid &aSnapshotId);
|
---|
1082 | HRESULT onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
|
---|
1083 | const ComObjPtr<Medium> &aSource,
|
---|
1084 | const ComObjPtr<Medium> &aTarget,
|
---|
1085 | bool fMergeForward,
|
---|
1086 | const ComObjPtr<Medium> &pParentForTarget,
|
---|
1087 | const MediaList &aChildrenToReparent,
|
---|
1088 | MediumLockList *aMediumLockList,
|
---|
1089 | ComObjPtr<Progress> &aProgress,
|
---|
1090 | bool *pfNeedsMachineSaveSettings);
|
---|
1091 |
|
---|
1092 | HRESULT lockMedia();
|
---|
1093 | void unlockMedia();
|
---|
1094 |
|
---|
1095 | HRESULT setMachineState(MachineState_T aMachineState);
|
---|
1096 | HRESULT updateMachineStateOnClient();
|
---|
1097 |
|
---|
1098 | HRESULT mRemoveSavedState;
|
---|
1099 |
|
---|
1100 | ConsoleTaskData mConsoleTaskData;
|
---|
1101 |
|
---|
1102 | /** interprocess semaphore handle for this machine */
|
---|
1103 | #if defined(RT_OS_WINDOWS)
|
---|
1104 | HANDLE mIPCSem;
|
---|
1105 | Bstr mIPCSemName;
|
---|
1106 | friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
|
---|
1107 | ComPtr<IInternalSessionControl> *aControl,
|
---|
1108 | HANDLE *aIPCSem, bool aAllowClosing);
|
---|
1109 | #elif defined(RT_OS_OS2)
|
---|
1110 | HMTX mIPCSem;
|
---|
1111 | Bstr mIPCSemName;
|
---|
1112 | friend bool Machine::isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
|
---|
1113 | ComPtr<IInternalSessionControl> *aControl,
|
---|
1114 | HMTX *aIPCSem, bool aAllowClosing);
|
---|
1115 | #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
|
---|
1116 | int mIPCSem;
|
---|
1117 | # ifdef VBOX_WITH_NEW_SYS_V_KEYGEN
|
---|
1118 | Bstr mIPCKey;
|
---|
1119 | # endif /*VBOX_WITH_NEW_SYS_V_KEYGEN */
|
---|
1120 | #else
|
---|
1121 | # error "Port me!"
|
---|
1122 | #endif
|
---|
1123 |
|
---|
1124 | static DECLCALLBACK(int) taskHandler(RTTHREAD thread, void *pvUser);
|
---|
1125 | };
|
---|
1126 |
|
---|
1127 | // SnapshotMachine class
|
---|
1128 | ////////////////////////////////////////////////////////////////////////////////
|
---|
1129 |
|
---|
1130 | /**
|
---|
1131 | * @note Notes on locking objects of this class:
|
---|
1132 | * SnapshotMachine shares some data with the primary Machine instance (pointed
|
---|
1133 | * to by the |mPeer| member). In order to provide data consistency it also
|
---|
1134 | * shares its lock handle. This means that whenever you lock a SessionMachine
|
---|
1135 | * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
|
---|
1136 | * instance is also locked in the same lock mode. Keep it in mind.
|
---|
1137 | */
|
---|
1138 | class ATL_NO_VTABLE SnapshotMachine :
|
---|
1139 | public Machine
|
---|
1140 | {
|
---|
1141 | public:
|
---|
1142 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
|
---|
1143 |
|
---|
1144 | DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
|
---|
1145 |
|
---|
1146 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
1147 |
|
---|
1148 | BEGIN_COM_MAP(SnapshotMachine)
|
---|
1149 | VBOX_DEFAULT_INTERFACE_ENTRIES(IMachine)
|
---|
1150 | END_COM_MAP()
|
---|
1151 |
|
---|
1152 | DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
|
---|
1153 |
|
---|
1154 | HRESULT FinalConstruct();
|
---|
1155 | void FinalRelease();
|
---|
1156 |
|
---|
1157 | // public initializer/uninitializer for internal purposes only
|
---|
1158 | HRESULT init(SessionMachine *aSessionMachine,
|
---|
1159 | IN_GUID aSnapshotId,
|
---|
1160 | const Utf8Str &aStateFilePath);
|
---|
1161 | HRESULT init(Machine *aMachine,
|
---|
1162 | const settings::Hardware &hardware,
|
---|
1163 | const settings::Storage &storage,
|
---|
1164 | IN_GUID aSnapshotId,
|
---|
1165 | const Utf8Str &aStateFilePath);
|
---|
1166 | void uninit();
|
---|
1167 |
|
---|
1168 | // util::Lockable interface
|
---|
1169 | RWLockHandle *lockHandle() const;
|
---|
1170 |
|
---|
1171 | // public methods only for internal purposes
|
---|
1172 |
|
---|
1173 | virtual bool isSnapshotMachine() const
|
---|
1174 | {
|
---|
1175 | return true;
|
---|
1176 | }
|
---|
1177 |
|
---|
1178 | HRESULT onSnapshotChange(Snapshot *aSnapshot);
|
---|
1179 |
|
---|
1180 | // unsafe inline public methods for internal purposes only (ensure there is
|
---|
1181 | // a caller and a read lock before calling them!)
|
---|
1182 |
|
---|
1183 | const Guid& getSnapshotId() const { return mSnapshotId; }
|
---|
1184 |
|
---|
1185 | private:
|
---|
1186 |
|
---|
1187 | Guid mSnapshotId;
|
---|
1188 |
|
---|
1189 | friend class Snapshot;
|
---|
1190 | };
|
---|
1191 |
|
---|
1192 | // third party methods that depend on SnapshotMachine definition
|
---|
1193 |
|
---|
1194 | inline const Guid &Machine::getSnapshotId() const
|
---|
1195 | {
|
---|
1196 | return (isSnapshotMachine())
|
---|
1197 | ? static_cast<const SnapshotMachine*>(this)->getSnapshotId()
|
---|
1198 | : Guid::Empty;
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 |
|
---|
1202 | #endif // ____H_MACHINEIMPL
|
---|
1203 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|