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