VirtualBox

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

Last change on this file since 71007 was 70712, checked in by vboxsync, 7 years ago

Main,VBoxManage: Added CPUPropertyType_HWVirt. Translates to --nested-hw-virt in VBoxManage/modifyvm

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