VirtualBox

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

Last change on this file since 75251 was 75251, checked in by vboxsync, 7 years ago

Capturing: Separated capturing settings into new interfaces ICaptureSettings and ICaptureScreenSettings to unload stuff from IMachine; a lot of internal interface / code cleanups. Also see #9286. Work in progress.

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

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