VirtualBox

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

Last change on this file since 78272 was 78261, checked in by vboxsync, 6 years ago

Main: bugref:6913: Added OnStorageControllerChanged to IVirtualBox events and fixed generation the medium events

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