VirtualBox

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

Last change on this file since 77863 was 77436, checked in by vboxsync, 6 years ago

Main: Eradicate the use of BSTR in regular API code, there were leaks in almost every occurrence. Also do some Bstr->Utf8Str shuffling to reduce the number of conversions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 68.3 KB
Line 
1/* $Id: MachineImpl.h 77436 2019-02-22 17:40:00Z 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() { 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_onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; }
527 virtual HRESULT i_onDnDModeChange(DnDMode_T /* aDnDMode */) { return S_OK; }
528 virtual HRESULT i_onBandwidthGroupChange(IBandwidthGroup * /* aBandwidthGroup */) { return S_OK; }
529 virtual HRESULT i_onStorageDeviceChange(IMediumAttachment * /* mediumAttachment */, BOOL /* remove */,
530 BOOL /* silent */) { return S_OK; }
531 virtual HRESULT i_onRecordingChange(BOOL /* aEnable */) { return S_OK; }
532
533 HRESULT i_saveRegistryEntry(settings::MachineRegistryEntry &data);
534
535 int i_calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
536 void i_copyPathRelativeToMachine(const Utf8Str &strSource, Utf8Str &strTarget);
537
538 void i_getLogFolder(Utf8Str &aLogFolder);
539 Utf8Str i_getLogFilename(ULONG idx);
540 Utf8Str i_getHardeningLogFilename(void);
541
542 void i_composeSavedStateFilename(Utf8Str &strStateFilePath);
543
544 bool i_isUSBControllerPresent();
545
546 HRESULT i_launchVMProcess(IInternalSessionControl *aControl,
547 const Utf8Str &strType,
548 const Utf8Str &strEnvironment,
549 ProgressProxy *aProgress);
550
551 HRESULT i_getDirectControl(ComPtr<IInternalSessionControl> *directControl)
552 {
553 HRESULT rc;
554 *directControl = mData->mSession.mDirectControl;
555
556 if (!*directControl)
557 rc = E_ACCESSDENIED;
558 else
559 rc = S_OK;
560
561 return rc;
562 }
563
564 bool i_isSessionOpen(ComObjPtr<SessionMachine> &aMachine,
565 ComPtr<IInternalSessionControl> *aControl = NULL,
566 bool aRequireVM = false,
567 bool aAllowClosing = false);
568 bool i_isSessionSpawning();
569
570 bool i_isSessionOpenOrClosing(ComObjPtr<SessionMachine> &aMachine,
571 ComPtr<IInternalSessionControl> *aControl = NULL)
572 { return i_isSessionOpen(aMachine, aControl, false /* aRequireVM */, true /* aAllowClosing */); }
573
574 bool i_isSessionOpenVM(ComObjPtr<SessionMachine> &aMachine,
575 ComPtr<IInternalSessionControl> *aControl = NULL)
576 { return i_isSessionOpen(aMachine, aControl, true /* aRequireVM */, false /* aAllowClosing */); }
577
578 bool i_checkForSpawnFailure();
579
580 HRESULT i_prepareRegister();
581
582 HRESULT i_getSharedFolder(const Utf8Str &aName,
583 ComObjPtr<SharedFolder> &aSharedFolder,
584 bool aSetError = false)
585 {
586 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
587 return i_findSharedFolder(aName, aSharedFolder, aSetError);
588 }
589
590 HRESULT i_addStateDependency(StateDependency aDepType = AnyStateDep,
591 MachineState_T *aState = NULL,
592 BOOL *aRegistered = NULL);
593 void i_releaseStateDependency();
594
595 HRESULT i_getStorageControllerByName(const Utf8Str &aName,
596 ComObjPtr<StorageController> &aStorageController,
597 bool aSetError = false);
598
599 HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
600 MediumAttachmentList &aAttachments);
601
602 HRESULT i_getUSBControllerByName(const Utf8Str &aName,
603 ComObjPtr<USBController> &aUSBController,
604 bool aSetError = false);
605
606 HRESULT i_getBandwidthGroup(const Utf8Str &strBandwidthGroup,
607 ComObjPtr<BandwidthGroup> &pBandwidthGroup,
608 bool fSetError = false)
609 {
610 return mBandwidthControl->i_getBandwidthGroupByName(strBandwidthGroup,
611 pBandwidthGroup,
612 fSetError);
613 }
614
615 static HRESULT i_setErrorStatic(HRESULT aResultCode, const char *pcszMsg, ...);
616
617protected:
618
619 class ClientToken;
620
621 HRESULT i_checkStateDependency(StateDependency aDepType);
622
623 Machine *i_getMachine();
624
625 void i_ensureNoStateDependencies();
626
627 virtual HRESULT i_setMachineState(MachineState_T aMachineState);
628
629 HRESULT i_findSharedFolder(const Utf8Str &aName,
630 ComObjPtr<SharedFolder> &aSharedFolder,
631 bool aSetError = false);
632
633 HRESULT i_loadSettings(bool aRegistered);
634 HRESULT i_loadMachineDataFromSettings(const settings::MachineConfigFile &config,
635 const Guid *puuidRegistry);
636 HRESULT i_loadSnapshot(const settings::Snapshot &data,
637 const Guid &aCurSnapshotId,
638 Snapshot *aParentSnapshot);
639 HRESULT i_loadHardware(const Guid *puuidRegistry,
640 const Guid *puuidSnapshot,
641 const settings::Hardware &data,
642 const settings::Debugging *pDbg,
643 const settings::Autostart *pAutostart);
644 HRESULT i_loadDebugging(const settings::Debugging *pDbg);
645 HRESULT i_loadAutostart(const settings::Autostart *pAutostart);
646 HRESULT i_loadStorageControllers(const settings::Storage &data,
647 const Guid *puuidRegistry,
648 const Guid *puuidSnapshot);
649 HRESULT i_loadStorageDevices(StorageController *aStorageController,
650 const settings::StorageController &data,
651 const Guid *puuidRegistry,
652 const Guid *puuidSnapshot);
653
654 HRESULT i_findSnapshotById(const Guid &aId,
655 ComObjPtr<Snapshot> &aSnapshot,
656 bool aSetError = false);
657 HRESULT i_findSnapshotByName(const Utf8Str &strName,
658 ComObjPtr<Snapshot> &aSnapshot,
659 bool aSetError = false);
660
661 ULONG i_getUSBControllerCountByType(USBControllerType_T enmType);
662
663 enum
664 {
665 /* flags for #saveSettings() */
666 SaveS_ResetCurStateModified = 0x01,
667 SaveS_Force = 0x04,
668 /* flags for #saveStateSettings() */
669 SaveSTS_CurStateModified = 0x20,
670 SaveSTS_StateFilePath = 0x40,
671 SaveSTS_StateTimeStamp = 0x80
672 };
673
674 HRESULT i_prepareSaveSettings(bool *pfNeedsGlobalSaveSettings);
675 HRESULT i_saveSettings(bool *pfNeedsGlobalSaveSettings, int aFlags = 0);
676
677 void i_copyMachineDataToSettings(settings::MachineConfigFile &config);
678 HRESULT i_saveAllSnapshots(settings::MachineConfigFile &config);
679 HRESULT i_saveHardware(settings::Hardware &data, settings::Debugging *pDbg,
680 settings::Autostart *pAutostart);
681 HRESULT i_saveStorageControllers(settings::Storage &data);
682 HRESULT i_saveStorageDevices(ComObjPtr<StorageController> aStorageController,
683 settings::StorageController &data);
684 HRESULT i_saveStateSettings(int aFlags);
685
686 void i_addMediumToRegistry(ComObjPtr<Medium> &pMedium);
687
688 HRESULT i_createImplicitDiffs(IProgress *aProgress,
689 ULONG aWeight,
690 bool aOnline);
691 HRESULT i_deleteImplicitDiffs(bool aOnline);
692
693 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
694 const Utf8Str &aControllerName,
695 LONG aControllerPort,
696 LONG aDevice);
697 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
698 ComObjPtr<Medium> pMedium);
699 MediumAttachment* i_findAttachment(const MediumAttachmentList &ll,
700 Guid &id);
701
702 HRESULT i_detachDevice(MediumAttachment *pAttach,
703 AutoWriteLock &writeLock,
704 Snapshot *pSnapshot);
705
706 HRESULT i_detachAllMedia(AutoWriteLock &writeLock,
707 Snapshot *pSnapshot,
708 CleanupMode_T cleanupMode,
709 MediaList &llMedia);
710
711 void i_commitMedia(bool aOnline = false);
712 void i_rollbackMedia();
713
714 bool i_isInOwnDir(Utf8Str *aSettingsDir = NULL) const;
715
716 void i_rollback(bool aNotify);
717 void i_commit();
718 void i_copyFrom(Machine *aThat);
719 bool i_isControllerHotplugCapable(StorageControllerType_T enmCtrlType);
720
721 Utf8Str i_getExtraData(const Utf8Str &strKey);
722
723#ifdef VBOX_WITH_GUEST_PROPS
724 HRESULT i_getGuestPropertyFromService(const com::Utf8Str &aName, com::Utf8Str &aValue,
725 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
726 HRESULT i_setGuestPropertyToService(const com::Utf8Str &aName, const com::Utf8Str &aValue,
727 const com::Utf8Str &aFlags, bool fDelete);
728 HRESULT i_getGuestPropertyFromVM(const com::Utf8Str &aName, com::Utf8Str &aValue,
729 LONG64 *aTimestamp, com::Utf8Str &aFlags) const;
730 HRESULT i_setGuestPropertyToVM(const com::Utf8Str &aName, const com::Utf8Str &aValue,
731 const com::Utf8Str &aFlags, bool fDelete);
732 HRESULT i_enumerateGuestPropertiesInService(const com::Utf8Str &aPatterns,
733 std::vector<com::Utf8Str> &aNames,
734 std::vector<com::Utf8Str> &aValues,
735 std::vector<LONG64> &aTimestamps,
736 std::vector<com::Utf8Str> &aFlags);
737 HRESULT i_enumerateGuestPropertiesOnVM(const com::Utf8Str &aPatterns,
738 std::vector<com::Utf8Str> &aNames,
739 std::vector<com::Utf8Str> &aValues,
740 std::vector<LONG64> &aTimestamps,
741 std::vector<com::Utf8Str> &aFlags);
742
743#endif /* VBOX_WITH_GUEST_PROPS */
744
745#ifdef VBOX_WITH_RESOURCE_USAGE_API
746 void i_getDiskList(MediaList &list);
747 void i_registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid);
748
749 pm::CollectorGuest *mCollectorGuest;
750#endif /* VBOX_WITH_RESOURCE_USAGE_API */
751
752 Machine * const mPeer;
753
754 VirtualBox * const mParent;
755
756 Shareable<Data> mData;
757 Shareable<SSData> mSSData;
758
759 Backupable<UserData> mUserData;
760 Backupable<HWData> mHWData;
761
762 /**
763 * Hard disk and other media data.
764 *
765 * The usage policy is the same as for mHWData, but a separate field
766 * is necessary because hard disk data requires different procedures when
767 * taking or deleting snapshots, etc.
768 *
769 * @todo r=klaus change this to a regular list and use the normal way to
770 * handle the settings when creating a session or taking a snapshot.
771 * Same thing applies to mStorageControllers and mUSBControllers.
772 */
773 Backupable<MediumAttachmentList> mMediumAttachments;
774
775 // the following fields need special backup/rollback/commit handling,
776 // so they cannot be a part of HWData
777
778 const ComObjPtr<VRDEServer> mVRDEServer;
779 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
780 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
781 const ComObjPtr<AudioAdapter> mAudioAdapter;
782 const ComObjPtr<USBDeviceFilters> mUSBDeviceFilters;
783 const ComObjPtr<BIOSSettings> mBIOSSettings;
784 const ComObjPtr<RecordingSettings> mRecordingSettings;
785 const ComObjPtr<BandwidthControl> mBandwidthControl;
786
787 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
788 NetworkAdapterVector mNetworkAdapters;
789
790 typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
791 Backupable<StorageControllerList> mStorageControllers;
792
793 typedef std::list<ComObjPtr<USBController> > USBControllerList;
794 Backupable<USBControllerList> mUSBControllers;
795
796 uint64_t uRegistryNeedsSaving;
797
798 /**
799 * Abstract base class for all Machine or SessionMachine related
800 * asynchronous tasks. This is necessary since RTThreadCreate cannot call
801 * a (non-static) method as its thread function, so instead we have it call
802 * the static Machine::taskHandler, which then calls the handler() method
803 * in here (implemented by the subclasses).
804 */
805 class Task : public ThreadTask
806 {
807 public:
808 Task(Machine *m, Progress *p, const Utf8Str &t)
809 : ThreadTask(t),
810 m_pMachine(m),
811 m_machineCaller(m),
812 m_pProgress(p),
813 m_machineStateBackup(m->mData->mMachineState) // save the current machine state
814 {}
815 virtual ~Task(){}
816
817 void modifyBackedUpState(MachineState_T s)
818 {
819 *const_cast<MachineState_T *>(&m_machineStateBackup) = s;
820 }
821
822 ComObjPtr<Machine> m_pMachine;
823 AutoCaller m_machineCaller;
824 ComObjPtr<Progress> m_pProgress;
825 const MachineState_T m_machineStateBackup;
826 };
827
828 class DeleteConfigTask;
829 void i_deleteConfigHandler(DeleteConfigTask &task);
830
831 friend class Appliance;
832 friend class RecordingSettings;
833 friend class RecordingScreenSettings;
834 friend class SessionMachine;
835 friend class SnapshotMachine;
836 friend class VirtualBox;
837
838 friend class MachineCloneVM;
839 friend class MachineMoveVM;
840private:
841 // wrapped IMachine properties
842 HRESULT getParent(ComPtr<IVirtualBox> &aParent);
843 HRESULT getIcon(std::vector<BYTE> &aIcon);
844 HRESULT setIcon(const std::vector<BYTE> &aIcon);
845 HRESULT getAccessible(BOOL *aAccessible);
846 HRESULT getAccessError(ComPtr<IVirtualBoxErrorInfo> &aAccessError);
847 HRESULT getName(com::Utf8Str &aName);
848 HRESULT setName(const com::Utf8Str &aName);
849 HRESULT getDescription(com::Utf8Str &aDescription);
850 HRESULT setDescription(const com::Utf8Str &aDescription);
851 HRESULT getId(com::Guid &aId);
852 HRESULT getGroups(std::vector<com::Utf8Str> &aGroups);
853 HRESULT setGroups(const std::vector<com::Utf8Str> &aGroups);
854 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
855 HRESULT setOSTypeId(const com::Utf8Str &aOSTypeId);
856 HRESULT getHardwareVersion(com::Utf8Str &aHardwareVersion);
857 HRESULT setHardwareVersion(const com::Utf8Str &aHardwareVersion);
858 HRESULT getHardwareUUID(com::Guid &aHardwareUUID);
859 HRESULT setHardwareUUID(const com::Guid &aHardwareUUID);
860 HRESULT getCPUCount(ULONG *aCPUCount);
861 HRESULT setCPUCount(ULONG aCPUCount);
862 HRESULT getCPUHotPlugEnabled(BOOL *aCPUHotPlugEnabled);
863 HRESULT setCPUHotPlugEnabled(BOOL aCPUHotPlugEnabled);
864 HRESULT getCPUExecutionCap(ULONG *aCPUExecutionCap);
865 HRESULT setCPUExecutionCap(ULONG aCPUExecutionCap);
866 HRESULT getCPUIDPortabilityLevel(ULONG *aCPUIDPortabilityLevel);
867 HRESULT setCPUIDPortabilityLevel(ULONG aCPUIDPortabilityLevel);
868 HRESULT getCPUProfile(com::Utf8Str &aCPUProfile);
869 HRESULT setCPUProfile(const com::Utf8Str &aCPUProfile);
870 HRESULT getMemorySize(ULONG *aMemorySize);
871 HRESULT setMemorySize(ULONG aMemorySize);
872 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
873 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
874 HRESULT getPageFusionEnabled(BOOL *aPageFusionEnabled);
875 HRESULT setPageFusionEnabled(BOOL aPageFusionEnabled);
876 HRESULT getGraphicsControllerType(GraphicsControllerType_T *aGraphicsControllerType);
877 HRESULT setGraphicsControllerType(GraphicsControllerType_T aGraphicsControllerType);
878 HRESULT getVRAMSize(ULONG *aVRAMSize);
879 HRESULT setVRAMSize(ULONG aVRAMSize);
880 HRESULT getAccelerate3DEnabled(BOOL *aAccelerate3DEnabled);
881 HRESULT setAccelerate3DEnabled(BOOL aAccelerate3DEnabled);
882 HRESULT getAccelerate2DVideoEnabled(BOOL *aAccelerate2DVideoEnabled);
883 HRESULT setAccelerate2DVideoEnabled(BOOL aAccelerate2DVideoEnabled);
884 HRESULT getMonitorCount(ULONG *aMonitorCount);
885 HRESULT setMonitorCount(ULONG aMonitorCount);
886 HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
887 HRESULT getRecordingSettings(ComPtr<IRecordingSettings> &aRecordingSettings);
888 HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
889 HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
890 HRESULT getPointingHIDType(PointingHIDType_T *aPointingHIDType);
891 HRESULT setPointingHIDType(PointingHIDType_T aPointingHIDType);
892 HRESULT getKeyboardHIDType(KeyboardHIDType_T *aKeyboardHIDType);
893 HRESULT setKeyboardHIDType(KeyboardHIDType_T aKeyboardHIDType);
894 HRESULT getHPETEnabled(BOOL *aHPETEnabled);
895 HRESULT setHPETEnabled(BOOL aHPETEnabled);
896 HRESULT getChipsetType(ChipsetType_T *aChipsetType);
897 HRESULT setChipsetType(ChipsetType_T aChipsetType);
898 HRESULT getSnapshotFolder(com::Utf8Str &aSnapshotFolder);
899 HRESULT setSnapshotFolder(const com::Utf8Str &aSnapshotFolder);
900 HRESULT getVRDEServer(ComPtr<IVRDEServer> &aVRDEServer);
901 HRESULT getEmulatedUSBCardReaderEnabled(BOOL *aEmulatedUSBCardReaderEnabled);
902 HRESULT setEmulatedUSBCardReaderEnabled(BOOL aEmulatedUSBCardReaderEnabled);
903 HRESULT getMediumAttachments(std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
904 HRESULT getUSBControllers(std::vector<ComPtr<IUSBController> > &aUSBControllers);
905 HRESULT getUSBDeviceFilters(ComPtr<IUSBDeviceFilters> &aUSBDeviceFilters);
906 HRESULT getAudioAdapter(ComPtr<IAudioAdapter> &aAudioAdapter);
907 HRESULT getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers);
908 HRESULT getSettingsFilePath(com::Utf8Str &aSettingsFilePath);
909 HRESULT getSettingsAuxFilePath(com::Utf8Str &aSettingsAuxFilePath);
910 HRESULT getSettingsModified(BOOL *aSettingsModified);
911 HRESULT getSessionState(SessionState_T *aSessionState);
912 HRESULT getSessionType(SessionType_T *aSessionType);
913 HRESULT getSessionName(com::Utf8Str &aSessionType);
914 HRESULT getSessionPID(ULONG *aSessionPID);
915 HRESULT getState(MachineState_T *aState);
916 HRESULT getLastStateChange(LONG64 *aLastStateChange);
917 HRESULT getStateFilePath(com::Utf8Str &aStateFilePath);
918 HRESULT getLogFolder(com::Utf8Str &aLogFolder);
919 HRESULT getCurrentSnapshot(ComPtr<ISnapshot> &aCurrentSnapshot);
920 HRESULT getSnapshotCount(ULONG *aSnapshotCount);
921 HRESULT getCurrentStateModified(BOOL *aCurrentStateModified);
922 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
923 HRESULT getClipboardMode(ClipboardMode_T *aClipboardMode);
924 HRESULT setClipboardMode(ClipboardMode_T aClipboardMode);
925 HRESULT getDnDMode(DnDMode_T *aDnDMode);
926 HRESULT setDnDMode(DnDMode_T aDnDMode);
927 HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
928 HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
929 HRESULT getTeleporterPort(ULONG *aTeleporterPort);
930 HRESULT setTeleporterPort(ULONG aTeleporterPort);
931 HRESULT getTeleporterAddress(com::Utf8Str &aTeleporterAddress);
932 HRESULT setTeleporterAddress(const com::Utf8Str &aTeleporterAddress);
933 HRESULT getTeleporterPassword(com::Utf8Str &aTeleporterPassword);
934 HRESULT setTeleporterPassword(const com::Utf8Str &aTeleporterPassword);
935 HRESULT getParavirtProvider(ParavirtProvider_T *aParavirtProvider);
936 HRESULT setParavirtProvider(ParavirtProvider_T aParavirtProvider);
937 HRESULT getParavirtDebug(com::Utf8Str &aParavirtDebug);
938 HRESULT setParavirtDebug(const com::Utf8Str &aParavirtDebug);
939 HRESULT getFaultToleranceState(FaultToleranceState_T *aFaultToleranceState);
940 HRESULT setFaultToleranceState(FaultToleranceState_T aFaultToleranceState);
941 HRESULT getFaultTolerancePort(ULONG *aFaultTolerancePort);
942 HRESULT setFaultTolerancePort(ULONG aFaultTolerancePort);
943 HRESULT getFaultToleranceAddress(com::Utf8Str &aFaultToleranceAddress);
944 HRESULT setFaultToleranceAddress(const com::Utf8Str &aFaultToleranceAddress);
945 HRESULT getFaultTolerancePassword(com::Utf8Str &aFaultTolerancePassword);
946 HRESULT setFaultTolerancePassword(const com::Utf8Str &aFaultTolerancePassword);
947 HRESULT getFaultToleranceSyncInterval(ULONG *aFaultToleranceSyncInterval);
948 HRESULT setFaultToleranceSyncInterval(ULONG aFaultToleranceSyncInterval);
949 HRESULT getRTCUseUTC(BOOL *aRTCUseUTC);
950 HRESULT setRTCUseUTC(BOOL aRTCUseUTC);
951 HRESULT getIOCacheEnabled(BOOL *aIOCacheEnabled);
952 HRESULT setIOCacheEnabled(BOOL aIOCacheEnabled);
953 HRESULT getIOCacheSize(ULONG *aIOCacheSize);
954 HRESULT setIOCacheSize(ULONG aIOCacheSize);
955 HRESULT getPCIDeviceAssignments(std::vector<ComPtr<IPCIDeviceAttachment> > &aPCIDeviceAssignments);
956 HRESULT getBandwidthControl(ComPtr<IBandwidthControl> &aBandwidthControl);
957 HRESULT getTracingEnabled(BOOL *aTracingEnabled);
958 HRESULT setTracingEnabled(BOOL aTracingEnabled);
959 HRESULT getTracingConfig(com::Utf8Str &aTracingConfig);
960 HRESULT setTracingConfig(const com::Utf8Str &aTracingConfig);
961 HRESULT getAllowTracingToAccessVM(BOOL *aAllowTracingToAccessVM);
962 HRESULT setAllowTracingToAccessVM(BOOL aAllowTracingToAccessVM);
963 HRESULT getAutostartEnabled(BOOL *aAutostartEnabled);
964 HRESULT setAutostartEnabled(BOOL aAutostartEnabled);
965 HRESULT getAutostartDelay(ULONG *aAutostartDelay);
966 HRESULT setAutostartDelay(ULONG aAutostartDelay);
967 HRESULT getAutostopType(AutostopType_T *aAutostopType);
968 HRESULT setAutostopType(AutostopType_T aAutostopType);
969 HRESULT getDefaultFrontend(com::Utf8Str &aDefaultFrontend);
970 HRESULT setDefaultFrontend(const com::Utf8Str &aDefaultFrontend);
971 HRESULT getUSBProxyAvailable(BOOL *aUSBProxyAvailable);
972 HRESULT getVMProcessPriority(com::Utf8Str &aVMProcessPriority);
973 HRESULT setVMProcessPriority(const com::Utf8Str &aVMProcessPriority);
974
975 // wrapped IMachine methods
976 HRESULT lockMachine(const ComPtr<ISession> &aSession,
977 LockType_T aLockType);
978 HRESULT launchVMProcess(const ComPtr<ISession> &aSession,
979 const com::Utf8Str &aType,
980 const com::Utf8Str &aEnvironment,
981 ComPtr<IProgress> &aProgress);
982 HRESULT setBootOrder(ULONG aPosition,
983 DeviceType_T aDevice);
984 HRESULT getBootOrder(ULONG aPosition,
985 DeviceType_T *aDevice);
986 HRESULT attachDevice(const com::Utf8Str &aName,
987 LONG aControllerPort,
988 LONG aDevice,
989 DeviceType_T aType,
990 const ComPtr<IMedium> &aMedium);
991 HRESULT attachDeviceWithoutMedium(const com::Utf8Str &aName,
992 LONG aControllerPort,
993 LONG aDevice,
994 DeviceType_T aType);
995 HRESULT detachDevice(const com::Utf8Str &aName,
996 LONG aControllerPort,
997 LONG aDevice);
998 HRESULT passthroughDevice(const com::Utf8Str &aName,
999 LONG aControllerPort,
1000 LONG aDevice,
1001 BOOL aPassthrough);
1002 HRESULT temporaryEjectDevice(const com::Utf8Str &aName,
1003 LONG aControllerPort,
1004 LONG aDevice,
1005 BOOL aTemporaryEject);
1006 HRESULT nonRotationalDevice(const com::Utf8Str &aName,
1007 LONG aControllerPort,
1008 LONG aDevice,
1009 BOOL aNonRotational);
1010 HRESULT setAutoDiscardForDevice(const com::Utf8Str &aName,
1011 LONG aControllerPort,
1012 LONG aDevice,
1013 BOOL aDiscard);
1014 HRESULT setHotPluggableForDevice(const com::Utf8Str &aName,
1015 LONG aControllerPort,
1016 LONG aDevice,
1017 BOOL aHotPluggable);
1018 HRESULT setBandwidthGroupForDevice(const com::Utf8Str &aName,
1019 LONG aControllerPort,
1020 LONG aDevice,
1021 const ComPtr<IBandwidthGroup> &aBandwidthGroup);
1022 HRESULT setNoBandwidthGroupForDevice(const com::Utf8Str &aName,
1023 LONG aControllerPort,
1024 LONG aDevice);
1025 HRESULT unmountMedium(const com::Utf8Str &aName,
1026 LONG aControllerPort,
1027 LONG aDevice,
1028 BOOL aForce);
1029 HRESULT mountMedium(const com::Utf8Str &aName,
1030 LONG aControllerPort,
1031 LONG aDevice,
1032 const ComPtr<IMedium> &aMedium,
1033 BOOL aForce);
1034 HRESULT getMedium(const com::Utf8Str &aName,
1035 LONG aControllerPort,
1036 LONG aDevice,
1037 ComPtr<IMedium> &aMedium);
1038 HRESULT getMediumAttachmentsOfController(const com::Utf8Str &aName,
1039 std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
1040 HRESULT getMediumAttachment(const com::Utf8Str &aName,
1041 LONG aControllerPort,
1042 LONG aDevice,
1043 ComPtr<IMediumAttachment> &aAttachment);
1044 HRESULT attachHostPCIDevice(LONG aHostAddress,
1045 LONG aDesiredGuestAddress,
1046 BOOL aTryToUnbind);
1047 HRESULT detachHostPCIDevice(LONG aHostAddress);
1048 HRESULT getNetworkAdapter(ULONG aSlot,
1049 ComPtr<INetworkAdapter> &aAdapter);
1050 HRESULT addStorageController(const com::Utf8Str &aName,
1051 StorageBus_T aConnectionType,
1052 ComPtr<IStorageController> &aController);
1053 HRESULT getStorageControllerByName(const com::Utf8Str &aName,
1054 ComPtr<IStorageController> &aStorageController);
1055 HRESULT getStorageControllerByInstance(StorageBus_T aConnectionType,
1056 ULONG aInstance,
1057 ComPtr<IStorageController> &aStorageController);
1058 HRESULT removeStorageController(const com::Utf8Str &aName);
1059 HRESULT setStorageControllerBootable(const com::Utf8Str &aName,
1060 BOOL aBootable);
1061 HRESULT addUSBController(const com::Utf8Str &aName,
1062 USBControllerType_T aType,
1063 ComPtr<IUSBController> &aController);
1064 HRESULT removeUSBController(const com::Utf8Str &aName);
1065 HRESULT getUSBControllerByName(const com::Utf8Str &aName,
1066 ComPtr<IUSBController> &aController);
1067 HRESULT getUSBControllerCountByType(USBControllerType_T aType,
1068 ULONG *aControllers);
1069 HRESULT getSerialPort(ULONG aSlot,
1070 ComPtr<ISerialPort> &aPort);
1071 HRESULT getParallelPort(ULONG aSlot,
1072 ComPtr<IParallelPort> &aPort);
1073 HRESULT getExtraDataKeys(std::vector<com::Utf8Str> &aKeys);
1074 HRESULT getExtraData(const com::Utf8Str &aKey,
1075 com::Utf8Str &aValue);
1076 HRESULT setExtraData(const com::Utf8Str &aKey,
1077 const com::Utf8Str &aValue);
1078 HRESULT getCPUProperty(CPUPropertyType_T aProperty,
1079 BOOL *aValue);
1080 HRESULT setCPUProperty(CPUPropertyType_T aProperty,
1081 BOOL aValue);
1082 HRESULT getCPUIDLeafByOrdinal(ULONG aOrdinal,
1083 ULONG *aIdx,
1084 ULONG *aSubIdx,
1085 ULONG *aValEax,
1086 ULONG *aValEbx,
1087 ULONG *aValEcx,
1088 ULONG *aValEdx);
1089 HRESULT getCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1090 ULONG *aValEax,
1091 ULONG *aValEbx,
1092 ULONG *aValEcx,
1093 ULONG *aValEdx);
1094 HRESULT setCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1095 ULONG aValEax,
1096 ULONG aValEbx,
1097 ULONG aValEcx,
1098 ULONG aValEdx);
1099 HRESULT removeCPUIDLeaf(ULONG aIdx, ULONG aSubIdx);
1100 HRESULT removeAllCPUIDLeaves();
1101 HRESULT getHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1102 BOOL *aValue);
1103 HRESULT setHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1104 BOOL aValue);
1105 HRESULT setSettingsFilePath(const com::Utf8Str &aSettingsFilePath,
1106 ComPtr<IProgress> &aProgress);
1107 HRESULT saveSettings();
1108 HRESULT discardSettings();
1109 HRESULT unregister(AutoCaller &aAutoCaller,
1110 CleanupMode_T aCleanupMode,
1111 std::vector<ComPtr<IMedium> > &aMedia);
1112 HRESULT deleteConfig(const std::vector<ComPtr<IMedium> > &aMedia,
1113 ComPtr<IProgress> &aProgress);
1114 HRESULT exportTo(const ComPtr<IAppliance> &aAppliance,
1115 const com::Utf8Str &aLocation,
1116 ComPtr<IVirtualSystemDescription> &aDescription);
1117 HRESULT findSnapshot(const com::Utf8Str &aNameOrId,
1118 ComPtr<ISnapshot> &aSnapshot);
1119 HRESULT createSharedFolder(const com::Utf8Str &aName,
1120 const com::Utf8Str &aHostPath,
1121 BOOL aWritable,
1122 BOOL aAutomount,
1123 const com::Utf8Str &aAutoMountPoint);
1124 HRESULT removeSharedFolder(const com::Utf8Str &aName);
1125 HRESULT canShowConsoleWindow(BOOL *aCanShow);
1126 HRESULT showConsoleWindow(LONG64 *aWinId);
1127 HRESULT getGuestProperty(const com::Utf8Str &aName,
1128 com::Utf8Str &aValue,
1129 LONG64 *aTimestamp,
1130 com::Utf8Str &aFlags);
1131 HRESULT getGuestPropertyValue(const com::Utf8Str &aProperty,
1132 com::Utf8Str &aValue);
1133 HRESULT getGuestPropertyTimestamp(const com::Utf8Str &aProperty,
1134 LONG64 *aValue);
1135 HRESULT setGuestProperty(const com::Utf8Str &aProperty,
1136 const com::Utf8Str &aValue,
1137 const com::Utf8Str &aFlags);
1138 HRESULT setGuestPropertyValue(const com::Utf8Str &aProperty,
1139 const com::Utf8Str &aValue);
1140 HRESULT deleteGuestProperty(const com::Utf8Str &aName);
1141 HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
1142 std::vector<com::Utf8Str> &aNames,
1143 std::vector<com::Utf8Str> &aValues,
1144 std::vector<LONG64> &aTimestamps,
1145 std::vector<com::Utf8Str> &aFlags);
1146 HRESULT querySavedGuestScreenInfo(ULONG aScreenId,
1147 ULONG *aOriginX,
1148 ULONG *aOriginY,
1149 ULONG *aWidth,
1150 ULONG *aHeight,
1151 BOOL *aEnabled);
1152 HRESULT readSavedThumbnailToArray(ULONG aScreenId,
1153 BitmapFormat_T aBitmapFormat,
1154 ULONG *aWidth,
1155 ULONG *aHeight,
1156 std::vector<BYTE> &aData);
1157 HRESULT querySavedScreenshotInfo(ULONG aScreenId,
1158 ULONG *aWidth,
1159 ULONG *aHeight,
1160 std::vector<BitmapFormat_T> &aBitmapFormats);
1161 HRESULT readSavedScreenshotToArray(ULONG aScreenId,
1162 BitmapFormat_T aBitmapFormat,
1163 ULONG *aWidth,
1164 ULONG *aHeight,
1165 std::vector<BYTE> &aData);
1166
1167 HRESULT hotPlugCPU(ULONG aCpu);
1168 HRESULT hotUnplugCPU(ULONG aCpu);
1169 HRESULT getCPUStatus(ULONG aCpu,
1170 BOOL *aAttached);
1171 HRESULT getEffectiveParavirtProvider(ParavirtProvider_T *aParavirtProvider);
1172 HRESULT queryLogFilename(ULONG aIdx,
1173 com::Utf8Str &aFilename);
1174 HRESULT readLog(ULONG aIdx,
1175 LONG64 aOffset,
1176 LONG64 aSize,
1177 std::vector<BYTE> &aData);
1178 HRESULT cloneTo(const ComPtr<IMachine> &aTarget,
1179 CloneMode_T aMode,
1180 const std::vector<CloneOptions_T> &aOptions,
1181 ComPtr<IProgress> &aProgress);
1182 HRESULT moveTo(const com::Utf8Str &aTargetPath,
1183 const com::Utf8Str &aType,
1184 ComPtr<IProgress> &aProgress);
1185 HRESULT saveState(ComPtr<IProgress> &aProgress);
1186 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1187 HRESULT discardSavedState(BOOL aFRemoveFile);
1188 HRESULT takeSnapshot(const com::Utf8Str &aName,
1189 const com::Utf8Str &aDescription,
1190 BOOL aPause,
1191 com::Guid &aId,
1192 ComPtr<IProgress> &aProgress);
1193 HRESULT deleteSnapshot(const com::Guid &aId,
1194 ComPtr<IProgress> &aProgress);
1195 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1196 ComPtr<IProgress> &aProgress);
1197 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1198 const com::Guid &aEndId,
1199 ComPtr<IProgress> &aProgress);
1200 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1201 ComPtr<IProgress> &aProgress);
1202 HRESULT applyDefaults(const com::Utf8Str &aFlags);
1203
1204 // wrapped IInternalMachineControl properties
1205
1206 // wrapped IInternalMachineControl methods
1207 HRESULT updateState(MachineState_T aState);
1208 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1209 HRESULT endPowerUp(LONG aResult);
1210 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1211 HRESULT endPoweringDown(LONG aResult,
1212 const com::Utf8Str &aErrMsg);
1213 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1214 BOOL *aMatched,
1215 ULONG *aMaskedInterfaces);
1216 HRESULT captureUSBDevice(const com::Guid &aId,
1217 const com::Utf8Str &aCaptureFilename);
1218 HRESULT detachUSBDevice(const com::Guid &aId,
1219 BOOL aDone);
1220 HRESULT autoCaptureUSBDevices();
1221 HRESULT detachAllUSBDevices(BOOL aDone);
1222 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1223 ComPtr<IProgress> &aProgress);
1224 HRESULT finishOnlineMergeMedium();
1225 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1226 std::vector<com::Utf8Str> &aValues,
1227 std::vector<LONG64> &aTimestamps,
1228 std::vector<com::Utf8Str> &aFlags);
1229 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1230 const com::Utf8Str &aValue,
1231 LONG64 aTimestamp,
1232 const com::Utf8Str &aFlags);
1233 HRESULT lockMedia();
1234 HRESULT unlockMedia();
1235 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1236 ComPtr<IMediumAttachment> &aNewAttachment);
1237 HRESULT reportVmStatistics(ULONG aValidStats,
1238 ULONG aCpuUser,
1239 ULONG aCpuKernel,
1240 ULONG aCpuIdle,
1241 ULONG aMemTotal,
1242 ULONG aMemFree,
1243 ULONG aMemBalloon,
1244 ULONG aMemShared,
1245 ULONG aMemCache,
1246 ULONG aPagedTotal,
1247 ULONG aMemAllocTotal,
1248 ULONG aMemFreeTotal,
1249 ULONG aMemBalloonTotal,
1250 ULONG aMemSharedTotal,
1251 ULONG aVmNetRx,
1252 ULONG aVmNetTx);
1253 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1254 com::Utf8Str &aResult);
1255};
1256
1257// SessionMachine class
1258////////////////////////////////////////////////////////////////////////////////
1259
1260/**
1261 * @note Notes on locking objects of this class:
1262 * SessionMachine shares some data with the primary Machine instance (pointed
1263 * to by the |mPeer| member). In order to provide data consistency it also
1264 * shares its lock handle. This means that whenever you lock a SessionMachine
1265 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1266 * instance is also locked in the same lock mode. Keep it in mind.
1267 */
1268class ATL_NO_VTABLE SessionMachine :
1269 public Machine
1270{
1271public:
1272 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
1273
1274 DECLARE_NOT_AGGREGATABLE(SessionMachine)
1275
1276 DECLARE_PROTECT_FINAL_CONSTRUCT()
1277
1278 BEGIN_COM_MAP(SessionMachine)
1279 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1280 COM_INTERFACE_ENTRY(IMachine)
1281 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1282 COM_INTERFACE_ENTRY(IInternalMachineControl)
1283 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1284 END_COM_MAP()
1285
1286 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
1287
1288 HRESULT FinalConstruct();
1289 void FinalRelease();
1290
1291 struct Uninit
1292 {
1293 enum Reason { Unexpected, Abnormal, Normal };
1294 };
1295
1296 // public initializer/uninitializer for internal purposes only
1297 HRESULT init(Machine *aMachine);
1298 void uninit() { uninit(Uninit::Unexpected); }
1299 void uninit(Uninit::Reason aReason);
1300
1301
1302 // util::Lockable interface
1303 RWLockHandle *lockHandle() const;
1304
1305 // public methods only for internal purposes
1306
1307 virtual bool i_isSessionMachine() const
1308 {
1309 return true;
1310 }
1311
1312#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
1313 bool i_checkForDeath();
1314
1315 void i_getTokenId(Utf8Str &strTokenId);
1316#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1317 IToken *i_getToken();
1318#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1319 // getClientToken must be only used by callers who can guarantee that
1320 // the object cannot be deleted in the mean time, i.e. have a caller/lock.
1321 ClientToken *i_getClientToken();
1322
1323 HRESULT i_onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
1324 HRESULT i_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1325 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1326 IN_BSTR aGuestIp, LONG aGuestPort);
1327 HRESULT i_onStorageControllerChange();
1328 HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
1329 HRESULT i_onAudioAdapterChange(IAudioAdapter *audioAdapter);
1330 HRESULT i_onSerialPortChange(ISerialPort *serialPort);
1331 HRESULT i_onParallelPortChange(IParallelPort *parallelPort);
1332 HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
1333 HRESULT i_onVRDEServerChange(BOOL aRestart);
1334 HRESULT i_onRecordingChange(BOOL aEnable);
1335 HRESULT i_onUSBControllerChange();
1336 HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
1337 IVirtualBoxErrorInfo *aError,
1338 ULONG aMaskedIfs,
1339 const com::Utf8Str &aCaptureFilename);
1340 HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
1341 IVirtualBoxErrorInfo *aError);
1342 HRESULT i_onSharedFolderChange();
1343 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
1344 HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
1345 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1346 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1347 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1348
1349 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1350
1351 HRESULT i_lockMedia();
1352 HRESULT i_unlockMedia();
1353
1354 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1355
1356private:
1357
1358 // wrapped IInternalMachineControl properties
1359
1360 // wrapped IInternalMachineControl methods
1361 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1362 HRESULT updateState(MachineState_T aState);
1363 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1364 HRESULT endPowerUp(LONG aResult);
1365 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1366 HRESULT endPoweringDown(LONG aResult,
1367 const com::Utf8Str &aErrMsg);
1368 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1369 BOOL *aMatched,
1370 ULONG *aMaskedInterfaces);
1371 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1372 HRESULT detachUSBDevice(const com::Guid &aId,
1373 BOOL aDone);
1374 HRESULT autoCaptureUSBDevices();
1375 HRESULT detachAllUSBDevices(BOOL aDone);
1376 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1377 ComPtr<IProgress> &aProgress);
1378 HRESULT finishOnlineMergeMedium();
1379 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1380 std::vector<com::Utf8Str> &aValues,
1381 std::vector<LONG64> &aTimestamps,
1382 std::vector<com::Utf8Str> &aFlags);
1383 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1384 const com::Utf8Str &aValue,
1385 LONG64 aTimestamp,
1386 const com::Utf8Str &aFlags);
1387 HRESULT lockMedia();
1388 HRESULT unlockMedia();
1389 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1390 ComPtr<IMediumAttachment> &aNewAttachment);
1391 HRESULT reportVmStatistics(ULONG aValidStats,
1392 ULONG aCpuUser,
1393 ULONG aCpuKernel,
1394 ULONG aCpuIdle,
1395 ULONG aMemTotal,
1396 ULONG aMemFree,
1397 ULONG aMemBalloon,
1398 ULONG aMemShared,
1399 ULONG aMemCache,
1400 ULONG aPagedTotal,
1401 ULONG aMemAllocTotal,
1402 ULONG aMemFreeTotal,
1403 ULONG aMemBalloonTotal,
1404 ULONG aMemSharedTotal,
1405 ULONG aVmNetRx,
1406 ULONG aVmNetTx);
1407 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1408 com::Utf8Str &aResult);
1409
1410
1411 struct ConsoleTaskData
1412 {
1413 ConsoleTaskData()
1414 : mLastState(MachineState_Null),
1415 mDeleteSnapshotInfo(NULL)
1416 { }
1417
1418 MachineState_T mLastState;
1419 ComObjPtr<Progress> mProgress;
1420
1421 // used when deleting online snaphshot
1422 void *mDeleteSnapshotInfo;
1423 };
1424
1425 class SaveStateTask;
1426 class SnapshotTask;
1427 class TakeSnapshotTask;
1428 class DeleteSnapshotTask;
1429 class RestoreSnapshotTask;
1430
1431 void i_saveStateHandler(SaveStateTask &aTask);
1432
1433 // Override some functionality for SessionMachine, this is where the
1434 // real action happens (the Machine methods are just dummies).
1435 HRESULT saveState(ComPtr<IProgress> &aProgress);
1436 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1437 HRESULT discardSavedState(BOOL aFRemoveFile);
1438 HRESULT takeSnapshot(const com::Utf8Str &aName,
1439 const com::Utf8Str &aDescription,
1440 BOOL aPause,
1441 com::Guid &aId,
1442 ComPtr<IProgress> &aProgress);
1443 HRESULT deleteSnapshot(const com::Guid &aId,
1444 ComPtr<IProgress> &aProgress);
1445 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1446 ComPtr<IProgress> &aProgress);
1447 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1448 const com::Guid &aEndId,
1449 ComPtr<IProgress> &aProgress);
1450 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1451 ComPtr<IProgress> &aProgress);
1452
1453 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1454
1455 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1456 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1457 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1458 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1459 const com::Guid &aEndId,
1460 BOOL aDeleteAllChildren,
1461 ComPtr<IProgress> &aProgress);
1462 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1463 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1464
1465 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1466 const Guid &machineId,
1467 const Guid &snapshotId,
1468 bool fOnlineMergePossible,
1469 MediumLockList *aVMMALockList,
1470 ComObjPtr<Medium> &aSource,
1471 ComObjPtr<Medium> &aTarget,
1472 bool &fMergeForward,
1473 ComObjPtr<Medium> &pParentForTarget,
1474 MediumLockList * &aChildrenToReparent,
1475 bool &fNeedOnlineMerge,
1476 MediumLockList * &aMediumLockList,
1477 ComPtr<IToken> &aHDLockToken);
1478 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1479 const ComObjPtr<Medium> &aSource,
1480 MediumLockList *aChildrenToReparent,
1481 bool fNeedsOnlineMerge,
1482 MediumLockList *aMediumLockList,
1483 const ComPtr<IToken> &aHDLockToken,
1484 const Guid &aMediumId,
1485 const Guid &aSnapshotId);
1486 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1487 const ComObjPtr<Medium> &aSource,
1488 const ComObjPtr<Medium> &aTarget,
1489 bool fMergeForward,
1490 const ComObjPtr<Medium> &pParentForTarget,
1491 MediumLockList *aChildrenToReparent,
1492 MediumLockList *aMediumLockList,
1493 ComObjPtr<Progress> &aProgress,
1494 bool *pfNeedsMachineSaveSettings);
1495
1496 HRESULT i_setMachineState(MachineState_T aMachineState);
1497 HRESULT i_updateMachineStateOnClient();
1498
1499 bool mRemoveSavedState;
1500
1501 ConsoleTaskData mConsoleTaskData;
1502
1503 /** client token for this machine */
1504 ClientToken *mClientToken;
1505
1506 int miNATNetworksStarted;
1507
1508 AUTHLIBRARYCONTEXT mAuthLibCtx;
1509};
1510
1511// SnapshotMachine class
1512////////////////////////////////////////////////////////////////////////////////
1513
1514/**
1515 * @note Notes on locking objects of this class:
1516 * SnapshotMachine shares some data with the primary Machine instance (pointed
1517 * to by the |mPeer| member). In order to provide data consistency it also
1518 * shares its lock handle. This means that whenever you lock a SessionMachine
1519 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1520 * instance is also locked in the same lock mode. Keep it in mind.
1521 */
1522class ATL_NO_VTABLE SnapshotMachine :
1523 public Machine
1524{
1525public:
1526 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1527
1528 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1529
1530 DECLARE_PROTECT_FINAL_CONSTRUCT()
1531
1532 BEGIN_COM_MAP(SnapshotMachine)
1533 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1534 COM_INTERFACE_ENTRY(IMachine)
1535 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1536 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1537 END_COM_MAP()
1538
1539 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1540
1541 HRESULT FinalConstruct();
1542 void FinalRelease();
1543
1544 // public initializer/uninitializer for internal purposes only
1545 HRESULT init(SessionMachine *aSessionMachine,
1546 IN_GUID aSnapshotId,
1547 const Utf8Str &aStateFilePath);
1548 HRESULT initFromSettings(Machine *aMachine,
1549 const settings::Hardware &hardware,
1550 const settings::Debugging *pDbg,
1551 const settings::Autostart *pAutostart,
1552 IN_GUID aSnapshotId,
1553 const Utf8Str &aStateFilePath);
1554 void uninit();
1555
1556 // util::Lockable interface
1557 RWLockHandle *lockHandle() const;
1558
1559 // public methods only for internal purposes
1560
1561 virtual bool i_isSnapshotMachine() const
1562 {
1563 return true;
1564 }
1565
1566 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1567
1568 // unsafe inline public methods for internal purposes only (ensure there is
1569 // a caller and a read lock before calling them!)
1570
1571 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1572
1573private:
1574
1575 Guid mSnapshotId;
1576 /** This field replaces mPeer for SessionMachine instances, as having
1577 * a peer reference is plain meaningless and causes many subtle problems
1578 * with saving settings and the like. */
1579 Machine * const mMachine;
1580
1581 friend class Snapshot;
1582};
1583
1584// third party methods that depend on SnapshotMachine definition
1585
1586inline const Guid &Machine::i_getSnapshotId() const
1587{
1588 return (i_isSnapshotMachine())
1589 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1590 : Guid::Empty;
1591}
1592
1593
1594#endif /* !MAIN_INCLUDED_MachineImpl_h */
1595/* 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