VirtualBox

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

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

Main/Machine+GraphicsAdapter: previously missed proper removal of settings which are now in a different object

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