VirtualBox

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

Last change on this file since 60441 was 60410, checked in by vboxsync, 9 years ago

IMachine: Added CPUProfile attribute (read/write string). Added a modifyvm option for setting it. Show non-default values in showvminfo, but always show it starting with 6.0.

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