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