VirtualBox

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

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

bugref:8527. added Unattended object as class member into MachineImpl class

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

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