VirtualBox

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

Last change on this file since 92154 was 92133, checked in by vboxsync, 3 years ago

Main,FE/VBoxManage: Allow changing the localhost reachable flag for the NAT attachment type, bugref:9896

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

© 2023 Oracle
ContactPrivacy policyTerms of Use