VirtualBox

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

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

OCI: (bugref:9469) cloud network integration multiple targets and configuration support (enabled in Config.kmk).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 69.0 KB
Line 
1/* $Id: MachineImpl.h 83169 2020-02-27 09:28:41Z vboxsync $ */
2/** @file
3 * Implementation of IMachine in VBoxSVC - Header.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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();
770HRESULT i_setMacAddress(int slot, const Utf8Str& strMac);
771#endif /* VBOX_WITH_CLOUD_NET */
772
773 Machine * const mPeer;
774
775 VirtualBox * const mParent;
776
777 Shareable<Data> mData;
778 Shareable<SSData> mSSData;
779
780 Backupable<UserData> mUserData;
781 Backupable<HWData> mHWData;
782
783 /**
784 * Hard disk and other media data.
785 *
786 * The usage policy is the same as for mHWData, but a separate field
787 * is necessary because hard disk data requires different procedures when
788 * taking or deleting snapshots, etc.
789 *
790 * @todo r=klaus change this to a regular list and use the normal way to
791 * handle the settings when creating a session or taking a snapshot.
792 * Same thing applies to mStorageControllers and mUSBControllers.
793 */
794 Backupable<MediumAttachmentList> mMediumAttachments;
795
796 // the following fields need special backup/rollback/commit handling,
797 // so they cannot be a part of HWData
798
799 const ComObjPtr<VRDEServer> mVRDEServer;
800 const ComObjPtr<SerialPort> mSerialPorts[SchemaDefs::SerialPortCount];
801 const ComObjPtr<ParallelPort> mParallelPorts[SchemaDefs::ParallelPortCount];
802 const ComObjPtr<AudioAdapter> mAudioAdapter;
803 const ComObjPtr<USBDeviceFilters> mUSBDeviceFilters;
804 const ComObjPtr<BIOSSettings> mBIOSSettings;
805 const ComObjPtr<RecordingSettings> mRecordingSettings;
806 const ComObjPtr<GraphicsAdapter> mGraphicsAdapter;
807 const ComObjPtr<BandwidthControl> mBandwidthControl;
808
809 typedef std::vector<ComObjPtr<NetworkAdapter> > NetworkAdapterVector;
810 NetworkAdapterVector mNetworkAdapters;
811
812 typedef std::list<ComObjPtr<StorageController> > StorageControllerList;
813 Backupable<StorageControllerList> mStorageControllers;
814
815 typedef std::list<ComObjPtr<USBController> > USBControllerList;
816 Backupable<USBControllerList> mUSBControllers;
817
818 uint64_t uRegistryNeedsSaving;
819
820 /**
821 * Abstract base class for all Machine or SessionMachine related
822 * asynchronous tasks. This is necessary since RTThreadCreate cannot call
823 * a (non-static) method as its thread function, so instead we have it call
824 * the static Machine::taskHandler, which then calls the handler() method
825 * in here (implemented by the subclasses).
826 */
827 class Task : public ThreadTask
828 {
829 public:
830 Task(Machine *m, Progress *p, const Utf8Str &t)
831 : ThreadTask(t),
832 m_pMachine(m),
833 m_machineCaller(m),
834 m_pProgress(p),
835 m_machineStateBackup(m->mData->mMachineState) // save the current machine state
836 {}
837 virtual ~Task(){}
838
839 void modifyBackedUpState(MachineState_T s)
840 {
841 *const_cast<MachineState_T *>(&m_machineStateBackup) = s;
842 }
843
844 ComObjPtr<Machine> m_pMachine;
845 AutoCaller m_machineCaller;
846 ComObjPtr<Progress> m_pProgress;
847 const MachineState_T m_machineStateBackup;
848 };
849
850 class DeleteConfigTask;
851 void i_deleteConfigHandler(DeleteConfigTask &task);
852
853 friend class Appliance;
854 friend class RecordingSettings;
855 friend class RecordingScreenSettings;
856 friend class SessionMachine;
857 friend class SnapshotMachine;
858 friend class VirtualBox;
859
860 friend class MachineCloneVM;
861 friend class MachineMoveVM;
862private:
863 // wrapped IMachine properties
864 HRESULT getParent(ComPtr<IVirtualBox> &aParent);
865 HRESULT getIcon(std::vector<BYTE> &aIcon);
866 HRESULT setIcon(const std::vector<BYTE> &aIcon);
867 HRESULT getAccessible(BOOL *aAccessible);
868 HRESULT getAccessError(ComPtr<IVirtualBoxErrorInfo> &aAccessError);
869 HRESULT getName(com::Utf8Str &aName);
870 HRESULT setName(const com::Utf8Str &aName);
871 HRESULT getDescription(com::Utf8Str &aDescription);
872 HRESULT setDescription(const com::Utf8Str &aDescription);
873 HRESULT getId(com::Guid &aId);
874 HRESULT getGroups(std::vector<com::Utf8Str> &aGroups);
875 HRESULT setGroups(const std::vector<com::Utf8Str> &aGroups);
876 HRESULT getOSTypeId(com::Utf8Str &aOSTypeId);
877 HRESULT setOSTypeId(const com::Utf8Str &aOSTypeId);
878 HRESULT getHardwareVersion(com::Utf8Str &aHardwareVersion);
879 HRESULT setHardwareVersion(const com::Utf8Str &aHardwareVersion);
880 HRESULT getHardwareUUID(com::Guid &aHardwareUUID);
881 HRESULT setHardwareUUID(const com::Guid &aHardwareUUID);
882 HRESULT getCPUCount(ULONG *aCPUCount);
883 HRESULT setCPUCount(ULONG aCPUCount);
884 HRESULT getCPUHotPlugEnabled(BOOL *aCPUHotPlugEnabled);
885 HRESULT setCPUHotPlugEnabled(BOOL aCPUHotPlugEnabled);
886 HRESULT getCPUExecutionCap(ULONG *aCPUExecutionCap);
887 HRESULT setCPUExecutionCap(ULONG aCPUExecutionCap);
888 HRESULT getCPUIDPortabilityLevel(ULONG *aCPUIDPortabilityLevel);
889 HRESULT setCPUIDPortabilityLevel(ULONG aCPUIDPortabilityLevel);
890 HRESULT getCPUProfile(com::Utf8Str &aCPUProfile);
891 HRESULT setCPUProfile(const com::Utf8Str &aCPUProfile);
892 HRESULT getMemorySize(ULONG *aMemorySize);
893 HRESULT setMemorySize(ULONG aMemorySize);
894 HRESULT getMemoryBalloonSize(ULONG *aMemoryBalloonSize);
895 HRESULT setMemoryBalloonSize(ULONG aMemoryBalloonSize);
896 HRESULT getPageFusionEnabled(BOOL *aPageFusionEnabled);
897 HRESULT setPageFusionEnabled(BOOL aPageFusionEnabled);
898 HRESULT getGraphicsAdapter(ComPtr<IGraphicsAdapter> &aGraphicsAdapter);
899 HRESULT getBIOSSettings(ComPtr<IBIOSSettings> &aBIOSSettings);
900 HRESULT getRecordingSettings(ComPtr<IRecordingSettings> &aRecordingSettings);
901 HRESULT getFirmwareType(FirmwareType_T *aFirmwareType);
902 HRESULT setFirmwareType(FirmwareType_T aFirmwareType);
903 HRESULT getPointingHIDType(PointingHIDType_T *aPointingHIDType);
904 HRESULT setPointingHIDType(PointingHIDType_T aPointingHIDType);
905 HRESULT getKeyboardHIDType(KeyboardHIDType_T *aKeyboardHIDType);
906 HRESULT setKeyboardHIDType(KeyboardHIDType_T aKeyboardHIDType);
907 HRESULT getHPETEnabled(BOOL *aHPETEnabled);
908 HRESULT setHPETEnabled(BOOL aHPETEnabled);
909 HRESULT getChipsetType(ChipsetType_T *aChipsetType);
910 HRESULT setChipsetType(ChipsetType_T aChipsetType);
911 HRESULT getSnapshotFolder(com::Utf8Str &aSnapshotFolder);
912 HRESULT setSnapshotFolder(const com::Utf8Str &aSnapshotFolder);
913 HRESULT getVRDEServer(ComPtr<IVRDEServer> &aVRDEServer);
914 HRESULT getEmulatedUSBCardReaderEnabled(BOOL *aEmulatedUSBCardReaderEnabled);
915 HRESULT setEmulatedUSBCardReaderEnabled(BOOL aEmulatedUSBCardReaderEnabled);
916 HRESULT getMediumAttachments(std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
917 HRESULT getUSBControllers(std::vector<ComPtr<IUSBController> > &aUSBControllers);
918 HRESULT getUSBDeviceFilters(ComPtr<IUSBDeviceFilters> &aUSBDeviceFilters);
919 HRESULT getAudioAdapter(ComPtr<IAudioAdapter> &aAudioAdapter);
920 HRESULT getStorageControllers(std::vector<ComPtr<IStorageController> > &aStorageControllers);
921 HRESULT getSettingsFilePath(com::Utf8Str &aSettingsFilePath);
922 HRESULT getSettingsAuxFilePath(com::Utf8Str &aSettingsAuxFilePath);
923 HRESULT getSettingsModified(BOOL *aSettingsModified);
924 HRESULT getSessionState(SessionState_T *aSessionState);
925 HRESULT getSessionType(SessionType_T *aSessionType);
926 HRESULT getSessionName(com::Utf8Str &aSessionType);
927 HRESULT getSessionPID(ULONG *aSessionPID);
928 HRESULT getState(MachineState_T *aState);
929 HRESULT getLastStateChange(LONG64 *aLastStateChange);
930 HRESULT getStateFilePath(com::Utf8Str &aStateFilePath);
931 HRESULT getLogFolder(com::Utf8Str &aLogFolder);
932 HRESULT getCurrentSnapshot(ComPtr<ISnapshot> &aCurrentSnapshot);
933 HRESULT getSnapshotCount(ULONG *aSnapshotCount);
934 HRESULT getCurrentStateModified(BOOL *aCurrentStateModified);
935 HRESULT getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders);
936 HRESULT getClipboardMode(ClipboardMode_T *aClipboardMode);
937 HRESULT setClipboardMode(ClipboardMode_T aClipboardMode);
938 HRESULT getClipboardFileTransfersEnabled(BOOL *aEnabled);
939 HRESULT setClipboardFileTransfersEnabled(BOOL aEnabled);
940 HRESULT getDnDMode(DnDMode_T *aDnDMode);
941 HRESULT setDnDMode(DnDMode_T aDnDMode);
942 HRESULT getTeleporterEnabled(BOOL *aTeleporterEnabled);
943 HRESULT setTeleporterEnabled(BOOL aTeleporterEnabled);
944 HRESULT getTeleporterPort(ULONG *aTeleporterPort);
945 HRESULT setTeleporterPort(ULONG aTeleporterPort);
946 HRESULT getTeleporterAddress(com::Utf8Str &aTeleporterAddress);
947 HRESULT setTeleporterAddress(const com::Utf8Str &aTeleporterAddress);
948 HRESULT getTeleporterPassword(com::Utf8Str &aTeleporterPassword);
949 HRESULT setTeleporterPassword(const com::Utf8Str &aTeleporterPassword);
950 HRESULT getParavirtProvider(ParavirtProvider_T *aParavirtProvider);
951 HRESULT setParavirtProvider(ParavirtProvider_T aParavirtProvider);
952 HRESULT getParavirtDebug(com::Utf8Str &aParavirtDebug);
953 HRESULT setParavirtDebug(const com::Utf8Str &aParavirtDebug);
954 HRESULT getRTCUseUTC(BOOL *aRTCUseUTC);
955 HRESULT setRTCUseUTC(BOOL aRTCUseUTC);
956 HRESULT getIOCacheEnabled(BOOL *aIOCacheEnabled);
957 HRESULT setIOCacheEnabled(BOOL aIOCacheEnabled);
958 HRESULT getIOCacheSize(ULONG *aIOCacheSize);
959 HRESULT setIOCacheSize(ULONG aIOCacheSize);
960 HRESULT getPCIDeviceAssignments(std::vector<ComPtr<IPCIDeviceAttachment> > &aPCIDeviceAssignments);
961 HRESULT getBandwidthControl(ComPtr<IBandwidthControl> &aBandwidthControl);
962 HRESULT getTracingEnabled(BOOL *aTracingEnabled);
963 HRESULT setTracingEnabled(BOOL aTracingEnabled);
964 HRESULT getTracingConfig(com::Utf8Str &aTracingConfig);
965 HRESULT setTracingConfig(const com::Utf8Str &aTracingConfig);
966 HRESULT getAllowTracingToAccessVM(BOOL *aAllowTracingToAccessVM);
967 HRESULT setAllowTracingToAccessVM(BOOL aAllowTracingToAccessVM);
968 HRESULT getAutostartEnabled(BOOL *aAutostartEnabled);
969 HRESULT setAutostartEnabled(BOOL aAutostartEnabled);
970 HRESULT getAutostartDelay(ULONG *aAutostartDelay);
971 HRESULT setAutostartDelay(ULONG aAutostartDelay);
972 HRESULT getAutostopType(AutostopType_T *aAutostopType);
973 HRESULT setAutostopType(AutostopType_T aAutostopType);
974 HRESULT getDefaultFrontend(com::Utf8Str &aDefaultFrontend);
975 HRESULT setDefaultFrontend(const com::Utf8Str &aDefaultFrontend);
976 HRESULT getUSBProxyAvailable(BOOL *aUSBProxyAvailable);
977 HRESULT getVMProcessPriority(VMProcPriority_T *aVMProcessPriority);
978 HRESULT setVMProcessPriority(VMProcPriority_T aVMProcessPriority);
979
980 // wrapped IMachine methods
981 HRESULT lockMachine(const ComPtr<ISession> &aSession,
982 LockType_T aLockType);
983 HRESULT launchVMProcess(const ComPtr<ISession> &aSession,
984 const com::Utf8Str &aType,
985 const std::vector<com::Utf8Str> &aEnvironmentChanges,
986 ComPtr<IProgress> &aProgress);
987 HRESULT setBootOrder(ULONG aPosition,
988 DeviceType_T aDevice);
989 HRESULT getBootOrder(ULONG aPosition,
990 DeviceType_T *aDevice);
991 HRESULT attachDevice(const com::Utf8Str &aName,
992 LONG aControllerPort,
993 LONG aDevice,
994 DeviceType_T aType,
995 const ComPtr<IMedium> &aMedium);
996 HRESULT attachDeviceWithoutMedium(const com::Utf8Str &aName,
997 LONG aControllerPort,
998 LONG aDevice,
999 DeviceType_T aType);
1000 HRESULT detachDevice(const com::Utf8Str &aName,
1001 LONG aControllerPort,
1002 LONG aDevice);
1003 HRESULT passthroughDevice(const com::Utf8Str &aName,
1004 LONG aControllerPort,
1005 LONG aDevice,
1006 BOOL aPassthrough);
1007 HRESULT temporaryEjectDevice(const com::Utf8Str &aName,
1008 LONG aControllerPort,
1009 LONG aDevice,
1010 BOOL aTemporaryEject);
1011 HRESULT nonRotationalDevice(const com::Utf8Str &aName,
1012 LONG aControllerPort,
1013 LONG aDevice,
1014 BOOL aNonRotational);
1015 HRESULT setAutoDiscardForDevice(const com::Utf8Str &aName,
1016 LONG aControllerPort,
1017 LONG aDevice,
1018 BOOL aDiscard);
1019 HRESULT setHotPluggableForDevice(const com::Utf8Str &aName,
1020 LONG aControllerPort,
1021 LONG aDevice,
1022 BOOL aHotPluggable);
1023 HRESULT setBandwidthGroupForDevice(const com::Utf8Str &aName,
1024 LONG aControllerPort,
1025 LONG aDevice,
1026 const ComPtr<IBandwidthGroup> &aBandwidthGroup);
1027 HRESULT setNoBandwidthGroupForDevice(const com::Utf8Str &aName,
1028 LONG aControllerPort,
1029 LONG aDevice);
1030 HRESULT unmountMedium(const com::Utf8Str &aName,
1031 LONG aControllerPort,
1032 LONG aDevice,
1033 BOOL aForce);
1034 HRESULT mountMedium(const com::Utf8Str &aName,
1035 LONG aControllerPort,
1036 LONG aDevice,
1037 const ComPtr<IMedium> &aMedium,
1038 BOOL aForce);
1039 HRESULT getMedium(const com::Utf8Str &aName,
1040 LONG aControllerPort,
1041 LONG aDevice,
1042 ComPtr<IMedium> &aMedium);
1043 HRESULT getMediumAttachmentsOfController(const com::Utf8Str &aName,
1044 std::vector<ComPtr<IMediumAttachment> > &aMediumAttachments);
1045 HRESULT getMediumAttachment(const com::Utf8Str &aName,
1046 LONG aControllerPort,
1047 LONG aDevice,
1048 ComPtr<IMediumAttachment> &aAttachment);
1049 HRESULT attachHostPCIDevice(LONG aHostAddress,
1050 LONG aDesiredGuestAddress,
1051 BOOL aTryToUnbind);
1052 HRESULT detachHostPCIDevice(LONG aHostAddress);
1053 HRESULT getNetworkAdapter(ULONG aSlot,
1054 ComPtr<INetworkAdapter> &aAdapter);
1055 HRESULT addStorageController(const com::Utf8Str &aName,
1056 StorageBus_T aConnectionType,
1057 ComPtr<IStorageController> &aController);
1058 HRESULT getStorageControllerByName(const com::Utf8Str &aName,
1059 ComPtr<IStorageController> &aStorageController);
1060 HRESULT getStorageControllerByInstance(StorageBus_T aConnectionType,
1061 ULONG aInstance,
1062 ComPtr<IStorageController> &aStorageController);
1063 HRESULT removeStorageController(const com::Utf8Str &aName);
1064 HRESULT setStorageControllerBootable(const com::Utf8Str &aName,
1065 BOOL aBootable);
1066 HRESULT addUSBController(const com::Utf8Str &aName,
1067 USBControllerType_T aType,
1068 ComPtr<IUSBController> &aController);
1069 HRESULT removeUSBController(const com::Utf8Str &aName);
1070 HRESULT getUSBControllerByName(const com::Utf8Str &aName,
1071 ComPtr<IUSBController> &aController);
1072 HRESULT getUSBControllerCountByType(USBControllerType_T aType,
1073 ULONG *aControllers);
1074 HRESULT getSerialPort(ULONG aSlot,
1075 ComPtr<ISerialPort> &aPort);
1076 HRESULT getParallelPort(ULONG aSlot,
1077 ComPtr<IParallelPort> &aPort);
1078 HRESULT getExtraDataKeys(std::vector<com::Utf8Str> &aKeys);
1079 HRESULT getExtraData(const com::Utf8Str &aKey,
1080 com::Utf8Str &aValue);
1081 HRESULT setExtraData(const com::Utf8Str &aKey,
1082 const com::Utf8Str &aValue);
1083 HRESULT getCPUProperty(CPUPropertyType_T aProperty,
1084 BOOL *aValue);
1085 HRESULT setCPUProperty(CPUPropertyType_T aProperty,
1086 BOOL aValue);
1087 HRESULT getCPUIDLeafByOrdinal(ULONG aOrdinal,
1088 ULONG *aIdx,
1089 ULONG *aSubIdx,
1090 ULONG *aValEax,
1091 ULONG *aValEbx,
1092 ULONG *aValEcx,
1093 ULONG *aValEdx);
1094 HRESULT getCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1095 ULONG *aValEax,
1096 ULONG *aValEbx,
1097 ULONG *aValEcx,
1098 ULONG *aValEdx);
1099 HRESULT setCPUIDLeaf(ULONG aIdx, ULONG aSubIdx,
1100 ULONG aValEax,
1101 ULONG aValEbx,
1102 ULONG aValEcx,
1103 ULONG aValEdx);
1104 HRESULT removeCPUIDLeaf(ULONG aIdx, ULONG aSubIdx);
1105 HRESULT removeAllCPUIDLeaves();
1106 HRESULT getHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1107 BOOL *aValue);
1108 HRESULT setHWVirtExProperty(HWVirtExPropertyType_T aProperty,
1109 BOOL aValue);
1110 HRESULT setSettingsFilePath(const com::Utf8Str &aSettingsFilePath,
1111 ComPtr<IProgress> &aProgress);
1112 HRESULT saveSettings();
1113 HRESULT discardSettings();
1114 HRESULT unregister(AutoCaller &aAutoCaller,
1115 CleanupMode_T aCleanupMode,
1116 std::vector<ComPtr<IMedium> > &aMedia);
1117 HRESULT deleteConfig(const std::vector<ComPtr<IMedium> > &aMedia,
1118 ComPtr<IProgress> &aProgress);
1119 HRESULT exportTo(const ComPtr<IAppliance> &aAppliance,
1120 const com::Utf8Str &aLocation,
1121 ComPtr<IVirtualSystemDescription> &aDescription);
1122 HRESULT findSnapshot(const com::Utf8Str &aNameOrId,
1123 ComPtr<ISnapshot> &aSnapshot);
1124 HRESULT createSharedFolder(const com::Utf8Str &aName,
1125 const com::Utf8Str &aHostPath,
1126 BOOL aWritable,
1127 BOOL aAutomount,
1128 const com::Utf8Str &aAutoMountPoint);
1129 HRESULT removeSharedFolder(const com::Utf8Str &aName);
1130 HRESULT canShowConsoleWindow(BOOL *aCanShow);
1131 HRESULT showConsoleWindow(LONG64 *aWinId);
1132 HRESULT getGuestProperty(const com::Utf8Str &aName,
1133 com::Utf8Str &aValue,
1134 LONG64 *aTimestamp,
1135 com::Utf8Str &aFlags);
1136 HRESULT getGuestPropertyValue(const com::Utf8Str &aProperty,
1137 com::Utf8Str &aValue);
1138 HRESULT getGuestPropertyTimestamp(const com::Utf8Str &aProperty,
1139 LONG64 *aValue);
1140 HRESULT setGuestProperty(const com::Utf8Str &aProperty,
1141 const com::Utf8Str &aValue,
1142 const com::Utf8Str &aFlags);
1143 HRESULT setGuestPropertyValue(const com::Utf8Str &aProperty,
1144 const com::Utf8Str &aValue);
1145 HRESULT deleteGuestProperty(const com::Utf8Str &aName);
1146 HRESULT enumerateGuestProperties(const com::Utf8Str &aPatterns,
1147 std::vector<com::Utf8Str> &aNames,
1148 std::vector<com::Utf8Str> &aValues,
1149 std::vector<LONG64> &aTimestamps,
1150 std::vector<com::Utf8Str> &aFlags);
1151 HRESULT querySavedGuestScreenInfo(ULONG aScreenId,
1152 ULONG *aOriginX,
1153 ULONG *aOriginY,
1154 ULONG *aWidth,
1155 ULONG *aHeight,
1156 BOOL *aEnabled);
1157 HRESULT readSavedThumbnailToArray(ULONG aScreenId,
1158 BitmapFormat_T aBitmapFormat,
1159 ULONG *aWidth,
1160 ULONG *aHeight,
1161 std::vector<BYTE> &aData);
1162 HRESULT querySavedScreenshotInfo(ULONG aScreenId,
1163 ULONG *aWidth,
1164 ULONG *aHeight,
1165 std::vector<BitmapFormat_T> &aBitmapFormats);
1166 HRESULT readSavedScreenshotToArray(ULONG aScreenId,
1167 BitmapFormat_T aBitmapFormat,
1168 ULONG *aWidth,
1169 ULONG *aHeight,
1170 std::vector<BYTE> &aData);
1171
1172 HRESULT hotPlugCPU(ULONG aCpu);
1173 HRESULT hotUnplugCPU(ULONG aCpu);
1174 HRESULT getCPUStatus(ULONG aCpu,
1175 BOOL *aAttached);
1176 HRESULT getEffectiveParavirtProvider(ParavirtProvider_T *aParavirtProvider);
1177 HRESULT queryLogFilename(ULONG aIdx,
1178 com::Utf8Str &aFilename);
1179 HRESULT readLog(ULONG aIdx,
1180 LONG64 aOffset,
1181 LONG64 aSize,
1182 std::vector<BYTE> &aData);
1183 HRESULT cloneTo(const ComPtr<IMachine> &aTarget,
1184 CloneMode_T aMode,
1185 const std::vector<CloneOptions_T> &aOptions,
1186 ComPtr<IProgress> &aProgress);
1187 HRESULT moveTo(const com::Utf8Str &aTargetPath,
1188 const com::Utf8Str &aType,
1189 ComPtr<IProgress> &aProgress);
1190 HRESULT saveState(ComPtr<IProgress> &aProgress);
1191 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1192 HRESULT discardSavedState(BOOL aFRemoveFile);
1193 HRESULT takeSnapshot(const com::Utf8Str &aName,
1194 const com::Utf8Str &aDescription,
1195 BOOL aPause,
1196 com::Guid &aId,
1197 ComPtr<IProgress> &aProgress);
1198 HRESULT deleteSnapshot(const com::Guid &aId,
1199 ComPtr<IProgress> &aProgress);
1200 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1201 ComPtr<IProgress> &aProgress);
1202 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1203 const com::Guid &aEndId,
1204 ComPtr<IProgress> &aProgress);
1205 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1206 ComPtr<IProgress> &aProgress);
1207 HRESULT applyDefaults(const com::Utf8Str &aFlags);
1208
1209 // wrapped IInternalMachineControl properties
1210
1211 // wrapped IInternalMachineControl methods
1212 HRESULT updateState(MachineState_T aState);
1213 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1214 HRESULT endPowerUp(LONG aResult);
1215 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1216 HRESULT endPoweringDown(LONG aResult,
1217 const com::Utf8Str &aErrMsg);
1218 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1219 BOOL *aMatched,
1220 ULONG *aMaskedInterfaces);
1221 HRESULT captureUSBDevice(const com::Guid &aId,
1222 const com::Utf8Str &aCaptureFilename);
1223 HRESULT detachUSBDevice(const com::Guid &aId,
1224 BOOL aDone);
1225 HRESULT autoCaptureUSBDevices();
1226 HRESULT detachAllUSBDevices(BOOL aDone);
1227 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1228 ComPtr<IProgress> &aProgress);
1229 HRESULT finishOnlineMergeMedium();
1230 HRESULT clipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID);
1231 HRESULT clipboardAreaUnregister(ULONG aID);
1232 HRESULT clipboardAreaAttach(ULONG aID);
1233 HRESULT clipboardAreaDetach(ULONG aID);
1234 HRESULT clipboardAreaGetMostRecent(ULONG *aID);
1235 HRESULT clipboardAreaGetRefCount(ULONG aID, ULONG *aRefCount);
1236 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1237 std::vector<com::Utf8Str> &aValues,
1238 std::vector<LONG64> &aTimestamps,
1239 std::vector<com::Utf8Str> &aFlags);
1240 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1241 const com::Utf8Str &aValue,
1242 LONG64 aTimestamp,
1243 const com::Utf8Str &aFlags);
1244 HRESULT lockMedia();
1245 HRESULT unlockMedia();
1246 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1247 ComPtr<IMediumAttachment> &aNewAttachment);
1248 HRESULT reportVmStatistics(ULONG aValidStats,
1249 ULONG aCpuUser,
1250 ULONG aCpuKernel,
1251 ULONG aCpuIdle,
1252 ULONG aMemTotal,
1253 ULONG aMemFree,
1254 ULONG aMemBalloon,
1255 ULONG aMemShared,
1256 ULONG aMemCache,
1257 ULONG aPagedTotal,
1258 ULONG aMemAllocTotal,
1259 ULONG aMemFreeTotal,
1260 ULONG aMemBalloonTotal,
1261 ULONG aMemSharedTotal,
1262 ULONG aVmNetRx,
1263 ULONG aVmNetTx);
1264 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1265 com::Utf8Str &aResult);
1266};
1267
1268// SessionMachine class
1269////////////////////////////////////////////////////////////////////////////////
1270
1271/**
1272 * @note Notes on locking objects of this class:
1273 * SessionMachine shares some data with the primary Machine instance (pointed
1274 * to by the |mPeer| member). In order to provide data consistency it also
1275 * shares its lock handle. This means that whenever you lock a SessionMachine
1276 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1277 * instance is also locked in the same lock mode. Keep it in mind.
1278 */
1279class ATL_NO_VTABLE SessionMachine :
1280 public Machine
1281{
1282public:
1283 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SessionMachine, IMachine)
1284
1285 DECLARE_NOT_AGGREGATABLE(SessionMachine)
1286
1287 DECLARE_PROTECT_FINAL_CONSTRUCT()
1288
1289 BEGIN_COM_MAP(SessionMachine)
1290 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1291 COM_INTERFACE_ENTRY(IMachine)
1292 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1293 COM_INTERFACE_ENTRY(IInternalMachineControl)
1294 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1295 END_COM_MAP()
1296
1297 DECLARE_EMPTY_CTOR_DTOR(SessionMachine)
1298
1299 HRESULT FinalConstruct();
1300 void FinalRelease();
1301
1302 struct Uninit
1303 {
1304 enum Reason { Unexpected, Abnormal, Normal };
1305 };
1306
1307 // public initializer/uninitializer for internal purposes only
1308 HRESULT init(Machine *aMachine);
1309 void uninit() { uninit(Uninit::Unexpected); }
1310 void uninit(Uninit::Reason aReason);
1311
1312
1313 // util::Lockable interface
1314 RWLockHandle *lockHandle() const;
1315
1316 // public methods only for internal purposes
1317
1318 virtual bool i_isSessionMachine() const
1319 {
1320 return true;
1321 }
1322
1323#ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
1324 bool i_checkForDeath();
1325
1326 void i_getTokenId(Utf8Str &strTokenId);
1327#else /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1328 IToken *i_getToken();
1329#endif /* VBOX_WITH_GENERIC_SESSION_WATCHER */
1330 // getClientToken must be only used by callers who can guarantee that
1331 // the object cannot be deleted in the mean time, i.e. have a caller/lock.
1332 ClientToken *i_getClientToken();
1333
1334 HRESULT i_onNetworkAdapterChange(INetworkAdapter *networkAdapter, BOOL changeAdapter);
1335 HRESULT i_onNATRedirectRuleChange(ULONG ulSlot, BOOL aNatRuleRemove, IN_BSTR aRuleName,
1336 NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
1337 IN_BSTR aGuestIp, LONG aGuestPort);
1338 HRESULT i_onStorageControllerChange(const com::Guid &aMachineId, const com::Utf8Str &aControllerName);
1339 HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
1340 HRESULT i_onVMProcessPriorityChange(VMProcPriority_T aPriority);
1341 HRESULT i_onAudioAdapterChange(IAudioAdapter *audioAdapter);
1342 HRESULT i_onSerialPortChange(ISerialPort *serialPort);
1343 HRESULT i_onParallelPortChange(IParallelPort *parallelPort);
1344 HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
1345 HRESULT i_onVRDEServerChange(BOOL aRestart);
1346 HRESULT i_onRecordingChange(BOOL aEnable);
1347 HRESULT i_onUSBControllerChange();
1348 HRESULT i_onUSBDeviceAttach(IUSBDevice *aDevice,
1349 IVirtualBoxErrorInfo *aError,
1350 ULONG aMaskedIfs,
1351 const com::Utf8Str &aCaptureFilename);
1352 HRESULT i_onUSBDeviceDetach(IN_BSTR aId,
1353 IVirtualBoxErrorInfo *aError);
1354 HRESULT i_onSharedFolderChange();
1355 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode);
1356 HRESULT i_onClipboardFileTransferModeChange(BOOL aEnable);
1357 HRESULT i_onDnDModeChange(DnDMode_T aDnDMode);
1358 HRESULT i_onBandwidthGroupChange(IBandwidthGroup *aBandwidthGroup);
1359 HRESULT i_onStorageDeviceChange(IMediumAttachment *aMediumAttachment, BOOL aRemove, BOOL aSilent);
1360 HRESULT i_onCPUExecutionCapChange(ULONG aCpuExecutionCap);
1361
1362 bool i_hasMatchingUSBFilter(const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
1363
1364 HRESULT i_lockMedia();
1365 HRESULT i_unlockMedia();
1366
1367 HRESULT i_saveStateWithReason(Reason_T aReason, ComPtr<IProgress> &aProgress);
1368
1369private:
1370
1371 // wrapped IInternalMachineControl properties
1372
1373 // wrapped IInternalMachineControl methods
1374 HRESULT setRemoveSavedStateFile(BOOL aRemove);
1375 HRESULT updateState(MachineState_T aState);
1376 HRESULT beginPowerUp(const ComPtr<IProgress> &aProgress);
1377 HRESULT endPowerUp(LONG aResult);
1378 HRESULT beginPoweringDown(ComPtr<IProgress> &aProgress);
1379 HRESULT endPoweringDown(LONG aResult,
1380 const com::Utf8Str &aErrMsg);
1381 HRESULT runUSBDeviceFilters(const ComPtr<IUSBDevice> &aDevice,
1382 BOOL *aMatched,
1383 ULONG *aMaskedInterfaces);
1384 HRESULT captureUSBDevice(const com::Guid &aId, const com::Utf8Str &aCaptureFilename);
1385 HRESULT detachUSBDevice(const com::Guid &aId,
1386 BOOL aDone);
1387 HRESULT autoCaptureUSBDevices();
1388 HRESULT detachAllUSBDevices(BOOL aDone);
1389 HRESULT onSessionEnd(const ComPtr<ISession> &aSession,
1390 ComPtr<IProgress> &aProgress);
1391 HRESULT finishOnlineMergeMedium();
1392 HRESULT clipboardAreaRegister(const std::vector<com::Utf8Str> &aParms, ULONG *aID);
1393 HRESULT clipboardAreaUnregister(ULONG aID);
1394 HRESULT clipboardAreaAttach(ULONG aID);
1395 HRESULT clipboardAreaDetach(ULONG aID);
1396 HRESULT clipboardAreaGetMostRecent(ULONG *aID);
1397 HRESULT clipboardAreaGetRefCount(ULONG aID, ULONG *aRefCount);
1398 HRESULT pullGuestProperties(std::vector<com::Utf8Str> &aNames,
1399 std::vector<com::Utf8Str> &aValues,
1400 std::vector<LONG64> &aTimestamps,
1401 std::vector<com::Utf8Str> &aFlags);
1402 HRESULT pushGuestProperty(const com::Utf8Str &aName,
1403 const com::Utf8Str &aValue,
1404 LONG64 aTimestamp,
1405 const com::Utf8Str &aFlags);
1406 HRESULT lockMedia();
1407 HRESULT unlockMedia();
1408 HRESULT ejectMedium(const ComPtr<IMediumAttachment> &aAttachment,
1409 ComPtr<IMediumAttachment> &aNewAttachment);
1410 HRESULT reportVmStatistics(ULONG aValidStats,
1411 ULONG aCpuUser,
1412 ULONG aCpuKernel,
1413 ULONG aCpuIdle,
1414 ULONG aMemTotal,
1415 ULONG aMemFree,
1416 ULONG aMemBalloon,
1417 ULONG aMemShared,
1418 ULONG aMemCache,
1419 ULONG aPagedTotal,
1420 ULONG aMemAllocTotal,
1421 ULONG aMemFreeTotal,
1422 ULONG aMemBalloonTotal,
1423 ULONG aMemSharedTotal,
1424 ULONG aVmNetRx,
1425 ULONG aVmNetTx);
1426 HRESULT authenticateExternal(const std::vector<com::Utf8Str> &aAuthParams,
1427 com::Utf8Str &aResult);
1428
1429
1430 struct ConsoleTaskData
1431 {
1432 ConsoleTaskData()
1433 : mLastState(MachineState_Null),
1434 mDeleteSnapshotInfo(NULL)
1435 { }
1436
1437 MachineState_T mLastState;
1438 ComObjPtr<Progress> mProgress;
1439
1440 // used when deleting online snaphshot
1441 void *mDeleteSnapshotInfo;
1442 };
1443
1444 class SaveStateTask;
1445 class SnapshotTask;
1446 class TakeSnapshotTask;
1447 class DeleteSnapshotTask;
1448 class RestoreSnapshotTask;
1449
1450 void i_saveStateHandler(SaveStateTask &aTask);
1451
1452 // Override some functionality for SessionMachine, this is where the
1453 // real action happens (the Machine methods are just dummies).
1454 HRESULT saveState(ComPtr<IProgress> &aProgress);
1455 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile);
1456 HRESULT discardSavedState(BOOL aFRemoveFile);
1457 HRESULT takeSnapshot(const com::Utf8Str &aName,
1458 const com::Utf8Str &aDescription,
1459 BOOL aPause,
1460 com::Guid &aId,
1461 ComPtr<IProgress> &aProgress);
1462 HRESULT deleteSnapshot(const com::Guid &aId,
1463 ComPtr<IProgress> &aProgress);
1464 HRESULT deleteSnapshotAndAllChildren(const com::Guid &aId,
1465 ComPtr<IProgress> &aProgress);
1466 HRESULT deleteSnapshotRange(const com::Guid &aStartId,
1467 const com::Guid &aEndId,
1468 ComPtr<IProgress> &aProgress);
1469 HRESULT restoreSnapshot(const ComPtr<ISnapshot> &aSnapshot,
1470 ComPtr<IProgress> &aProgress);
1471
1472 void i_releaseSavedStateFile(const Utf8Str &strSavedStateFile, Snapshot *pSnapshotToIgnore);
1473
1474 void i_takeSnapshotHandler(TakeSnapshotTask &aTask);
1475 static void i_takeSnapshotProgressCancelCallback(void *pvUser);
1476 HRESULT i_finishTakingSnapshot(TakeSnapshotTask &aTask, AutoWriteLock &alock, bool aSuccess);
1477 HRESULT i_deleteSnapshot(const com::Guid &aStartId,
1478 const com::Guid &aEndId,
1479 BOOL aDeleteAllChildren,
1480 ComPtr<IProgress> &aProgress);
1481 void i_deleteSnapshotHandler(DeleteSnapshotTask &aTask);
1482 void i_restoreSnapshotHandler(RestoreSnapshotTask &aTask);
1483
1484 HRESULT i_prepareDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1485 const Guid &machineId,
1486 const Guid &snapshotId,
1487 bool fOnlineMergePossible,
1488 MediumLockList *aVMMALockList,
1489 ComObjPtr<Medium> &aSource,
1490 ComObjPtr<Medium> &aTarget,
1491 bool &fMergeForward,
1492 ComObjPtr<Medium> &pParentForTarget,
1493 MediumLockList * &aChildrenToReparent,
1494 bool &fNeedOnlineMerge,
1495 MediumLockList * &aMediumLockList,
1496 ComPtr<IToken> &aHDLockToken);
1497 void i_cancelDeleteSnapshotMedium(const ComObjPtr<Medium> &aHD,
1498 const ComObjPtr<Medium> &aSource,
1499 MediumLockList *aChildrenToReparent,
1500 bool fNeedsOnlineMerge,
1501 MediumLockList *aMediumLockList,
1502 const ComPtr<IToken> &aHDLockToken,
1503 const Guid &aMediumId,
1504 const Guid &aSnapshotId);
1505 HRESULT i_onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment,
1506 const ComObjPtr<Medium> &aSource,
1507 const ComObjPtr<Medium> &aTarget,
1508 bool fMergeForward,
1509 const ComObjPtr<Medium> &pParentForTarget,
1510 MediumLockList *aChildrenToReparent,
1511 MediumLockList *aMediumLockList,
1512 ComObjPtr<Progress> &aProgress,
1513 bool *pfNeedsMachineSaveSettings);
1514
1515 HRESULT i_setMachineState(MachineState_T aMachineState);
1516 HRESULT i_updateMachineStateOnClient();
1517
1518 bool mRemoveSavedState;
1519
1520 ConsoleTaskData mConsoleTaskData;
1521
1522 /** client token for this machine */
1523 ClientToken *mClientToken;
1524
1525 int miNATNetworksStarted;
1526
1527 AUTHLIBRARYCONTEXT mAuthLibCtx;
1528};
1529
1530// SnapshotMachine class
1531////////////////////////////////////////////////////////////////////////////////
1532
1533/**
1534 * @note Notes on locking objects of this class:
1535 * SnapshotMachine shares some data with the primary Machine instance (pointed
1536 * to by the |mPeer| member). In order to provide data consistency it also
1537 * shares its lock handle. This means that whenever you lock a SessionMachine
1538 * instance using Auto[Reader]Lock or AutoMultiLock, the corresponding Machine
1539 * instance is also locked in the same lock mode. Keep it in mind.
1540 */
1541class ATL_NO_VTABLE SnapshotMachine :
1542 public Machine
1543{
1544public:
1545 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(SnapshotMachine, IMachine)
1546
1547 DECLARE_NOT_AGGREGATABLE(SnapshotMachine)
1548
1549 DECLARE_PROTECT_FINAL_CONSTRUCT()
1550
1551 BEGIN_COM_MAP(SnapshotMachine)
1552 COM_INTERFACE_ENTRY(ISupportErrorInfo)
1553 COM_INTERFACE_ENTRY(IMachine)
1554 COM_INTERFACE_ENTRY2(IDispatch, IMachine)
1555 VBOX_TWEAK_INTERFACE_ENTRY(IMachine)
1556 END_COM_MAP()
1557
1558 DECLARE_EMPTY_CTOR_DTOR(SnapshotMachine)
1559
1560 HRESULT FinalConstruct();
1561 void FinalRelease();
1562
1563 // public initializer/uninitializer for internal purposes only
1564 HRESULT init(SessionMachine *aSessionMachine,
1565 IN_GUID aSnapshotId,
1566 const Utf8Str &aStateFilePath);
1567 HRESULT initFromSettings(Machine *aMachine,
1568 const settings::Hardware &hardware,
1569 const settings::Debugging *pDbg,
1570 const settings::Autostart *pAutostart,
1571 IN_GUID aSnapshotId,
1572 const Utf8Str &aStateFilePath);
1573 void uninit();
1574
1575 // util::Lockable interface
1576 RWLockHandle *lockHandle() const;
1577
1578 // public methods only for internal purposes
1579
1580 virtual bool i_isSnapshotMachine() const
1581 {
1582 return true;
1583 }
1584
1585 HRESULT i_onSnapshotChange(Snapshot *aSnapshot);
1586
1587 // unsafe inline public methods for internal purposes only (ensure there is
1588 // a caller and a read lock before calling them!)
1589
1590 const Guid& i_getSnapshotId() const { return mSnapshotId; }
1591
1592private:
1593
1594 Guid mSnapshotId;
1595 /** This field replaces mPeer for SessionMachine instances, as having
1596 * a peer reference is plain meaningless and causes many subtle problems
1597 * with saving settings and the like. */
1598 Machine * const mMachine;
1599
1600 friend class Snapshot;
1601};
1602
1603// third party methods that depend on SnapshotMachine definition
1604
1605inline const Guid &Machine::i_getSnapshotId() const
1606{
1607 return (i_isSnapshotMachine())
1608 ? static_cast<const SnapshotMachine*>(this)->i_getSnapshotId()
1609 : Guid::Empty;
1610}
1611
1612
1613#endif /* !MAIN_INCLUDED_MachineImpl_h */
1614/* 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