VirtualBox

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

Last change on this file since 87093 was 86908, checked in by vboxsync, 4 years ago

Shared Clipboard/Transfers: Removed clipboard area handling code. bugref:9437

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

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