VirtualBox

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

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

Recording/Main: Renaming (IMachine::IsModified_Record -> IMachine::IsModified_Recording).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 68.1 KB
Line 
1/* $Id: MachineImpl.h 75453 2018-11-14 14:46:01Z 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 "RecordingSettingsImpl.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::RecordingSettings mRecordSettings;
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_Recording = 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_onRecordChange() { 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<RecordingSettings> mRecordingSettings;
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 RecordingSettings;
828 friend class RecordingScreenSettings;
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 getRecordingSettings(ComPtr<IRecordingSettings> &aRecordingSettings);
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 const com::Utf8Str &aAutoMountPoint);
1119 HRESULT removeSharedFolder(const com::Utf8Str &aName);
1120 HRESULT canShowConsoleWindow(BOOL *aCanShow);
1121 HRESULT showConsoleWindow(LONG64 *aWinId);
1122 HRESULT getGuestProperty(const com::Utf8Str &aName,
1123 com::Utf8Str &aValue,
1124 LONG64 *aTimestamp,
1125 com::Utf8Str &aFlags);
1126 HRESULT getGuestPropertyValue(const com::Utf8Str &aProperty,
1127 com::Utf8Str &aValue);
1128 HRESULT getGuestPropertyTimestamp(const com::Utf8Str &aProperty,
1129 LONG64 *aValue);
1130 HRESULT setGuestProperty(const com::Utf8Str &aProperty,
1131 const com::Utf8Str &aValue,
1132 const com::Utf8Str &aFlags);
1133 HRESULT setGuestPropertyValue(const com::Utf8Str &aProperty,
1134 const com::Utf8Str &aValue);
1135 HRESULT deleteGuestProperty(const com::Utf8Str &aName);
1136 HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
1137 std::vector<com::Utf8Str> &aNames,
1138 std::vector<com::Utf8Str> &aValues,
1139 std::vector<LONG64> &aTimestamps,
1140 std::vector<com::Utf8Str> &aFlags);
1141 HRESULT querySavedGuestScreenInfo(ULONG aScreenId,
1142 ULONG *aOriginX,
1143 ULONG *aOriginY,
1144 ULONG *aWidth,
1145 ULONG *aHeight,
1146 BOOL *aEnabled);
1147 HRESULT readSavedThumbnailToArray(ULONG aScreenId,
1148 BitmapFormat_T aBitmapFormat,
1149 ULONG *aWidth,
1150 ULONG *aHeight,
1151 std::vector<BYTE> &aData);
1152 HRESULT querySavedScreenshotInfo(ULONG aScreenId,
1153 ULONG *aWidth,
1154 ULONG *aHeight,
1155 std::vector<BitmapFormat_T> &aBitmapFormats);
1156 HRESULT readSavedScreenshotToArray(ULONG aScreenId,
1157 BitmapFormat_T aBitmapFormat,
1158 ULONG *aWidth,
1159 ULONG *aHeight,
1160 std::vector<BYTE> &aData);
1161
1162 HRESULT hotPlugCPU(ULONG aCpu);
1163 HRESULT hotUnplugCPU(ULONG aCpu);
1164 HRESULT getCPUStatus(ULONG aCpu,
1165 BOOL *aAttached);
1166 HRESULT getEffectiveParavirtProvider(ParavirtProvider_T *aParavirtProvider);
1167 HRESULT queryLogFilename(ULONG aIdx,
1168 com::Utf8Str &aFilename);
1169 HRESULT readLog(ULONG aIdx,
1170 LONG64 aOffset,
1171 LONG64 aSize,
1172 std::vector<BYTE> &aData);
1173 HRESULT cloneTo(const ComPtr<IMachine> &aTarget,
1174 CloneMode_T aMode,
1175 const std::vector<CloneOptions_T> &aOptions,
1176 ComPtr<IProgress> &aProgress);
1177 HRESULT moveTo(const com::Utf8Str &aTargetPath,
1178 const com::Utf8Str &aType,
1179 ComPtr<IProgress> &aProgress);
1180 HRESULT saveState(ComPtr<IProgress> &aProgress);
1181 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1182 HRESULT discardSavedState(BOOL aFRemoveFile);
1183 HRESULT takeSnapshot(const com::Utf8Str &aName,
1184 const com::Utf8Str &aDescription,
1185 BOOL aPause,
1186 com::Guid &aId,
1187 ComPtr<IProgress> &aProgress);
1188 HRESULT deleteSnapshot(const com::Guid &aId,
1189 ComPtr<IProgress> &aProgress);
1190 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1191 ComPtr<IProgress> &aProgress);
1192 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1193 const com::Guid &aEndId,
1194 ComPtr<IProgress> &aProgress);
1195 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1196 ComPtr<IProgress> &aProgress);
1197 HRESULT applyDefaults(const com::Utf8Str &aFlags);
1198
1199 // wrapped IInternalMachineControl properties
1200
1201 // wrapped IInternalMachineControl methods
1202 HRESULT updateState(MachineState_T aState);
1203 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1204 HRESULT endPowerUp(LONG aResult);
1205 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1206 HRESULT endPoweringDown(LONG aResult,
1207 const com::Utf8Str &aErrMsg);
1208 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1209 BOOL *aMatched,
1210 ULONG *aMaskedInterfaces);
1211 HRESULT captureUSBDevice(const com::Guid &aId,
1212 const com::Utf8Str &aCaptureFilename);
1213 HRESULT detachUSBDevice(const com::Guid &aId,
1214 BOOL aDone);
1215 HRESULT autoCaptureUSBDevices();
1216 HRESULT detachAllUSBDevices(BOOL aDone);
1217 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1218 ComPtr<IProgress> &aProgress);
1219 HRESULT finishOnlineMergeMedium();
1220 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1221 std::vector<com::Utf8Str> &aValues,
1222 std::vector<LONG64> &aTimestamps,
1223 std::vector<com::Utf8Str> &aFlags);
1224 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1225 const com::Utf8Str &aValue,
1226 LONG64 aTimestamp,
1227 const com::Utf8Str &aFlags);
1228 HRESULT lockMedia();
1229 HRESULT unlockMedia();
1230 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1231 ComPtr<IMediumAttachment> &aNewAttachment);
1232 HRESULT reportVmStatistics(ULONG aValidStats,
1233 ULONG aCpuUser,
1234 ULONG aCpuKernel,
1235 ULONG aCpuIdle,
1236 ULONG aMemTotal,
1237 ULONG aMemFree,
1238 ULONG aMemBalloon,
1239 ULONG aMemShared,
1240 ULONG aMemCache,
1241 ULONG aPagedTotal,
1242 ULONG aMemAllocTotal,
1243 ULONG aMemFreeTotal,
1244 ULONG aMemBalloonTotal,
1245 ULONG aMemSharedTotal,
1246 ULONG aVmNetRx,
1247 ULONG aVmNetTx);
1248 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1249 com::Utf8Str &aResult);
1250};
1251
1252// SessionMachine class
1253////////////////////////////////////////////////////////////////////////////////
1254
1255/**
1256 * @note Notes on locking objects of this class:
1257 * SessionMachine shares some data with the primary Machine instance (pointed
1258 * to by the |mPeer| member). In order to provide data consistency it also
1259 * shares its lock handle. This means that whenever you lock a SessionMachine
1260 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1261 * instance is also locked in the same lock mode. Keep it in mind.
1262 */
1263class ATL_NO_VTABLE SessionMachine :
1264 public Machine
1265{
1266public:
1267 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
1268
1269 DECLARE_NOT_AGGREGATABLE(SessionMachine)
1270
1271 DECLARE_PROTECT_FINAL_CONSTRUCT()
1272
1273 BEGIN_COM_MAP(SessionMachine)
1274 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1275 COM_INTERFACE_ENTRY(IMachine)
1276 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1277 COM_INTERFACE_ENTRY(IInternalMachineControl)
1278 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1279 END_COM_MAP()
1280
1281 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
1282
1283 HRESULT FinalConstruct();
1284 void FinalRelease();
1285
1286 struct Uninit
1287 {
1288 enum Reason { Unexpected, Abnormal, Normal };
1289 };
1290
1291 // public initializer/uninitializer for internal purposes only
1292 HRESULT init(Machine *aMachine);
1293 void uninit() { uninit(Uninit::Unexpected); }
1294 void uninit(Uninit::Reason aReason);
1295
1296
1297 // util::Lockable interface
1298 RWLockHandle *lockHandle() const;
1299
1300 // public methods only for internal purposes
1301
1302 virtual bool i_isSessionMachine() const
1303 {
1304 return true;
1305 }
1306
1307#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
1308 bool i_checkForDeath();
1309
1310 void i_getTokenId(Utf8Str &strTokenId);
1311#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1312 IToken *i_getToken();
1313#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1314 // getClientToken must be only used by callers who can guarantee that
1315 // the object cannot be deleted in the mean time, i.e. have a caller/lock.
1316 ClientToken *i_getClientToken();
1317
1318 HRESULT i_onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
1319 HRESULT i_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1320 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1321 IN_BSTR aGuestIp, LONG aGuestPort);
1322 HRESULT i_onStorageControllerChange();
1323 HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
1324 HRESULT i_onAudioAdapterChange(IAudioAdapter *audioAdapter);
1325 HRESULT i_onSerialPortChange(ISerialPort *serialPort);
1326 HRESULT i_onParallelPortChange(IParallelPort *parallelPort);
1327 HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
1328 HRESULT i_onVRDEServerChange(BOOL aRestart);
1329 HRESULT i_onRecordChange();
1330 HRESULT i_onUSBControllerChange();
1331 HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
1332 IVirtualBoxErrorInfo *aError,
1333 ULONG aMaskedIfs,
1334 const com::Utf8Str &aCaptureFilename);
1335 HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
1336 IVirtualBoxErrorInfo *aError);
1337 HRESULT i_onSharedFolderChange();
1338 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
1339 HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
1340 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1341 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1342 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1343
1344 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1345
1346 HRESULT i_lockMedia();
1347 HRESULT i_unlockMedia();
1348
1349 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1350
1351private:
1352
1353 // wrapped IInternalMachineControl properties
1354
1355 // wrapped IInternalMachineControl methods
1356 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1357 HRESULT updateState(MachineState_T aState);
1358 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1359 HRESULT endPowerUp(LONG aResult);
1360 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1361 HRESULT endPoweringDown(LONG aResult,
1362 const com::Utf8Str &aErrMsg);
1363 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1364 BOOL *aMatched,
1365 ULONG *aMaskedInterfaces);
1366 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1367 HRESULT detachUSBDevice(const com::Guid &aId,
1368 BOOL aDone);
1369 HRESULT autoCaptureUSBDevices();
1370 HRESULT detachAllUSBDevices(BOOL aDone);
1371 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1372 ComPtr<IProgress> &aProgress);
1373 HRESULT finishOnlineMergeMedium();
1374 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1375 std::vector<com::Utf8Str> &aValues,
1376 std::vector<LONG64> &aTimestamps,
1377 std::vector<com::Utf8Str> &aFlags);
1378 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1379 const com::Utf8Str &aValue,
1380 LONG64 aTimestamp,
1381 const com::Utf8Str &aFlags);
1382 HRESULT lockMedia();
1383 HRESULT unlockMedia();
1384 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1385 ComPtr<IMediumAttachment> &aNewAttachment);
1386 HRESULT reportVmStatistics(ULONG aValidStats,
1387 ULONG aCpuUser,
1388 ULONG aCpuKernel,
1389 ULONG aCpuIdle,
1390 ULONG aMemTotal,
1391 ULONG aMemFree,
1392 ULONG aMemBalloon,
1393 ULONG aMemShared,
1394 ULONG aMemCache,
1395 ULONG aPagedTotal,
1396 ULONG aMemAllocTotal,
1397 ULONG aMemFreeTotal,
1398 ULONG aMemBalloonTotal,
1399 ULONG aMemSharedTotal,
1400 ULONG aVmNetRx,
1401 ULONG aVmNetTx);
1402 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1403 com::Utf8Str &aResult);
1404
1405
1406 struct ConsoleTaskData
1407 {
1408 ConsoleTaskData()
1409 : mLastState(MachineState_Null),
1410 mDeleteSnapshotInfo(NULL)
1411 { }
1412
1413 MachineState_T mLastState;
1414 ComObjPtr<Progress> mProgress;
1415
1416 // used when deleting online snaphshot
1417 void *mDeleteSnapshotInfo;
1418 };
1419
1420 class SaveStateTask;
1421 class SnapshotTask;
1422 class TakeSnapshotTask;
1423 class DeleteSnapshotTask;
1424 class RestoreSnapshotTask;
1425
1426 void i_saveStateHandler(SaveStateTask &aTask);
1427
1428 // Override some functionality for SessionMachine, this is where the
1429 // real action happens (the Machine methods are just dummies).
1430 HRESULT saveState(ComPtr<IProgress> &aProgress);
1431 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1432 HRESULT discardSavedState(BOOL aFRemoveFile);
1433 HRESULT takeSnapshot(const com::Utf8Str &aName,
1434 const com::Utf8Str &aDescription,
1435 BOOL aPause,
1436 com::Guid &aId,
1437 ComPtr<IProgress> &aProgress);
1438 HRESULT deleteSnapshot(const com::Guid &aId,
1439 ComPtr<IProgress> &aProgress);
1440 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1441 ComPtr<IProgress> &aProgress);
1442 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1443 const com::Guid &aEndId,
1444 ComPtr<IProgress> &aProgress);
1445 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1446 ComPtr<IProgress> &aProgress);
1447
1448 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1449
1450 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1451 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1452 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1453 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1454 const com::Guid &aEndId,
1455 BOOL aDeleteAllChildren,
1456 ComPtr<IProgress> &aProgress);
1457 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1458 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1459
1460 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1461 const Guid &machineId,
1462 const Guid &snapshotId,
1463 bool fOnlineMergePossible,
1464 MediumLockList *aVMMALockList,
1465 ComObjPtr<Medium> &aSource,
1466 ComObjPtr<Medium> &aTarget,
1467 bool &fMergeForward,
1468 ComObjPtr<Medium> &pParentForTarget,
1469 MediumLockList * &aChildrenToReparent,
1470 bool &fNeedOnlineMerge,
1471 MediumLockList * &aMediumLockList,
1472 ComPtr<IToken> &aHDLockToken);
1473 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1474 const ComObjPtr<Medium> &aSource,
1475 MediumLockList *aChildrenToReparent,
1476 bool fNeedsOnlineMerge,
1477 MediumLockList *aMediumLockList,
1478 const ComPtr<IToken> &aHDLockToken,
1479 const Guid &aMediumId,
1480 const Guid &aSnapshotId);
1481 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1482 const ComObjPtr<Medium> &aSource,
1483 const ComObjPtr<Medium> &aTarget,
1484 bool fMergeForward,
1485 const ComObjPtr<Medium> &pParentForTarget,
1486 MediumLockList *aChildrenToReparent,
1487 MediumLockList *aMediumLockList,
1488 ComObjPtr<Progress> &aProgress,
1489 bool *pfNeedsMachineSaveSettings);
1490
1491 HRESULT i_setMachineState(MachineState_T aMachineState);
1492 HRESULT i_updateMachineStateOnClient();
1493
1494 bool mRemoveSavedState;
1495
1496 ConsoleTaskData mConsoleTaskData;
1497
1498 /** client token for this machine */
1499 ClientToken *mClientToken;
1500
1501 int miNATNetworksStarted;
1502
1503 AUTHLIBRARYCONTEXT mAuthLibCtx;
1504};
1505
1506// SnapshotMachine class
1507////////////////////////////////////////////////////////////////////////////////
1508
1509/**
1510 * @note Notes on locking objects of this class:
1511 * SnapshotMachine shares some data with the primary Machine instance (pointed
1512 * to by the |mPeer| member). In order to provide data consistency it also
1513 * shares its lock handle. This means that whenever you lock a SessionMachine
1514 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1515 * instance is also locked in the same lock mode. Keep it in mind.
1516 */
1517class ATL_NO_VTABLE SnapshotMachine :
1518 public Machine
1519{
1520public:
1521 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1522
1523 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1524
1525 DECLARE_PROTECT_FINAL_CONSTRUCT()
1526
1527 BEGIN_COM_MAP(SnapshotMachine)
1528 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1529 COM_INTERFACE_ENTRY(IMachine)
1530 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1531 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1532 END_COM_MAP()
1533
1534 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1535
1536 HRESULT FinalConstruct();
1537 void FinalRelease();
1538
1539 // public initializer/uninitializer for internal purposes only
1540 HRESULT init(SessionMachine *aSessionMachine,
1541 IN_GUID aSnapshotId,
1542 const Utf8Str &aStateFilePath);
1543 HRESULT initFromSettings(Machine *aMachine,
1544 const settings::Hardware &hardware,
1545 const settings::Debugging *pDbg,
1546 const settings::Autostart *pAutostart,
1547 IN_GUID aSnapshotId,
1548 const Utf8Str &aStateFilePath);
1549 void uninit();
1550
1551 // util::Lockable interface
1552 RWLockHandle *lockHandle() const;
1553
1554 // public methods only for internal purposes
1555
1556 virtual bool i_isSnapshotMachine() const
1557 {
1558 return true;
1559 }
1560
1561 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1562
1563 // unsafe inline public methods for internal purposes only (ensure there is
1564 // a caller and a read lock before calling them!)
1565
1566 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1567
1568private:
1569
1570 Guid mSnapshotId;
1571 /** This field replaces mPeer for SessionMachine instances, as having
1572 * a peer reference is plain meaningless and causes many subtle problems
1573 * with saving settings and the like. */
1574 Machine * const mMachine;
1575
1576 friend class Snapshot;
1577};
1578
1579// third party methods that depend on SnapshotMachine definition
1580
1581inline const Guid &Machine::i_getSnapshotId() const
1582{
1583 return (i_isSnapshotMachine())
1584 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1585 : Guid::Empty;
1586}
1587
1588
1589#endif // ____H_MACHINEIMPL
1590/* 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