VirtualBox

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

Last change on this file since 85007 was 84618, checked in by vboxsync, 5 years ago

OCI: (bugref:9469) cloud network integration code moved from Machine to Console, cloud network environment setup (cloud part).

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

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