VirtualBox

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

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

Recording: 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 75307 2018-11-07 13:56:14Z 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 ParavirtProvider_T i_getParavirtProvider() const { return mHWData->mParavirtProvider; }
492 Utf8Str i_getParavirtDebug() const { return mHWData->mParavirtDebug; }
493
494 void i_setModified(uint32_t fl, bool fAllowStateModification = true);
495 void i_setModifiedLock(uint32_t fl, bool fAllowStateModification = true);
496
497 MachineState_T i_getMachineState() const { return mData->mMachineState; }
498
499 bool i_isStateModificationAllowed() const { return mData->m_fAllowStateModification; }
500 void i_allowStateModification() { mData->m_fAllowStateModification = true; }
501 void i_disallowStateModification() { mData->m_fAllowStateModification = false; }
502
503 const StringsList &i_getGroups() const { return mUserData->s.llGroups; }
504
505 // callback handlers
506 virtual HRESULT i_onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
507 virtual HRESULT i_onNATRedirectRuleChange(ULONG /* slot */, BOOL /* fRemove */ , IN_BSTR /* name */,
508 NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */,
509 IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
510 virtual HRESULT i_onAudioAdapterChange(IAudioAdapter * /* audioAdapter */) { return S_OK; }
511 virtual HRESULT i_onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
512 virtual HRESULT i_onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
513 virtual HRESULT i_onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
514 virtual HRESULT i_onUSBControllerChange() { return S_OK; }
515 virtual HRESULT i_onStorageControllerChange() { return S_OK; }
516 virtual HRESULT i_onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
517 virtual HRESULT i_onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
518 virtual HRESULT i_onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
519 virtual HRESULT i_onSharedFolderChange() { return S_OK; }
520 virtual HRESULT i_onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
521 virtual HRESULT i_onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; }
522 virtual HRESULT i_onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
523 virtual HRESULT i_onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */,
524 BOOL /* silent */) { return S_OK; }
525 virtual HRESULT i_onCaptureChange() { return S_OK; }
526
527 HRESULT i_saveRegistryEntry(settings::MachineRegistryEntry &data);
528
529 int i_calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
530 void i_copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
531
532 void i_getLogFolder(Utf8Str &aLogFolder);
533 Utf8Str i_getLogFilename(ULONG idx);
534 Utf8Str i_getHardeningLogFilename(void);
535
536 void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
537
538 bool i_isUSBControllerPresent();
539
540 HRESULT i_launchVMProcess(IInternalSessionControl *aControl,
541 const Utf8Str &strType,
542 const Utf8Str &strEnvironment,
543 ProgressProxy *aProgress);
544
545 HRESULT i_getDirectControl(ComPtr<IInternalSessionControl> *directControl)
546 {
547 HRESULT rc;
548 *directControl = mData->mSession.mDirectControl;
549
550 if (!*directControl)
551 rc = E_ACCESSDENIED;
552 else
553 rc = S_OK;
554
555 return rc;
556 }
557
558 bool i_isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
559 ComPtr<IInternalSessionControl> *aControl = NULL,
560 bool aRequireVM = false,
561 bool aAllowClosing = false);
562 bool i_isSessionSpawning();
563
564 bool i_isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
565 ComPtr<IInternalSessionControl> *aControl = NULL)
566 { return i_isSessionOpen(aMachine, aControl, false /* aRequireVM */, true /* aAllowClosing */); }
567
568 bool i_isSessionOpenVM(ComObjPtr<SessionMachine> &aMachine,
569 ComPtr<IInternalSessionControl> *aControl = NULL)
570 { return i_isSessionOpen(aMachine, aControl, true /* aRequireVM */, false /* aAllowClosing */); }
571
572 bool i_checkForSpawnFailure();
573
574 HRESULT i_prepareRegister();
575
576 HRESULT i_getSharedFolder(CBSTR aName,
577 ComObjPtr<SharedFolder> &aSharedFolder,
578 bool aSetError = false)
579 {
580 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
581 return i_findSharedFolder(aName, aSharedFolder, aSetError);
582 }
583
584 HRESULT i_addStateDependency(StateDependency aDepType = AnyStateDep,
585 MachineState_T *aState = NULL,
586 BOOL *aRegistered = NULL);
587 void i_releaseStateDependency();
588
589 HRESULT i_getStorageControllerByName(const Utf8Str &aName,
590 ComObjPtr<StorageController> &aStorageController,
591 bool aSetError = false);
592
593 HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
594 MediumAttachmentList &aAttachments);
595
596 HRESULT i_getUSBControllerByName(const Utf8Str &aName,
597 ComObjPtr<USBController> &aUSBController,
598 bool aSetError = false);
599
600 HRESULT i_getBandwidthGroup(const Utf8Str &strBandwidthGroup,
601 ComObjPtr<BandwidthGroup> &pBandwidthGroup,
602 bool fSetError = false)
603 {
604 return mBandwidthControl->i_getBandwidthGroupByName(strBandwidthGroup,
605 pBandwidthGroup,
606 fSetError);
607 }
608
609 static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcszMsg, ...);
610
611protected:
612
613 class ClientToken;
614
615 HRESULT i_checkStateDependency(StateDependency aDepType);
616
617 Machine *i_getMachine();
618
619 void i_ensureNoStateDependencies();
620
621 virtual HRESULT i_setMachineState(MachineState_T aMachineState);
622
623 HRESULT i_findSharedFolder(const Utf8Str &aName,
624 ComObjPtr<SharedFolder> &aSharedFolder,
625 bool aSetError = false);
626
627 HRESULT i_loadSettings(bool aRegistered);
628 HRESULT i_loadMachineDataFromSettings(const settings::MachineConfigFile &config,
629 const Guid *puuidRegistry);
630 HRESULT i_loadSnapshot(const settings::Snapshot &data,
631 const Guid &aCurSnapshotId,
632 Snapshot *aParentSnapshot);
633 HRESULT i_loadHardware(const Guid *puuidRegistry,
634 const Guid *puuidSnapshot,
635 const settings::Hardware &data,
636 const settings::Debugging *pDbg,
637 const settings::Autostart *pAutostart);
638 HRESULT i_loadDebugging(const settings::Debugging *pDbg);
639 HRESULT i_loadAutostart(const settings::Autostart *pAutostart);
640 HRESULT i_loadStorageControllers(const settings::Storage &data,
641 const Guid *puuidRegistry,
642 const Guid *puuidSnapshot);
643 HRESULT i_loadStorageDevices(StorageController *aStorageController,
644 const settings::StorageController &data,
645 const Guid *puuidRegistry,
646 const Guid *puuidSnapshot);
647
648 HRESULT i_findSnapshotById(const Guid &aId,
649 ComObjPtr<Snapshot> &aSnapshot,
650 bool aSetError = false);
651 HRESULT i_findSnapshotByName(const Utf8Str &strName,
652 ComObjPtr<Snapshot> &aSnapshot,
653 bool aSetError = false);
654
655 ULONG i_getUSBControllerCountByType(USBControllerType_T enmType);
656
657 enum
658 {
659 /* flags for #saveSettings() */
660 SaveS_ResetCurStateModified = 0x01,
661 SaveS_Force = 0x04,
662 /* flags for #saveStateSettings() */
663 SaveSTS_CurStateModified = 0x20,
664 SaveSTS_StateFilePath = 0x40,
665 SaveSTS_StateTimeStamp = 0x80
666 };
667
668 HRESULT i_prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
669 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
670
671 void i_copyMachineDataToSettings(settings::MachineConfigFile &config);
672 HRESULT i_saveAllSnapshots(settings::MachineConfigFile &config);
673 HRESULT i_saveHardware(settings::Hardware &data, settings::Debugging *pDbg,
674 settings::Autostart *pAutostart);
675 HRESULT i_saveStorageControllers(settings::Storage &data);
676 HRESULT i_saveStorageDevices(ComObjPtr<StorageController> aStorageController,
677 settings::StorageController &data);
678 HRESULT i_saveStateSettings(int aFlags);
679
680 void i_addMediumToRegistry(ComObjPtr<Medium> &pMedium);
681
682 HRESULT i_createImplicitDiffs(IProgress *aProgress,
683 ULONG aWeight,
684 bool aOnline);
685 HRESULT i_deleteImplicitDiffs(bool aOnline);
686
687 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
688 const Utf8Str &aControllerName,
689 LONG aControllerPort,
690 LONG aDevice);
691 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
692 ComObjPtr<Medium> pMedium);
693 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
694 Guid &id);
695
696 HRESULT i_detachDevice(MediumAttachment *pAttach,
697 AutoWriteLock &writeLock,
698 Snapshot *pSnapshot);
699
700 HRESULT i_detachAllMedia(AutoWriteLock &writeLock,
701 Snapshot *pSnapshot,
702 CleanupMode_T cleanupMode,
703 MediaList &llMedia);
704
705 void i_commitMedia(bool aOnline = false);
706 void i_rollbackMedia();
707
708 bool i_isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
709
710 void i_rollback(bool aNotify);
711 void i_commit();
712 void i_copyFrom(Machine *aThat);
713 bool i_isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
714
715 Utf8Str i_getExtraData(const Utf8Str &strKey);
716
717#ifdef VBOX_WITH_GUEST_PROPS
718 HRESULT i_getGuestPropertyFromService(const com::Utf8Str &aName, com::Utf8Str &aValue,
719 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
720 HRESULT i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue,
721 const com::Utf8Str &aFlags, bool fDelete);
722 HRESULT i_getGuestPropertyFromVM(const com::Utf8Str &aName, com::Utf8Str &aValue,
723 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
724 HRESULT i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue,
725 const com::Utf8Str &aFlags, bool fDelete);
726 HRESULT i_enumerateGuestPropertiesInService(const com::Utf8Str &aPatterns,
727 std::vector<com::Utf8Str> &aNames,
728 std::vector<com::Utf8Str> &aValues,
729 std::vector<LONG64> &aTimestamps,
730 std::vector<com::Utf8Str> &aFlags);
731 HRESULT i_enumerateGuestPropertiesOnVM(const com::Utf8Str &aPatterns,
732 std::vector<com::Utf8Str> &aNames,
733 std::vector<com::Utf8Str> &aValues,
734 std::vector<LONG64> &aTimestamps,
735 std::vector<com::Utf8Str> &aFlags);
736
737#endif /* VBOX_WITH_GUEST_PROPS */
738
739#ifdef VBOX_WITH_RESOURCE_USAGE_API
740 void i_getDiskList(MediaList &list);
741 void i_registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
742
743 pm::CollectorGuest *mCollectorGuest;
744#endif /* VBOX_WITH_RESOURCE_USAGE_API */
745
746 Machine * const mPeer;
747
748 VirtualBox * const mParent;
749
750 Shareable<Data> mData;
751 Shareable<SSData> mSSData;
752
753 Backupable<UserData> mUserData;
754 Backupable<HWData> mHWData;
755
756 /**
757 * Hard disk and other media data.
758 *
759 * The usage policy is the same as for mHWData, but a separate field
760 * is necessary because hard disk data requires different procedures when
761 * taking or deleting snapshots, etc.
762 *
763 * @todo r=klaus change this to a regular list and use the normal way to
764 * handle the settings when creating a session or taking a snapshot.
765 * Same thing applies to mStorageControllers and mUSBControllers.
766 */
767 Backupable<MediumAttachmentList> mMediumAttachments;
768
769 // the following fields need special backup/rollback/commit handling,
770 // so they cannot be a part of HWData
771
772 const ComObjPtr<VRDEServer> mVRDEServer;
773 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
774 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
775 const ComObjPtr<AudioAdapter> mAudioAdapter;
776 const ComObjPtr<USBDeviceFilters> mUSBDeviceFilters;
777 const ComObjPtr<BIOSSettings> mBIOSSettings;
778 const ComObjPtr<CaptureSettings> mCaptureSettings;
779 const ComObjPtr<BandwidthControl> mBandwidthControl;
780
781 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
782 NetworkAdapterVector mNetworkAdapters;
783
784 typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
785 Backupable<StorageControllerList> mStorageControllers;
786
787 typedef std::list<ComObjPtr<USBController> > USBControllerList;
788 Backupable<USBControllerList> mUSBControllers;
789
790 uint64_t uRegistryNeedsSaving;
791
792 /**
793 * Abstract base class for all Machine or SessionMachine related
794 * asynchronous tasks. This is necessary since RTThreadCreate cannot call
795 * a (non-static) method as its thread function, so instead we have it call
796 * the static Machine::taskHandler, which then calls the handler() method
797 * in here (implemented by the subclasses).
798 */
799 class Task : public ThreadTask
800 {
801 public:
802 Task(Machine *m, Progress *p, const Utf8Str &t)
803 : ThreadTask(t),
804 m_pMachine(m),
805 m_machineCaller(m),
806 m_pProgress(p),
807 m_machineStateBackup(m->mData->mMachineState) // save the current machine state
808 {}
809 virtual ~Task(){}
810
811 void modifyBackedUpState(MachineState_T s)
812 {
813 *const_cast<MachineState_T *>(&m_machineStateBackup) = s;
814 }
815
816 ComObjPtr<Machine> m_pMachine;
817 AutoCaller m_machineCaller;
818 ComObjPtr<Progress> m_pProgress;
819 const MachineState_T m_machineStateBackup;
820 };
821
822 class DeleteConfigTask;
823 void i_deleteConfigHandler(DeleteConfigTask &task);
824
825 friend class Appliance;
826 friend class CaptureSettings;
827 friend class CaptureScreenSettings;
828 friend class SessionMachine;
829 friend class SnapshotMachine;
830 friend class VirtualBox;
831
832 friend class MachineCloneVM;
833 friend class MachineMoveVM;
834private:
835 // wrapped IMachine properties
836 HRESULT getParent(ComPtr<IVirtualBox> &aParent);
837 HRESULT getIcon(std::vector<BYTE> &aIcon);
838 HRESULT setIcon(const std::vector<BYTE> &aIcon);
839 HRESULT getAccessible(BOOL *aAccessible);
840 HRESULT getAccessError(ComPtr<IVirtualBoxErrorInfo> &aAccessError);
841 HRESULT getName(com::Utf8Str &aName);
842 HRESULT setName(const com::Utf8Str &aName);
843 HRESULT getDescription(com::Utf8Str &aDescription);
844 HRESULT setDescription(const com::Utf8Str &aDescription);
845 HRESULT getId(com::Guid &aId);
846 HRESULT getGroups(std::vector<com::Utf8Str> &aGroups);
847 HRESULT setGroups(const std::vector<com::Utf8Str> &aGroups);
848 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
849 HRESULT setOSTypeId(const com::Utf8Str &aOSTypeId);
850 HRESULT getHardwareVersion(com::Utf8Str &aHardwareVersion);
851 HRESULT setHardwareVersion(const com::Utf8Str &aHardwareVersion);
852 HRESULT getHardwareUUID(com::Guid &aHardwareUUID);
853 HRESULT setHardwareUUID(const com::Guid &aHardwareUUID);
854 HRESULT getCPUCount(ULONG *aCPUCount);
855 HRESULT setCPUCount(ULONG aCPUCount);
856 HRESULT getCPUHotPlugEnabled(BOOL *aCPUHotPlugEnabled);
857 HRESULT setCPUHotPlugEnabled(BOOL aCPUHotPlugEnabled);
858 HRESULT getCPUExecutionCap(ULONG *aCPUExecutionCap);
859 HRESULT setCPUExecutionCap(ULONG aCPUExecutionCap);
860 HRESULT getCPUIDPortabilityLevel(ULONG *aCPUIDPortabilityLevel);
861 HRESULT setCPUIDPortabilityLevel(ULONG aCPUIDPortabilityLevel);
862 HRESULT getCPUProfile(com::Utf8Str &aCPUProfile);
863 HRESULT setCPUProfile(const com::Utf8Str &aCPUProfile);
864 HRESULT getMemorySize(ULONG *aMemorySize);
865 HRESULT setMemorySize(ULONG aMemorySize);
866 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
867 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
868 HRESULT getPageFusionEnabled(BOOL *aPageFusionEnabled);
869 HRESULT setPageFusionEnabled(BOOL aPageFusionEnabled);
870 HRESULT getGraphicsControllerType(GraphicsControllerType_T *aGraphicsControllerType);
871 HRESULT setGraphicsControllerType(GraphicsControllerType_T aGraphicsControllerType);
872 HRESULT getVRAMSize(ULONG *aVRAMSize);
873 HRESULT setVRAMSize(ULONG aVRAMSize);
874 HRESULT getAccelerate3DEnabled(BOOL *aAccelerate3DEnabled);
875 HRESULT setAccelerate3DEnabled(BOOL aAccelerate3DEnabled);
876 HRESULT getAccelerate2DVideoEnabled(BOOL *aAccelerate2DVideoEnabled);
877 HRESULT setAccelerate2DVideoEnabled(BOOL aAccelerate2DVideoEnabled);
878 HRESULT getMonitorCount(ULONG *aMonitorCount);
879 HRESULT setMonitorCount(ULONG aMonitorCount);
880 HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
881 HRESULT getCaptureSettings(ComPtr<ICaptureSettings> &aCaptureSettings);
882 HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
883 HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
884 HRESULT getPointingHIDType(PointingHIDType_T *aPointingHIDType);
885 HRESULT setPointingHIDType(PointingHIDType_T aPointingHIDType);
886 HRESULT getKeyboardHIDType(KeyboardHIDType_T *aKeyboardHIDType);
887 HRESULT setKeyboardHIDType(KeyboardHIDType_T aKeyboardHIDType);
888 HRESULT getHPETEnabled(BOOL *aHPETEnabled);
889 HRESULT setHPETEnabled(BOOL aHPETEnabled);
890 HRESULT getChipsetType(ChipsetType_T *aChipsetType);
891 HRESULT setChipsetType(ChipsetType_T aChipsetType);
892 HRESULT getSnapshotFolder(com::Utf8Str &aSnapshotFolder);
893 HRESULT setSnapshotFolder(const com::Utf8Str &aSnapshotFolder);
894 HRESULT getVRDEServer(ComPtr<IVRDEServer> &aVRDEServer);
895 HRESULT getEmulatedUSBCardReaderEnabled(BOOL *aEmulatedUSBCardReaderEnabled);
896 HRESULT setEmulatedUSBCardReaderEnabled(BOOL aEmulatedUSBCardReaderEnabled);
897 HRESULT getMediumAttachments(std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
898 HRESULT getUSBControllers(std::vector<ComPtr<IUSBController> > &aUSBControllers);
899 HRESULT getUSBDeviceFilters(ComPtr<IUSBDeviceFilters> &aUSBDeviceFilters);
900 HRESULT getAudioAdapter(ComPtr<IAudioAdapter> &aAudioAdapter);
901 HRESULT getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers);
902 HRESULT getSettingsFilePath(com::Utf8Str &aSettingsFilePath);
903 HRESULT getSettingsAuxFilePath(com::Utf8Str &aSettingsAuxFilePath);
904 HRESULT getSettingsModified(BOOL *aSettingsModified);
905 HRESULT getSessionState(SessionState_T *aSessionState);
906 HRESULT getSessionType(SessionType_T *aSessionType);
907 HRESULT getSessionName(com::Utf8Str &aSessionType);
908 HRESULT getSessionPID(ULONG *aSessionPID);
909 HRESULT getState(MachineState_T *aState);
910 HRESULT getLastStateChange(LONG64 *aLastStateChange);
911 HRESULT getStateFilePath(com::Utf8Str &aStateFilePath);
912 HRESULT getLogFolder(com::Utf8Str &aLogFolder);
913 HRESULT getCurrentSnapshot(ComPtr<ISnapshot> &aCurrentSnapshot);
914 HRESULT getSnapshotCount(ULONG *aSnapshotCount);
915 HRESULT getCurrentStateModified(BOOL *aCurrentStateModified);
916 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
917 HRESULT getClipboardMode(ClipboardMode_T *aClipboardMode);
918 HRESULT setClipboardMode(ClipboardMode_T aClipboardMode);
919 HRESULT getDnDMode(DnDMode_T *aDnDMode);
920 HRESULT setDnDMode(DnDMode_T aDnDMode);
921 HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
922 HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
923 HRESULT getTeleporterPort(ULONG *aTeleporterPort);
924 HRESULT setTeleporterPort(ULONG aTeleporterPort);
925 HRESULT getTeleporterAddress(com::Utf8Str &aTeleporterAddress);
926 HRESULT setTeleporterAddress(const com::Utf8Str &aTeleporterAddress);
927 HRESULT getTeleporterPassword(com::Utf8Str &aTeleporterPassword);
928 HRESULT setTeleporterPassword(const com::Utf8Str &aTeleporterPassword);
929 HRESULT getParavirtProvider(ParavirtProvider_T *aParavirtProvider);
930 HRESULT setParavirtProvider(ParavirtProvider_T aParavirtProvider);
931 HRESULT getParavirtDebug(com::Utf8Str &aParavirtDebug);
932 HRESULT setParavirtDebug(const com::Utf8Str &aParavirtDebug);
933 HRESULT getFaultToleranceState(FaultToleranceState_T *aFaultToleranceState);
934 HRESULT setFaultToleranceState(FaultToleranceState_T aFaultToleranceState);
935 HRESULT getFaultTolerancePort(ULONG *aFaultTolerancePort);
936 HRESULT setFaultTolerancePort(ULONG aFaultTolerancePort);
937 HRESULT getFaultToleranceAddress(com::Utf8Str &aFaultToleranceAddress);
938 HRESULT setFaultToleranceAddress(const com::Utf8Str &aFaultToleranceAddress);
939 HRESULT getFaultTolerancePassword(com::Utf8Str &aFaultTolerancePassword);
940 HRESULT setFaultTolerancePassword(const com::Utf8Str &aFaultTolerancePassword);
941 HRESULT getFaultToleranceSyncInterval(ULONG *aFaultToleranceSyncInterval);
942 HRESULT setFaultToleranceSyncInterval(ULONG aFaultToleranceSyncInterval);
943 HRESULT getRTCUseUTC(BOOL *aRTCUseUTC);
944 HRESULT setRTCUseUTC(BOOL aRTCUseUTC);
945 HRESULT getIOCacheEnabled(BOOL *aIOCacheEnabled);
946 HRESULT setIOCacheEnabled(BOOL aIOCacheEnabled);
947 HRESULT getIOCacheSize(ULONG *aIOCacheSize);
948 HRESULT setIOCacheSize(ULONG aIOCacheSize);
949 HRESULT getPCIDeviceAssignments(std::vector<ComPtr<IPCIDeviceAttachment> > &aPCIDeviceAssignments);
950 HRESULT getBandwidthControl(ComPtr<IBandwidthControl> &aBandwidthControl);
951 HRESULT getTracingEnabled(BOOL *aTracingEnabled);
952 HRESULT setTracingEnabled(BOOL aTracingEnabled);
953 HRESULT getTracingConfig(com::Utf8Str &aTracingConfig);
954 HRESULT setTracingConfig(const com::Utf8Str &aTracingConfig);
955 HRESULT getAllowTracingToAccessVM(BOOL *aAllowTracingToAccessVM);
956 HRESULT setAllowTracingToAccessVM(BOOL aAllowTracingToAccessVM);
957 HRESULT getAutostartEnabled(BOOL *aAutostartEnabled);
958 HRESULT setAutostartEnabled(BOOL aAutostartEnabled);
959 HRESULT getAutostartDelay(ULONG *aAutostartDelay);
960 HRESULT setAutostartDelay(ULONG aAutostartDelay);
961 HRESULT getAutostopType(AutostopType_T *aAutostopType);
962 HRESULT setAutostopType(AutostopType_T aAutostopType);
963 HRESULT getDefaultFrontend(com::Utf8Str &aDefaultFrontend);
964 HRESULT setDefaultFrontend(const com::Utf8Str &aDefaultFrontend);
965 HRESULT getUSBProxyAvailable(BOOL *aUSBProxyAvailable);
966 HRESULT getVMProcessPriority(com::Utf8Str &aVMProcessPriority);
967 HRESULT setVMProcessPriority(const com::Utf8Str &aVMProcessPriority);
968
969 // wrapped IMachine methods
970 HRESULT lockMachine(const ComPtr<ISession> &aSession,
971 LockType_T aLockType);
972 HRESULT launchVMProcess(const ComPtr<ISession> &aSession,
973 const com::Utf8Str &aType,
974 const com::Utf8Str &aEnvironment,
975 ComPtr<IProgress> &aProgress);
976 HRESULT setBootOrder(ULONG aPosition,
977 DeviceType_T aDevice);
978 HRESULT getBootOrder(ULONG aPosition,
979 DeviceType_T *aDevice);
980 HRESULT attachDevice(const com::Utf8Str &aName,
981 LONG aControllerPort,
982 LONG aDevice,
983 DeviceType_T aType,
984 const ComPtr<IMedium> &aMedium);
985 HRESULT attachDeviceWithoutMedium(const com::Utf8Str &aName,
986 LONG aControllerPort,
987 LONG aDevice,
988 DeviceType_T aType);
989 HRESULT detachDevice(const com::Utf8Str &aName,
990 LONG aControllerPort,
991 LONG aDevice);
992 HRESULT passthroughDevice(const com::Utf8Str &aName,
993 LONG aControllerPort,
994 LONG aDevice,
995 BOOL aPassthrough);
996 HRESULT temporaryEjectDevice(const com::Utf8Str &aName,
997 LONG aControllerPort,
998 LONG aDevice,
999 BOOL aTemporaryEject);
1000 HRESULT nonRotationalDevice(const com::Utf8Str &aName,
1001 LONG aControllerPort,
1002 LONG aDevice,
1003 BOOL aNonRotational);
1004 HRESULT setAutoDiscardForDevice(const com::Utf8Str &aName,
1005 LONG aControllerPort,
1006 LONG aDevice,
1007 BOOL aDiscard);
1008 HRESULT setHotPluggableForDevice(const com::Utf8Str &aName,
1009 LONG aControllerPort,
1010 LONG aDevice,
1011 BOOL aHotPluggable);
1012 HRESULT setBandwidthGroupForDevice(const com::Utf8Str &aName,
1013 LONG aControllerPort,
1014 LONG aDevice,
1015 const ComPtr<IBandwidthGroup> &aBandwidthGroup);
1016 HRESULT setNoBandwidthGroupForDevice(const com::Utf8Str &aName,
1017 LONG aControllerPort,
1018 LONG aDevice);
1019 HRESULT unmountMedium(const com::Utf8Str &aName,
1020 LONG aControllerPort,
1021 LONG aDevice,
1022 BOOL aForce);
1023 HRESULT mountMedium(const com::Utf8Str &aName,
1024 LONG aControllerPort,
1025 LONG aDevice,
1026 const ComPtr<IMedium> &aMedium,
1027 BOOL aForce);
1028 HRESULT getMedium(const com::Utf8Str &aName,
1029 LONG aControllerPort,
1030 LONG aDevice,
1031 ComPtr<IMedium> &aMedium);
1032 HRESULT getMediumAttachmentsOfController(const com::Utf8Str &aName,
1033 std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
1034 HRESULT getMediumAttachment(const com::Utf8Str &aName,
1035 LONG aControllerPort,
1036 LONG aDevice,
1037 ComPtr<IMediumAttachment> &aAttachment);
1038 HRESULT attachHostPCIDevice(LONG aHostAddress,
1039 LONG aDesiredGuestAddress,
1040 BOOL aTryToUnbind);
1041 HRESULT detachHostPCIDevice(LONG aHostAddress);
1042 HRESULT getNetworkAdapter(ULONG aSlot,
1043 ComPtr<INetworkAdapter> &aAdapter);
1044 HRESULT addStorageController(const com::Utf8Str &aName,
1045 StorageBus_T aConnectionType,
1046 ComPtr<IStorageController> &aController);
1047 HRESULT getStorageControllerByName(const com::Utf8Str &aName,
1048 ComPtr<IStorageController> &aStorageController);
1049 HRESULT getStorageControllerByInstance(StorageBus_T aConnectionType,
1050 ULONG aInstance,
1051 ComPtr<IStorageController> &aStorageController);
1052 HRESULT removeStorageController(const com::Utf8Str &aName);
1053 HRESULT setStorageControllerBootable(const com::Utf8Str &aName,
1054 BOOL aBootable);
1055 HRESULT addUSBController(const com::Utf8Str &aName,
1056 USBControllerType_T aType,
1057 ComPtr<IUSBController> &aController);
1058 HRESULT removeUSBController(const com::Utf8Str &aName);
1059 HRESULT getUSBControllerByName(const com::Utf8Str &aName,
1060 ComPtr<IUSBController> &aController);
1061 HRESULT getUSBControllerCountByType(USBControllerType_T aType,
1062 ULONG *aControllers);
1063 HRESULT getSerialPort(ULONG aSlot,
1064 ComPtr<ISerialPort> &aPort);
1065 HRESULT getParallelPort(ULONG aSlot,
1066 ComPtr<IParallelPort> &aPort);
1067 HRESULT getExtraDataKeys(std::vector<com::Utf8Str> &aKeys);
1068 HRESULT getExtraData(const com::Utf8Str &aKey,
1069 com::Utf8Str &aValue);
1070 HRESULT setExtraData(const com::Utf8Str &aKey,
1071 const com::Utf8Str &aValue);
1072 HRESULT getCPUProperty(CPUPropertyType_T aProperty,
1073 BOOL *aValue);
1074 HRESULT setCPUProperty(CPUPropertyType_T aProperty,
1075 BOOL aValue);
1076 HRESULT getCPUIDLeafByOrdinal(ULONG aOrdinal,
1077 ULONG *aIdx,
1078 ULONG *aSubIdx,
1079 ULONG *aValEax,
1080 ULONG *aValEbx,
1081 ULONG *aValEcx,
1082 ULONG *aValEdx);
1083 HRESULT getCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1084 ULONG *aValEax,
1085 ULONG *aValEbx,
1086 ULONG *aValEcx,
1087 ULONG *aValEdx);
1088 HRESULT setCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1089 ULONG aValEax,
1090 ULONG aValEbx,
1091 ULONG aValEcx,
1092 ULONG aValEdx);
1093 HRESULT removeCPUIDLeaf(ULONG aIdx, ULONG aSubIdx);
1094 HRESULT removeAllCPUIDLeaves();
1095 HRESULT getHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1096 BOOL *aValue);
1097 HRESULT setHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1098 BOOL aValue);
1099 HRESULT setSettingsFilePath(const com::Utf8Str &aSettingsFilePath,
1100 ComPtr<IProgress> &aProgress);
1101 HRESULT saveSettings();
1102 HRESULT discardSettings();
1103 HRESULT unregister(AutoCaller &aAutoCaller,
1104 CleanupMode_T aCleanupMode,
1105 std::vector<ComPtr<IMedium> > &aMedia);
1106 HRESULT deleteConfig(const std::vector<ComPtr<IMedium> > &aMedia,
1107 ComPtr<IProgress> &aProgress);
1108 HRESULT exportTo(const ComPtr<IAppliance> &aAppliance,
1109 const com::Utf8Str &aLocation,
1110 ComPtr<IVirtualSystemDescription> &aDescription);
1111 HRESULT findSnapshot(const com::Utf8Str &aNameOrId,
1112 ComPtr<ISnapshot> &aSnapshot);
1113 HRESULT createSharedFolder(const com::Utf8Str &aName,
1114 const com::Utf8Str &aHostPath,
1115 BOOL aWritable,
1116 BOOL aAutomount);
1117 HRESULT removeSharedFolder(const com::Utf8Str &aName);
1118 HRESULT canShowConsoleWindow(BOOL *aCanShow);
1119 HRESULT showConsoleWindow(LONG64 *aWinId);
1120 HRESULT getGuestProperty(const com::Utf8Str &aName,
1121 com::Utf8Str &aValue,
1122 LONG64 *aTimestamp,
1123 com::Utf8Str &aFlags);
1124 HRESULT getGuestPropertyValue(const com::Utf8Str &aProperty,
1125 com::Utf8Str &aValue);
1126 HRESULT getGuestPropertyTimestamp(const com::Utf8Str &aProperty,
1127 LONG64 *aValue);
1128 HRESULT setGuestProperty(const com::Utf8Str &aProperty,
1129 const com::Utf8Str &aValue,
1130 const com::Utf8Str &aFlags);
1131 HRESULT setGuestPropertyValue(const com::Utf8Str &aProperty,
1132 const com::Utf8Str &aValue);
1133 HRESULT deleteGuestProperty(const com::Utf8Str &aName);
1134 HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
1135 std::vector<com::Utf8Str> &aNames,
1136 std::vector<com::Utf8Str> &aValues,
1137 std::vector<LONG64> &aTimestamps,
1138 std::vector<com::Utf8Str> &aFlags);
1139 HRESULT querySavedGuestScreenInfo(ULONG aScreenId,
1140 ULONG *aOriginX,
1141 ULONG *aOriginY,
1142 ULONG *aWidth,
1143 ULONG *aHeight,
1144 BOOL *aEnabled);
1145 HRESULT readSavedThumbnailToArray(ULONG aScreenId,
1146 BitmapFormat_T aBitmapFormat,
1147 ULONG *aWidth,
1148 ULONG *aHeight,
1149 std::vector<BYTE> &aData);
1150 HRESULT querySavedScreenshotInfo(ULONG aScreenId,
1151 ULONG *aWidth,
1152 ULONG *aHeight,
1153 std::vector<BitmapFormat_T> &aBitmapFormats);
1154 HRESULT readSavedScreenshotToArray(ULONG aScreenId,
1155 BitmapFormat_T aBitmapFormat,
1156 ULONG *aWidth,
1157 ULONG *aHeight,
1158 std::vector<BYTE> &aData);
1159
1160 HRESULT hotPlugCPU(ULONG aCpu);
1161 HRESULT hotUnplugCPU(ULONG aCpu);
1162 HRESULT getCPUStatus(ULONG aCpu,
1163 BOOL *aAttached);
1164 HRESULT getEffectiveParavirtProvider(ParavirtProvider_T *aParavirtProvider);
1165 HRESULT queryLogFilename(ULONG aIdx,
1166 com::Utf8Str &aFilename);
1167 HRESULT readLog(ULONG aIdx,
1168 LONG64 aOffset,
1169 LONG64 aSize,
1170 std::vector<BYTE> &aData);
1171 HRESULT cloneTo(const ComPtr<IMachine> &aTarget,
1172 CloneMode_T aMode,
1173 const std::vector<CloneOptions_T> &aOptions,
1174 ComPtr<IProgress> &aProgress);
1175 HRESULT moveTo(const com::Utf8Str &aTargetPath,
1176 const com::Utf8Str &aType,
1177 ComPtr<IProgress> &aProgress);
1178 HRESULT saveState(ComPtr<IProgress> &aProgress);
1179 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1180 HRESULT discardSavedState(BOOL aFRemoveFile);
1181 HRESULT takeSnapshot(const com::Utf8Str &aName,
1182 const com::Utf8Str &aDescription,
1183 BOOL aPause,
1184 com::Guid &aId,
1185 ComPtr<IProgress> &aProgress);
1186 HRESULT deleteSnapshot(const com::Guid &aId,
1187 ComPtr<IProgress> &aProgress);
1188 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1189 ComPtr<IProgress> &aProgress);
1190 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1191 const com::Guid &aEndId,
1192 ComPtr<IProgress> &aProgress);
1193 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1194 ComPtr<IProgress> &aProgress);
1195 HRESULT applyDefaults(const com::Utf8Str &aFlags);
1196
1197 // wrapped IInternalMachineControl properties
1198
1199 // wrapped IInternalMachineControl methods
1200 HRESULT updateState(MachineState_T aState);
1201 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1202 HRESULT endPowerUp(LONG aResult);
1203 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1204 HRESULT endPoweringDown(LONG aResult,
1205 const com::Utf8Str &aErrMsg);
1206 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1207 BOOL *aMatched,
1208 ULONG *aMaskedInterfaces);
1209 HRESULT captureUSBDevice(const com::Guid &aId,
1210 const com::Utf8Str &aCaptureFilename);
1211 HRESULT detachUSBDevice(const com::Guid &aId,
1212 BOOL aDone);
1213 HRESULT autoCaptureUSBDevices();
1214 HRESULT detachAllUSBDevices(BOOL aDone);
1215 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1216 ComPtr<IProgress> &aProgress);
1217 HRESULT finishOnlineMergeMedium();
1218 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1219 std::vector<com::Utf8Str> &aValues,
1220 std::vector<LONG64> &aTimestamps,
1221 std::vector<com::Utf8Str> &aFlags);
1222 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1223 const com::Utf8Str &aValue,
1224 LONG64 aTimestamp,
1225 const com::Utf8Str &aFlags);
1226 HRESULT lockMedia();
1227 HRESULT unlockMedia();
1228 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1229 ComPtr<IMediumAttachment> &aNewAttachment);
1230 HRESULT reportVmStatistics(ULONG aValidStats,
1231 ULONG aCpuUser,
1232 ULONG aCpuKernel,
1233 ULONG aCpuIdle,
1234 ULONG aMemTotal,
1235 ULONG aMemFree,
1236 ULONG aMemBalloon,
1237 ULONG aMemShared,
1238 ULONG aMemCache,
1239 ULONG aPagedTotal,
1240 ULONG aMemAllocTotal,
1241 ULONG aMemFreeTotal,
1242 ULONG aMemBalloonTotal,
1243 ULONG aMemSharedTotal,
1244 ULONG aVmNetRx,
1245 ULONG aVmNetTx);
1246 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1247 com::Utf8Str &aResult);
1248};
1249
1250// SessionMachine class
1251////////////////////////////////////////////////////////////////////////////////
1252
1253/**
1254 * @note Notes on locking objects of this class:
1255 * SessionMachine shares some data with the primary Machine instance (pointed
1256 * to by the |mPeer| member). In order to provide data consistency it also
1257 * shares its lock handle. This means that whenever you lock a SessionMachine
1258 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1259 * instance is also locked in the same lock mode. Keep it in mind.
1260 */
1261class ATL_NO_VTABLE SessionMachine :
1262 public Machine
1263{
1264public:
1265 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
1266
1267 DECLARE_NOT_AGGREGATABLE(SessionMachine)
1268
1269 DECLARE_PROTECT_FINAL_CONSTRUCT()
1270
1271 BEGIN_COM_MAP(SessionMachine)
1272 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1273 COM_INTERFACE_ENTRY(IMachine)
1274 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1275 COM_INTERFACE_ENTRY(IInternalMachineControl)
1276 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1277 END_COM_MAP()
1278
1279 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
1280
1281 HRESULT FinalConstruct();
1282 void FinalRelease();
1283
1284 struct Uninit
1285 {
1286 enum Reason { Unexpected, Abnormal, Normal };
1287 };
1288
1289 // public initializer/uninitializer for internal purposes only
1290 HRESULT init(Machine *aMachine);
1291 void uninit() { uninit(Uninit::Unexpected); }
1292 void uninit(Uninit::Reason aReason);
1293
1294
1295 // util::Lockable interface
1296 RWLockHandle *lockHandle() const;
1297
1298 // public methods only for internal purposes
1299
1300 virtual bool i_isSessionMachine() const
1301 {
1302 return true;
1303 }
1304
1305#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
1306 bool i_checkForDeath();
1307
1308 void i_getTokenId(Utf8Str &strTokenId);
1309#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1310 IToken *i_getToken();
1311#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1312 // getClientToken must be only used by callers who can guarantee that
1313 // the object cannot be deleted in the mean time, i.e. have a caller/lock.
1314 ClientToken *i_getClientToken();
1315
1316 HRESULT i_onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
1317 HRESULT i_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1318 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1319 IN_BSTR aGuestIp, LONG aGuestPort);
1320 HRESULT i_onStorageControllerChange();
1321 HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
1322 HRESULT i_onAudioAdapterChange(IAudioAdapter *audioAdapter);
1323 HRESULT i_onSerialPortChange(ISerialPort *serialPort);
1324 HRESULT i_onParallelPortChange(IParallelPort *parallelPort);
1325 HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
1326 HRESULT i_onVRDEServerChange(BOOL aRestart);
1327 HRESULT i_onCaptureChange();
1328 HRESULT i_onUSBControllerChange();
1329 HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
1330 IVirtualBoxErrorInfo *aError,
1331 ULONG aMaskedIfs,
1332 const com::Utf8Str &aCaptureFilename);
1333 HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
1334 IVirtualBoxErrorInfo *aError);
1335 HRESULT i_onSharedFolderChange();
1336 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
1337 HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
1338 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1339 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1340 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1341
1342 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1343
1344 HRESULT i_lockMedia();
1345 HRESULT i_unlockMedia();
1346
1347 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1348
1349private:
1350
1351 // wrapped IInternalMachineControl properties
1352
1353 // wrapped IInternalMachineControl methods
1354 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1355 HRESULT updateState(MachineState_T aState);
1356 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1357 HRESULT endPowerUp(LONG aResult);
1358 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1359 HRESULT endPoweringDown(LONG aResult,
1360 const com::Utf8Str &aErrMsg);
1361 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1362 BOOL *aMatched,
1363 ULONG *aMaskedInterfaces);
1364 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1365 HRESULT detachUSBDevice(const com::Guid &aId,
1366 BOOL aDone);
1367 HRESULT autoCaptureUSBDevices();
1368 HRESULT detachAllUSBDevices(BOOL aDone);
1369 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1370 ComPtr<IProgress> &aProgress);
1371 HRESULT finishOnlineMergeMedium();
1372 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1373 std::vector<com::Utf8Str> &aValues,
1374 std::vector<LONG64> &aTimestamps,
1375 std::vector<com::Utf8Str> &aFlags);
1376 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1377 const com::Utf8Str &aValue,
1378 LONG64 aTimestamp,
1379 const com::Utf8Str &aFlags);
1380 HRESULT lockMedia();
1381 HRESULT unlockMedia();
1382 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1383 ComPtr<IMediumAttachment> &aNewAttachment);
1384 HRESULT reportVmStatistics(ULONG aValidStats,
1385 ULONG aCpuUser,
1386 ULONG aCpuKernel,
1387 ULONG aCpuIdle,
1388 ULONG aMemTotal,
1389 ULONG aMemFree,
1390 ULONG aMemBalloon,
1391 ULONG aMemShared,
1392 ULONG aMemCache,
1393 ULONG aPagedTotal,
1394 ULONG aMemAllocTotal,
1395 ULONG aMemFreeTotal,
1396 ULONG aMemBalloonTotal,
1397 ULONG aMemSharedTotal,
1398 ULONG aVmNetRx,
1399 ULONG aVmNetTx);
1400 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1401 com::Utf8Str &aResult);
1402
1403
1404 struct ConsoleTaskData
1405 {
1406 ConsoleTaskData()
1407 : mLastState(MachineState_Null),
1408 mDeleteSnapshotInfo(NULL)
1409 { }
1410
1411 MachineState_T mLastState;
1412 ComObjPtr<Progress> mProgress;
1413
1414 // used when deleting online snaphshot
1415 void *mDeleteSnapshotInfo;
1416 };
1417
1418 class SaveStateTask;
1419 class SnapshotTask;
1420 class TakeSnapshotTask;
1421 class DeleteSnapshotTask;
1422 class RestoreSnapshotTask;
1423
1424 void i_saveStateHandler(SaveStateTask &aTask);
1425
1426 // Override some functionality for SessionMachine, this is where the
1427 // real action happens (the Machine methods are just dummies).
1428 HRESULT saveState(ComPtr<IProgress> &aProgress);
1429 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1430 HRESULT discardSavedState(BOOL aFRemoveFile);
1431 HRESULT takeSnapshot(const com::Utf8Str &aName,
1432 const com::Utf8Str &aDescription,
1433 BOOL aPause,
1434 com::Guid &aId,
1435 ComPtr<IProgress> &aProgress);
1436 HRESULT deleteSnapshot(const com::Guid &aId,
1437 ComPtr<IProgress> &aProgress);
1438 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1439 ComPtr<IProgress> &aProgress);
1440 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1441 const com::Guid &aEndId,
1442 ComPtr<IProgress> &aProgress);
1443 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1444 ComPtr<IProgress> &aProgress);
1445
1446 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1447
1448 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1449 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1450 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1451 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1452 const com::Guid &aEndId,
1453 BOOL aDeleteAllChildren,
1454 ComPtr<IProgress> &aProgress);
1455 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1456 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1457
1458 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1459 const Guid &machineId,
1460 const Guid &snapshotId,
1461 bool fOnlineMergePossible,
1462 MediumLockList *aVMMALockList,
1463 ComObjPtr<Medium> &aSource,
1464 ComObjPtr<Medium> &aTarget,
1465 bool &fMergeForward,
1466 ComObjPtr<Medium> &pParentForTarget,
1467 MediumLockList * &aChildrenToReparent,
1468 bool &fNeedOnlineMerge,
1469 MediumLockList * &aMediumLockList,
1470 ComPtr<IToken> &aHDLockToken);
1471 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1472 const ComObjPtr<Medium> &aSource,
1473 MediumLockList *aChildrenToReparent,
1474 bool fNeedsOnlineMerge,
1475 MediumLockList *aMediumLockList,
1476 const ComPtr<IToken> &aHDLockToken,
1477 const Guid &aMediumId,
1478 const Guid &aSnapshotId);
1479 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1480 const ComObjPtr<Medium> &aSource,
1481 const ComObjPtr<Medium> &aTarget,
1482 bool fMergeForward,
1483 const ComObjPtr<Medium> &pParentForTarget,
1484 MediumLockList *aChildrenToReparent,
1485 MediumLockList *aMediumLockList,
1486 ComObjPtr<Progress> &aProgress,
1487 bool *pfNeedsMachineSaveSettings);
1488
1489 HRESULT i_setMachineState(MachineState_T aMachineState);
1490 HRESULT i_updateMachineStateOnClient();
1491
1492 bool mRemoveSavedState;
1493
1494 ConsoleTaskData mConsoleTaskData;
1495
1496 /** client token for this machine */
1497 ClientToken *mClientToken;
1498
1499 int miNATNetworksStarted;
1500
1501 AUTHLIBRARYCONTEXT mAuthLibCtx;
1502};
1503
1504// SnapshotMachine class
1505////////////////////////////////////////////////////////////////////////////////
1506
1507/**
1508 * @note Notes on locking objects of this class:
1509 * SnapshotMachine shares some data with the primary Machine instance (pointed
1510 * to by the |mPeer| member). In order to provide data consistency it also
1511 * shares its lock handle. This means that whenever you lock a SessionMachine
1512 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1513 * instance is also locked in the same lock mode. Keep it in mind.
1514 */
1515class ATL_NO_VTABLE SnapshotMachine :
1516 public Machine
1517{
1518public:
1519 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1520
1521 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1522
1523 DECLARE_PROTECT_FINAL_CONSTRUCT()
1524
1525 BEGIN_COM_MAP(SnapshotMachine)
1526 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1527 COM_INTERFACE_ENTRY(IMachine)
1528 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1529 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1530 END_COM_MAP()
1531
1532 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1533
1534 HRESULT FinalConstruct();
1535 void FinalRelease();
1536
1537 // public initializer/uninitializer for internal purposes only
1538 HRESULT init(SessionMachine *aSessionMachine,
1539 IN_GUID aSnapshotId,
1540 const Utf8Str &aStateFilePath);
1541 HRESULT initFromSettings(Machine *aMachine,
1542 const settings::Hardware &hardware,
1543 const settings::Debugging *pDbg,
1544 const settings::Autostart *pAutostart,
1545 IN_GUID aSnapshotId,
1546 const Utf8Str &aStateFilePath);
1547 void uninit();
1548
1549 // util::Lockable interface
1550 RWLockHandle *lockHandle() const;
1551
1552 // public methods only for internal purposes
1553
1554 virtual bool i_isSnapshotMachine() const
1555 {
1556 return true;
1557 }
1558
1559 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1560
1561 // unsafe inline public methods for internal purposes only (ensure there is
1562 // a caller and a read lock before calling them!)
1563
1564 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1565
1566private:
1567
1568 Guid mSnapshotId;
1569 /** This field replaces mPeer for SessionMachine instances, as having
1570 * a peer reference is plain meaningless and causes many subtle problems
1571 * with saving settings and the like. */
1572 Machine * const mMachine;
1573
1574 friend class Snapshot;
1575};
1576
1577// third party methods that depend on SnapshotMachine definition
1578
1579inline const Guid &Machine::i_getSnapshotId() const
1580{
1581 return (i_isSnapshotMachine())
1582 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1583 : Guid::Empty;
1584}
1585
1586
1587#endif // ____H_MACHINEIMPL
1588/* 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