VirtualBox

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

Last change on this file since 78493 was 78296, checked in by vboxsync, 6 years ago

Main: bugref:8612: Fixed error happened during VM creation with default settings. Also changed storage controller name generation according to bus type

  • 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 78296 2019-04-25 15:52:38Z vboxsync $ */
2/** @file
3 * Implementation of IMachine in VBoxSVC - Header.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef MAIN_INCLUDED_MachineImpl_h
19#define MAIN_INCLUDED_MachineImpl_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include "AuthLibrary.h"
25#include "VirtualBoxBase.h"
26#include "SnapshotImpl.h"
27#include "ProgressImpl.h"
28#include "VRDEServerImpl.h"
29#include "MediumAttachmentImpl.h"
30#include "PCIDeviceAttachmentImpl.h"
31#include "MediumLock.h"
32#include "NetworkAdapterImpl.h"
33#include "AudioAdapterImpl.h"
34#include "SerialPortImpl.h"
35#include "ParallelPortImpl.h"
36#include "BIOSSettingsImpl.h"
37#include "RecordingSettingsImpl.h"
38#include "StorageControllerImpl.h" // required for MachineImpl.h to compile on Windows
39#include "USBControllerImpl.h" // required for MachineImpl.h to compile on Windows
40#include "BandwidthControlImpl.h"
41#include "BandwidthGroupImpl.h"
42#ifdef VBOX_WITH_RESOURCE_USAGE_API
43# include "Performance.h"
44# include "PerformanceImpl.h"
45# include "ThreadTask.h"
46#endif
47
48// generated header
49#include "SchemaDefs.h"
50
51#include "VBox/com/ErrorInfo.h"
52
53#include <iprt/file.h>
54#include <iprt/thread.h>
55#include <iprt/time.h>
56
57#include <list>
58#include <vector>
59
60#include "MachineWrap.h"
61
62/** @todo r=klaus after moving the various Machine settings structs to
63 * MachineImpl.cpp it should be possible to eliminate this include. */
64#include <VBox/settings.h>
65
66// defines
67////////////////////////////////////////////////////////////////////////////////
68
69// helper declarations
70////////////////////////////////////////////////////////////////////////////////
71
72class Progress;
73class ProgressProxy;
74class Keyboard;
75class Mouse;
76class Display;
77class MachineDebugger;
78class USBController;
79class USBDeviceFilters;
80class Snapshot;
81class SharedFolder;
82class HostUSBDevice;
83class StorageController;
84class SessionMachine;
85#ifdef VBOX_WITH_UNATTENDED
86class Unattended;
87#endif
88
89// Machine class
90////////////////////////////////////////////////////////////////////////////////
91//
92class ATL_NO_VTABLE Machine :
93 public MachineWrap
94{
95
96public:
97
98 enum StateDependency
99 {
100 AnyStateDep = 0,
101 MutableStateDep,
102 MutableOrSavedStateDep,
103 MutableOrRunningStateDep,
104 MutableOrSavedOrRunningStateDep,
105 };
106
107 /**
108 * Internal machine data.
109 *
110 * Only one instance of this data exists per every machine -- it is shared
111 * by the Machine, SessionMachine and all SnapshotMachine instances
112 * associated with the given machine using the util::Shareable template
113 * through the mData variable.
114 *
115 * @note |const| members are persistent during lifetime so can be
116 * accessed without locking.
117 *
118 * @note There is no need to lock anything inside init() or uninit()
119 * methods, because they are always serialized (see AutoCaller).
120 */
121 struct Data
122 {
123 /**
124 * Data structure to hold information about sessions opened for the
125 * given machine.
126 */
127 struct Session
128 {
129 /** Type of lock which created this session */
130 LockType_T mLockType;
131
132 /** Control of the direct session opened by lockMachine() */
133 ComPtr<IInternalSessionControl> mDirectControl;
134
135 typedef std::list<ComPtr<IInternalSessionControl> > RemoteControlList;
136
137 /** list of controls of all opened remote sessions */
138 RemoteControlList mRemoteControls;
139
140 /** launchVMProcess() and OnSessionEnd() progress indicator */
141 ComObjPtr<ProgressProxy> mProgress;
142
143 /**
144 * PID of the session object that must be passed to openSession()
145 * to finalize the launchVMProcess() request (i.e., PID of the
146 * process created by launchVMProcess())
147 */
148 RTPROCESS mPID;
149
150 /** Current session state */
151 SessionState_T mState;
152
153 /** Session name string (of the primary session) */
154 Utf8Str mName;
155
156 /** Session machine object */
157 ComObjPtr<SessionMachine> mMachine;
158
159 /** Medium object lock collection. */
160 MediumLockListMap mLockedMedia;
161 };
162
163 Data();
164 ~Data();
165
166 const Guid mUuid;
167 BOOL mRegistered;
168
169 Utf8Str m_strConfigFile;
170 Utf8Str m_strConfigFileFull;
171
172 // machine settings XML file
173 settings::MachineConfigFile *pMachineConfigFile;
174 uint32_t flModifications;
175 bool m_fAllowStateModification;
176
177 BOOL mAccessible;
178 com::ErrorInfo mAccessError;
179
180 MachineState_T mMachineState;
181 RTTIMESPEC mLastStateChange;
182
183 /* Note: These are guarded by VirtualBoxBase::stateLockHandle() */
184 uint32_t mMachineStateDeps;
185 RTSEMEVENTMULTI mMachineStateDepsSem;
186 uint32_t mMachineStateChangePending;
187
188 BOOL mCurrentStateModified;
189 /** Guest properties have been modified and need saving since the
190 * machine was started, or there are transient properties which need
191 * deleting and the machine is being shut down. */
192 BOOL mGuestPropertiesModified;
193
194 Session mSession;
195
196 ComObjPtr<Snapshot> mFirstSnapshot;
197 ComObjPtr<Snapshot> mCurrentSnapshot;
198
199 // list of files to delete in Delete(); this list is filled by Unregister()
200 std::list<Utf8Str> llFilesToDelete;
201 };
202
203 /**
204 * Saved state data.
205 *
206 * It's actually only the state file path string, but it needs to be
207 * separate from Data, because Machine and SessionMachine instances
208 * share it, while SnapshotMachine does not.
209 *
210 * The data variable is |mSSData|.
211 */
212 struct SSData
213 {
214 Utf8Str strStateFilePath;
215 };
216
217 /**
218 * User changeable machine data.
219 *
220 * This data is common for all machine snapshots, i.e. it is shared
221 * by all SnapshotMachine instances associated with the given machine
222 * using the util::Backupable template through the |mUserData| variable.
223 *
224 * SessionMachine instances can alter this data and discard changes.
225 *
226 * @note There is no need to lock anything inside init() or uninit()
227 * methods, because they are always serialized (see AutoCaller).
228 */
229 struct UserData
230 {
231 settings::MachineUserData s;
232 };
233
234 /**
235 * Hardware data.
236 *
237 * This data is unique for a machine and for every machine snapshot.
238 * Stored using the util::Backupable template in the |mHWData| variable.
239 *
240 * SessionMachine instances can alter this data and discard changes.
241 *
242 * @todo r=klaus move all "pointer" objects out of this struct, as they
243 * need non-obvious handling when creating a new session or when taking
244 * a snapshot. Better do this right straight away, not relying on the
245 * template magic which doesn't work right in this case.
246 */
247 struct HWData
248 {
249 /**
250 * Data structure to hold information about a guest property.
251 */
252 struct GuestProperty {
253 /** Property value */
254 Utf8Str strValue;
255 /** Property timestamp */
256 LONG64 mTimestamp;
257 /** Property flags */
258 ULONG mFlags;
259 };
260
261 HWData();
262 ~HWData();
263
264 Bstr mHWVersion;
265 Guid mHardwareUUID; /**< If Null, use mData.mUuid. */
266 ULONG mMemorySize;
267 ULONG mMemoryBalloonSize;
268 BOOL mPageFusionEnabled;
269 GraphicsControllerType_T mGraphicsControllerType;
270 ULONG mVRAMSize;
271 settings::RecordingSettings mRecordSettings;
272 ULONG mMonitorCount;
273 BOOL mHWVirtExEnabled;
274 BOOL mHWVirtExNestedPagingEnabled;
275 BOOL mHWVirtExLargePagesEnabled;
276 BOOL mHWVirtExVPIDEnabled;
277 BOOL mHWVirtExUXEnabled;
278 BOOL mHWVirtExForceEnabled;
279 BOOL mHWVirtExUseNativeApi;
280 BOOL mAccelerate2DVideoEnabled;
281 BOOL mPAEEnabled;
282 settings::Hardware::LongModeType mLongMode;
283 BOOL mTripleFaultReset;
284 BOOL mAPIC;
285 BOOL mX2APIC;
286 BOOL mIBPBOnVMExit;
287 BOOL mIBPBOnVMEntry;
288 BOOL mSpecCtrl;
289 BOOL mSpecCtrlByHost;
290 BOOL mL1DFlushOnSched;
291 BOOL mL1DFlushOnVMEntry;
292 BOOL mNestedHWVirt;
293 ULONG mCPUCount;
294 BOOL mCPUHotPlugEnabled;
295 ULONG mCpuExecutionCap;
296 uint32_t mCpuIdPortabilityLevel;
297 Utf8Str mCpuProfile;
298 BOOL mAccelerate3DEnabled;
299 BOOL mHPETEnabled;
300
301 BOOL mCPUAttached[SchemaDefs::MaxCPUCount];
302
303 std::list<settings::CpuIdLeaf> mCpuIdLeafList;
304
305 DeviceType_T mBootOrder[SchemaDefs::MaxBootPosition];
306
307 typedef std::list<ComObjPtr<SharedFolder> > SharedFolderList;
308 SharedFolderList mSharedFolders;
309
310 ClipboardMode_T mClipboardMode;
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 };
486
487 /**
488 * Returns various information about this machine.
489 *
490 * @note This method doesn't lock this object or check its readiness.
491 * Intended to be used only after doing addCaller() manually and locking it
492 * for reading.
493 */
494 Utf8Str i_getOSTypeId() const { return mUserData->s.strOsType; }
495 ChipsetType_T i_getChipsetType() const { return mHWData->mChipsetType; }
496 ULONG i_getMonitorCount() const { return mHWData->mMonitorCount; }
497 ParavirtProvider_T i_getParavirtProvider() const { return mHWData->mParavirtProvider; }
498 Utf8Str i_getParavirtDebug() const { return mHWData->mParavirtDebug; }
499
500 void i_setModified(uint32_t fl, bool fAllowStateModification = true);
501 void i_setModifiedLock(uint32_t fl, bool fAllowStateModification = true);
502
503 MachineState_T i_getMachineState() const { return mData->mMachineState; }
504
505 bool i_isStateModificationAllowed() const { return mData->m_fAllowStateModification; }
506 void i_allowStateModification() { mData->m_fAllowStateModification = true; }
507 void i_disallowStateModification() { mData->m_fAllowStateModification = false; }
508
509 const StringsList &i_getGroups() const { return mUserData->s.llGroups; }
510
511 // callback handlers
512 virtual HRESULT i_onNetworkAdapterChange(INetworkAdapter * /* networkAdapter */, BOOL /* changeAdapter */) { return S_OK; }
513 virtual HRESULT i_onNATRedirectRuleChange(ULONG /* slot */, BOOL /* fRemove */ , IN_BSTR /* name */,
514 NATProtocol_T /* protocol */, IN_BSTR /* host ip */, LONG /* host port */,
515 IN_BSTR /* guest port */, LONG /* guest port */ ) { return S_OK; }
516 virtual HRESULT i_onAudioAdapterChange(IAudioAdapter * /* audioAdapter */) { return S_OK; }
517 virtual HRESULT i_onSerialPortChange(ISerialPort * /* serialPort */) { return S_OK; }
518 virtual HRESULT i_onParallelPortChange(IParallelPort * /* parallelPort */) { return S_OK; }
519 virtual HRESULT i_onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
520 virtual HRESULT i_onUSBControllerChange() { return S_OK; }
521 virtual HRESULT i_onStorageControllerChange(const com::Guid & /* aMachineId */, const com::Utf8Str & /* aControllerName */) { return S_OK; }
522 virtual HRESULT i_onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
523 virtual HRESULT i_onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
524 virtual HRESULT i_onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; }
525 virtual HRESULT i_onSharedFolderChange() { return S_OK; }
526 virtual HRESULT i_onVMProcessPriorityChange(VMProcPriority_T /* aPriority */) { return S_OK; }
527 virtual HRESULT i_onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
528 virtual HRESULT i_onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; }
529 virtual HRESULT i_onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
530 virtual HRESULT i_onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */,
531 BOOL /* silent */) { return S_OK; }
532 virtual HRESULT i_onRecordingChange(BOOL /* aEnable */) { return S_OK; }
533
534 HRESULT i_saveRegistryEntry(settings::MachineRegistryEntry &data);
535
536 int i_calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
537 void i_copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
538
539 void i_getLogFolder(Utf8Str &aLogFolder);
540 Utf8Str i_getLogFilename(ULONG idx);
541 Utf8Str i_getHardeningLogFilename(void);
542
543 void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
544
545 bool i_isUSBControllerPresent();
546
547 HRESULT i_launchVMProcess(IInternalSessionControl *aControl,
548 const Utf8Str &strType,
549 const Utf8Str &strEnvironment,
550 ProgressProxy *aProgress);
551
552 HRESULT i_getDirectControl(ComPtr<IInternalSessionControl> *directControl)
553 {
554 HRESULT rc;
555 *directControl = mData->mSession.mDirectControl;
556
557 if (!*directControl)
558 rc = E_ACCESSDENIED;
559 else
560 rc = S_OK;
561
562 return rc;
563 }
564
565 bool i_isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
566 ComPtr<IInternalSessionControl> *aControl = NULL,
567 bool aRequireVM = false,
568 bool aAllowClosing = false);
569 bool i_isSessionSpawning();
570
571 bool i_isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
572 ComPtr<IInternalSessionControl> *aControl = NULL)
573 { return i_isSessionOpen(aMachine, aControl, false /* aRequireVM */, true /* aAllowClosing */); }
574
575 bool i_isSessionOpenVM(ComObjPtr<SessionMachine> &aMachine,
576 ComPtr<IInternalSessionControl> *aControl = NULL)
577 { return i_isSessionOpen(aMachine, aControl, true /* aRequireVM */, false /* aAllowClosing */); }
578
579 bool i_checkForSpawnFailure();
580
581 HRESULT i_prepareRegister();
582
583 HRESULT i_getSharedFolder(const Utf8Str &aName,
584 ComObjPtr<SharedFolder> &aSharedFolder,
585 bool aSetError = false)
586 {
587 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
588 return i_findSharedFolder(aName, aSharedFolder, aSetError);
589 }
590
591 HRESULT i_addStateDependency(StateDependency aDepType = AnyStateDep,
592 MachineState_T *aState = NULL,
593 BOOL *aRegistered = NULL);
594 void i_releaseStateDependency();
595
596 HRESULT i_getStorageControllerByName(const Utf8Str &aName,
597 ComObjPtr<StorageController> &aStorageController,
598 bool aSetError = false);
599
600 HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
601 MediumAttachmentList &aAttachments);
602
603 HRESULT i_getUSBControllerByName(const Utf8Str &aName,
604 ComObjPtr<USBController> &aUSBController,
605 bool aSetError = false);
606
607 HRESULT i_getBandwidthGroup(const Utf8Str &strBandwidthGroup,
608 ComObjPtr<BandwidthGroup> &pBandwidthGroup,
609 bool fSetError = false)
610 {
611 return mBandwidthControl->i_getBandwidthGroupByName(strBandwidthGroup,
612 pBandwidthGroup,
613 fSetError);
614 }
615
616 static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcszMsg, ...);
617
618protected:
619
620 class ClientToken;
621
622 HRESULT i_checkStateDependency(StateDependency aDepType);
623
624 Machine *i_getMachine();
625
626 void i_ensureNoStateDependencies();
627
628 virtual HRESULT i_setMachineState(MachineState_T aMachineState);
629
630 HRESULT i_findSharedFolder(const Utf8Str &aName,
631 ComObjPtr<SharedFolder> &aSharedFolder,
632 bool aSetError = false);
633
634 HRESULT i_loadSettings(bool aRegistered);
635 HRESULT i_loadMachineDataFromSettings(const settings::MachineConfigFile &config,
636 const Guid *puuidRegistry);
637 HRESULT i_loadSnapshot(const settings::Snapshot &data,
638 const Guid &aCurSnapshotId,
639 Snapshot *aParentSnapshot);
640 HRESULT i_loadHardware(const Guid *puuidRegistry,
641 const Guid *puuidSnapshot,
642 const settings::Hardware &data,
643 const settings::Debugging *pDbg,
644 const settings::Autostart *pAutostart);
645 HRESULT i_loadDebugging(const settings::Debugging *pDbg);
646 HRESULT i_loadAutostart(const settings::Autostart *pAutostart);
647 HRESULT i_loadStorageControllers(const settings::Storage &data,
648 const Guid *puuidRegistry,
649 const Guid *puuidSnapshot);
650 HRESULT i_loadStorageDevices(StorageController *aStorageController,
651 const settings::StorageController &data,
652 const Guid *puuidRegistry,
653 const Guid *puuidSnapshot);
654
655 HRESULT i_findSnapshotById(const Guid &aId,
656 ComObjPtr<Snapshot> &aSnapshot,
657 bool aSetError = false);
658 HRESULT i_findSnapshotByName(const Utf8Str &strName,
659 ComObjPtr<Snapshot> &aSnapshot,
660 bool aSetError = false);
661
662 ULONG i_getUSBControllerCountByType(USBControllerType_T enmType);
663
664 enum
665 {
666 /* flags for #saveSettings() */
667 SaveS_ResetCurStateModified = 0x01,
668 SaveS_Force = 0x04,
669 /* flags for #saveStateSettings() */
670 SaveSTS_CurStateModified = 0x20,
671 SaveSTS_StateFilePath = 0x40,
672 SaveSTS_StateTimeStamp = 0x80
673 };
674
675 HRESULT i_prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
676 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
677
678 void i_copyMachineDataToSettings(settings::MachineConfigFile &config);
679 HRESULT i_saveAllSnapshots(settings::MachineConfigFile &config);
680 HRESULT i_saveHardware(settings::Hardware &data, settings::Debugging *pDbg,
681 settings::Autostart *pAutostart);
682 HRESULT i_saveStorageControllers(settings::Storage &data);
683 HRESULT i_saveStorageDevices(ComObjPtr<StorageController> aStorageController,
684 settings::StorageController &data);
685 HRESULT i_saveStateSettings(int aFlags);
686
687 void i_addMediumToRegistry(ComObjPtr<Medium> &pMedium);
688
689 HRESULT i_createImplicitDiffs(IProgress *aProgress,
690 ULONG aWeight,
691 bool aOnline);
692 HRESULT i_deleteImplicitDiffs(bool aOnline);
693
694 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
695 const Utf8Str &aControllerName,
696 LONG aControllerPort,
697 LONG aDevice);
698 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
699 ComObjPtr<Medium> pMedium);
700 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
701 Guid &id);
702
703 HRESULT i_detachDevice(MediumAttachment *pAttach,
704 AutoWriteLock &writeLock,
705 Snapshot *pSnapshot);
706
707 HRESULT i_detachAllMedia(AutoWriteLock &writeLock,
708 Snapshot *pSnapshot,
709 CleanupMode_T cleanupMode,
710 MediaList &llMedia);
711
712 void i_commitMedia(bool aOnline = false);
713 void i_rollbackMedia();
714
715 bool i_isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
716
717 void i_rollback(bool aNotify);
718 void i_commit();
719 void i_copyFrom(Machine *aThat);
720 bool i_isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
721
722 Utf8Str i_getExtraData(const Utf8Str &strKey);
723
724 com::Utf8Str i_controllerNameFromBusType(StorageBus_T aBusType);
725
726#ifdef VBOX_WITH_GUEST_PROPS
727 HRESULT i_getGuestPropertyFromService(const com::Utf8Str &aName, com::Utf8Str &aValue,
728 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
729 HRESULT i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue,
730 const com::Utf8Str &aFlags, bool fDelete);
731 HRESULT i_getGuestPropertyFromVM(const com::Utf8Str &aName, com::Utf8Str &aValue,
732 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
733 HRESULT i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue,
734 const com::Utf8Str &aFlags, bool fDelete);
735 HRESULT i_enumerateGuestPropertiesInService(const com::Utf8Str &aPatterns,
736 std::vector<com::Utf8Str> &aNames,
737 std::vector<com::Utf8Str> &aValues,
738 std::vector<LONG64> &aTimestamps,
739 std::vector<com::Utf8Str> &aFlags);
740 HRESULT i_enumerateGuestPropertiesOnVM(const com::Utf8Str &aPatterns,
741 std::vector<com::Utf8Str> &aNames,
742 std::vector<com::Utf8Str> &aValues,
743 std::vector<LONG64> &aTimestamps,
744 std::vector<com::Utf8Str> &aFlags);
745
746#endif /* VBOX_WITH_GUEST_PROPS */
747
748#ifdef VBOX_WITH_RESOURCE_USAGE_API
749 void i_getDiskList(MediaList &list);
750 void i_registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
751
752 pm::CollectorGuest *mCollectorGuest;
753#endif /* VBOX_WITH_RESOURCE_USAGE_API */
754
755 Machine * const mPeer;
756
757 VirtualBox * const mParent;
758
759 Shareable<Data> mData;
760 Shareable<SSData> mSSData;
761
762 Backupable<UserData> mUserData;
763 Backupable<HWData> mHWData;
764
765 /**
766 * Hard disk and other media data.
767 *
768 * The usage policy is the same as for mHWData, but a separate field
769 * is necessary because hard disk data requires different procedures when
770 * taking or deleting snapshots, etc.
771 *
772 * @todo r=klaus change this to a regular list and use the normal way to
773 * handle the settings when creating a session or taking a snapshot.
774 * Same thing applies to mStorageControllers and mUSBControllers.
775 */
776 Backupable<MediumAttachmentList> mMediumAttachments;
777
778 // the following fields need special backup/rollback/commit handling,
779 // so they cannot be a part of HWData
780
781 const ComObjPtr<VRDEServer> mVRDEServer;
782 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
783 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
784 const ComObjPtr<AudioAdapter> mAudioAdapter;
785 const ComObjPtr<USBDeviceFilters> mUSBDeviceFilters;
786 const ComObjPtr<BIOSSettings> mBIOSSettings;
787 const ComObjPtr<RecordingSettings> mRecordingSettings;
788 const ComObjPtr<BandwidthControl> mBandwidthControl;
789
790 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
791 NetworkAdapterVector mNetworkAdapters;
792
793 typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
794 Backupable<StorageControllerList> mStorageControllers;
795
796 typedef std::list<ComObjPtr<USBController> > USBControllerList;
797 Backupable<USBControllerList> mUSBControllers;
798
799 uint64_t uRegistryNeedsSaving;
800
801 /**
802 * Abstract base class for all Machine or SessionMachine related
803 * asynchronous tasks. This is necessary since RTThreadCreate cannot call
804 * a (non-static) method as its thread function, so instead we have it call
805 * the static Machine::taskHandler, which then calls the handler() method
806 * in here (implemented by the subclasses).
807 */
808 class Task : public ThreadTask
809 {
810 public:
811 Task(Machine *m, Progress *p, const Utf8Str &t)
812 : ThreadTask(t),
813 m_pMachine(m),
814 m_machineCaller(m),
815 m_pProgress(p),
816 m_machineStateBackup(m->mData->mMachineState) // save the current machine state
817 {}
818 virtual ~Task(){}
819
820 void modifyBackedUpState(MachineState_T s)
821 {
822 *const_cast<MachineState_T *>(&m_machineStateBackup) = s;
823 }
824
825 ComObjPtr<Machine> m_pMachine;
826 AutoCaller m_machineCaller;
827 ComObjPtr<Progress> m_pProgress;
828 const MachineState_T m_machineStateBackup;
829 };
830
831 class DeleteConfigTask;
832 void i_deleteConfigHandler(DeleteConfigTask &task);
833
834 friend class Appliance;
835 friend class RecordingSettings;
836 friend class RecordingScreenSettings;
837 friend class SessionMachine;
838 friend class SnapshotMachine;
839 friend class VirtualBox;
840
841 friend class MachineCloneVM;
842 friend class MachineMoveVM;
843private:
844 // wrapped IMachine properties
845 HRESULT getParent(ComPtr<IVirtualBox> &aParent);
846 HRESULT getIcon(std::vector<BYTE> &aIcon);
847 HRESULT setIcon(const std::vector<BYTE> &aIcon);
848 HRESULT getAccessible(BOOL *aAccessible);
849 HRESULT getAccessError(ComPtr<IVirtualBoxErrorInfo> &aAccessError);
850 HRESULT getName(com::Utf8Str &aName);
851 HRESULT setName(const com::Utf8Str &aName);
852 HRESULT getDescription(com::Utf8Str &aDescription);
853 HRESULT setDescription(const com::Utf8Str &aDescription);
854 HRESULT getId(com::Guid &aId);
855 HRESULT getGroups(std::vector<com::Utf8Str> &aGroups);
856 HRESULT setGroups(const std::vector<com::Utf8Str> &aGroups);
857 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
858 HRESULT setOSTypeId(const com::Utf8Str &aOSTypeId);
859 HRESULT getHardwareVersion(com::Utf8Str &aHardwareVersion);
860 HRESULT setHardwareVersion(const com::Utf8Str &aHardwareVersion);
861 HRESULT getHardwareUUID(com::Guid &aHardwareUUID);
862 HRESULT setHardwareUUID(const com::Guid &aHardwareUUID);
863 HRESULT getCPUCount(ULONG *aCPUCount);
864 HRESULT setCPUCount(ULONG aCPUCount);
865 HRESULT getCPUHotPlugEnabled(BOOL *aCPUHotPlugEnabled);
866 HRESULT setCPUHotPlugEnabled(BOOL aCPUHotPlugEnabled);
867 HRESULT getCPUExecutionCap(ULONG *aCPUExecutionCap);
868 HRESULT setCPUExecutionCap(ULONG aCPUExecutionCap);
869 HRESULT getCPUIDPortabilityLevel(ULONG *aCPUIDPortabilityLevel);
870 HRESULT setCPUIDPortabilityLevel(ULONG aCPUIDPortabilityLevel);
871 HRESULT getCPUProfile(com::Utf8Str &aCPUProfile);
872 HRESULT setCPUProfile(const com::Utf8Str &aCPUProfile);
873 HRESULT getMemorySize(ULONG *aMemorySize);
874 HRESULT setMemorySize(ULONG aMemorySize);
875 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
876 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
877 HRESULT getPageFusionEnabled(BOOL *aPageFusionEnabled);
878 HRESULT setPageFusionEnabled(BOOL aPageFusionEnabled);
879 HRESULT getGraphicsControllerType(GraphicsControllerType_T *aGraphicsControllerType);
880 HRESULT setGraphicsControllerType(GraphicsControllerType_T aGraphicsControllerType);
881 HRESULT getVRAMSize(ULONG *aVRAMSize);
882 HRESULT setVRAMSize(ULONG aVRAMSize);
883 HRESULT getAccelerate3DEnabled(BOOL *aAccelerate3DEnabled);
884 HRESULT setAccelerate3DEnabled(BOOL aAccelerate3DEnabled);
885 HRESULT getAccelerate2DVideoEnabled(BOOL *aAccelerate2DVideoEnabled);
886 HRESULT setAccelerate2DVideoEnabled(BOOL aAccelerate2DVideoEnabled);
887 HRESULT getMonitorCount(ULONG *aMonitorCount);
888 HRESULT setMonitorCount(ULONG aMonitorCount);
889 HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
890 HRESULT getRecordingSettings(ComPtr<IRecordingSettings> &aRecordingSettings);
891 HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
892 HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
893 HRESULT getPointingHIDType(PointingHIDType_T *aPointingHIDType);
894 HRESULT setPointingHIDType(PointingHIDType_T aPointingHIDType);
895 HRESULT getKeyboardHIDType(KeyboardHIDType_T *aKeyboardHIDType);
896 HRESULT setKeyboardHIDType(KeyboardHIDType_T aKeyboardHIDType);
897 HRESULT getHPETEnabled(BOOL *aHPETEnabled);
898 HRESULT setHPETEnabled(BOOL aHPETEnabled);
899 HRESULT getChipsetType(ChipsetType_T *aChipsetType);
900 HRESULT setChipsetType(ChipsetType_T aChipsetType);
901 HRESULT getSnapshotFolder(com::Utf8Str &aSnapshotFolder);
902 HRESULT setSnapshotFolder(const com::Utf8Str &aSnapshotFolder);
903 HRESULT getVRDEServer(ComPtr<IVRDEServer> &aVRDEServer);
904 HRESULT getEmulatedUSBCardReaderEnabled(BOOL *aEmulatedUSBCardReaderEnabled);
905 HRESULT setEmulatedUSBCardReaderEnabled(BOOL aEmulatedUSBCardReaderEnabled);
906 HRESULT getMediumAttachments(std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
907 HRESULT getUSBControllers(std::vector<ComPtr<IUSBController> > &aUSBControllers);
908 HRESULT getUSBDeviceFilters(ComPtr<IUSBDeviceFilters> &aUSBDeviceFilters);
909 HRESULT getAudioAdapter(ComPtr<IAudioAdapter> &aAudioAdapter);
910 HRESULT getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers);
911 HRESULT getSettingsFilePath(com::Utf8Str &aSettingsFilePath);
912 HRESULT getSettingsAuxFilePath(com::Utf8Str &aSettingsAuxFilePath);
913 HRESULT getSettingsModified(BOOL *aSettingsModified);
914 HRESULT getSessionState(SessionState_T *aSessionState);
915 HRESULT getSessionType(SessionType_T *aSessionType);
916 HRESULT getSessionName(com::Utf8Str &aSessionType);
917 HRESULT getSessionPID(ULONG *aSessionPID);
918 HRESULT getState(MachineState_T *aState);
919 HRESULT getLastStateChange(LONG64 *aLastStateChange);
920 HRESULT getStateFilePath(com::Utf8Str &aStateFilePath);
921 HRESULT getLogFolder(com::Utf8Str &aLogFolder);
922 HRESULT getCurrentSnapshot(ComPtr<ISnapshot> &aCurrentSnapshot);
923 HRESULT getSnapshotCount(ULONG *aSnapshotCount);
924 HRESULT getCurrentStateModified(BOOL *aCurrentStateModified);
925 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
926 HRESULT getClipboardMode(ClipboardMode_T *aClipboardMode);
927 HRESULT setClipboardMode(ClipboardMode_T aClipboardMode);
928 HRESULT getDnDMode(DnDMode_T *aDnDMode);
929 HRESULT setDnDMode(DnDMode_T aDnDMode);
930 HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
931 HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
932 HRESULT getTeleporterPort(ULONG *aTeleporterPort);
933 HRESULT setTeleporterPort(ULONG aTeleporterPort);
934 HRESULT getTeleporterAddress(com::Utf8Str &aTeleporterAddress);
935 HRESULT setTeleporterAddress(const com::Utf8Str &aTeleporterAddress);
936 HRESULT getTeleporterPassword(com::Utf8Str &aTeleporterPassword);
937 HRESULT setTeleporterPassword(const com::Utf8Str &aTeleporterPassword);
938 HRESULT getParavirtProvider(ParavirtProvider_T *aParavirtProvider);
939 HRESULT setParavirtProvider(ParavirtProvider_T aParavirtProvider);
940 HRESULT getParavirtDebug(com::Utf8Str &aParavirtDebug);
941 HRESULT setParavirtDebug(const com::Utf8Str &aParavirtDebug);
942 HRESULT getFaultToleranceState(FaultToleranceState_T *aFaultToleranceState);
943 HRESULT setFaultToleranceState(FaultToleranceState_T aFaultToleranceState);
944 HRESULT getFaultTolerancePort(ULONG *aFaultTolerancePort);
945 HRESULT setFaultTolerancePort(ULONG aFaultTolerancePort);
946 HRESULT getFaultToleranceAddress(com::Utf8Str &aFaultToleranceAddress);
947 HRESULT setFaultToleranceAddress(const com::Utf8Str &aFaultToleranceAddress);
948 HRESULT getFaultTolerancePassword(com::Utf8Str &aFaultTolerancePassword);
949 HRESULT setFaultTolerancePassword(const com::Utf8Str &aFaultTolerancePassword);
950 HRESULT getFaultToleranceSyncInterval(ULONG *aFaultToleranceSyncInterval);
951 HRESULT setFaultToleranceSyncInterval(ULONG aFaultToleranceSyncInterval);
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 com::Utf8Str &aEnvironment,
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_EMPTY_CTOR_DTOR(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_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1328 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1329 IN_BSTR aGuestIp, LONG aGuestPort);
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_onDnDModeChange(DnDMode_T aDnDMode);
1349 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1350 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1351 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1352
1353 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1354
1355 HRESULT i_lockMedia();
1356 HRESULT i_unlockMedia();
1357
1358 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1359
1360private:
1361
1362 // wrapped IInternalMachineControl properties
1363
1364 // wrapped IInternalMachineControl methods
1365 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1366 HRESULT updateState(MachineState_T aState);
1367 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1368 HRESULT endPowerUp(LONG aResult);
1369 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1370 HRESULT endPoweringDown(LONG aResult,
1371 const com::Utf8Str &aErrMsg);
1372 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1373 BOOL *aMatched,
1374 ULONG *aMaskedInterfaces);
1375 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1376 HRESULT detachUSBDevice(const com::Guid &aId,
1377 BOOL aDone);
1378 HRESULT autoCaptureUSBDevices();
1379 HRESULT detachAllUSBDevices(BOOL aDone);
1380 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1381 ComPtr<IProgress> &aProgress);
1382 HRESULT finishOnlineMergeMedium();
1383 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1384 std::vector<com::Utf8Str> &aValues,
1385 std::vector<LONG64> &aTimestamps,
1386 std::vector<com::Utf8Str> &aFlags);
1387 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1388 const com::Utf8Str &aValue,
1389 LONG64 aTimestamp,
1390 const com::Utf8Str &aFlags);
1391 HRESULT lockMedia();
1392 HRESULT unlockMedia();
1393 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1394 ComPtr<IMediumAttachment> &aNewAttachment);
1395 HRESULT reportVmStatistics(ULONG aValidStats,
1396 ULONG aCpuUser,
1397 ULONG aCpuKernel,
1398 ULONG aCpuIdle,
1399 ULONG aMemTotal,
1400 ULONG aMemFree,
1401 ULONG aMemBalloon,
1402 ULONG aMemShared,
1403 ULONG aMemCache,
1404 ULONG aPagedTotal,
1405 ULONG aMemAllocTotal,
1406 ULONG aMemFreeTotal,
1407 ULONG aMemBalloonTotal,
1408 ULONG aMemSharedTotal,
1409 ULONG aVmNetRx,
1410 ULONG aVmNetTx);
1411 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1412 com::Utf8Str &aResult);
1413
1414
1415 struct ConsoleTaskData
1416 {
1417 ConsoleTaskData()
1418 : mLastState(MachineState_Null),
1419 mDeleteSnapshotInfo(NULL)
1420 { }
1421
1422 MachineState_T mLastState;
1423 ComObjPtr<Progress> mProgress;
1424
1425 // used when deleting online snaphshot
1426 void *mDeleteSnapshotInfo;
1427 };
1428
1429 class SaveStateTask;
1430 class SnapshotTask;
1431 class TakeSnapshotTask;
1432 class DeleteSnapshotTask;
1433 class RestoreSnapshotTask;
1434
1435 void i_saveStateHandler(SaveStateTask &aTask);
1436
1437 // Override some functionality for SessionMachine, this is where the
1438 // real action happens (the Machine methods are just dummies).
1439 HRESULT saveState(ComPtr<IProgress> &aProgress);
1440 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1441 HRESULT discardSavedState(BOOL aFRemoveFile);
1442 HRESULT takeSnapshot(const com::Utf8Str &aName,
1443 const com::Utf8Str &aDescription,
1444 BOOL aPause,
1445 com::Guid &aId,
1446 ComPtr<IProgress> &aProgress);
1447 HRESULT deleteSnapshot(const com::Guid &aId,
1448 ComPtr<IProgress> &aProgress);
1449 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1450 ComPtr<IProgress> &aProgress);
1451 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1452 const com::Guid &aEndId,
1453 ComPtr<IProgress> &aProgress);
1454 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1455 ComPtr<IProgress> &aProgress);
1456
1457 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1458
1459 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1460 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1461 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1462 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1463 const com::Guid &aEndId,
1464 BOOL aDeleteAllChildren,
1465 ComPtr<IProgress> &aProgress);
1466 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1467 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1468
1469 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1470 const Guid &machineId,
1471 const Guid &snapshotId,
1472 bool fOnlineMergePossible,
1473 MediumLockList *aVMMALockList,
1474 ComObjPtr<Medium> &aSource,
1475 ComObjPtr<Medium> &aTarget,
1476 bool &fMergeForward,
1477 ComObjPtr<Medium> &pParentForTarget,
1478 MediumLockList * &aChildrenToReparent,
1479 bool &fNeedOnlineMerge,
1480 MediumLockList * &aMediumLockList,
1481 ComPtr<IToken> &aHDLockToken);
1482 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1483 const ComObjPtr<Medium> &aSource,
1484 MediumLockList *aChildrenToReparent,
1485 bool fNeedsOnlineMerge,
1486 MediumLockList *aMediumLockList,
1487 const ComPtr<IToken> &aHDLockToken,
1488 const Guid &aMediumId,
1489 const Guid &aSnapshotId);
1490 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1491 const ComObjPtr<Medium> &aSource,
1492 const ComObjPtr<Medium> &aTarget,
1493 bool fMergeForward,
1494 const ComObjPtr<Medium> &pParentForTarget,
1495 MediumLockList *aChildrenToReparent,
1496 MediumLockList *aMediumLockList,
1497 ComObjPtr<Progress> &aProgress,
1498 bool *pfNeedsMachineSaveSettings);
1499
1500 HRESULT i_setMachineState(MachineState_T aMachineState);
1501 HRESULT i_updateMachineStateOnClient();
1502
1503 bool mRemoveSavedState;
1504
1505 ConsoleTaskData mConsoleTaskData;
1506
1507 /** client token for this machine */
1508 ClientToken *mClientToken;
1509
1510 int miNATNetworksStarted;
1511
1512 AUTHLIBRARYCONTEXT mAuthLibCtx;
1513};
1514
1515// SnapshotMachine class
1516////////////////////////////////////////////////////////////////////////////////
1517
1518/**
1519 * @note Notes on locking objects of this class:
1520 * SnapshotMachine shares some data with the primary Machine instance (pointed
1521 * to by the |mPeer| member). In order to provide data consistency it also
1522 * shares its lock handle. This means that whenever you lock a SessionMachine
1523 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1524 * instance is also locked in the same lock mode. Keep it in mind.
1525 */
1526class ATL_NO_VTABLE SnapshotMachine :
1527 public Machine
1528{
1529public:
1530 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1531
1532 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1533
1534 DECLARE_PROTECT_FINAL_CONSTRUCT()
1535
1536 BEGIN_COM_MAP(SnapshotMachine)
1537 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1538 COM_INTERFACE_ENTRY(IMachine)
1539 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1540 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1541 END_COM_MAP()
1542
1543 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1544
1545 HRESULT FinalConstruct();
1546 void FinalRelease();
1547
1548 // public initializer/uninitializer for internal purposes only
1549 HRESULT init(SessionMachine *aSessionMachine,
1550 IN_GUID aSnapshotId,
1551 const Utf8Str &aStateFilePath);
1552 HRESULT initFromSettings(Machine *aMachine,
1553 const settings::Hardware &hardware,
1554 const settings::Debugging *pDbg,
1555 const settings::Autostart *pAutostart,
1556 IN_GUID aSnapshotId,
1557 const Utf8Str &aStateFilePath);
1558 void uninit();
1559
1560 // util::Lockable interface
1561 RWLockHandle *lockHandle() const;
1562
1563 // public methods only for internal purposes
1564
1565 virtual bool i_isSnapshotMachine() const
1566 {
1567 return true;
1568 }
1569
1570 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1571
1572 // unsafe inline public methods for internal purposes only (ensure there is
1573 // a caller and a read lock before calling them!)
1574
1575 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1576
1577private:
1578
1579 Guid mSnapshotId;
1580 /** This field replaces mPeer for SessionMachine instances, as having
1581 * a peer reference is plain meaningless and causes many subtle problems
1582 * with saving settings and the like. */
1583 Machine * const mMachine;
1584
1585 friend class Snapshot;
1586};
1587
1588// third party methods that depend on SnapshotMachine definition
1589
1590inline const Guid &Machine::i_getSnapshotId() const
1591{
1592 return (i_isSnapshotMachine())
1593 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1594 : Guid::Empty;
1595}
1596
1597
1598#endif /* !MAIN_INCLUDED_MachineImpl_h */
1599/* 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