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