- Timestamp:
- Sep 25, 2009 11:36:00 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostPower.cpp
r23223 r23327 44 44 } 45 45 46 void HostPowerService::notify 46 void HostPowerService::notify(HostPowerEvent aEvent) 47 47 { 48 VirtualBox::SessionMachine Vectormachines;49 VirtualBox::InternalControl Vectorcontrols;48 VirtualBox::SessionMachineList machines; 49 VirtualBox::InternalControlList controls; 50 50 51 51 HRESULT rc = S_OK; … … 64 64 perfcollector->suspendSampling(); 65 65 #endif 66 mVirtualBox->getOpenedMachines AndControls (machines,controls);66 mVirtualBox->getOpenedMachines(machines, &controls); 67 67 68 68 /* pause running VMs */ 69 for (size_t i = 0; i < controls.size(); ++ i) 69 for (VirtualBox::InternalControlList::const_iterator it = controls.begin(); 70 it != controls.end(); 71 ++it) 70 72 { 73 ComPtr<IInternalSessionControl> pControl = *it; 74 71 75 /* get the remote console */ 72 76 ComPtr<IConsole> console; 73 rc = controls [i]->GetRemoteConsole (console.asOutParam());77 rc = pControl->GetRemoteConsole (console.asOutParam()); 74 78 /* the VM could have been powered down and closed or whatever */ 75 79 if (FAILED (rc)) … … 83 87 84 88 /* save the control to un-pause the VM later */ 85 mConsoles.push_back 89 mConsoles.push_back(console); 86 90 } 87 91 … … 130 134 LogFunc (("BATTERY LOW\n")); 131 135 132 mVirtualBox->getOpenedMachines AndControls (machines,controls);136 mVirtualBox->getOpenedMachines(machines, &controls); 133 137 134 138 size_t saved = 0; 135 139 136 140 /* save running VMs */ 137 for (size_t i = 0; i < controls.size(); ++ i) 141 for (VirtualBox::InternalControlList::const_iterator it = controls.begin(); 142 it != controls.end(); 143 ++it) 138 144 { 145 ComPtr<IInternalSessionControl> pControl = *it; 139 146 /* get the remote console */ 140 147 ComPtr<IConsole> console; 141 rc = controls [i]->GetRemoteConsole (console.asOutParam());148 rc = pControl->GetRemoteConsole (console.asOutParam()); 142 149 /* the VM could have been powered down and closed or whatever */ 143 150 if (FAILED (rc)) -
trunk/src/VBox/Main/MediumImpl.cpp
r23257 r23327 3307 3307 RWLockHandle* Medium::treeLock() 3308 3308 { 3309 return mVirtualBox->hardDiskTreeLockHandle();3309 return &mVirtualBox->hardDiskTreeLockHandle(); 3310 3310 } 3311 3311 -
trunk/src/VBox/Main/VFSExplorerImpl.cpp
r23223 r23327 26 26 #include <iprt/s3.h> 27 27 28 #include <VBox/com/array.h> 29 28 30 #include <VBox/param.h> 29 31 #include <VBox/version.h> -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r23319 r23327 65 65 #include "DHCPServerRunner.h" 66 66 #include "DHCPServerImpl.h" 67 #ifdef VBOX_WITH_RESOURCE_USAGE_API 68 #include "PerformanceImpl.h" 69 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 67 70 68 71 #include "Logging.h" … … 72 75 #endif 73 76 74 // defines 75 ///////////////////////////////////////////////////////////////////////////// 77 //////////////////////////////////////////////////////////////////////////////// 78 // 79 // Definitions 80 // 81 //////////////////////////////////////////////////////////////////////////////// 76 82 77 83 #define VBOX_GLOBAL_SETTINGS_FILE "VirtualBox.xml" … … 79 85 typedef std::vector< ComObjPtr<Machine> > MachineVector; 80 86 81 // globals 82 ///////////////////////////////////////////////////////////////////////////// 87 typedef std::list< ComObjPtr<Machine> > MachineList; 88 typedef std::vector< ComObjPtr<SessionMachine> > SessionMachineVector; 89 typedef std::list< ComObjPtr<GuestOSType> > GuestOSTypeList; 90 91 typedef std::map<Guid, ComPtr<IProgress> > ProgressMap; 92 93 typedef std::list <ComObjPtr<Medium> > HardDiskList; 94 typedef std::list <ComObjPtr<Medium> > DVDImageList; 95 typedef std::list <ComObjPtr<Medium> > FloppyImageList; 96 typedef std::list <ComObjPtr<SharedFolder> > SharedFolderList; 97 typedef std::list <ComObjPtr<DHCPServer> > DHCPServerList; 98 99 typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap; 100 101 102 //////////////////////////////////////////////////////////////////////////////// 103 // 104 // Global variables 105 // 106 //////////////////////////////////////////////////////////////////////////////// 83 107 84 108 // static … … 93 117 //////////////////////////////////////////////////////////////////////////////// 94 118 // 95 // Callback event119 // CallbackEvent class 96 120 // 97 121 //////////////////////////////////////////////////////////////////////////////// … … 129 153 }; 130 154 155 //////////////////////////////////////////////////////////////////////////////// 156 // 157 // VirtualBox data definition 158 // 159 //////////////////////////////////////////////////////////////////////////////// 160 161 #if defined(RT_OS_WINDOWS) 162 #define UPDATEREQARG NULL 163 #define UPDATEREQTYPE HANDLE 164 #elif defined(RT_OS_OS2) 165 #define UPDATEREQARG NIL_RTSEMEVENT 166 #define UPDATEREQTYPE RTSEMEVENT 167 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 168 #define UPDATEREQARG 169 #define UPDATEREQTYPE RTSEMEVENT 170 #else 171 # error "Port me!" 172 #endif 173 174 /** 175 * Main VirtualBox data structure. 176 * @note |const| members are persistent during lifetime so can be accessed 177 * without locking. 178 */ 179 struct VirtualBox::Data 180 { 181 Data() 182 : pMainConfigFile(NULL), 183 updateReq(UPDATEREQARG), 184 threadClientWatcher(NIL_RTTHREAD), 185 threadAsyncEvent(NIL_RTTHREAD), 186 pAsyncEventQ(NULL) 187 {} 188 189 // const data members not requiring locking 190 const Utf8Str strHomeDir; 191 192 // VirtualBox main settings file 193 const Utf8Str strSettingsFilePath; 194 settings::MainConfigFile *pMainConfigFile; 195 196 // const objects not requiring locking 197 const ComObjPtr<Host> pHost; 198 const ComObjPtr<SystemProperties> pSystemProperties; 199 #ifdef VBOX_WITH_RESOURCE_USAGE_API 200 const ComObjPtr<PerformanceCollector> pPerformanceCollector; 201 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 202 203 MachineList llMachines; 204 GuestOSTypeList llGuestOSTypes; 205 206 ProgressMap mapProgressOperations; 207 208 HardDiskList llHardDisks; 209 DVDImageList llDVDImages; 210 FloppyImageList llFloppyImages; 211 SharedFolderList llSharedFolders; 212 DHCPServerList llDHCPServers; 213 214 /// @todo NEWMEDIA do we really need this map? Used only in 215 /// find() it seems 216 HardDiskMap mapHardDisks; 217 218 CallbackList llCallbacks; 219 220 RWLockHandle mtxProgressOperations; 221 // protects mutex operations; "leaf" lock, no other lock may be requested after this 222 RWLockHandle mtxHardDiskTree; 223 // protects the hard disk tree; this is implemented here, but only requested through 224 // Medium::treeLock, which returns exactly this 225 RWLockHandle mtxChildrenMap; 226 // used for VirtualBoxWithChildrenNEXT management 227 228 // the following are data for the client watcher thread 229 const UPDATEREQTYPE updateReq; 230 const RTTHREAD threadClientWatcher; 231 typedef std::list<RTPROCESS> ProcessList; 232 ProcessList llProcesses; 233 234 // the following are data for the async event thread 235 const RTTHREAD threadAsyncEvent; 236 EventQueue * const pAsyncEventQ; 237 238 }; 239 131 240 // constructor / destructor 132 241 ///////////////////////////////////////////////////////////////////////////// 133 242 134 243 VirtualBox::VirtualBox() 135 : mAsyncEventThread (NIL_RTTHREAD)136 , mAsyncEventQ (NULL)137 244 {} 138 245 139 VirtualBox::~VirtualBox() {} 246 VirtualBox::~VirtualBox() 247 {} 140 248 141 249 HRESULT VirtualBox::FinalConstruct() … … 151 259 152 260 uninit(); 153 }154 155 VirtualBox::Data::Data()156 {157 261 } 158 262 … … 175 279 * read lock and later calls code which wants the same write lock. */ 176 280 AutoWriteLock lock(this); 281 282 // allocate our instance data 283 m = new Data; 177 284 178 285 LogFlow (("===========================================================\n")); … … 196 303 homeDir, vrc); 197 304 198 unconst(m Data.mHomeDir) = homeDir;305 unconst(m->strHomeDir) = homeDir; 199 306 } 200 307 201 308 /* compose the VirtualBox.xml file name */ 202 unconst(m _strSettingsFilePath) = Utf8StrFmt("%s%c%s",203 m Data.mHomeDir.raw(),309 unconst(m->strSettingsFilePath) = Utf8StrFmt("%s%c%s", 310 m->strHomeDir.raw(), 204 311 RTPATH_DELIMITER, 205 312 VBOX_GLOBAL_SETTINGS_FILE); … … 211 318 try 212 319 { 213 m _pMainConfigFile = new settings::MainConfigFile(&m_strSettingsFilePath);320 m->pMainConfigFile = new settings::MainConfigFile(&m->strSettingsFilePath); 214 321 } 215 322 catch (xml::EIPRTFailure &e) … … 225 332 226 333 if (fCreate) 227 m _pMainConfigFile = new settings::MainConfigFile(NULL);334 m->pMainConfigFile = new settings::MainConfigFile(NULL); 228 335 229 336 #ifdef VBOX_WITH_RESOURCE_USAGE_API 230 337 /* create the performance collector object BEFORE host */ 231 unconst (mData.mPerformanceCollector).createObject();232 rc = m Data.mPerformanceCollector->init();338 unconst(m->pPerformanceCollector).createObject(); 339 rc = m->pPerformanceCollector->init(); 233 340 ComAssertComRCThrowRC(rc); 234 341 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 235 342 236 343 /* create the host object early, machines will need it */ 237 unconst (mData.mHost).createObject();238 rc = m Data.mHost->init(this);344 unconst(m->pHost).createObject(); 345 rc = m->pHost->init(this); 239 346 ComAssertComRCThrowRC(rc); 240 347 241 rc = m Data.mHost->loadSettings(m_pMainConfigFile->host);348 rc = m->pHost->loadSettings(m->pMainConfigFile->host); 242 349 CheckComRCThrowRC(rc); 243 350 244 351 /* create the system properties object, someone may need it too */ 245 unconst (mData.mSystemProperties).createObject();246 rc = m Data.mSystemProperties->init(this);352 unconst(m->pSystemProperties).createObject(); 353 rc = m->pSystemProperties->init(this); 247 354 ComAssertComRCThrowRC (rc); 248 355 249 rc = m Data.mSystemProperties->loadSettings(m_pMainConfigFile->systemProperties);356 rc = m->pSystemProperties->loadSettings(m->pMainConfigFile->systemProperties); 250 357 CheckComRCThrowRC(rc); 251 358 … … 269 376 Global::sOSTypes [i].numSerialEnabled); 270 377 if (SUCCEEDED(rc)) 271 m Data.mGuestOSTypes.push_back (guestOSTypeObj);378 m->llGuestOSTypes.push_back (guestOSTypeObj); 272 379 } 273 380 ComAssertComRCThrowRC (rc); … … 283 390 284 391 /* net services */ 285 for (settings::DHCPServersList::const_iterator it = m _pMainConfigFile->llDhcpServers.begin();286 it != m _pMainConfigFile->llDhcpServers.end();392 for (settings::DHCPServersList::const_iterator it = m->pMainConfigFile->llDhcpServers.begin(); 393 it != m->pMainConfigFile->llDhcpServers.end(); 287 394 ++it) 288 395 { … … 312 419 /* start the client watcher thread */ 313 420 #if defined(RT_OS_WINDOWS) 314 unconst(m WatcherData.mUpdateReq) = ::CreateEvent (NULL, FALSE, FALSE, NULL);421 unconst(m->updateReq) = ::CreateEvent (NULL, FALSE, FALSE, NULL); 315 422 #elif defined(RT_OS_OS2) 316 RTSemEventCreate (&unconst(mWatcherData.mUpdateReq));423 RTSemEventCreate(&unconst(m->updateReq)); 317 424 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 318 RTSemEventCreate (&unconst(mWatcherData.mUpdateReq));425 RTSemEventCreate(&unconst(m->updateReq)); 319 426 #else 320 427 # error "Port me!" 321 428 #endif 322 int vrc = RTThreadCreate (&unconst(mWatcherData.mThread), 323 ClientWatcher, (void *) this, 324 0, RTTHREADTYPE_MAIN_WORKER, 325 RTTHREADFLAGS_WAITABLE, "Watcher"); 429 int vrc = RTThreadCreate(&unconst(m->threadClientWatcher), 430 ClientWatcher, 431 (void *) this, 432 0, 433 RTTHREADTYPE_MAIN_WORKER, 434 RTTHREADFLAGS_WAITABLE, 435 "Watcher"); 326 436 ComAssertRC (vrc); 327 437 if (RT_FAILURE(vrc)) … … 332 442 { 333 443 /* start the async event handler thread */ 334 int vrc = RTThreadCreate (&unconst(mAsyncEventThread), AsyncEventHandler, 335 &unconst(mAsyncEventQ), 336 0, RTTHREADTYPE_MAIN_WORKER, 337 RTTHREADFLAGS_WAITABLE, "EventHandler"); 444 int vrc = RTThreadCreate(&unconst(m->threadAsyncEvent), 445 AsyncEventHandler, 446 &unconst(m->pAsyncEventQ), 447 0, 448 RTTHREADTYPE_MAIN_WORKER, 449 RTTHREADFLAGS_WAITABLE, 450 "EventHandler"); 338 451 ComAssertRCBreak (vrc, rc = E_FAIL); 339 452 340 /* wait until the thread sets m AsyncEventQ */341 RTThreadUserWait (mAsyncEventThread, RT_INDEFINITE_WAIT);342 ComAssertBreak (mAsyncEventQ, rc = E_FAIL);453 /* wait until the thread sets m->pAsyncEventQ */ 454 RTThreadUserWait(m->threadAsyncEvent, RT_INDEFINITE_WAIT); 455 ComAssertBreak(m->pAsyncEventQ, rc = E_FAIL); 343 456 } 344 457 while (0); … … 356 469 HRESULT VirtualBox::initMachines() 357 470 { 358 for (settings::MachinesRegistry::const_iterator it = m _pMainConfigFile->llMachines.begin();359 it != m _pMainConfigFile->llMachines.end();471 for (settings::MachinesRegistry::const_iterator it = m->pMainConfigFile->llMachines.begin(); 472 it != m->pMainConfigFile->llMachines.end(); 360 473 ++it) 361 474 { … … 388 501 HRESULT rc = S_OK; 389 502 settings::MediaList::const_iterator it; 390 for (it = m _pMainConfigFile->llHardDisks.begin();391 it != m _pMainConfigFile->llHardDisks.end();503 for (it = m->pMainConfigFile->llHardDisks.begin(); 504 it != m->pMainConfigFile->llHardDisks.end(); 392 505 ++it) 393 506 { … … 406 519 } 407 520 408 for (it = m _pMainConfigFile->llDvdImages.begin();409 it != m _pMainConfigFile->llDvdImages.end();521 for (it = m->pMainConfigFile->llDvdImages.begin(); 522 it != m->pMainConfigFile->llDvdImages.end(); 410 523 ++it) 411 524 { … … 421 534 } 422 535 423 for (it = m _pMainConfigFile->llFloppyImages.begin();424 it != m _pMainConfigFile->llFloppyImages.end();536 for (it = m->pMainConfigFile->llFloppyImages.begin(); 537 it != m->pMainConfigFile->llFloppyImages.end(); 425 538 ++it) 426 539 { … … 452 565 /* tell all our child objects we've been uninitialized */ 453 566 454 LogFlowThisFunc(("Uninitializing machines (%d)...\n", m Data.mMachines.size()));455 if (m Data.mMachines.size())456 { 457 MachineList::iterator it = m Data.mMachines.begin();458 while (it != m Data.mMachines.end())567 LogFlowThisFunc(("Uninitializing machines (%d)...\n", m->llMachines.size())); 568 if (m->llMachines.size()) 569 { 570 MachineList::iterator it = m->llMachines.begin(); 571 while (it != m->llMachines.end()) 459 572 (*it++)->uninit(); 460 m Data.mMachines.clear();573 m->llMachines.clear(); 461 574 } 462 575 … … 466 579 uninitDependentChildren(); 467 580 468 m Data.mHardDiskMap.clear();469 470 m Data.mFloppyImages.clear();471 m Data.mDVDImages.clear();472 m Data.mHardDisks.clear();473 m Data.mDHCPServers.clear();474 475 m Data.mProgressOperations.clear();476 477 m Data.mGuestOSTypes.clear();581 m->mapHardDisks.clear(); 582 583 m->llFloppyImages.clear(); 584 m->llDVDImages.clear(); 585 m->llHardDisks.clear(); 586 m->llDHCPServers.clear(); 587 588 m->mapProgressOperations.clear(); 589 590 m->llGuestOSTypes.clear(); 478 591 479 592 /* Note that we release singleton children after we've all other children. … … 482 595 * uninitializing (as for example, mSystemProperties which owns 483 596 * MediumFormat objects which Medium objects refer to) */ 484 if (m Data.mSystemProperties)485 { 486 m Data.mSystemProperties->uninit();487 unconst(m Data.mSystemProperties).setNull();488 } 489 490 if (m Data.mHost)491 { 492 m Data.mHost->uninit();493 unconst(m Data.mHost).setNull();597 if (m->pSystemProperties) 598 { 599 m->pSystemProperties->uninit(); 600 unconst(m->pSystemProperties).setNull(); 601 } 602 603 if (m->pHost) 604 { 605 m->pHost->uninit(); 606 unconst(m->pHost).setNull(); 494 607 } 495 608 496 609 #ifdef VBOX_WITH_RESOURCE_USAGE_API 497 if (m Data.mPerformanceCollector)498 { 499 m Data.mPerformanceCollector->uninit();500 unconst(m Data.mPerformanceCollector).setNull();610 if (m->pPerformanceCollector) 611 { 612 m->pPerformanceCollector->uninit(); 613 unconst(m->pPerformanceCollector).setNull(); 501 614 } 502 615 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 503 616 504 617 LogFlowThisFunc(("Releasing callbacks...\n")); 505 if (m Data.mCallbacks.size())618 if (m->llCallbacks.size()) 506 619 { 507 620 /* release all callbacks */ 508 621 LogWarningFunc (("%d unregistered callbacks!\n", 509 m Data.mCallbacks.size()));510 m Data.mCallbacks.clear();622 m->llCallbacks.size())); 623 m->llCallbacks.clear(); 511 624 } 512 625 513 626 LogFlowThisFunc(("Terminating the async event handler...\n")); 514 if (m AsyncEventThread!= NIL_RTTHREAD)627 if (m->threadAsyncEvent != NIL_RTTHREAD) 515 628 { 516 629 /* signal to exit the event loop */ 517 if (m AsyncEventQ->postEvent (NULL))630 if (m->pAsyncEventQ->postEvent (NULL)) 518 631 { 519 632 /* … … 521 634 * a NULL event!) 522 635 */ 523 int vrc = RTThreadWait (mAsyncEventThread, 60000, NULL);636 int vrc = RTThreadWait(m->threadAsyncEvent, 60000, NULL); 524 637 if (RT_FAILURE(vrc)) 525 LogWarningFunc 526 mAsyncEventThread, vrc));638 LogWarningFunc(("RTThreadWait(%RTthrd) -> %Rrc\n", 639 m->threadAsyncEvent, vrc)); 527 640 } 528 641 else 529 642 { 530 AssertMsgFailed 531 RTThreadWait (mAsyncEventThread, 0, NULL);643 AssertMsgFailed(("postEvent(NULL) failed\n")); 644 RTThreadWait(m->threadAsyncEvent, 0, NULL); 532 645 } 533 646 534 unconst(m AsyncEventThread) = NIL_RTTHREAD;535 unconst(m AsyncEventQ) = NULL;647 unconst(m->threadAsyncEvent) = NIL_RTTHREAD; 648 unconst(m->pAsyncEventQ) = NULL; 536 649 } 537 650 538 651 LogFlowThisFunc(("Terminating the client watcher...\n")); 539 if (m WatcherData.mThread!= NIL_RTTHREAD)652 if (m->threadClientWatcher != NIL_RTTHREAD) 540 653 { 541 654 /* signal the client watcher thread */ 542 655 updateClientWatcher(); 543 656 /* wait for the termination */ 544 RTThreadWait (mWatcherData.mThread, RT_INDEFINITE_WAIT, NULL);545 unconst(m WatcherData.mThread) = NIL_RTTHREAD;546 } 547 m WatcherData.mProcesses.clear();657 RTThreadWait(m->threadClientWatcher, RT_INDEFINITE_WAIT, NULL); 658 unconst(m->threadClientWatcher) = NIL_RTTHREAD; 659 } 660 m->llProcesses.clear(); 548 661 #if defined(RT_OS_WINDOWS) 549 if (m WatcherData.mUpdateReq != NULL)550 { 551 ::CloseHandle (m WatcherData.mUpdateReq);552 unconst(m WatcherData.mUpdateReq) = NULL;662 if (m->updateReq != NULL) 663 { 664 ::CloseHandle (m->updateReq); 665 unconst(m->updateReq) = NULL; 553 666 } 554 667 #elif defined(RT_OS_OS2) 555 if (m WatcherData.mUpdateReq != NIL_RTSEMEVENT)556 { 557 RTSemEventDestroy (m WatcherData.mUpdateReq);558 unconst(m WatcherData.mUpdateReq) = NIL_RTSEMEVENT;668 if (m->updateReq != NIL_RTSEMEVENT) 669 { 670 RTSemEventDestroy (m->updateReq); 671 unconst(m->updateReq) = NIL_RTSEMEVENT; 559 672 } 560 673 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 561 if (m WatcherData.mUpdateReq != NIL_RTSEMEVENT)562 { 563 RTSemEventDestroy (m WatcherData.mUpdateReq);564 unconst(m WatcherData.mUpdateReq) = NIL_RTSEMEVENT;674 if (m->updateReq != NIL_RTSEMEVENT) 675 { 676 RTSemEventDestroy (m->updateReq); 677 unconst(m->updateReq) = NIL_RTSEMEVENT; 565 678 } 566 679 #else … … 568 681 #endif 569 682 683 // clean up our instance data 684 delete m; 685 570 686 /* Unload hard disk plugin backends. */ 571 687 VDShutdown(); … … 619 735 620 736 /* mHomeDir is const and doesn't need a lock */ 621 m Data.mHomeDir.cloneTo(aHomeFolder);737 m->strHomeDir.cloneTo(aHomeFolder); 622 738 return S_OK; 623 739 } … … 631 747 632 748 /* mCfgFile.mName is const and doesn't need a lock */ 633 m _strSettingsFilePath.cloneTo(aSettingsFilePath);749 m->strSettingsFilePath.cloneTo(aSettingsFilePath); 634 750 return S_OK; 635 751 } … … 643 759 644 760 /* mHost is const, no need to lock */ 645 m Data.mHost.queryInterfaceTo(aHost);761 m->pHost.queryInterfaceTo(aHost); 646 762 return S_OK; 647 763 } … … 656 772 657 773 /* mSystemProperties is const, no need to lock */ 658 m Data.mSystemProperties.queryInterfaceTo(aSystemProperties);774 m->pSystemProperties.queryInterfaceTo(aSystemProperties); 659 775 return S_OK; 660 776 } … … 671 787 AutoReadLock alock(this); 672 788 673 SafeIfaceArray<IMachine> machines (mData.mMachines);789 SafeIfaceArray<IMachine> machines(m->llMachines); 674 790 machines.detachTo(ComSafeArrayOutArg(aMachines)); 675 791 … … 687 803 AutoReadLock alock(this); 688 804 689 SafeIfaceArray<IMedium> hardDisks (mData.mHardDisks);805 SafeIfaceArray<IMedium> hardDisks(m->llHardDisks); 690 806 hardDisks.detachTo(ComSafeArrayOutArg(aHardDisks)); 691 807 … … 704 820 AutoReadLock alock(this); 705 821 706 SafeIfaceArray<IMedium> images (mData.mDVDImages);822 SafeIfaceArray<IMedium> images(m->llDVDImages); 707 823 images.detachTo(ComSafeArrayOutArg(aDVDImages)); 708 824 … … 721 837 AutoReadLock alock(this); 722 838 723 SafeIfaceArray<IMedium> images (mData.mFloppyImages);839 SafeIfaceArray<IMedium> images(m->llFloppyImages); 724 840 images.detachTo(ComSafeArrayOutArg(aFloppyImages)); 725 841 … … 735 851 736 852 /* protect mProgressOperations */ 737 AutoReadLock safeLock (mSafeLock);738 739 SafeIfaceArray<IProgress> progress (mData.mProgressOperations);853 AutoReadLock safeLock(m->mtxProgressOperations); 854 855 SafeIfaceArray<IProgress> progress(m->mapProgressOperations); 740 856 progress.detachTo(ComSafeArrayOutArg(aOperations)); 741 857 … … 752 868 AutoReadLock alock(this); 753 869 754 SafeIfaceArray<IGuestOSType> ostypes (mData.mGuestOSTypes);870 SafeIfaceArray<IGuestOSType> ostypes(m->llGuestOSTypes); 755 871 ostypes.detachTo(ComSafeArrayOutArg(aGuestOSTypes)); 756 872 … … 783 899 784 900 /* mPerformanceCollector is const, no need to lock */ 785 m Data.mPerformanceCollector.queryInterfaceTo(aPerformanceCollector);901 m->pPerformanceCollector.queryInterfaceTo(aPerformanceCollector); 786 902 787 903 return S_OK; … … 802 918 AutoReadLock alock(this); 803 919 804 SafeIfaceArray<IDHCPServer> svrs (m Data.mDHCPServers);920 SafeIfaceArray<IDHCPServer> svrs (m->llDHCPServers); 805 921 svrs.detachTo(ComSafeArrayOutArg(aDHCPServers)); 806 922 … … 859 975 id.create(); 860 976 861 /* Look for a GuestOSType object */ 862 AssertMsg (mData.mGuestOSTypes.size() != 0, 863 ("Guest OS types array must be filled")); 864 865 GuestOSType *osType = NULL; 866 if (aOsTypeId != NULL) 867 { 868 for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin(); 869 it != mData.mGuestOSTypes.end(); 870 ++ it) 871 { 872 if ((*it)->id() == aOsTypeId) 873 { 874 osType = *it; 875 break; 876 } 877 } 878 879 if (osType == NULL) 880 return setError(VBOX_E_OBJECT_NOT_FOUND, 881 tr("Guest OS type '%ls' is invalid"), 882 aOsTypeId); 883 } 977 GuestOSType *osType; 978 rc = findGuestOSType(aOsTypeId, osType); 979 CheckComRCReturnRC(rc); 884 980 885 981 /* initialize the machine object */ … … 934 1030 id.create(); 935 1031 936 /* Look for a GuestOSType object */ 937 AssertMsg (mData.mGuestOSTypes.size() != 0, 938 ("Guest OS types array must be filled")); 939 940 GuestOSType *osType = NULL; 941 if (aOsTypeId != NULL) 942 { 943 for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin(); 944 it != mData.mGuestOSTypes.end(); ++ it) 945 { 946 if ((*it)->id() == aOsTypeId) 947 { 948 osType = *it; 949 break; 950 } 951 } 952 953 if (osType == NULL) 954 return setError (VBOX_E_OBJECT_NOT_FOUND, 955 tr ("Guest OS type '%ls' is invalid"), aOsTypeId); 956 } 1032 GuestOSType *osType; 1033 rc = findGuestOSType(aOsTypeId, osType); 1034 CheckComRCReturnRC(rc); 957 1035 958 1036 /* initialize the machine object */ … … 1082 1160 /* take a copy for safe iteration outside the lock */ 1083 1161 AutoReadLock alock(this); 1084 machines = m Data.mMachines;1162 machines = m->llMachines; 1085 1163 } 1086 1164 … … 1137 1215 1138 1216 /* remove from the collection of registered machines */ 1139 m Data.mMachines.remove (machine);1217 m->llMachines.remove (machine); 1140 1218 1141 1219 /* save the global registry */ … … 1446 1524 AutoReadLock alock(this); 1447 1525 1448 for (GuestOSTypeList::iterator it = m Data.mGuestOSTypes.begin();1449 it != m Data.mGuestOSTypes.end();1526 for (GuestOSTypeList::iterator it = m->llGuestOSTypes.begin(); 1527 it != m->llGuestOSTypes.end(); 1450 1528 ++ it) 1451 1529 { … … 1502 1580 AutoReadLock alock (this); 1503 1581 1504 com::SafeArray<BSTR> saKeys(m _pMainConfigFile->mapExtraDataItems.size());1582 com::SafeArray<BSTR> saKeys(m->pMainConfigFile->mapExtraDataItems.size()); 1505 1583 int i = 0; 1506 for (ExtraDataItemsMap::const_iterator it = m _pMainConfigFile->mapExtraDataItems.begin();1507 it != m _pMainConfigFile->mapExtraDataItems.end();1584 for (ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.begin(); 1585 it != m->pMainConfigFile->mapExtraDataItems.end(); 1508 1586 ++it, ++i) 1509 1587 { … … 1531 1609 Bstr("").cloneTo(aValue); 1532 1610 1533 settings::ExtraDataItemsMap::const_iterator it = m _pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey));1534 if (it != m _pMainConfigFile->mapExtraDataItems.end())1611 settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey)); 1612 if (it != m->pMainConfigFile->mapExtraDataItems.end()) 1535 1613 { 1536 1614 // found: … … 1567 1645 { 1568 1646 AutoReadLock alock(this); // hold read lock only while looking up 1569 settings::ExtraDataItemsMap::const_iterator it = m _pMainConfigFile->mapExtraDataItems.find(strKey);1570 if (it != m _pMainConfigFile->mapExtraDataItems.end())1647 settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(strKey); 1648 if (it != m->pMainConfigFile->mapExtraDataItems.end()) 1571 1649 strOldValue = it->second; 1572 1650 } … … 1604 1682 1605 1683 if (strValue.isEmpty()) 1606 m _pMainConfigFile->mapExtraDataItems.erase(strKey);1684 m->pMainConfigFile->mapExtraDataItems.erase(strKey); 1607 1685 else 1608 m _pMainConfigFile->mapExtraDataItems[strKey] = strValue;1686 m->pMainConfigFile->mapExtraDataItems[strKey] = strValue; 1609 1687 // creates a new key if needed 1610 1688 … … 1787 1865 1788 1866 AutoWriteLock alock(this); 1789 m Data.mCallbacks.push_back (CallbackList::value_type (aCallback));1867 m->llCallbacks.push_back (CallbackList::value_type (aCallback)); 1790 1868 1791 1869 return S_OK; … … 1807 1885 1808 1886 CallbackList::iterator it; 1809 it = std::find (m Data.mCallbacks.begin(),1810 m Data.mCallbacks.end(),1887 it = std::find (m->llCallbacks.begin(), 1888 m->llCallbacks.end(), 1811 1889 CallbackList::value_type (aCallback)); 1812 if (it == m Data.mCallbacks.end())1890 if (it == m->llCallbacks.end()) 1813 1891 rc = E_INVALIDARG; 1814 1892 else 1815 m Data.mCallbacks.erase (it);1893 m->llCallbacks.erase (it); 1816 1894 1817 1895 LogFlowThisFunc(("aCallback=%p, rc=%08X\n", aCallback, rc)); … … 1820 1898 1821 1899 1822 STDMETHODIMP VirtualBox::WaitForPropertyChange (IN_BSTR /* aWhat */, ULONG /* aTimeout */, 1823 BSTR * /* aChanged */, BSTR * /* aValues */) 1900 STDMETHODIMP VirtualBox::WaitForPropertyChange(IN_BSTR /* aWhat */, 1901 ULONG /* aTimeout */, 1902 BSTR * /* aChanged */, 1903 BSTR * /* aValues */) 1824 1904 { 1825 1905 ReturnComNotImplemented(); … … 1844 1924 * @note Doesn't lock any object. 1845 1925 */ 1846 HRESULT VirtualBox::postEvent 1847 { 1848 AutoCaller autoCaller(this); 1849 AssertComRCReturn 1926 HRESULT VirtualBox::postEvent(Event *event) 1927 { 1928 AutoCaller autoCaller(this); 1929 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 1850 1930 1851 1931 if (autoCaller.state() != Ready) … … 1858 1938 1859 1939 AssertReturn(event, E_FAIL); 1860 AssertReturn(m AsyncEventQ, E_FAIL);1861 1862 if (m AsyncEventQ->postEvent(event))1940 AssertReturn(m->pAsyncEventQ, E_FAIL); 1941 1942 if (m->pAsyncEventQ->postEvent(event)) 1863 1943 return S_OK; 1864 1944 … … 1874 1954 * @note Doesn't lock objects. 1875 1955 */ 1876 HRESULT VirtualBox::addProgress 1956 HRESULT VirtualBox::addProgress(IProgress *aProgress) 1877 1957 { 1878 1958 CheckComArgNotNull(aProgress); … … 1886 1966 1887 1967 /* protect mProgressOperations */ 1888 AutoWriteLock safeLock (mSafeLock);1889 1890 m Data.mProgressOperations.insert (ProgressMap::value_type (Guid(id), aProgress));1968 AutoWriteLock safeLock(m->mtxProgressOperations); 1969 1970 m->mapProgressOperations.insert (ProgressMap::value_type (Guid(id), aProgress)); 1891 1971 return S_OK; 1892 1972 } … … 1900 1980 * @note Doesn't lock objects. 1901 1981 */ 1902 HRESULT VirtualBox::removeProgress 1982 HRESULT VirtualBox::removeProgress(IN_GUID aId) 1903 1983 { 1904 1984 AutoCaller autoCaller(this); … … 1908 1988 1909 1989 /* protect mProgressOperations */ 1910 AutoWriteLock safeLock (mSafeLock);1911 1912 size_t cnt = m Data.mProgressOperations.erase (aId);1990 AutoWriteLock safeLock(m->mtxProgressOperations); 1991 1992 size_t cnt = m->mapProgressOperations.erase (aId); 1913 1993 Assert (cnt == 1); 1914 1994 NOREF(cnt); … … 2162 2242 { 2163 2243 AutoCaller autoCaller(this); 2164 AssertComRCReturn 2165 2166 AssertReturn(m WatcherData.mThread!= NIL_RTTHREAD, (void) 0);2244 AssertComRCReturn(autoCaller.rc(), (void) 0); 2245 2246 AssertReturn(m->threadClientWatcher != NIL_RTTHREAD, (void) 0); 2167 2247 2168 2248 /* sent an update request */ 2169 2249 #if defined(RT_OS_WINDOWS) 2170 ::SetEvent (m WatcherData.mUpdateReq);2250 ::SetEvent (m->updateReq); 2171 2251 #elif defined(RT_OS_OS2) 2172 RTSemEventSignal (m WatcherData.mUpdateReq);2252 RTSemEventSignal (m->updateReq); 2173 2253 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 2174 RTSemEventSignal (m WatcherData.mUpdateReq);2254 RTSemEventSignal (m->updateReq); 2175 2255 #else 2176 2256 # error "Port me!" … … 2185 2265 { 2186 2266 AutoCaller autoCaller(this); 2187 AssertComRCReturn 2267 AssertComRCReturn(autoCaller.rc(), (void) 0); 2188 2268 2189 2269 /// @todo (dmik) Win32? 2190 2270 #ifndef RT_OS_WINDOWS 2191 2271 AutoWriteLock alock(this); 2192 m WatcherData.mProcesses.push_back (pid);2272 m->llProcesses.push_back (pid); 2193 2273 #endif 2194 2274 } … … 2269 2349 2270 2350 AutoCaller autoCaller(this); 2271 AssertComRCReturn 2351 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 2272 2352 2273 2353 CallbackList list; 2274 2354 { 2275 2355 AutoReadLock alock(this); 2276 list = m Data.mCallbacks;2356 list = m->llCallbacks; 2277 2357 } 2278 2358 … … 2467 2547 2468 2548 AutoCaller autoCaller(this); 2469 AssertComRCReturn 2549 AssertComRCReturn(autoCaller.rc(), type); 2470 2550 2471 2551 AutoReadLock alock(this); 2472 2552 2473 2553 /* unknown type must always be the first */ 2474 ComAssertRet (m Data.mGuestOSTypes.size() > 0, type);2475 2476 type = m Data.mGuestOSTypes.front();2554 ComAssertRet (m->llGuestOSTypes.size() > 0, type); 2555 2556 type = m->llGuestOSTypes.front(); 2477 2557 return type; 2478 2558 } … … 2494 2574 * @note Locks objects for reading. 2495 2575 */ 2496 void VirtualBox::getOpenedMachines (SessionMachineVector&aMachines,2497 InternalControlVector*aControls /*= NULL*/)2576 void VirtualBox::getOpenedMachines(SessionMachineList &aMachines, 2577 InternalControlList *aControls /*= NULL*/) 2498 2578 { 2499 2579 AutoCaller autoCaller(this); … … 2506 2586 AutoReadLock alock(this); 2507 2587 2508 for (MachineList::iterator it = m Data.mMachines.begin();2509 it != m Data.mMachines.end();2510 ++ 2588 for (MachineList::iterator it = m->llMachines.begin(); 2589 it != m->llMachines.end(); 2590 ++it) 2511 2591 { 2512 2592 ComObjPtr<SessionMachine> sm; 2513 2593 ComPtr<IInternalSessionControl> ctl; 2514 if ((*it)->isSessionOpen 2594 if ((*it)->isSessionOpen(sm, &ctl)) 2515 2595 { 2516 aMachines.push_back 2596 aMachines.push_back(sm); 2517 2597 if (aControls) 2518 aControls->push_back 2598 aControls->push_back(ctl); 2519 2599 } 2520 2600 } … … 2542 2622 { 2543 2623 AutoCaller autoCaller(this); 2544 AssertComRCReturn 2624 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 2545 2625 2546 2626 bool found = false; … … 2549 2629 AutoReadLock alock(this); 2550 2630 2551 for (MachineList::iterator it = m Data.mMachines.begin();2552 !found && it != m Data.mMachines.end();2631 for (MachineList::iterator it = m->llMachines.begin(); 2632 !found && it != m->llMachines.end(); 2553 2633 ++ it) 2554 2634 { … … 2602 2682 if (aId) 2603 2683 { 2604 HardDiskMap::const_iterator it = m Data.mHardDiskMap.find (*aId);2605 if (it != m Data.mHardDiskMap.end())2684 HardDiskMap::const_iterator it = m->mapHardDisks.find (*aId); 2685 if (it != m->mapHardDisks.end()) 2606 2686 { 2607 2687 if (aHardDisk) … … 2617 2697 Utf8Str location = aLocation; 2618 2698 2619 for (HardDiskMap::const_iterator it = m Data.mHardDiskMap.begin();2620 it != m Data.mHardDiskMap.end();2699 for (HardDiskMap::const_iterator it = m->mapHardDisks.begin(); 2700 it != m->mapHardDisks.end(); 2621 2701 ++ it) 2622 2702 { … … 2643 2723 tr("Could not find a hard disk with UUID {%RTuuid} in the media registry ('%s')"), 2644 2724 aId->raw(), 2645 m _strSettingsFilePath.raw());2725 m->strSettingsFilePath.raw()); 2646 2726 else 2647 2727 setError(rc, 2648 2728 tr("Could not find a hard disk with location '%ls' in the media registry ('%s')"), 2649 2729 aLocation, 2650 m _strSettingsFilePath.raw());2730 m->strSettingsFilePath.raw()); 2651 2731 } 2652 2732 … … 2692 2772 bool found = false; 2693 2773 2694 for (DVDImageList::const_iterator it = m Data.mDVDImages.begin();2695 it != m Data.mDVDImages.end();2774 for (DVDImageList::const_iterator it = m->llDVDImages.begin(); 2775 it != m->llDVDImages.end(); 2696 2776 ++ it) 2697 2777 { … … 2720 2800 tr("Could not find a CD/DVD image with UUID {%RTuuid} in the media registry ('%s')"), 2721 2801 aId->raw(), 2722 m _strSettingsFilePath.raw());2802 m->strSettingsFilePath.raw()); 2723 2803 else 2724 2804 setError(rc, 2725 2805 tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"), 2726 2806 aLocation, 2727 m _strSettingsFilePath.raw());2807 m->strSettingsFilePath.raw()); 2728 2808 } 2729 2809 … … 2768 2848 bool found = false; 2769 2849 2770 for (FloppyImageList::const_iterator it = m Data.mFloppyImages.begin();2771 it != m Data.mFloppyImages.end();2850 for (FloppyImageList::const_iterator it = m->llFloppyImages.begin(); 2851 it != m->llFloppyImages.end(); 2772 2852 ++ it) 2773 2853 { … … 2796 2876 tr("Could not find a floppy image with UUID {%RTuuid} in the media registry ('%s')"), 2797 2877 aId->raw(), 2798 m _strSettingsFilePath.raw());2878 m->strSettingsFilePath.raw()); 2799 2879 else 2800 2880 setError(rc, 2801 2881 tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"), 2802 2882 aLocation, 2803 m _strSettingsFilePath.raw());2883 m->strSettingsFilePath.raw()); 2804 2884 } 2805 2885 2806 2886 return rc; 2807 2887 } 2888 2889 HRESULT VirtualBox::findGuestOSType(CBSTR bstrOSType, 2890 GuestOSType*& pGuestOSType) 2891 { 2892 AutoReadLock alock(this); 2893 2894 /* Look for a GuestOSType object */ 2895 AssertMsg(m->llGuestOSTypes.size() != 0, 2896 ("Guest OS types array must be filled")); 2897 2898 if (bstrOSType == NULL) 2899 { 2900 pGuestOSType = NULL; 2901 return S_OK; 2902 } 2903 2904 for (GuestOSTypeList::const_iterator it = m->llGuestOSTypes.begin(); 2905 it != m->llGuestOSTypes.end(); 2906 ++it) 2907 { 2908 if ((*it)->id() == bstrOSType) 2909 { 2910 pGuestOSType = *it; 2911 return S_OK; 2912 } 2913 } 2914 2915 return setError(VBOX_E_OBJECT_NOT_FOUND, 2916 tr("Guest OS type '%ls' is invalid"), 2917 bstrOSType); 2918 } 2919 2920 const ComObjPtr<Host>& VirtualBox::host() const 2921 { 2922 return m->pHost; 2923 } 2924 2925 const ComObjPtr<SystemProperties>& VirtualBox::systemProperties() const 2926 { 2927 return m->pSystemProperties; 2928 } 2929 2930 #ifdef VBOX_WITH_RESOURCE_USAGE_API 2931 const ComObjPtr<PerformanceCollector>& VirtualBox::performanceCollector() const 2932 { 2933 return m->pPerformanceCollector; 2934 } 2935 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 2808 2936 2809 2937 /** … … 2814 2942 const Utf8Str& VirtualBox::getDefaultMachineFolder() const 2815 2943 { 2816 AutoReadLock propsLock(m Data.mSystemProperties);2817 return m Data.mSystemProperties->m_strDefaultMachineFolder;2944 AutoReadLock propsLock(m->pSystemProperties); 2945 return m->pSystemProperties->m_strDefaultMachineFolder; 2818 2946 } 2819 2947 … … 2825 2953 const Utf8Str& VirtualBox::getDefaultHardDiskFolder() const 2826 2954 { 2827 AutoReadLock propsLock(m Data.mSystemProperties);2828 return m Data.mSystemProperties->m_strDefaultHardDiskFolder;2955 AutoReadLock propsLock(m->pSystemProperties); 2956 return m->pSystemProperties->m_strDefaultHardDiskFolder; 2829 2957 } 2830 2958 … … 2836 2964 const Utf8Str& VirtualBox::getDefaultHardDiskFormat() const 2837 2965 { 2838 AutoReadLock propsLock(mData.mSystemProperties); 2839 return mData.mSystemProperties->m_strDefaultHardDiskFormat; 2966 AutoReadLock propsLock(m->pSystemProperties); 2967 return m->pSystemProperties->m_strDefaultHardDiskFormat; 2968 } 2969 2970 const Utf8Str& VirtualBox::homeDir() const 2971 { 2972 return m->strHomeDir; 2840 2973 } 2841 2974 … … 2854 2987 { 2855 2988 AutoCaller autoCaller(this); 2856 AssertComRCReturn 2989 AssertComRCReturn(autoCaller.rc(), VERR_GENERAL_FAILURE); 2857 2990 2858 2991 /* no need to lock since mHomeDir is const */ 2859 2992 2860 2993 char folder[RTPATH_MAX]; 2861 int vrc = RTPathAbsEx(m Data.mHomeDir.c_str(), strPath.c_str(), folder, sizeof(folder));2994 int vrc = RTPathAbsEx(m->strHomeDir.c_str(), strPath.c_str(), folder, sizeof(folder)); 2862 2995 if (RT_SUCCESS(vrc)) 2863 2996 aResult = folder; … … 2884 3017 /* no need to lock since mHomeDir is const */ 2885 3018 2886 Utf8Str settingsDir = m Data.mHomeDir;3019 Utf8Str settingsDir = m->strHomeDir; 2887 3020 2888 3021 if (RTPathStartsWith(strPath.c_str(), settingsDir.c_str())) … … 2981 3114 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 2982 3115 2983 AssertReturn(!m _strSettingsFilePath.isEmpty(), E_FAIL);3116 AssertReturn(!m->strSettingsFilePath.isEmpty(), E_FAIL); 2984 3117 2985 3118 HRESULT rc = S_OK; … … 2991 3124 { 2992 3125 // machines 2993 m _pMainConfigFile->llMachines.clear();2994 for (MachineList::iterator it = m Data.mMachines.begin();2995 it != m Data.mMachines.end();3126 m->pMainConfigFile->llMachines.clear(); 3127 for (MachineList::iterator it = m->llMachines.begin(); 3128 it != m->llMachines.end(); 2996 3129 ++it) 2997 3130 { 2998 3131 settings::MachineRegistryEntry mre; 2999 3132 rc = (*it)->saveRegistryEntry(mre); 3000 m _pMainConfigFile->llMachines.push_back(mre);3133 m->pMainConfigFile->llMachines.push_back(mre); 3001 3134 } 3002 3135 3003 3136 // hard disks 3004 m _pMainConfigFile->llHardDisks.clear();3005 for (HardDiskList::const_iterator it = m Data.mHardDisks.begin();3006 it != m Data.mHardDisks.end();3137 m->pMainConfigFile->llHardDisks.clear(); 3138 for (HardDiskList::const_iterator it = m->llHardDisks.begin(); 3139 it != m->llHardDisks.end(); 3007 3140 ++it) 3008 3141 { 3009 settings::Medium m ;3010 rc = (*it)->saveSettings(m );3011 m _pMainConfigFile->llHardDisks.push_back(m);3142 settings::Medium med; 3143 rc = (*it)->saveSettings(med); 3144 m->pMainConfigFile->llHardDisks.push_back(med); 3012 3145 CheckComRCThrowRC(rc); 3013 3146 } 3014 3147 3015 3148 /* CD/DVD images */ 3016 m _pMainConfigFile->llDvdImages.clear();3017 for (DVDImageList::const_iterator it = m Data.mDVDImages.begin();3018 it != m Data.mDVDImages.end();3149 m->pMainConfigFile->llDvdImages.clear(); 3150 for (DVDImageList::const_iterator it = m->llDVDImages.begin(); 3151 it != m->llDVDImages.end(); 3019 3152 ++it) 3020 3153 { 3021 settings::Medium m ;3022 rc = (*it)->saveSettings(m );3154 settings::Medium med; 3155 rc = (*it)->saveSettings(med); 3023 3156 CheckComRCThrowRC(rc); 3024 m _pMainConfigFile->llDvdImages.push_back(m);3157 m->pMainConfigFile->llDvdImages.push_back(med); 3025 3158 } 3026 3159 3027 3160 /* floppy images */ 3028 m _pMainConfigFile->llFloppyImages.clear();3029 for (FloppyImageList::const_iterator it = m Data.mFloppyImages.begin();3030 it != m Data.mFloppyImages.end();3161 m->pMainConfigFile->llFloppyImages.clear(); 3162 for (FloppyImageList::const_iterator it = m->llFloppyImages.begin(); 3163 it != m->llFloppyImages.end(); 3031 3164 ++it) 3032 3165 { 3033 settings::Medium m ;3034 rc = (*it)->saveSettings(m );3166 settings::Medium med; 3167 rc = (*it)->saveSettings(med); 3035 3168 CheckComRCThrowRC(rc); 3036 m _pMainConfigFile->llFloppyImages.push_back(m);3169 m->pMainConfigFile->llFloppyImages.push_back(med); 3037 3170 } 3038 3171 3039 m _pMainConfigFile->llDhcpServers.clear();3172 m->pMainConfigFile->llDhcpServers.clear(); 3040 3173 for (DHCPServerList::const_iterator it = 3041 m Data.mDHCPServers.begin();3042 it != m Data.mDHCPServers.end();3174 m->llDHCPServers.begin(); 3175 it != m->llDHCPServers.end(); 3043 3176 ++ it) 3044 3177 { … … 3046 3179 rc = (*it)->saveSettings(d); 3047 3180 CheckComRCThrowRC(rc); 3048 m _pMainConfigFile->llDhcpServers.push_back(d);3181 m->pMainConfigFile->llDhcpServers.push_back(d); 3049 3182 } 3050 3183 3051 3184 /* host data (USB filters) */ 3052 rc = m Data.mHost->saveSettings(m_pMainConfigFile->host);3185 rc = m->pHost->saveSettings(m->pMainConfigFile->host); 3053 3186 CheckComRCThrowRC(rc); 3054 3187 3055 rc = m Data.mSystemProperties->saveSettings(m_pMainConfigFile->systemProperties);3188 rc = m->pSystemProperties->saveSettings(m->pMainConfigFile->systemProperties); 3056 3189 CheckComRCThrowRC(rc); 3057 3190 3058 3191 // now write out the XML 3059 m _pMainConfigFile->write(m_strSettingsFilePath);3192 m->pMainConfigFile->write(m->strSettingsFilePath); 3060 3193 } 3061 3194 catch (HRESULT err) … … 3124 3257 3125 3258 /* add to the collection of registered machines */ 3126 m Data.mMachines.push_back(aMachine);3259 m->llMachines.push_back(aMachine); 3127 3260 3128 3261 if (autoCaller.state() != InInit) … … 3153 3286 3154 3287 AutoCaller autoCaller(this); 3155 AssertComRCReturn 3288 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3156 3289 3157 3290 AutoWriteLock alock(this); 3158 3291 3159 3292 AutoCaller hardDiskCaller (aHardDisk); 3160 AssertComRCReturn 3293 AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc()); 3161 3294 3162 3295 AutoReadLock hardDiskLock (aHardDisk); … … 3175 3308 aHardDisk->id().raw(), 3176 3309 strConflict.raw(), 3177 m _strSettingsFilePath.raw());3310 m->strSettingsFilePath.raw()); 3178 3311 } 3179 3312 … … 3181 3314 { 3182 3315 /* base (root) hard disk */ 3183 m Data.mHardDisks.push_back (aHardDisk);3184 } 3185 3186 m Data.mHardDiskMap3316 m->llHardDisks.push_back (aHardDisk); 3317 } 3318 3319 m->mapHardDisks 3187 3320 .insert (HardDiskMap::value_type ( 3188 3321 aHardDisk->id(), HardDiskMap::mapped_type (aHardDisk))); … … 3219 3352 3220 3353 AutoCaller autoCaller(this); 3221 AssertComRCReturn 3354 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3222 3355 3223 3356 AutoWriteLock alock(this); 3224 3357 3225 3358 AutoCaller hardDiskCaller (aHardDisk); 3226 AssertComRCReturn 3359 AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc()); 3227 3360 3228 3361 AutoReadLock hardDiskLock (aHardDisk); 3229 3362 3230 size_t cnt = m Data.mHardDiskMap.erase (aHardDisk->id());3363 size_t cnt = m->mapHardDisks.erase (aHardDisk->id()); 3231 3364 Assert (cnt == 1); 3232 3365 NOREF(cnt); … … 3235 3368 { 3236 3369 /* base (root) hard disk */ 3237 m Data.mHardDisks.remove (aHardDisk);3370 m->llHardDisks.remove (aHardDisk); 3238 3371 } 3239 3372 … … 3271 3404 3272 3405 AutoCaller autoCaller(this); 3273 AssertComRCReturn 3406 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3274 3407 3275 3408 AutoWriteLock alock(this); 3276 3409 3277 3410 AutoCaller imageCaller (aImage); 3278 AssertComRCReturn 3411 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3279 3412 3280 3413 AutoReadLock imageLock (aImage); … … 3293 3426 aImage->id().raw(), 3294 3427 strConflict.raw(), 3295 m _strSettingsFilePath.raw());3428 m->strSettingsFilePath.raw()); 3296 3429 } 3297 3430 3298 3431 /* add to the collection */ 3299 m Data.mDVDImages.push_back (aImage);3432 m->llDVDImages.push_back (aImage); 3300 3433 3301 3434 if (aSaveRegistry) … … 3330 3463 3331 3464 AutoCaller autoCaller(this); 3332 AssertComRCReturn 3465 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3333 3466 3334 3467 AutoWriteLock alock(this); 3335 3468 3336 3469 AutoCaller imageCaller (aImage); 3337 AssertComRCReturn 3470 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3338 3471 3339 3472 AutoReadLock imageLock (aImage); 3340 3473 3341 m Data.mDVDImages.remove (aImage);3474 m->llDVDImages.remove (aImage); 3342 3475 3343 3476 HRESULT rc = S_OK; … … 3374 3507 3375 3508 AutoCaller autoCaller(this); 3376 AssertComRCReturn 3509 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3377 3510 3378 3511 AutoWriteLock alock(this); 3379 3512 3380 3513 AutoCaller imageCaller (aImage); 3381 AssertComRCReturn 3514 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3382 3515 3383 3516 AutoReadLock imageLock (aImage); … … 3396 3529 aImage->id().raw(), 3397 3530 strConflict.raw(), 3398 m _strSettingsFilePath.raw());3531 m->strSettingsFilePath.raw()); 3399 3532 } 3400 3533 3401 3534 /* add to the collection */ 3402 m Data.mFloppyImages.push_back (aImage);3535 m->llFloppyImages.push_back (aImage); 3403 3536 3404 3537 if (aSaveRegistry) … … 3433 3566 3434 3567 AutoCaller autoCaller(this); 3435 AssertComRCReturn 3568 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3436 3569 3437 3570 AutoWriteLock alock(this); 3438 3571 3439 3572 AutoCaller imageCaller (aImage); 3440 AssertComRCReturn 3573 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3441 3574 3442 3575 AutoReadLock imageLock (aImage); 3443 3576 3444 m Data.mFloppyImages.remove (aImage);3577 m->llFloppyImages.remove (aImage); 3445 3578 3446 3579 HRESULT rc = S_OK; … … 3471 3604 3472 3605 AutoCaller autoCaller(this); 3473 AssertComRCReturn 3606 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3474 3607 3475 3608 /* We need the children map lock here to keep the getDependentChild() result … … 3508 3641 3509 3642 AutoCaller autoCaller(this); 3510 AssertComRCReturn 3643 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3511 3644 3512 3645 AutoWriteLock alock(this); 3513 3646 3514 3647 /* check DVD paths */ 3515 for (DVDImageList::iterator it = m Data.mDVDImages.begin();3516 it != m Data.mDVDImages.end();3648 for (DVDImageList::iterator it = m->llDVDImages.begin(); 3649 it != m->llDVDImages.end(); 3517 3650 ++ it) 3518 3651 { … … 3521 3654 3522 3655 /* check Floppy paths */ 3523 for (FloppyImageList::iterator it = m Data.mFloppyImages.begin();3524 it != m Data.mFloppyImages .end();3656 for (FloppyImageList::iterator it = m->llFloppyImages.begin(); 3657 it != m->llFloppyImages .end(); 3525 3658 ++ it) 3526 3659 { … … 3529 3662 3530 3663 /* check HardDisk paths */ 3531 for (HardDiskList::const_iterator it = m Data.mHardDisks.begin();3532 it != m Data.mHardDisks.end();3664 for (HardDiskList::const_iterator it = m->llHardDisks.begin(); 3665 it != m->llHardDisks.end(); 3533 3666 ++ it) 3534 3667 { … … 3624 3757 } 3625 3758 3759 const Utf8Str& VirtualBox::settingsFilePath() 3760 { 3761 return m->strSettingsFilePath; 3762 } 3763 3764 /** 3765 * Returns a lock handle used to protect changes to the hard disk hierarchy 3766 * (e.g. serialize access to the Medium::mParent fields and methods 3767 * adding/removing children). When using this lock, the following rules must 3768 * be obeyed: 3769 * 3770 * 1. The write lock on this handle must be either held alone on the thread 3771 * or requested *after* the VirtualBox object lock. Mixing with other 3772 * locks is prohibited. 3773 * 3774 * 2. The read lock on this handle may be intermixed with any other lock 3775 * with the exception that it must be requested *after* the VirtualBox 3776 * object lock. 3777 */ 3778 RWLockHandle& VirtualBox::hardDiskTreeLockHandle() 3779 { 3780 return m->mtxHardDiskTree; 3781 } 3782 3783 /** 3784 * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a 3785 * dedicated lock instead of the main object lock. The dedicated lock for 3786 * child map operations frees callers of init() methods of these children 3787 * from acquiring a write parent (VirtualBox) lock (which would be mandatory 3788 * otherwise). Since VirtualBox has a lot of heterogenous children which 3789 * init() methods are called here and there, it definitely makes sense. 3790 */ 3791 RWLockHandle* VirtualBox::childrenLock() 3792 { 3793 return &m->mtxChildrenMap; 3794 } 3795 3626 3796 /** 3627 3797 * Thread function that watches the termination of all client processes … … 3629 3799 */ 3630 3800 // static 3631 DECLCALLBACK(int) VirtualBox::ClientWatcher 3801 DECLCALLBACK(int) VirtualBox::ClientWatcher(RTTHREAD /* thread */, void *pvUser) 3632 3802 { 3633 3803 LogFlowFuncEnter(); … … 3644 3814 #if defined(RT_OS_WINDOWS) 3645 3815 3646 HRESULT hrc = CoInitializeEx 3647 3648 3816 HRESULT hrc = CoInitializeEx(NULL, 3817 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE | 3818 COINIT_SPEED_OVER_MEMORY); 3649 3819 AssertComRC (hrc); 3650 3820 3651 3821 /// @todo (dmik) processes reaping! 3652 3822 3653 HANDLE handles 3654 handles [0] = that->mWatcherData.mUpdateReq;3823 HANDLE handles[MAXIMUM_WAIT_OBJECTS]; 3824 handles[0] = that->m->updateReq; 3655 3825 3656 3826 do … … 3666 3836 autoCaller.release(); 3667 3837 3668 DWORD rc = ::WaitForMultipleObjects ((DWORD)(1 + cnt + cntSpawned), 3669 handles, FALSE, INFINITE); 3838 DWORD rc = ::WaitForMultipleObjects((DWORD)(1 + cnt + cntSpawned), 3839 handles, 3840 FALSE, 3841 INFINITE); 3670 3842 3671 3843 /* Restore the caller before using VirtualBox. If it fails, this … … 3714 3886 machines.clear(); 3715 3887 3716 for (MachineList::iterator it = that->m Data.mMachines.begin();3717 it != that->m Data.mMachines.end(); ++ it)3888 for (MachineList::iterator it = that->m->llMachines.begin(); 3889 it != that->m->llMachines.end(); ++ it) 3718 3890 { 3719 3891 /// @todo handle situations with more than 64 objects … … 3737 3909 spawnedMachines.clear(); 3738 3910 3739 for (MachineList::iterator it = that->m Data.mMachines.begin();3740 it != that->m Data.mMachines.end(); ++ it)3911 for (MachineList::iterator it = that->m->llMachines.begin(); 3912 it != that->m->llMachines.end(); ++ it) 3741 3913 { 3742 3914 /// @todo handle situations with more than 64 objects … … 3797 3969 autoCaller.release(); 3798 3970 3799 int vrc = RTSemEventWait (that->m WatcherData.mUpdateReq, 500);3971 int vrc = RTSemEventWait (that->m->updateReq, 500); 3800 3972 3801 3973 /* Restore the caller before using VirtualBox. If it fails, this … … 3905 4077 machines.clear(); 3906 4078 3907 for (MachineList::iterator it = that->m Data.mMachines.begin();3908 it != that->m Data.mMachines.end(); ++ it)4079 for (MachineList::iterator it = that->m->llMachines.begin(); 4080 it != that->m->llMachines.end(); ++ it) 3909 4081 { 3910 4082 /// @todo handle situations with more than 64 objects … … 3943 4115 spawnedMachines.clear(); 3944 4116 3945 for (MachineList::iterator it = that->m Data.mMachines.begin();3946 it != that->m Data.mMachines.end(); ++ it)4117 for (MachineList::iterator it = that->m->llMachines.begin(); 4118 it != that->m->llMachines.end(); ++ it) 3947 4119 { 3948 4120 if ((*it)->isSessionSpawning()) … … 3983 4155 autoCaller.release(); 3984 4156 3985 int rc = RTSemEventWait (that->mWatcherData.mUpdateReq, 500);4157 int rc = RTSemEventWait(that->m->updateReq, 500); 3986 4158 3987 4159 /* … … 4004 4176 machines.clear(); 4005 4177 4006 for (MachineList::iterator it = that->m Data.mMachines.begin();4007 it != that->m Data.mMachines.end(); ++ it)4178 for (MachineList::iterator it = that->m->llMachines.begin(); 4179 it != that->m->llMachines.end(); ++ it) 4008 4180 { 4009 4181 ComObjPtr<SessionMachine> sm; … … 4021 4193 spawnedMachines.clear(); 4022 4194 4023 for (MachineList::iterator it = that->m Data.mMachines.begin();4024 it != that->m Data.mMachines.end(); ++ it)4195 for (MachineList::iterator it = that->m->llMachines.begin(); 4196 it != that->m->llMachines.end(); ++ it) 4025 4197 { 4026 4198 if ((*it)->isSessionSpawning()) … … 4044 4216 { 4045 4217 AutoWriteLock alock(that); 4046 if (that->m WatcherData.mProcesses.size())4218 if (that->m->llProcesses.size()) 4047 4219 { 4048 4220 LogFlowFunc (("UPDATE: child process count = %d\n", 4049 that->mWatcherData.mProcesses.size())); 4050 ClientWatcherData::ProcessList::iterator it = 4051 that->mWatcherData.mProcesses.begin(); 4052 while (it != that->mWatcherData.mProcesses.end()) 4221 that->m->llProcesses.size())); 4222 VirtualBox::Data::ProcessList::iterator it = that->m->llProcesses.begin(); 4223 while (it != that->m->llProcesses.end()) 4053 4224 { 4054 4225 RTPROCESS pid = *it; 4055 4226 RTPROCSTATUS status; 4056 int vrc = ::RTProcWait (pid, RTPROCWAIT_FLAGS_NOBLOCK, 4057 &status); 4227 int vrc = ::RTProcWait(pid, RTPROCWAIT_FLAGS_NOBLOCK, &status); 4058 4228 if (vrc == VINF_SUCCESS) 4059 4229 { … … 4062 4232 pid, pid, status.iStatus, 4063 4233 status.enmReason)); 4064 it = that->m WatcherData.mProcesses.erase(it);4234 it = that->m->llProcesses.erase(it); 4065 4235 } 4066 4236 else … … 4071 4241 { 4072 4242 /* remove the process if it is not already running */ 4073 it = that->m WatcherData.mProcesses.erase(it);4243 it = that->m->llProcesses.erase(it); 4074 4244 } 4075 4245 else … … 4160 4330 /* Make a copy to release the lock before iterating */ 4161 4331 AutoReadLock alock(mVirtualBox); 4162 callbacks = mVirtualBox->m Data.mCallbacks;4332 callbacks = mVirtualBox->m->llCallbacks; 4163 4333 /* We don't need mVirtualBox any more, so release it */ 4164 4334 mVirtualBox.setNull(); … … 4219 4389 4220 4390 for (DHCPServerList::const_iterator it = 4221 m Data.mDHCPServers.begin();4222 it != m Data.mDHCPServers.end();4391 m->llDHCPServers.begin(); 4392 it != m->llDHCPServers.end(); 4223 4393 ++ it) 4224 4394 { … … 4272 4442 4273 4443 AutoCaller autoCaller(this); 4274 AssertComRCReturn 4444 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 4275 4445 4276 4446 AutoWriteLock alock(this); 4277 4447 4278 4448 AutoCaller dhcpServerCaller (aDHCPServer); 4279 AssertComRCReturn 4449 AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc()); 4280 4450 4281 4451 AutoReadLock dhcpServerLock (aDHCPServer); … … 4294 4464 rc = S_OK; 4295 4465 4296 m Data.mDHCPServers.push_back (aDHCPServer);4466 m->llDHCPServers.push_back (aDHCPServer); 4297 4467 4298 4468 if (aSaveRegistry) … … 4327 4497 4328 4498 AutoCaller autoCaller(this); 4329 AssertComRCReturn 4499 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 4330 4500 4331 4501 AutoWriteLock alock(this); 4332 4502 4333 4503 AutoCaller dhcpServerCaller (aDHCPServer); 4334 AssertComRCReturn 4504 AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc()); 4335 4505 4336 4506 AutoReadLock dhcpServerLock (aDHCPServer); 4337 4507 4338 m Data.mDHCPServers.remove (aDHCPServer);4508 m->llDHCPServers.remove (aDHCPServer); 4339 4509 4340 4510 HRESULT rc = S_OK; -
trunk/src/VBox/Main/include/VirtualBoxBase.h
r23279 r23327 24 24 25 25 #include <iprt/cdefs.h> 26 #include <iprt/critsect.h>27 #include <iprt/thread.h>28 26 29 27 #include <list> -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r23319 r23327 27 27 #include "VirtualBoxBase.h" 28 28 29 #include <vector>30 31 29 #ifdef RT_OS_WINDOWS 32 30 # include "win/resource.h" 33 31 #endif 34 35 #ifdef VBOX_WITH_RESOURCE_USAGE_API36 #include "PerformanceImpl.h"37 #endif /* VBOX_WITH_RESOURCE_USAGE_API */38 32 39 33 namespace com … … 52 46 class SystemProperties; 53 47 class DHCPServer; 48 class PerformanceCollector; 54 49 55 50 #ifdef RT_OS_WINDOWS … … 77 72 78 73 typedef std::list< ComPtr<IVirtualBoxCallback> > CallbackList; 79 typedef std:: vector< ComObjPtr<SessionMachine> > SessionMachineVector;80 typedef std:: vector< ComPtr<IInternalSessionControl> > InternalControlVector;74 typedef std::list< ComObjPtr<SessionMachine> > SessionMachineList; 75 typedef std::list< ComPtr<IInternalSessionControl> > InternalControlList; 81 76 82 77 class CallbackEvent; … … 179 174 BSTR *aChanged, BSTR *aValues); 180 175 181 // STDMETHOD(CreateDHCPServerForInterface) (/*IHostNetworkInterface * aIinterface, */IDHCPServer ** aServer);182 176 STDMETHOD(CreateDHCPServer) (IN_BSTR aName, IDHCPServer ** aServer); 183 // STDMETHOD(FindDHCPServerForInterface) (IHostNetworkInterface * aIinterface, IDHCPServer ** aServer);184 177 STDMETHOD(FindDHCPServerByNetworkName) (IN_BSTR aName, IDHCPServer ** aServer); 185 178 STDMETHOD(RemoveDHCPServer) (IDHCPServer * aServer); … … 187 180 /* public methods only for internal purposes */ 188 181 189 HRESULT postEvent 190 191 HRESULT addProgress 192 HRESULT removeProgress 182 HRESULT postEvent(Event *event); 183 184 HRESULT addProgress(IProgress *aProgress); 185 HRESULT removeProgress(IN_GUID aId); 193 186 194 187 #ifdef RT_OS_WINDOWS 195 188 typedef DECLCALLBACKPTR (HRESULT, SVCHelperClientFunc) 196 189 (SVCHlpClient *aClient, Progress *aProgress, void *aUser, int *aVrc); 197 HRESULT startSVCHelperClient 198 199 190 HRESULT startSVCHelperClient(bool aPrivileged, 191 SVCHelperClientFunc aFunc, 192 void *aUser, Progress *aProgress); 200 193 #endif 201 194 … … 219 212 ComObjPtr<GuestOSType> getUnknownOSType(); 220 213 221 void getOpenedMachines (SessionMachineVector &aMachines, 222 InternalControlVector *aControls = NULL); 223 224 /** Shortcut to #getOpenedMachines (aMachines, &aControls). */ 225 void getOpenedMachinesAndControls (SessionMachineVector &aMachines, 226 InternalControlVector &aControls) 227 { getOpenedMachines (aMachines, &aControls); } 228 229 bool isMachineIdValid (const Guid &aId) 214 void getOpenedMachines(SessionMachineList &aMachines, 215 InternalControlList *aControls = NULL); 216 217 bool isMachineIdValid(const Guid &aId) 230 218 { 231 return SUCCEEDED (findMachine(aId, false /* aSetError */, NULL));219 return SUCCEEDED(findMachine(aId, false /* aSetError */, NULL)); 232 220 } 233 221 … … 242 230 bool aSetError, ComObjPtr<Medium> *aImage = NULL); 243 231 244 const ComObjPtr<Host> &host() { return mData.mHost; } 245 const ComObjPtr<SystemProperties> &systemProperties() 246 { return mData.mSystemProperties; } 232 HRESULT findGuestOSType(CBSTR bstrOSType, 233 GuestOSType*& pGuestOSType); 234 235 const ComObjPtr<Host>& host() const; 236 const ComObjPtr<SystemProperties>& systemProperties() const; 247 237 #ifdef VBOX_WITH_RESOURCE_USAGE_API 248 const ComObjPtr<PerformanceCollector> &performanceCollector() 249 { return mData.mPerformanceCollector; } 238 const ComObjPtr<PerformanceCollector>& performanceCollector() const; 250 239 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 251 240 … … 255 244 256 245 /** Returns the VirtualBox home directory */ 257 const Utf8Str &homeDir() { return mData.mHomeDir; }246 const Utf8Str& homeDir() const; 258 247 259 248 int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult); … … 278 267 static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL); 279 268 280 const Utf8Str& settingsFilePath() 281 { 282 return m_strSettingsFilePath; 283 } 284 285 /** 286 * Returns a lock handle used to protect changes to the hard disk hierarchy 287 * (e.g. serialize access to the Medium::mParent fields and methods 288 * adding/removing children). When using this lock, the following rules must 289 * be obeyed: 290 * 291 * 1. The write lock on this handle must be either held alone on the thread 292 * or requested *after* the VirtualBox object lock. Mixing with other 293 * locks is prohibited. 294 * 295 * 2. The read lock on this handle may be intermixed with any other lock 296 * with the exception that it must be requested *after* the VirtualBox 297 * object lock. 298 */ 299 RWLockHandle *hardDiskTreeLockHandle() { return &mHardDiskTreeLockHandle; } 269 const Utf8Str& settingsFilePath(); 270 271 RWLockHandle& hardDiskTreeLockHandle(); 272 RWLockHandle* childrenLock(); 300 273 301 274 /* for VirtualBoxSupportErrorInfoImpl */ … … 304 277 private: 305 278 306 typedef std::list< ComObjPtr<Machine> > MachineList; 307 typedef std::list< ComObjPtr<GuestOSType> > GuestOSTypeList; 308 309 typedef std::map<Guid, ComPtr<IProgress> > ProgressMap; 310 311 typedef std::list <ComObjPtr<Medium> > HardDiskList; 312 typedef std::list <ComObjPtr<Medium> > DVDImageList; 313 typedef std::list <ComObjPtr<Medium> > FloppyImageList; 314 typedef std::list <ComObjPtr<SharedFolder> > SharedFolderList; 315 typedef std::list <ComObjPtr<DHCPServer> > DHCPServerList; 316 317 typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap; 318 319 /** 320 * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a 321 * dedicated lock instead of the main object lock. The dedicated lock for 322 * child map operations frees callers of init() methods of these children 323 * from acquiring a write parent (VirtualBox) lock (which would be mandatory 324 * otherwise). Since VirtualBox has a lot of heterogenous children which 325 * init() methods are called here and there, it definitely makes sense. 326 */ 327 RWLockHandle *childrenLock() { return &mChildrenMapLockHandle; } 328 329 HRESULT checkMediaForConflicts2 (const Guid &aId, const Bstr &aLocation, 330 Utf8Str &aConflictType); 279 HRESULT checkMediaForConflicts2(const Guid &aId, const Bstr &aLocation, 280 Utf8Str &aConflictType); 331 281 332 282 HRESULT registerMachine (Machine *aMachine); … … 337 287 bool aSaveRegistry = true); 338 288 339 // VirtualBox main settings file 340 const Utf8Str m_strSettingsFilePath; 341 settings::MainConfigFile *m_pMainConfigFile; 342 343 /** 344 * Main VirtualBox data structure. 345 * @note |const| members are persistent during lifetime so can be accessed 346 * without locking. 347 */ 348 struct Data 349 { 350 Data(); 351 352 // const data members not requiring locking 353 const Utf8Str mHomeDir; 354 355 // const objects not requiring locking 356 const ComObjPtr<Host> mHost; 357 const ComObjPtr<SystemProperties> mSystemProperties; 358 #ifdef VBOX_WITH_RESOURCE_USAGE_API 359 const ComObjPtr<PerformanceCollector> mPerformanceCollector; 360 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 361 362 MachineList mMachines; 363 GuestOSTypeList mGuestOSTypes; 364 365 ProgressMap mProgressOperations; 366 367 HardDiskList mHardDisks; 368 DVDImageList mDVDImages; 369 FloppyImageList mFloppyImages; 370 SharedFolderList mSharedFolders; 371 DHCPServerList mDHCPServers; 372 373 /// @todo NEWMEDIA do we really need this map? Used only in 374 /// find() it seems 375 HardDiskMap mHardDiskMap; 376 377 CallbackList mCallbacks; 378 }; 379 380 Data mData; 381 382 #if defined(RT_OS_WINDOWS) 383 #define UPDATEREQARG NULL 384 #define UPDATEREQTYPE HANDLE 385 #elif defined(RT_OS_OS2) 386 #define UPDATEREQARG NIL_RTSEMEVENT 387 #define UPDATEREQTYPE RTSEMEVENT 388 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER) 389 #define UPDATEREQARG 390 #define UPDATEREQTYPE RTSEMEVENT 391 #else 392 # error "Port me!" 393 #endif 394 395 /** Client watcher thread data structure */ 396 struct ClientWatcherData 397 { 398 ClientWatcherData() 399 : mUpdateReq(UPDATEREQARG), 400 mThread(NIL_RTTHREAD) 401 {} 402 403 // const objects not requiring locking 404 const UPDATEREQTYPE mUpdateReq; 405 const RTTHREAD mThread; 406 407 typedef std::list <RTPROCESS> ProcessList; 408 ProcessList mProcesses; 409 }; 410 411 ClientWatcherData mWatcherData; 412 413 const RTTHREAD mAsyncEventThread; 414 EventQueue * const mAsyncEventQ; 415 416 /** 417 * "Safe" lock. May only be used if guaranteed that no other locks are 418 * requested while holding it and no functions that may do so are called. 419 * Currently, protects the following: 420 * 421 * - mProgressOperations 422 */ 423 RWLockHandle mSafeLock; 424 425 RWLockHandle mHardDiskTreeLockHandle; 426 RWLockHandle mChildrenMapLockHandle; 289 struct Data; // opaque data structure, defined in VirtualBoxImpl.cpp 290 Data *m; 427 291 428 292 /* static variables (defined in VirtualBoxImpl.cpp) */
Note:
See TracChangeset
for help on using the changeset viewer.