VirtualBox

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

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

Main: Use MAIN_INCLUDED_ and MAIN_INCLUDED_SRC_ as header guard prefixes with scm.

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