VirtualBox

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

最後變更 在這個檔案從91420是 91326,由 vboxsync 提交於 4 年 前

Main/NvramStore,FE/VBoxManage: Allow multiple NVRAM states (UEFI,TPM,etc.) to exist for a VM and and manage them in a central place. This allows to collect them in a single tar archive and provide a single interface to get access to the individual states (work in progress), bugref:10098

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

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