VirtualBox

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

Last change on this file since 65158 was 65158, checked in by vboxsync, 8 years ago

Main: doxygen fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 68.1 KB
Line 
1/* $Id: MachineImpl.h 65158 2017-01-05 16:52:22Z vboxsync $ */
2/** @file
3 * Implementation of IMachine in VBoxSVC - Header.
4 */
5
6/*
7 * Copyright (C) 2006-2016 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 "AuthLibrary.h"
22#include "VirtualBoxBase.h"
23#include "SnapshotImpl.h"
24#include "ProgressImpl.h"
25#include "VRDEServerImpl.h"
26#include "MediumAttachmentImpl.h"
27#include "PCIDeviceAttachmentImpl.h"
28#include "MediumLock.h"
29#include "NetworkAdapterImpl.h"
30#include "AudioAdapterImpl.h"
31#include "SerialPortImpl.h"
32#include "ParallelPortImpl.h"
33#include "BIOSSettingsImpl.h"
34#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
35#include "USBControllerImpl.h" // required for MachineImpl.h to compile on Windows
36#include "BandwidthControlImpl.h"
37#include "BandwidthGroupImpl.h"
38#ifdef VBOX_WITH_RESOURCE_USAGE_API
39# include "Performance.h"
40# include "PerformanceImpl.h"
41# include "ThreadTask.h"
42#endif
43#ifdef VBOX_WITH_UNATTENDED
44# include "UnattendedImpl.h"
45#endif
46
47// generated header
48#include "SchemaDefs.h"
49
50#include "VBox/com/ErrorInfo.h"
51
52#include <iprt/file.h>
53#include <iprt/thread.h>
54#include <iprt/time.h>
55
56#include <list>
57#include <vector>
58
59#include "MachineWrap.h"
60
61/** @todo r=klaus after moving the various Machine settings structs to
62 * MachineImpl.cpp it should be possible to eliminate this include. */
63#include <VBox/settings.h>
64
65// defines
66////////////////////////////////////////////////////////////////////////////////
67
68// helper declarations
69////////////////////////////////////////////////////////////////////////////////
70
71class Progress;
72class ProgressProxy;
73class Keyboard;
74class Mouse;
75class Display;
76class MachineDebugger;
77class USBController;
78class USBDeviceFilters;
79class Snapshot;
80class SharedFolder;
81class HostUSBDevice;
82class StorageController;
83class SessionMachine;
84
85// Machine class
86////////////////////////////////////////////////////////////////////////////////
87//
88class ATL_NO_VTABLE Machine :
89 public MachineWrap
90{
91
92public:
93
94 enum StateDependency
95 {
96 AnyStateDep = 0,
97 MutableStateDep,
98 MutableOrSavedStateDep,
99 MutableOrRunningStateDep,
100 MutableOrSavedOrRunningStateDep,
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 /** Type of lock which created this session */
126 LockType_T mLockType;
127
128 /** Control of the direct session opened by lockMachine() */
129 ComPtr<IInternalSessionControl> mDirectControl;
130
131 typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
132
133 /** list of controls of all opened remote sessions */
134 RemoteControlList mRemoteControls;
135
136 /** launchVMProcess() and OnSessionEnd() progress indicator */
137 ComObjPtr<ProgressProxy> mProgress;
138
139 /**
140 * PID of the session object that must be passed to openSession()
141 * to finalize the launchVMProcess() request (i.e., PID of the
142 * process created by launchVMProcess())
143 */
144 RTPROCESS mPID;
145
146 /** Current session state */
147 SessionState_T mState;
148
149 /** Session name string (of the primary session) */
150 Utf8Str mName;
151
152 /** Session machine object */
153 ComObjPtr<SessionMachine> mMachine;
154
155 /** Medium object lock collection. */
156 MediumLockListMap mLockedMedia;
157 };
158
159 Data();
160 ~Data();
161
162 const Guid mUuid;
163 BOOL mRegistered;
164
165 Utf8Str m_strConfigFile;
166 Utf8Str m_strConfigFileFull;
167
168 // machine settings XML file
169 settings::MachineConfigFile *pMachineConfigFile;
170 uint32_t flModifications;
171 bool m_fAllowStateModification;
172
173 BOOL mAccessible;
174 com::ErrorInfo mAccessError;
175
176 MachineState_T mMachineState;
177 RTTIMESPEC mLastStateChange;
178
179 /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
180 uint32_t mMachineStateDeps;
181 RTSEMEVENTMULTI mMachineStateDepsSem;
182 uint32_t mMachineStateChangePending;
183
184 BOOL mCurrentStateModified;
185 /** Guest properties have been modified and need saving since the
186 * machine was started, or there are transient properties which need
187 * deleting and the machine is being shut down. */
188 BOOL mGuestPropertiesModified;
189
190 Session mSession;
191
192 ComObjPtr<Snapshot> mFirstSnapshot;
193 ComObjPtr<Snapshot> mCurrentSnapshot;
194
195 // list of files to delete in Delete(); this list is filled by Unregister()
196 std::list<Utf8Str> llFilesToDelete;
197 };
198
199 /**
200 * Saved state data.
201 *
202 * It's actually only the state file path string, but it needs to be
203 * separate from Data, because Machine and SessionMachine instances
204 * share it, while SnapshotMachine does not.
205 *
206 * The data variable is |mSSData|.
207 */
208 struct SSData
209 {
210 Utf8Str strStateFilePath;
211 };
212
213 /**
214 * User changeable machine data.
215 *
216 * This data is common for all machine snapshots, i.e. it is shared
217 * by all SnapshotMachine instances associated with the given machine
218 * using the util::Backupable template through the |mUserData| variable.
219 *
220 * SessionMachine instances can alter this data and discard changes.
221 *
222 * @note There is no need to lock anything inside init() or uninit()
223 * methods, because they are always serialized (see AutoCaller).
224 */
225 struct UserData
226 {
227 settings::MachineUserData s;
228 };
229
230 /**
231 * Hardware data.
232 *
233 * This data is unique for a machine and for every machine snapshot.
234 * Stored using the util::Backupable template in the |mHWData| variable.
235 *
236 * SessionMachine instances can alter this data and discard changes.
237 */
238 struct HWData
239 {
240 /**
241 * Data structure to hold information about a guest property.
242 */
243 struct GuestProperty {
244 /** Property value */
245 Utf8Str strValue;
246 /** Property timestamp */
247 LONG64 mTimestamp;
248 /** Property flags */
249 ULONG mFlags;
250 };
251
252 HWData();
253 ~HWData();
254
255 Bstr mHWVersion;
256 Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
257 ULONG mMemorySize;
258 ULONG mMemoryBalloonSize;
259 BOOL mPageFusionEnabled;
260 GraphicsControllerType_T mGraphicsControllerType;
261 ULONG mVRAMSize;
262 ULONG mVideoCaptureWidth;
263 ULONG mVideoCaptureHeight;
264 ULONG mVideoCaptureRate;
265 ULONG mVideoCaptureFPS;
266 ULONG mVideoCaptureMaxTime;
267 ULONG mVideoCaptureMaxFileSize;
268 Utf8Str mVideoCaptureOptions;
269 Utf8Str mVideoCaptureFile;
270 BOOL mVideoCaptureEnabled;
271 BOOL maVideoCaptureScreens[SchemaDefs::MaxGuestMonitors];
272 ULONG mMonitorCount;
273 BOOL mHWVirtExEnabled;
274 BOOL mHWVirtExNestedPagingEnabled;
275 BOOL mHWVirtExLargePagesEnabled;
276 BOOL mHWVirtExVPIDEnabled;
277 BOOL mHWVirtExUXEnabled;
278 BOOL mHWVirtExForceEnabled;
279 BOOL mAccelerate2DVideoEnabled;
280 BOOL mPAEEnabled;
281 settings::Hardware::LongModeType mLongMode;
282 BOOL mTripleFaultReset;
283 BOOL mAPIC;
284 BOOL mX2APIC;
285 ULONG mCPUCount;
286 BOOL mCPUHotPlugEnabled;
287 ULONG mCpuExecutionCap;
288 uint32_t mCpuIdPortabilityLevel;
289 Utf8Str mCpuProfile;
290 BOOL mAccelerate3DEnabled;
291 BOOL mHPETEnabled;
292
293 BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
294
295 settings::CpuIdLeaf mCpuIdStdLeafs[11];
296 settings::CpuIdLeaf mCpuIdExtLeafs[11];
297
298 DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
299
300 typedef std::list<ComObjPtr<SharedFolder> > SharedFolderList;
301 SharedFolderList mSharedFolders;
302
303 ClipboardMode_T mClipboardMode;
304 DnDMode_T mDnDMode;
305
306 typedef std::map<Utf8Str, GuestProperty> GuestPropertyMap;
307 GuestPropertyMap mGuestProperties;
308
309 FirmwareType_T mFirmwareType;
310 KeyboardHIDType_T mKeyboardHIDType;
311 PointingHIDType_T mPointingHIDType;
312 ChipsetType_T mChipsetType;
313 ParavirtProvider_T mParavirtProvider;
314 Utf8Str mParavirtDebug;
315 BOOL mEmulatedUSBCardReaderEnabled;
316
317 BOOL mIOCacheEnabled;
318 ULONG mIOCacheSize;
319
320 typedef std::list<ComObjPtr<PCIDeviceAttachment> > PCIDeviceAssignmentList;
321 PCIDeviceAssignmentList mPCIDeviceAssignments;
322
323 settings::Debugging mDebugging;
324 settings::Autostart mAutostart;
325
326 Utf8Str mDefaultFrontend;
327 };
328
329 /**
330 * Hard disk and other media data.
331 *
332 * The usage policy is the same as for HWData, but a separate structure
333 * is necessary because hard disk data requires different procedures when
334 * taking or deleting snapshots, etc.
335 *
336 * The data variable is |mMediaData|.
337 */
338 struct MediaData
339 {
340 MediaData();
341 ~MediaData();
342
343 typedef std::list<ComObjPtr<MediumAttachment> > AttachmentList;
344 AttachmentList mAttachments;
345 };
346
347 DECLARE_EMPTY_CTOR_DTOR(Machine)
348
349 HRESULT FinalConstruct();
350 void FinalRelease();
351
352 // public initializer/uninitializer for internal purposes only:
353
354 // initializer for creating a new, empty machine
355 HRESULT init(VirtualBox *aParent,
356 const Utf8Str &strConfigFile,
357 const Utf8Str &strName,
358 const StringsList &llGroups,
359 GuestOSType *aOsType,
360 const Guid &aId,
361 bool fForceOverwrite,
362 bool fDirectoryIncludesUUID);
363
364 // initializer for loading existing machine XML (either registered or not)
365 HRESULT initFromSettings(VirtualBox *aParent,
366 const Utf8Str &strConfigFile,
367 const Guid *aId);
368
369 // initializer for machine config in memory (OVF import)
370 HRESULT init(VirtualBox *aParent,
371 const Utf8Str &strName,
372 const settings::MachineConfigFile &config);
373
374 void uninit();
375
376#ifdef VBOX_WITH_RESOURCE_USAGE_API
377 // Needed from VirtualBox, for the delayed metrics cleanup.
378 void i_unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine);
379#endif /* VBOX_WITH_RESOURCE_USAGE_API */
380
381protected:
382 HRESULT initImpl(VirtualBox *aParent,
383 const Utf8Str &strConfigFile);
384 HRESULT initDataAndChildObjects();
385 HRESULT i_registeredInit();
386 HRESULT i_tryCreateMachineConfigFile(bool fForceOverwrite);
387 void uninitDataAndChildObjects();
388
389public:
390
391
392 // public methods only for internal purposes
393
394 virtual bool i_isSnapshotMachine() const
395 {
396 return false;
397 }
398
399 virtual bool i_isSessionMachine() const
400 {
401 return false;
402 }
403
404 /**
405 * Override of the default locking class to be used for validating lock
406 * order with the standard member lock handle.
407 */
408 virtual VBoxLockingClass getLockingClass() const
409 {
410 return LOCKCLASS_MACHINEOBJECT;
411 }
412
413 /// @todo (dmik) add lock and make non-inlined after revising classes
414 // that use it. Note: they should enter Machine lock to keep the returned
415 // information valid!
416 bool i_isRegistered() { return !!mData->mRegistered; }
417
418 // unsafe inline public methods for internal purposes only (ensure there is
419 // a caller and a read lock before calling them!)
420
421 /**
422 * Returns the VirtualBox object this machine belongs to.
423 *
424 * @note This method doesn't check this object's readiness. Intended to be
425 * used by ready Machine children (whose readiness is bound to the parent's
426 * one) or after doing addCaller() manually.
427 */
428 VirtualBox* i_getVirtualBox() const { return mParent; }
429
430 /**
431 * Checks if this machine is accessible, without attempting to load the
432 * config file.
433 *
434 * @note This method doesn't check this object's readiness. Intended to be
435 * used by ready Machine children (whose readiness is bound to the parent's
436 * one) or after doing addCaller() manually.
437 */
438 bool i_isAccessible() const { return !!mData->mAccessible; }
439
440 /**
441 * Returns this machine ID.
442 *
443 * @note This method doesn't check this object's readiness. Intended to be
444 * used by ready Machine children (whose readiness is bound to the parent's
445 * one) or after adding a caller manually.
446 */
447 const Guid& i_getId() const { return mData->mUuid; }
448
449 /**
450 * Returns the snapshot ID this machine represents or an empty UUID if this
451 * instance is not SnapshotMachine.
452 *
453 * @note This method doesn't check this object's readiness. Intended to be
454 * used by ready Machine children (whose readiness is bound to the parent's
455 * one) or after adding a caller manually.
456 */
457 inline const Guid& i_getSnapshotId() const;
458
459 /**
460 * Returns this machine's full settings file path.
461 *
462 * @note This method doesn't lock this object or check its readiness.
463 * Intended to be used only after doing addCaller() manually and locking it
464 * for reading.
465 */
466 const Utf8Str& i_getSettingsFileFull() const { return mData->m_strConfigFileFull; }
467
468 /**
469 * Returns this machine name.
470 *
471 * @note This method doesn't lock this object or check its readiness.
472 * Intended to be used only after doing addCaller() manually and locking it
473 * for reading.
474 */
475 const Utf8Str& i_getName() const { return mUserData->s.strName; }
476
477 enum
478 {
479 IsModified_MachineData = 0x0001,
480 IsModified_Storage = 0x0002,
481 IsModified_NetworkAdapters = 0x0008,
482 IsModified_SerialPorts = 0x0010,
483 IsModified_ParallelPorts = 0x0020,
484 IsModified_VRDEServer = 0x0040,
485 IsModified_AudioAdapter = 0x0080,
486 IsModified_USB = 0x0100,
487 IsModified_BIOS = 0x0200,
488 IsModified_SharedFolders = 0x0400,
489 IsModified_Snapshots = 0x0800,
490 IsModified_BandwidthControl = 0x1000
491 };
492
493 /**
494 * Returns various information about this machine.
495 *
496 * @note This method doesn't lock this object or check its readiness.
497 * Intended to be used only after doing addCaller() manually and locking it
498 * for reading.
499 */
500 ChipsetType_T i_getChipsetType() const { return mHWData->mChipsetType; }
501 ParavirtProvider_T i_getParavirtProvider() const { return mHWData->mParavirtProvider; }
502 Utf8Str i_getParavirtDebug() const { return mHWData->mParavirtDebug; }
503
504 void i_setModified(uint32_t fl, bool fAllowStateModification = true);
505 void i_setModifiedLock(uint32_t fl, bool fAllowStateModification = true);
506
507 bool i_isStateModificationAllowed() const { return mData->m_fAllowStateModification; }
508 void i_allowStateModification() { mData->m_fAllowStateModification = true; }
509 void i_disallowStateModification() { mData->m_fAllowStateModification = false; }
510
511 const StringsList &i_getGroups() const { return mUserData->s.llGroups; }
512
513 // callback handlers
514 virtual HRESULT i_onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
515 virtual HRESULT i_onNATRedirectRuleChange(ULONG /* slot */, BOOL /* fRemove */ , IN_BSTR /* name */,
516 NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */,
517 IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
518 virtual HRESULT i_onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
519 virtual HRESULT i_onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
520 virtual HRESULT i_onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
521 virtual HRESULT i_onUSBControllerChange() { return S_OK; }
522 virtual HRESULT i_onStorageControllerChange() { return S_OK; }
523 virtual HRESULT i_onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
524 virtual HRESULT i_onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
525 virtual HRESULT i_onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
526 virtual HRESULT i_onSharedFolderChange() { return S_OK; }
527 virtual HRESULT i_onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
528 virtual HRESULT i_onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; }
529 virtual HRESULT i_onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
530 virtual HRESULT i_onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */,
531 BOOL /* silent */) { return S_OK; }
532 virtual HRESULT i_onVideoCaptureChange() { return S_OK; }
533
534 HRESULT i_saveRegistryEntry(settings::MachineRegistryEntry &data);
535
536 int i_calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
537 void i_copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
538
539 void i_getLogFolder(Utf8Str &aLogFolder);
540 Utf8Str i_getLogFilename(ULONG idx);
541 Utf8Str i_getHardeningLogFilename(void);
542
543 void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
544
545 void i_getDefaultVideoCaptureFile(Utf8Str &strFile);
546
547 bool i_isUSBControllerPresent();
548
549 HRESULT i_launchVMProcess(IInternalSessionControl *aControl,
550 const Utf8Str &strType,
551 const Utf8Str &strEnvironment,
552 ProgressProxy *aProgress);
553
554 HRESULT i_getDirectControl(ComPtr<IInternalSessionControl> *directControl)
555 {
556 HRESULT rc;
557 *directControl = mData->mSession.mDirectControl;
558
559 if (!*directControl)
560 rc = E_ACCESSDENIED;
561 else
562 rc = S_OK;
563
564 return rc;
565 }
566
567 bool i_isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
568 ComPtr<IInternalSessionControl> *aControl = NULL,
569 bool aRequireVM = false,
570 bool aAllowClosing = false);
571 bool i_isSessionSpawning();
572
573 bool i_isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
574 ComPtr<IInternalSessionControl> *aControl = NULL)
575 { return i_isSessionOpen(aMachine, aControl, false /* aRequireVM */, true /* aAllowClosing */); }
576
577 bool i_isSessionOpenVM(ComObjPtr<SessionMachine> &aMachine,
578 ComPtr<IInternalSessionControl> *aControl = NULL)
579 { return i_isSessionOpen(aMachine, aControl, true /* aRequireVM */, false /* aAllowClosing */); }
580
581 bool i_checkForSpawnFailure();
582
583 HRESULT i_prepareRegister();
584
585 HRESULT i_getSharedFolder(CBSTR aName,
586 ComObjPtr<SharedFolder> &aSharedFolder,
587 bool aSetError = false)
588 {
589 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
590 return i_findSharedFolder(aName, aSharedFolder, aSetError);
591 }
592
593 HRESULT i_addStateDependency(StateDependency aDepType = AnyStateDep,
594 MachineState_T *aState = NULL,
595 BOOL *aRegistered = NULL);
596 void i_releaseStateDependency();
597
598 HRESULT i_getStorageControllerByName(const Utf8Str &aName,
599 ComObjPtr<StorageController> &aStorageController,
600 bool aSetError = false);
601
602 HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
603 MediaData::AttachmentList &aAttachments);
604
605 HRESULT i_getUSBControllerByName(const Utf8Str &aName,
606 ComObjPtr<USBController> &aUSBController,
607 bool aSetError = false);
608
609 HRESULT i_getBandwidthGroup(const Utf8Str &strBandwidthGroup,
610 ComObjPtr<BandwidthGroup> &pBandwidthGroup,
611 bool fSetError = false)
612 {
613 return mBandwidthControl->i_getBandwidthGroupByName(strBandwidthGroup,
614 pBandwidthGroup,
615 fSetError);
616 }
617
618 static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcszMsg, ...);
619
620protected:
621
622 class ClientToken;
623
624 HRESULT i_checkStateDependency(StateDependency aDepType);
625
626 Machine *i_getMachine();
627
628 void i_ensureNoStateDependencies();
629
630 virtual HRESULT i_setMachineState(MachineState_T aMachineState);
631
632 HRESULT i_findSharedFolder(const Utf8Str &aName,
633 ComObjPtr<SharedFolder> &aSharedFolder,
634 bool aSetError = false);
635
636 HRESULT i_loadSettings(bool aRegistered);
637 HRESULT i_loadMachineDataFromSettings(const settings::MachineConfigFile &config,
638 const Guid *puuidRegistry);
639 HRESULT i_loadSnapshot(const settings::Snapshot &data,
640 const Guid &aCurSnapshotId,
641 Snapshot *aParentSnapshot);
642 HRESULT i_loadHardware(const Guid *puuidRegistry,
643 const Guid *puuidSnapshot,
644 const settings::Hardware &data,
645 const settings::Debugging *pDbg,
646 const settings::Autostart *pAutostart);
647 HRESULT i_loadDebugging(const settings::Debugging *pDbg);
648 HRESULT i_loadAutostart(const settings::Autostart *pAutostart);
649 HRESULT i_loadStorageControllers(const settings::Storage &data,
650 const Guid *puuidRegistry,
651 const Guid *puuidSnapshot);
652 HRESULT i_loadStorageDevices(StorageController *aStorageController,
653 const settings::StorageController &data,
654 const Guid *puuidRegistry,
655 const Guid *puuidSnapshot);
656
657 HRESULT i_findSnapshotById(const Guid &aId,
658 ComObjPtr<Snapshot> &aSnapshot,
659 bool aSetError = false);
660 HRESULT i_findSnapshotByName(const Utf8Str &strName,
661 ComObjPtr<Snapshot> &aSnapshot,
662 bool aSetError = false);
663
664 ULONG i_getUSBControllerCountByType(USBControllerType_T enmType);
665
666 enum
667 {
668 /* flags for #saveSettings() */
669 SaveS_ResetCurStateModified = 0x01,
670 SaveS_Force = 0x04,
671 /* flags for #saveStateSettings() */
672 SaveSTS_CurStateModified = 0x20,
673 SaveSTS_StateFilePath = 0x40,
674 SaveSTS_StateTimeStamp = 0x80
675 };
676
677 HRESULT i_prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
678 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
679
680 void i_copyMachineDataToSettings(settings::MachineConfigFile &config);
681 HRESULT i_saveAllSnapshots(settings::MachineConfigFile &config);
682 HRESULT i_saveHardware(settings::Hardware &data, settings::Debugging *pDbg,
683 settings::Autostart *pAutostart);
684 HRESULT i_saveStorageControllers(settings::Storage &data);
685 HRESULT i_saveStorageDevices(ComObjPtr<StorageController> aStorageController,
686 settings::StorageController &data);
687 HRESULT i_saveStateSettings(int aFlags);
688
689 void i_addMediumToRegistry(ComObjPtr<Medium> &pMedium);
690
691 HRESULT i_createImplicitDiffs(IProgress *aProgress,
692 ULONG aWeight,
693 bool aOnline);
694 HRESULT i_deleteImplicitDiffs(bool aOnline);
695
696 MediumAttachment* i_findAttachment(const MediaData::AttachmentList &ll,
697 const Utf8Str &aControllerName,
698 LONG aControllerPort,
699 LONG aDevice);
700 MediumAttachment* i_findAttachment(const MediaData::AttachmentList &ll,
701 ComObjPtr<Medium> pMedium);
702 MediumAttachment* i_findAttachment(const MediaData::AttachmentList &ll,
703 Guid &id);
704
705 HRESULT i_detachDevice(MediumAttachment *pAttach,
706 AutoWriteLock &writeLock,
707 Snapshot *pSnapshot);
708
709 HRESULT i_detachAllMedia(AutoWriteLock &writeLock,
710 Snapshot *pSnapshot,
711 CleanupMode_T cleanupMode,
712 MediaList &llMedia);
713
714 void i_commitMedia(bool aOnline = false);
715 void i_rollbackMedia();
716
717 bool i_isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
718
719 void i_rollback(bool aNotify);
720 void i_commit();
721 void i_copyFrom(Machine *aThat);
722 bool i_isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
723
724 Utf8Str i_getExtraData(const Utf8Str &strKey);
725
726#ifdef VBOX_WITH_GUEST_PROPS
727 HRESULT i_getGuestPropertyFromService(const com::Utf8Str &aName, com::Utf8Str &aValue,
728 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
729 HRESULT i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue,
730 const com::Utf8Str &aFlags, bool fDelete);
731 HRESULT i_getGuestPropertyFromVM(const com::Utf8Str &aName, com::Utf8Str &aValue,
732 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
733 HRESULT i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue,
734 const com::Utf8Str &aFlags, bool fDelete);
735 HRESULT i_enumerateGuestPropertiesInService(const com::Utf8Str &aPatterns,
736 std::vector<com::Utf8Str> &aNames,
737 std::vector<com::Utf8Str> &aValues,
738 std::vector<LONG64> &aTimestamps,
739 std::vector<com::Utf8Str> &aFlags);
740 HRESULT i_enumerateGuestPropertiesOnVM(const com::Utf8Str &aPatterns,
741 std::vector<com::Utf8Str> &aNames,
742 std::vector<com::Utf8Str> &aValues,
743 std::vector<LONG64> &aTimestamps,
744 std::vector<com::Utf8Str> &aFlags);
745
746#endif /* VBOX_WITH_GUEST_PROPS */
747
748#ifdef VBOX_WITH_RESOURCE_USAGE_API
749 void i_getDiskList(MediaList &list);
750 void i_registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
751
752 pm::CollectorGuest *mCollectorGuest;
753#endif /* VBOX_WITH_RESOURCE_USAGE_API */
754
755 Machine * const mPeer;
756
757 VirtualBox * const mParent;
758
759 Shareable<Data> mData;
760 Shareable<SSData> mSSData;
761
762 Backupable<UserData> mUserData;
763 Backupable<HWData> mHWData;
764 Backupable<MediaData> mMediaData;
765
766 // the following fields need special backup/rollback/commit handling,
767 // so they cannot be a part of HWData
768
769 const ComObjPtr<VRDEServer> mVRDEServer;
770 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
771 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
772 const ComObjPtr<AudioAdapter> mAudioAdapter;
773 const ComObjPtr<USBDeviceFilters> mUSBDeviceFilters;
774 const ComObjPtr<BIOSSettings> mBIOSSettings;
775 const ComObjPtr<BandwidthControl> mBandwidthControl;
776#ifdef VBOX_WITH_UNATTENDED
777 const ComObjPtr<Unattended> mUnattended;
778#endif
779
780 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
781 NetworkAdapterVector mNetworkAdapters;
782
783 typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
784 Backupable<StorageControllerList> mStorageControllers;
785
786 typedef std::list<ComObjPtr<USBController> > USBControllerList;
787 Backupable<USBControllerList> mUSBControllers;
788
789 uint64_t uRegistryNeedsSaving;
790
791 /**
792 * Abstract base class for all Machine or SessionMachine related
793 * asynchronous tasks. This is necessary since RTThreadCreate cannot call
794 * a (non-static) method as its thread function, so instead we have it call
795 * the static Machine::taskHandler, which then calls the handler() method
796 * in here (implemented by the subclasses).
797 */
798 class Task : public ThreadTask
799 {
800 public:
801 Task(Machine *m, Progress *p, const Utf8Str &t)
802 : ThreadTask(t),
803 m_pMachine(m),
804 m_machineCaller(m),
805 m_pProgress(p),
806 m_machineStateBackup(m->mData->mMachineState) // save the current machine state
807 {}
808 virtual ~Task(){}
809
810 void modifyBackedUpState(MachineState_T s)
811 {
812 *const_cast<MachineState_T *>(&m_machineStateBackup) = s;
813 }
814
815 ComObjPtr<Machine> m_pMachine;
816 AutoCaller m_machineCaller;
817 ComObjPtr<Progress> m_pProgress;
818 const MachineState_T m_machineStateBackup;
819 };
820
821 class DeleteConfigTask;
822 void i_deleteConfigHandler(DeleteConfigTask &task);
823
824 friend class SessionMachine;
825 friend class SnapshotMachine;
826 friend class Appliance;
827 friend class VirtualBox;
828
829 friend class MachineCloneVM;
830
831private:
832 // wrapped IMachine properties
833 HRESULT getParent(ComPtr<IVirtualBox> &aParent);
834 HRESULT getIcon(std::vector<BYTE> &aIcon);
835 HRESULT setIcon(const std::vector<BYTE> &aIcon);
836 HRESULT getAccessible(BOOL *aAccessible);
837 HRESULT getAccessError(ComPtr<IVirtualBoxErrorInfo> &aAccessError);
838 HRESULT getName(com::Utf8Str &aName);
839 HRESULT setName(const com::Utf8Str &aName);
840 HRESULT getDescription(com::Utf8Str &aDescription);
841 HRESULT setDescription(const com::Utf8Str &aDescription);
842 HRESULT getId(com::Guid &aId);
843 HRESULT getGroups(std::vector<com::Utf8Str> &aGroups);
844 HRESULT setGroups(const std::vector<com::Utf8Str> &aGroups);
845 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
846 HRESULT setOSTypeId(const com::Utf8Str &aOSTypeId);
847 HRESULT getHardwareVersion(com::Utf8Str &aHardwareVersion);
848 HRESULT setHardwareVersion(const com::Utf8Str &aHardwareVersion);
849 HRESULT getHardwareUUID(com::Guid &aHardwareUUID);
850 HRESULT setHardwareUUID(const com::Guid &aHardwareUUID);
851 HRESULT getCPUCount(ULONG *aCPUCount);
852 HRESULT setCPUCount(ULONG aCPUCount);
853 HRESULT getCPUHotPlugEnabled(BOOL *aCPUHotPlugEnabled);
854 HRESULT setCPUHotPlugEnabled(BOOL aCPUHotPlugEnabled);
855 HRESULT getCPUExecutionCap(ULONG *aCPUExecutionCap);
856 HRESULT setCPUExecutionCap(ULONG aCPUExecutionCap);
857 HRESULT getCPUIDPortabilityLevel(ULONG *aCPUIDPortabilityLevel);
858 HRESULT setCPUIDPortabilityLevel(ULONG aCPUIDPortabilityLevel);
859 HRESULT getCPUProfile(com::Utf8Str &aCPUProfile);
860 HRESULT setCPUProfile(const com::Utf8Str &aCPUProfile);
861 HRESULT getMemorySize(ULONG *aMemorySize);
862 HRESULT setMemorySize(ULONG aMemorySize);
863 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
864 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
865 HRESULT getPageFusionEnabled(BOOL *aPageFusionEnabled);
866 HRESULT setPageFusionEnabled(BOOL aPageFusionEnabled);
867 HRESULT getGraphicsControllerType(GraphicsControllerType_T *aGraphicsControllerType);
868 HRESULT setGraphicsControllerType(GraphicsControllerType_T aGraphicsControllerType);
869 HRESULT getVRAMSize(ULONG *aVRAMSize);
870 HRESULT setVRAMSize(ULONG aVRAMSize);
871 HRESULT getAccelerate3DEnabled(BOOL *aAccelerate3DEnabled);
872 HRESULT setAccelerate3DEnabled(BOOL aAccelerate3DEnabled);
873 HRESULT getAccelerate2DVideoEnabled(BOOL *aAccelerate2DVideoEnabled);
874 HRESULT setAccelerate2DVideoEnabled(BOOL aAccelerate2DVideoEnabled);
875 HRESULT getMonitorCount(ULONG *aMonitorCount);
876 HRESULT setMonitorCount(ULONG aMonitorCount);
877 HRESULT getVideoCaptureEnabled(BOOL *aVideoCaptureEnabled);
878 HRESULT setVideoCaptureEnabled(BOOL aVideoCaptureEnabled);
879 HRESULT getVideoCaptureScreens(std::vector<BOOL> &aVideoCaptureScreens);
880 HRESULT setVideoCaptureScreens(const std::vector<BOOL> &aVideoCaptureScreens);
881 HRESULT getVideoCaptureFile(com::Utf8Str &aVideoCaptureFile);
882 HRESULT setVideoCaptureFile(const com::Utf8Str &aVideoCaptureFile);
883 HRESULT getVideoCaptureWidth(ULONG *aVideoCaptureWidth);
884 HRESULT setVideoCaptureWidth(ULONG aVideoCaptureWidth);
885 HRESULT getVideoCaptureHeight(ULONG *aVideoCaptureHeight);
886 HRESULT setVideoCaptureHeight(ULONG aVideoCaptureHeight);
887 HRESULT getVideoCaptureRate(ULONG *aVideoCaptureRate);
888 HRESULT setVideoCaptureRate(ULONG aVideoCaptureRate);
889 HRESULT getVideoCaptureFPS(ULONG *aVideoCaptureFPS);
890 HRESULT setVideoCaptureFPS(ULONG aVideoCaptureFPS);
891 HRESULT getVideoCaptureMaxTime(ULONG *aVideoCaptureMaxTime);
892 HRESULT setVideoCaptureMaxTime(ULONG aVideoCaptureMaxTime);
893 HRESULT getVideoCaptureMaxFileSize(ULONG *aVideoCaptureMaxFileSize);
894 HRESULT setVideoCaptureMaxFileSize(ULONG aVideoCaptureMaxFileSize);
895 HRESULT getVideoCaptureOptions(com::Utf8Str &aVideoCaptureOptions);
896 HRESULT setVideoCaptureOptions(const com::Utf8Str &aVideoCaptureOptions);
897 HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
898 HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
899 HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
900 HRESULT getPointingHIDType(PointingHIDType_T *aPointingHIDType);
901 HRESULT setPointingHIDType(PointingHIDType_T aPointingHIDType);
902 HRESULT getKeyboardHIDType(KeyboardHIDType_T *aKeyboardHIDType);
903 HRESULT setKeyboardHIDType(KeyboardHIDType_T aKeyboardHIDType);
904 HRESULT getHPETEnabled(BOOL *aHPETEnabled);
905 HRESULT setHPETEnabled(BOOL aHPETEnabled);
906 HRESULT getChipsetType(ChipsetType_T *aChipsetType);
907 HRESULT setChipsetType(ChipsetType_T aChipsetType);
908 HRESULT getSnapshotFolder(com::Utf8Str &aSnapshotFolder);
909 HRESULT setSnapshotFolder(const com::Utf8Str &aSnapshotFolder);
910 HRESULT getVRDEServer(ComPtr<IVRDEServer> &aVRDEServer);
911 HRESULT getEmulatedUSBCardReaderEnabled(BOOL *aEmulatedUSBCardReaderEnabled);
912 HRESULT setEmulatedUSBCardReaderEnabled(BOOL aEmulatedUSBCardReaderEnabled);
913 HRESULT getMediumAttachments(std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
914 HRESULT getUSBControllers(std::vector<ComPtr<IUSBController> > &aUSBControllers);
915 HRESULT getUSBDeviceFilters(ComPtr<IUSBDeviceFilters> &aUSBDeviceFilters);
916 HRESULT getAudioAdapter(ComPtr<IAudioAdapter> &aAudioAdapter);
917 HRESULT getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers);
918 HRESULT getSettingsFilePath(com::Utf8Str &aSettingsFilePath);
919 HRESULT getSettingsAuxFilePath(com::Utf8Str &aSettingsAuxFilePath);
920 HRESULT getSettingsModified(BOOL *aSettingsModified);
921 HRESULT getSessionState(SessionState_T *aSessionState);
922 HRESULT getSessionType(SessionType_T *aSessionType);
923 HRESULT getSessionName(com::Utf8Str &aSessionType);
924 HRESULT getSessionPID(ULONG *aSessionPID);
925 HRESULT getState(MachineState_T *aState);
926 HRESULT getLastStateChange(LONG64 *aLastStateChange);
927 HRESULT getStateFilePath(com::Utf8Str &aStateFilePath);
928 HRESULT getLogFolder(com::Utf8Str &aLogFolder);
929 HRESULT getCurrentSnapshot(ComPtr<ISnapshot> &aCurrentSnapshot);
930 HRESULT getSnapshotCount(ULONG *aSnapshotCount);
931 HRESULT getCurrentStateModified(BOOL *aCurrentStateModified);
932 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
933 HRESULT getClipboardMode(ClipboardMode_T *aClipboardMode);
934 HRESULT setClipboardMode(ClipboardMode_T aClipboardMode);
935 HRESULT getDnDMode(DnDMode_T *aDnDMode);
936 HRESULT setDnDMode(DnDMode_T aDnDMode);
937 HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
938 HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
939 HRESULT getTeleporterPort(ULONG *aTeleporterPort);
940 HRESULT setTeleporterPort(ULONG aTeleporterPort);
941 HRESULT getTeleporterAddress(com::Utf8Str &aTeleporterAddress);
942 HRESULT setTeleporterAddress(const com::Utf8Str &aTeleporterAddress);
943 HRESULT getTeleporterPassword(com::Utf8Str &aTeleporterPassword);
944 HRESULT setTeleporterPassword(const com::Utf8Str &aTeleporterPassword);
945 HRESULT getParavirtProvider(ParavirtProvider_T *aParavirtProvider);
946 HRESULT setParavirtProvider(ParavirtProvider_T aParavirtProvider);
947 HRESULT getParavirtDebug(com::Utf8Str &aParavirtDebug);
948 HRESULT setParavirtDebug(const com::Utf8Str &aParavirtDebug);
949 HRESULT getFaultToleranceState(FaultToleranceState_T *aFaultToleranceState);
950 HRESULT setFaultToleranceState(FaultToleranceState_T aFaultToleranceState);
951 HRESULT getFaultTolerancePort(ULONG *aFaultTolerancePort);
952 HRESULT setFaultTolerancePort(ULONG aFaultTolerancePort);
953 HRESULT getFaultToleranceAddress(com::Utf8Str &aFaultToleranceAddress);
954 HRESULT setFaultToleranceAddress(const com::Utf8Str &aFaultToleranceAddress);
955 HRESULT getFaultTolerancePassword(com::Utf8Str &aFaultTolerancePassword);
956 HRESULT setFaultTolerancePassword(const com::Utf8Str &aFaultTolerancePassword);
957 HRESULT getFaultToleranceSyncInterval(ULONG *aFaultToleranceSyncInterval);
958 HRESULT setFaultToleranceSyncInterval(ULONG aFaultToleranceSyncInterval);
959 HRESULT getRTCUseUTC(BOOL *aRTCUseUTC);
960 HRESULT setRTCUseUTC(BOOL aRTCUseUTC);
961 HRESULT getIOCacheEnabled(BOOL *aIOCacheEnabled);
962 HRESULT setIOCacheEnabled(BOOL aIOCacheEnabled);
963 HRESULT getIOCacheSize(ULONG *aIOCacheSize);
964 HRESULT setIOCacheSize(ULONG aIOCacheSize);
965 HRESULT getPCIDeviceAssignments(std::vector<ComPtr<IPCIDeviceAttachment> > &aPCIDeviceAssignments);
966 HRESULT getBandwidthControl(ComPtr<IBandwidthControl> &aBandwidthControl);
967 HRESULT getTracingEnabled(BOOL *aTracingEnabled);
968 HRESULT setTracingEnabled(BOOL aTracingEnabled);
969 HRESULT getTracingConfig(com::Utf8Str &aTracingConfig);
970 HRESULT setTracingConfig(const com::Utf8Str &aTracingConfig);
971 HRESULT getAllowTracingToAccessVM(BOOL *aAllowTracingToAccessVM);
972 HRESULT setAllowTracingToAccessVM(BOOL aAllowTracingToAccessVM);
973 HRESULT getAutostartEnabled(BOOL *aAutostartEnabled);
974 HRESULT setAutostartEnabled(BOOL aAutostartEnabled);
975 HRESULT getAutostartDelay(ULONG *aAutostartDelay);
976 HRESULT setAutostartDelay(ULONG aAutostartDelay);
977 HRESULT getAutostopType(AutostopType_T *aAutostopType);
978 HRESULT setAutostopType(AutostopType_T aAutostopType);
979 HRESULT getDefaultFrontend(com::Utf8Str &aDefaultFrontend);
980 HRESULT setDefaultFrontend(const com::Utf8Str &aDefaultFrontend);
981 HRESULT getUSBProxyAvailable(BOOL *aUSBProxyAvailable);
982 HRESULT getVMProcessPriority(com::Utf8Str &aVMProcessPriority);
983 HRESULT setVMProcessPriority(const com::Utf8Str &aVMProcessPriority);
984 HRESULT getUnattended(ComPtr<IUnattended> &aUnattended);
985
986 // wrapped IMachine methods
987 HRESULT lockMachine(const ComPtr<ISession> &aSession,
988 LockType_T aLockType);
989 HRESULT launchVMProcess(const ComPtr<ISession> &aSession,
990 const com::Utf8Str &aType,
991 const com::Utf8Str &aEnvironment,
992 ComPtr<IProgress> &aProgress);
993 HRESULT setBootOrder(ULONG aPosition,
994 DeviceType_T aDevice);
995 HRESULT getBootOrder(ULONG aPosition,
996 DeviceType_T *aDevice);
997 HRESULT attachDevice(const com::Utf8Str &aName,
998 LONG aControllerPort,
999 LONG aDevice,
1000 DeviceType_T aType,
1001 const ComPtr<IMedium> &aMedium);
1002 HRESULT attachDeviceWithoutMedium(const com::Utf8Str &aName,
1003 LONG aControllerPort,
1004 LONG aDevice,
1005 DeviceType_T aType);
1006 HRESULT detachDevice(const com::Utf8Str &aName,
1007 LONG aControllerPort,
1008 LONG aDevice);
1009 HRESULT passthroughDevice(const com::Utf8Str &aName,
1010 LONG aControllerPort,
1011 LONG aDevice,
1012 BOOL aPassthrough);
1013 HRESULT temporaryEjectDevice(const com::Utf8Str &aName,
1014 LONG aControllerPort,
1015 LONG aDevice,
1016 BOOL aTemporaryEject);
1017 HRESULT nonRotationalDevice(const com::Utf8Str &aName,
1018 LONG aControllerPort,
1019 LONG aDevice,
1020 BOOL aNonRotational);
1021 HRESULT setAutoDiscardForDevice(const com::Utf8Str &aName,
1022 LONG aControllerPort,
1023 LONG aDevice,
1024 BOOL aDiscard);
1025 HRESULT setHotPluggableForDevice(const com::Utf8Str &aName,
1026 LONG aControllerPort,
1027 LONG aDevice,
1028 BOOL aHotPluggable);
1029 HRESULT setBandwidthGroupForDevice(const com::Utf8Str &aName,
1030 LONG aControllerPort,
1031 LONG aDevice,
1032 const ComPtr<IBandwidthGroup> &aBandwidthGroup);
1033 HRESULT setNoBandwidthGroupForDevice(const com::Utf8Str &aName,
1034 LONG aControllerPort,
1035 LONG aDevice);
1036 HRESULT unmountMedium(const com::Utf8Str &aName,
1037 LONG aControllerPort,
1038 LONG aDevice,
1039 BOOL aForce);
1040 HRESULT mountMedium(const com::Utf8Str &aName,
1041 LONG aControllerPort,
1042 LONG aDevice,
1043 const ComPtr<IMedium> &aMedium,
1044 BOOL aForce);
1045 HRESULT getMedium(const com::Utf8Str &aName,
1046 LONG aControllerPort,
1047 LONG aDevice,
1048 ComPtr<IMedium> &aMedium);
1049 HRESULT getMediumAttachmentsOfController(const com::Utf8Str &aName,
1050 std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
1051 HRESULT getMediumAttachment(const com::Utf8Str &aName,
1052 LONG aControllerPort,
1053 LONG aDevice,
1054 ComPtr<IMediumAttachment> &aAttachment);
1055 HRESULT attachHostPCIDevice(LONG aHostAddress,
1056 LONG aDesiredGuestAddress,
1057 BOOL aTryToUnbind);
1058 HRESULT detachHostPCIDevice(LONG aHostAddress);
1059 HRESULT getNetworkAdapter(ULONG aSlot,
1060 ComPtr<INetworkAdapter> &aAdapter);
1061 HRESULT addStorageController(const com::Utf8Str &aName,
1062 StorageBus_T aConnectionType,
1063 ComPtr<IStorageController> &aController);
1064 HRESULT getStorageControllerByName(const com::Utf8Str &aName,
1065 ComPtr<IStorageController> &aStorageController);
1066 HRESULT getStorageControllerByInstance(StorageBus_T aConnectionType,
1067 ULONG aInstance,
1068 ComPtr<IStorageController> &aStorageController);
1069 HRESULT removeStorageController(const com::Utf8Str &aName);
1070 HRESULT setStorageControllerBootable(const com::Utf8Str &aName,
1071 BOOL aBootable);
1072 HRESULT addUSBController(const com::Utf8Str &aName,
1073 USBControllerType_T aType,
1074 ComPtr<IUSBController> &aController);
1075 HRESULT removeUSBController(const com::Utf8Str &aName);
1076 HRESULT getUSBControllerByName(const com::Utf8Str &aName,
1077 ComPtr<IUSBController> &aController);
1078 HRESULT getUSBControllerCountByType(USBControllerType_T aType,
1079 ULONG *aControllers);
1080 HRESULT getSerialPort(ULONG aSlot,
1081 ComPtr<ISerialPort> &aPort);
1082 HRESULT getParallelPort(ULONG aSlot,
1083 ComPtr<IParallelPort> &aPort);
1084 HRESULT getExtraDataKeys(std::vector<com::Utf8Str> &aKeys);
1085 HRESULT getExtraData(const com::Utf8Str &aKey,
1086 com::Utf8Str &aValue);
1087 HRESULT setExtraData(const com::Utf8Str &aKey,
1088 const com::Utf8Str &aValue);
1089 HRESULT getCPUProperty(CPUPropertyType_T aProperty,
1090 BOOL *aValue);
1091 HRESULT setCPUProperty(CPUPropertyType_T aProperty,
1092 BOOL aValue);
1093 HRESULT getCPUIDLeaf(ULONG aId,
1094 ULONG *aValEax,
1095 ULONG *aValEbx,
1096 ULONG *aValEcx,
1097 ULONG *aValEdx);
1098 HRESULT setCPUIDLeaf(ULONG aId,
1099 ULONG aValEax,
1100 ULONG aValEbx,
1101 ULONG aValEcx,
1102 ULONG aValEdx);
1103 HRESULT removeCPUIDLeaf(ULONG aId);
1104 HRESULT removeAllCPUIDLeaves();
1105 HRESULT getHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1106 BOOL *aValue);
1107 HRESULT setHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1108 BOOL aValue);
1109 HRESULT setSettingsFilePath(const com::Utf8Str &aSettingsFilePath,
1110 ComPtr<IProgress> &aProgress);
1111 HRESULT saveSettings();
1112 HRESULT discardSettings();
1113 HRESULT unregister(AutoCaller &aAutoCaller,
1114 CleanupMode_T aCleanupMode,
1115 std::vector<ComPtr<IMedium> > &aMedia);
1116 HRESULT deleteConfig(const std::vector<ComPtr<IMedium> > &aMedia,
1117 ComPtr<IProgress> &aProgress);
1118 HRESULT exportTo(const ComPtr<IAppliance> &aAppliance,
1119 const com::Utf8Str &aLocation,
1120 ComPtr<IVirtualSystemDescription> &aDescription);
1121 HRESULT findSnapshot(const com::Utf8Str &aNameOrId,
1122 ComPtr<ISnapshot> &aSnapshot);
1123 HRESULT createSharedFolder(const com::Utf8Str &aName,
1124 const com::Utf8Str &aHostPath,
1125 BOOL aWritable,
1126 BOOL aAutomount);
1127 HRESULT removeSharedFolder(const com::Utf8Str &aName);
1128 HRESULT canShowConsoleWindow(BOOL *aCanShow);
1129 HRESULT showConsoleWindow(LONG64 *aWinId);
1130 HRESULT getGuestProperty(const com::Utf8Str &aName,
1131 com::Utf8Str &aValue,
1132 LONG64 *aTimestamp,
1133 com::Utf8Str &aFlags);
1134 HRESULT getGuestPropertyValue(const com::Utf8Str &aProperty,
1135 com::Utf8Str &aValue);
1136 HRESULT getGuestPropertyTimestamp(const com::Utf8Str &aProperty,
1137 LONG64 *aValue);
1138 HRESULT setGuestProperty(const com::Utf8Str &aProperty,
1139 const com::Utf8Str &aValue,
1140 const com::Utf8Str &aFlags);
1141 HRESULT setGuestPropertyValue(const com::Utf8Str &aProperty,
1142 const com::Utf8Str &aValue);
1143 HRESULT deleteGuestProperty(const com::Utf8Str &aName);
1144 HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
1145 std::vector<com::Utf8Str> &aNames,
1146 std::vector<com::Utf8Str> &aValues,
1147 std::vector<LONG64> &aTimestamps,
1148 std::vector<com::Utf8Str> &aFlags);
1149 HRESULT querySavedGuestScreenInfo(ULONG aScreenId,
1150 ULONG *aOriginX,
1151 ULONG *aOriginY,
1152 ULONG *aWidth,
1153 ULONG *aHeight,
1154 BOOL *aEnabled);
1155 HRESULT readSavedThumbnailToArray(ULONG aScreenId,
1156 BitmapFormat_T aBitmapFormat,
1157 ULONG *aWidth,
1158 ULONG *aHeight,
1159 std::vector<BYTE> &aData);
1160 HRESULT querySavedScreenshotInfo(ULONG aScreenId,
1161 ULONG *aWidth,
1162 ULONG *aHeight,
1163 std::vector<BitmapFormat_T> &aBitmapFormats);
1164 HRESULT readSavedScreenshotToArray(ULONG aScreenId,
1165 BitmapFormat_T aBitmapFormat,
1166 ULONG *aWidth,
1167 ULONG *aHeight,
1168 std::vector<BYTE> &aData);
1169
1170 HRESULT hotPlugCPU(ULONG aCpu);
1171 HRESULT hotUnplugCPU(ULONG aCpu);
1172 HRESULT getCPUStatus(ULONG aCpu,
1173 BOOL *aAttached);
1174 HRESULT getEffectiveParavirtProvider(ParavirtProvider_T *aParavirtProvider);
1175 HRESULT queryLogFilename(ULONG aIdx,
1176 com::Utf8Str &aFilename);
1177 HRESULT readLog(ULONG aIdx,
1178 LONG64 aOffset,
1179 LONG64 aSize,
1180 std::vector<BYTE> &aData);
1181 HRESULT cloneTo(const ComPtr<IMachine> &aTarget,
1182 CloneMode_T aMode,
1183 const std::vector<CloneOptions_T> &aOptions,
1184 ComPtr<IProgress> &aProgress);
1185 HRESULT saveState(ComPtr<IProgress> &aProgress);
1186 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1187 HRESULT discardSavedState(BOOL aFRemoveFile);
1188 HRESULT takeSnapshot(const com::Utf8Str &aName,
1189 const com::Utf8Str &aDescription,
1190 BOOL aPause,
1191 com::Guid &aId,
1192 ComPtr<IProgress> &aProgress);
1193 HRESULT deleteSnapshot(const com::Guid &aId,
1194 ComPtr<IProgress> &aProgress);
1195 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1196 ComPtr<IProgress> &aProgress);
1197 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1198 const com::Guid &aEndId,
1199 ComPtr<IProgress> &aProgress);
1200 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1201 ComPtr<IProgress> &aProgress);
1202 HRESULT applyDefaults(const com::Utf8Str &aFlags);
1203
1204 // wrapped IInternalMachineControl properties
1205
1206 // wrapped IInternalMachineControl methods
1207 HRESULT updateState(MachineState_T aState);
1208 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1209 HRESULT endPowerUp(LONG aResult);
1210 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1211 HRESULT endPoweringDown(LONG aResult,
1212 const com::Utf8Str &aErrMsg);
1213 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1214 BOOL *aMatched,
1215 ULONG *aMaskedInterfaces);
1216 HRESULT captureUSBDevice(const com::Guid &aId,
1217 const com::Utf8Str &aCaptureFilename);
1218 HRESULT detachUSBDevice(const com::Guid &aId,
1219 BOOL aDone);
1220 HRESULT autoCaptureUSBDevices();
1221 HRESULT detachAllUSBDevices(BOOL aDone);
1222 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1223 ComPtr<IProgress> &aProgress);
1224 HRESULT finishOnlineMergeMedium();
1225 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1226 std::vector<com::Utf8Str> &aValues,
1227 std::vector<LONG64> &aTimestamps,
1228 std::vector<com::Utf8Str> &aFlags);
1229 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1230 const com::Utf8Str &aValue,
1231 LONG64 aTimestamp,
1232 const com::Utf8Str &aFlags);
1233 HRESULT lockMedia();
1234 HRESULT unlockMedia();
1235 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1236 ComPtr<IMediumAttachment> &aNewAttachment);
1237 HRESULT reportVmStatistics(ULONG aValidStats,
1238 ULONG aCpuUser,
1239 ULONG aCpuKernel,
1240 ULONG aCpuIdle,
1241 ULONG aMemTotal,
1242 ULONG aMemFree,
1243 ULONG aMemBalloon,
1244 ULONG aMemShared,
1245 ULONG aMemCache,
1246 ULONG aPagedTotal,
1247 ULONG aMemAllocTotal,
1248 ULONG aMemFreeTotal,
1249 ULONG aMemBalloonTotal,
1250 ULONG aMemSharedTotal,
1251 ULONG aVmNetRx,
1252 ULONG aVmNetTx);
1253 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1254 com::Utf8Str &aResult);
1255};
1256
1257// SessionMachine class
1258////////////////////////////////////////////////////////////////////////////////
1259
1260/**
1261 * @note Notes on locking objects of this class:
1262 * SessionMachine shares some data with the primary Machine instance (pointed
1263 * to by the |mPeer| member). In order to provide data consistency it also
1264 * shares its lock handle. This means that whenever you lock a SessionMachine
1265 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1266 * instance is also locked in the same lock mode. Keep it in mind.
1267 */
1268class ATL_NO_VTABLE SessionMachine :
1269 public Machine
1270{
1271public:
1272 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
1273
1274 DECLARE_NOT_AGGREGATABLE(SessionMachine)
1275
1276 DECLARE_PROTECT_FINAL_CONSTRUCT()
1277
1278 BEGIN_COM_MAP(SessionMachine)
1279 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1280 COM_INTERFACE_ENTRY(IMachine)
1281 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1282 COM_INTERFACE_ENTRY(IInternalMachineControl)
1283 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1284 END_COM_MAP()
1285
1286 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
1287
1288 HRESULT FinalConstruct();
1289 void FinalRelease();
1290
1291 struct Uninit
1292 {
1293 enum Reason { Unexpected, Abnormal, Normal };
1294 };
1295
1296 // public initializer/uninitializer for internal purposes only
1297 HRESULT init(Machine *aMachine);
1298 void uninit() { uninit(Uninit::Unexpected); }
1299 void uninit(Uninit::Reason aReason);
1300
1301
1302 // util::Lockable interface
1303 RWLockHandle *lockHandle() const;
1304
1305 // public methods only for internal purposes
1306
1307 virtual bool i_isSessionMachine() const
1308 {
1309 return true;
1310 }
1311
1312#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
1313 bool i_checkForDeath();
1314
1315 void i_getTokenId(Utf8Str &strTokenId);
1316#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1317 IToken *i_getToken();
1318#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1319 // getClientToken must be only used by callers who can guarantee that
1320 // the object cannot be deleted in the mean time, i.e. have a caller/lock.
1321 ClientToken *i_getClientToken();
1322
1323 HRESULT i_onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
1324 HRESULT i_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1325 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1326 IN_BSTR aGuestIp, LONG aGuestPort);
1327 HRESULT i_onStorageControllerChange();
1328 HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
1329 HRESULT i_onSerialPortChange(ISerialPort *serialPort);
1330 HRESULT i_onParallelPortChange(IParallelPort *parallelPort);
1331 HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
1332 HRESULT i_onVRDEServerChange(BOOL aRestart);
1333 HRESULT i_onVideoCaptureChange();
1334 HRESULT i_onUSBControllerChange();
1335 HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
1336 IVirtualBoxErrorInfo *aError,
1337 ULONG aMaskedIfs,
1338 const com::Utf8Str &aCaptureFilename);
1339 HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
1340 IVirtualBoxErrorInfo *aError);
1341 HRESULT i_onSharedFolderChange();
1342 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
1343 HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
1344 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1345 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1346 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1347
1348 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1349
1350 HRESULT i_lockMedia();
1351 HRESULT i_unlockMedia();
1352
1353 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1354
1355private:
1356
1357 // wrapped IInternalMachineControl properties
1358
1359 // wrapped IInternalMachineControl methods
1360 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1361 HRESULT updateState(MachineState_T aState);
1362 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1363 HRESULT endPowerUp(LONG aResult);
1364 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1365 HRESULT endPoweringDown(LONG aResult,
1366 const com::Utf8Str &aErrMsg);
1367 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1368 BOOL *aMatched,
1369 ULONG *aMaskedInterfaces);
1370 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1371 HRESULT detachUSBDevice(const com::Guid &aId,
1372 BOOL aDone);
1373 HRESULT autoCaptureUSBDevices();
1374 HRESULT detachAllUSBDevices(BOOL aDone);
1375 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1376 ComPtr<IProgress> &aProgress);
1377 HRESULT finishOnlineMergeMedium();
1378 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1379 std::vector<com::Utf8Str> &aValues,
1380 std::vector<LONG64> &aTimestamps,
1381 std::vector<com::Utf8Str> &aFlags);
1382 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1383 const com::Utf8Str &aValue,
1384 LONG64 aTimestamp,
1385 const com::Utf8Str &aFlags);
1386 HRESULT lockMedia();
1387 HRESULT unlockMedia();
1388 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1389 ComPtr<IMediumAttachment> &aNewAttachment);
1390 HRESULT reportVmStatistics(ULONG aValidStats,
1391 ULONG aCpuUser,
1392 ULONG aCpuKernel,
1393 ULONG aCpuIdle,
1394 ULONG aMemTotal,
1395 ULONG aMemFree,
1396 ULONG aMemBalloon,
1397 ULONG aMemShared,
1398 ULONG aMemCache,
1399 ULONG aPagedTotal,
1400 ULONG aMemAllocTotal,
1401 ULONG aMemFreeTotal,
1402 ULONG aMemBalloonTotal,
1403 ULONG aMemSharedTotal,
1404 ULONG aVmNetRx,
1405 ULONG aVmNetTx);
1406 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1407 com::Utf8Str &aResult);
1408
1409
1410 struct ConsoleTaskData
1411 {
1412 ConsoleTaskData()
1413 : mLastState(MachineState_Null),
1414 mDeleteSnapshotInfo(NULL)
1415 { }
1416
1417 MachineState_T mLastState;
1418 ComObjPtr<Progress> mProgress;
1419
1420 // used when deleting online snaphshot
1421 void *mDeleteSnapshotInfo;
1422 };
1423
1424 class SaveStateTask;
1425 class SnapshotTask;
1426 class TakeSnapshotTask;
1427 class DeleteSnapshotTask;
1428 class RestoreSnapshotTask;
1429
1430 void i_saveStateHandler(SaveStateTask &aTask);
1431
1432 // Override some functionality for SessionMachine, this is where the
1433 // real action happens (the Machine methods are just dummies).
1434 HRESULT saveState(ComPtr<IProgress> &aProgress);
1435 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1436 HRESULT discardSavedState(BOOL aFRemoveFile);
1437 HRESULT takeSnapshot(const com::Utf8Str &aName,
1438 const com::Utf8Str &aDescription,
1439 BOOL aPause,
1440 com::Guid &aId,
1441 ComPtr<IProgress> &aProgress);
1442 HRESULT deleteSnapshot(const com::Guid &aId,
1443 ComPtr<IProgress> &aProgress);
1444 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1445 ComPtr<IProgress> &aProgress);
1446 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1447 const com::Guid &aEndId,
1448 ComPtr<IProgress> &aProgress);
1449 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1450 ComPtr<IProgress> &aProgress);
1451
1452 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1453
1454 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1455 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1456 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1457 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1458 const com::Guid &aEndId,
1459 BOOL aDeleteAllChildren,
1460 ComPtr<IProgress> &aProgress);
1461 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1462 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1463
1464 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1465 const Guid &machineId,
1466 const Guid &snapshotId,
1467 bool fOnlineMergePossible,
1468 MediumLockList *aVMMALockList,
1469 ComObjPtr<Medium> &aSource,
1470 ComObjPtr<Medium> &aTarget,
1471 bool &fMergeForward,
1472 ComObjPtr<Medium> &pParentForTarget,
1473 MediumLockList * &aChildrenToReparent,
1474 bool &fNeedOnlineMerge,
1475 MediumLockList * &aMediumLockList,
1476 ComPtr<IToken> &aHDLockToken);
1477 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1478 const ComObjPtr<Medium> &aSource,
1479 MediumLockList *aChildrenToReparent,
1480 bool fNeedsOnlineMerge,
1481 MediumLockList *aMediumLockList,
1482 const ComPtr<IToken> &aHDLockToken,
1483 const Guid &aMediumId,
1484 const Guid &aSnapshotId);
1485 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1486 const ComObjPtr<Medium> &aSource,
1487 const ComObjPtr<Medium> &aTarget,
1488 bool fMergeForward,
1489 const ComObjPtr<Medium> &pParentForTarget,
1490 MediumLockList *aChildrenToReparent,
1491 MediumLockList *aMediumLockList,
1492 ComObjPtr<Progress> &aProgress,
1493 bool *pfNeedsMachineSaveSettings);
1494
1495 HRESULT i_setMachineState(MachineState_T aMachineState);
1496 HRESULT i_updateMachineStateOnClient();
1497
1498 bool mRemoveSavedState;
1499
1500 ConsoleTaskData mConsoleTaskData;
1501
1502 /** client token for this machine */
1503 ClientToken *mClientToken;
1504
1505 int miNATNetworksStarted;
1506
1507 AUTHLIBRARYCONTEXT mAuthLibCtx;
1508};
1509
1510// SnapshotMachine class
1511////////////////////////////////////////////////////////////////////////////////
1512
1513/**
1514 * @note Notes on locking objects of this class:
1515 * SnapshotMachine shares some data with the primary Machine instance (pointed
1516 * to by the |mPeer| member). In order to provide data consistency it also
1517 * shares its lock handle. This means that whenever you lock a SessionMachine
1518 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1519 * instance is also locked in the same lock mode. Keep it in mind.
1520 */
1521class ATL_NO_VTABLE SnapshotMachine :
1522 public Machine
1523{
1524public:
1525 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1526
1527 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1528
1529 DECLARE_PROTECT_FINAL_CONSTRUCT()
1530
1531 BEGIN_COM_MAP(SnapshotMachine)
1532 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1533 COM_INTERFACE_ENTRY(IMachine)
1534 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1535 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1536 END_COM_MAP()
1537
1538 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1539
1540 HRESULT FinalConstruct();
1541 void FinalRelease();
1542
1543 // public initializer/uninitializer for internal purposes only
1544 HRESULT init(SessionMachine *aSessionMachine,
1545 IN_GUID aSnapshotId,
1546 const Utf8Str &aStateFilePath);
1547 HRESULT initFromSettings(Machine *aMachine,
1548 const settings::Hardware &hardware,
1549 const settings::Debugging *pDbg,
1550 const settings::Autostart *pAutostart,
1551 IN_GUID aSnapshotId,
1552 const Utf8Str &aStateFilePath);
1553 void uninit();
1554
1555 // util::Lockable interface
1556 RWLockHandle *lockHandle() const;
1557
1558 // public methods only for internal purposes
1559
1560 virtual bool i_isSnapshotMachine() const
1561 {
1562 return true;
1563 }
1564
1565 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1566
1567 // unsafe inline public methods for internal purposes only (ensure there is
1568 // a caller and a read lock before calling them!)
1569
1570 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1571
1572private:
1573
1574 Guid mSnapshotId;
1575 /** This field replaces mPeer for SessionMachine instances, as having
1576 * a peer reference is plain meaningless and causes many subtle problems
1577 * with saving settings and the like. */
1578 Machine * const mMachine;
1579
1580 friend class Snapshot;
1581};
1582
1583// third party methods that depend on SnapshotMachine definition
1584
1585inline const Guid &Machine::i_getSnapshotId() const
1586{
1587 return (i_isSnapshotMachine())
1588 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1589 : Guid::Empty;
1590}
1591
1592
1593#endif // ____H_MACHINEIMPL
1594/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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