VirtualBox

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

Last change on this file since 75324 was 75324, checked in by vboxsync, 6 years ago

Recording: More settings bugfixes for Main and FE/Qt.

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