- Timestamp:
- Dec 4, 2009 10:50:15 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/DHCPServerImpl.cpp
r25170 r25182 52 52 return; 53 53 54 // /* we uninit children and reset mParent 55 // * and VirtualBox::removeDependentChild() needs a write lock */ 56 // AutoMultiWriteLock2 alock (mVirtualBox->lockHandle(), this->treeLock()); 57 58 mVirtualBox->removeDependentChild (this); 59 54 60 unconst(mVirtualBox).setNull(); 55 61 } … … 72 78 m.upperIP = "0.0.0.0"; 73 79 80 /* register with VirtualBox early, since uninit() will 81 * unconditionally unregister on failure */ 82 aVirtualBox->addDependentChild (this); 83 74 84 /* Confirm a successful initialization */ 75 85 autoInitSpan.setSucceeded(); … … 87 97 /* share VirtualBox weakly (parent remains NULL so far) */ 88 98 unconst(mVirtualBox) = aVirtualBox; 99 100 aVirtualBox->addDependentChild (this); 89 101 90 102 unconst(mName) = data.strNetworkName; -
trunk/src/VBox/Main/MachineImpl.cpp
r25179 r25182 395 395 unconst(mParent) = aParent; 396 396 397 /* register with parent early, since uninit() will unconditionally 398 * unregister on failure */ 399 mParent->addDependentChild (this); 400 397 401 /* allocate the essential machine data structure (the rest will be 398 402 * allocated later by initDataAndChildObjects() */ … … 687 691 /* free the essential data structure last */ 688 692 mData.free(); 693 694 mParent->removeDependentChild (this); 689 695 690 696 LogFlowThisFuncLeave(); … … 5458 5464 for (ULONG slot = 0; slot < RT_ELEMENTS (mNetworkAdapters); slot ++) 5459 5465 { 5460 if (mNetworkAdapters [slot])5461 { 5462 mNetworkAdapters [slot]->uninit();5463 unconst(mNetworkAdapters [slot]).setNull();5466 if (mNetworkAdapters [slot]) 5467 { 5468 mNetworkAdapters [slot]->uninit(); 5469 unconst(mNetworkAdapters [slot]).setNull(); 5464 5470 } 5465 5471 } … … 5479 5485 for (ULONG slot = 0; slot < RT_ELEMENTS (mParallelPorts); slot ++) 5480 5486 { 5481 if (mParallelPorts [slot])5482 { 5483 mParallelPorts [slot]->uninit();5484 unconst(mParallelPorts [slot]).setNull();5487 if (mParallelPorts [slot]) 5488 { 5489 mParallelPorts [slot]->uninit(); 5490 unconst(mParallelPorts [slot]).setNull(); 5485 5491 } 5486 5492 } … … 5488 5494 for (ULONG slot = 0; slot < RT_ELEMENTS (mSerialPorts); slot ++) 5489 5495 { 5490 if (mSerialPorts [slot])5491 { 5492 mSerialPorts [slot]->uninit();5493 unconst(mSerialPorts [slot]).setNull();5496 if (mSerialPorts [slot]) 5497 { 5498 mSerialPorts [slot]->uninit(); 5499 unconst(mSerialPorts [slot]).setNull(); 5494 5500 } 5495 5501 } … … 9018 9024 ComAssertRet (!control.isNull(), E_INVALIDARG); 9019 9025 9020 /* Creating a Progress object requires the VirtualBox lock, and9026 /* Creating a Progress object requires the VirtualBox children lock, and 9021 9027 * thus locking it here is required by the lock order rules. */ 9022 AutoMultiWriteLock2 alock(mParent-> lockHandle(), this->lockHandle());9023 9024 if (control.equalsTo (mData->mSession.mDirectControl))9028 AutoMultiWriteLock2 alock(mParent->childrenLock(), this->lockHandle()); 9029 9030 if (control.equalsTo (mData->mSession.mDirectControl)) 9025 9031 { 9026 9032 ComAssertRet (aProgress, E_POINTER); -
trunk/src/VBox/Main/MediumImpl.cpp
r25170 r25182 896 896 unconst(m->pVirtualBox) = aVirtualBox; 897 897 898 /* register with VirtualBox early, since uninit() will 899 * unconditionally unregister on failure */ 900 aVirtualBox->addDependentChild(this); 901 898 902 /* no storage yet */ 899 903 m->state = MediumState_NotCreated; … … 991 995 unconst(m->pVirtualBox) = aVirtualBox; 992 996 997 /* register with VirtualBox early, since uninit() will 998 * unconditionally unregister on failure */ 999 aVirtualBox->addDependentChild(this); 1000 993 1001 /* there must be a storage unit */ 994 1002 m->state = MediumState_Created; … … 1074 1082 /* register with VirtualBox/parent early, since uninit() will 1075 1083 * unconditionally unregister on failure */ 1076 if (aParent) 1084 if (aParent == NULL) 1085 // base disk: add to global list 1086 aVirtualBox->addDependentChild(this); 1087 else 1077 1088 { 1078 1089 // differencing image: add to parent … … 1215 1226 /* share VirtualBox weakly (parent remains NULL so far) */ 1216 1227 unconst(m->pVirtualBox) = aVirtualBox; 1228 aVirtualBox->addDependentChild(this); 1217 1229 1218 1230 /* fake up a UUID which is unique, but also reproducible */ … … 1302 1314 deparent(); 1303 1315 } 1316 else 1317 // base image: remove it from the global list 1318 m->pVirtualBox->removeDependentChild(this); 1304 1319 } 1305 1320 … … 2318 2333 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2319 2334 2320 ComObjPtr<Medium> diff = static_cast<Medium*>(aTarget); 2335 ComObjPtr<Medium> diff; 2336 HRESULT rc = m->pVirtualBox->cast(aTarget, diff); 2337 if (FAILED(rc)) return rc; 2321 2338 2322 2339 AutoWriteLock alock(this); … … 2329 2346 /* We want to be locked for reading as long as our diff child is being 2330 2347 * created */ 2331 HRESULTrc = LockRead(NULL);2348 rc = LockRead(NULL); 2332 2349 if (FAILED(rc)) return rc; 2333 2350 … … 2369 2386 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2370 2387 2371 ComObjPtr<Medium> target = static_cast<Medium*>(aTarget); 2372 ComObjPtr<Medium> parent; 2388 ComObjPtr <Medium> target; 2389 HRESULT rc = m->pVirtualBox->cast(aTarget, target); 2390 if (FAILED(rc)) return rc; 2391 ComObjPtr <Medium> parent; 2373 2392 if (aParent) 2374 parent = static_cast<Medium*>(aParent); 2393 { 2394 rc = m->pVirtualBox->cast(aParent, parent); 2395 if (FAILED(rc)) return rc; 2396 } 2375 2397 2376 2398 AutoMultiWriteLock3 alock(this, target, parent); 2377 2399 2378 ComObjPtr<Progress> progress; 2379 HRESULT rc = S_OK; 2400 ComObjPtr <Progress> progress; 2380 2401 2381 2402 try … … 3855 3876 } 3856 3877 3878 /* deassociate from VirtualBox, associate with parent */ 3879 3880 m->pVirtualBox->removeDependentChild(this); 3881 3857 3882 /* we set mParent & children() */ 3858 3883 AutoWriteLock treeLock(m->pVirtualBox->hardDiskTreeLockHandle()); … … 4678 4703 4679 4704 if (m->pParent) 4705 { 4706 /* deassociate from the parent, associate with VirtualBox */ 4707 m->pVirtualBox->addDependentChild(this); 4680 4708 deparent(); 4709 } 4681 4710 4682 4711 HRESULT rc = E_FAIL; … … 4684 4713 { 4685 4714 case DeviceType_DVD: 4686 rc = m->pVirtualBox->unregister Image(this, DeviceType_DVD);4715 rc = m->pVirtualBox->unregisterDVDImage(this); 4687 4716 break; 4688 4717 case DeviceType_Floppy: 4689 rc = m->pVirtualBox->unregister Image(this, DeviceType_Floppy);4718 rc = m->pVirtualBox->unregisterFloppyImage(this); 4690 4719 break; 4691 4720 case DeviceType_HardDisk: … … 4704 4733 m->pParent = pParentBackup; 4705 4734 m->pParent->m->llChildren.push_back(this); 4735 m->pVirtualBox->removeDependentChild(this); 4706 4736 } 4707 4737 } … … 5109 5139 Assert(target->m->pParent.isNull()); 5110 5140 5111 /* associate the child with the parent */ 5141 /* associate the child with the parent and deassociate from 5142 * VirtualBox */ 5112 5143 target->m->pParent = that; 5113 5144 that->m->llChildren.push_back(target); 5145 target->m->pVirtualBox->removeDependentChild(target); 5114 5146 5115 5147 /** @todo r=klaus neither target nor that->base() are locked, … … 5126 5158 5127 5159 if (FAILED(rc)) 5160 { 5128 5161 /* break the parent association on failure to register */ 5162 target->m->pVirtualBox->addDependentChild(target); 5129 5163 that->deparent(); 5164 } 5130 5165 } 5131 5166 … … 5337 5372 source->deparent(); 5338 5373 } 5374 else 5375 { 5376 target->m->pVirtualBox->addDependentChild(target); 5377 target->m->pVirtualBox->removeDependentChild(source); 5378 } 5339 5379 5340 5380 /* then, register again */ … … 5610 5650 target->m->pParent = parent; 5611 5651 parent->m->llChildren.push_back(target); 5652 target->m->pVirtualBox->removeDependentChild(target); 5612 5653 5613 5654 /* register with mVirtualBox as the last step and move to … … 5617 5658 5618 5659 if (FAILED(rc)) 5660 { 5619 5661 /* break parent association on failure to register */ 5662 target->m->pVirtualBox->addDependentChild(target); 5620 5663 target->deparent(); // removes target from parent 5664 } 5621 5665 } 5622 5666 else -
trunk/src/VBox/Main/PerformanceImpl.cpp
r25149 r25182 528 528 if (!SUCCEEDED(autoCaller.rc())) return; 529 529 530 Log(("PerformanceCollector::suspendSampling\n")); 530 531 int rc = RTTimerLRStop(m.sampler); 531 532 AssertRC(rc); … … 537 538 if (!SUCCEEDED(autoCaller.rc())) return; 538 539 540 Log(("PerformanceCollector::resumeSampling\n")); 539 541 int rc = RTTimerLRStart(m.sampler, 0); 540 542 AssertRC(rc); … … 554 556 if (collector->mMagic == MAGIC) 555 557 { 558 Log(("staticSamplerCallback %RX64\n", RTTimeNanoTS())); 556 559 collector->samplerCallback(); 557 560 } -
trunk/src/VBox/Main/ProgressImpl.cpp
r25170 r25182 121 121 /* share parent weakly */ 122 122 unconst(mParent) = aParent; 123 124 /* register with parent early, since uninit() will unconditionally 125 * unregister on failure */ 126 mParent->addDependentChild (this); 123 127 #endif 124 128 … … 190 194 if (aAutoUninitSpan.initFailed() && !mId.isEmpty()) 191 195 mParent->removeProgress (mId); 196 197 mParent->removeDependentChild (this); 192 198 193 199 unconst(mParent).setNull(); -
trunk/src/VBox/Main/SharedFolderImpl.cpp
r25170 r25182 161 161 unconst(mVirtualBox) = aVirtualBox; 162 162 163 HRESULT rc = protectedInit (aVirtualBox, aName, aHostPath, aWritable);163 HRESULT rc = protectedInit (aVirtualBox, aName, aHostPath, aWritable); 164 164 165 165 /* Confirm a successful initialization when it's the case */ … … 176 176 * Must be called from under the object's lock! 177 177 */ 178 HRESULT SharedFolder::protectedInit(VirtualBoxBase *aParent, 179 CBSTR aName, 180 CBSTR aHostPath, 181 BOOL aWritable) 178 HRESULT SharedFolder::protectedInit (VirtualBoxBaseWithChildrenNEXT *aParent, 179 CBSTR aName, CBSTR aHostPath, BOOL aWritable) 182 180 { 183 181 LogFlowThisFunc(("aName={%ls}, aHostPath={%ls}, aWritable={%d}\n", … … 223 221 unconst(mParent) = aParent; 224 222 223 /* register with parent */ 224 mParent->addDependentChild (this); 225 225 226 unconst(m.name) = aName; 226 227 unconst(m.hostPath) = hostPath; … … 242 243 if (autoUninitSpan.uninitDone()) 243 244 return; 245 246 if (mParent) 247 mParent->removeDependentChild (this); 244 248 245 249 unconst(mParent) = NULL; -
trunk/src/VBox/Main/VirtualBoxBase.cpp
r25170 r25182 38 38 #include "Logging.h" 39 39 40 #include "objectslist.h" 41 42 //////////////////////////////////////////////////////////////////////////////// 43 // 44 // VirtualBoxBaseProto 45 // 40 // VirtualBoxBaseProto methods 46 41 //////////////////////////////////////////////////////////////////////////////// 47 42 … … 291 286 } 292 287 293 ////////////////////////////////////////////////////////////////////////////////294 //295 288 // VirtualBoxBaseProto::AutoInitSpan methods 296 //297 289 //////////////////////////////////////////////////////////////////////////////// 298 290 … … 645 637 } 646 638 647 //////////////////////////////////////////////////////////////////////////////// 648 // 649 // VirtualBoxBase 650 // 639 // VirtualBoxBase methods 651 640 //////////////////////////////////////////////////////////////////////////////// 652 641 … … 686 675 } 687 676 688 //////////////////////////////////////////////////////////////////////////////// 689 // 690 // VirtualBoxSupportTranslationBase 691 // 677 // VirtualBoxSupportTranslationBase methods 692 678 //////////////////////////////////////////////////////////////////////////////// 693 679 … … 752 738 } 753 739 754 //////////////////////////////////////////////////////////////////////////////// 755 // 756 // VirtualBoxSupportErrorInfoImplBase 757 // 740 // VirtualBoxSupportErrorInfoImplBase methods 758 741 //////////////////////////////////////////////////////////////////////////////// 759 742 … … 929 912 } 930 913 914 // VirtualBoxBaseWithChildrenNEXT methods 915 //////////////////////////////////////////////////////////////////////////////// 931 916 932 917 /** -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r25170 r25182 70 70 71 71 #include "Logging.h" 72 #include "objectslist.h"73 72 74 73 #ifdef RT_OS_WINDOWS … … 83 82 84 83 #define VBOX_GLOBAL_SETTINGS_FILE "VirtualBox.xml" 84 85 typedef std::vector< ComObjPtr<Machine> > MachineVector; 86 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<SharedFolder> > SharedFolderList; 94 typedef std::list <ComObjPtr<DHCPServer> > DHCPServerList; 95 96 typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap; 97 85 98 86 99 //////////////////////////////////////////////////////////////////////////////// … … 156 169 #endif 157 170 158 typedef ObjectsList<Machine> MachinesOList;159 typedef ObjectsList<Medium> MediaOList;160 typedef ObjectsList<GuestOSType> GuestOSTypesOList;161 typedef ObjectsList<SharedFolder> SharedFoldersOList;162 typedef ObjectsList<DHCPServer> DHCPServersOList;163 164 typedef std::map<Guid, ComPtr<IProgress> > ProgressMap;165 typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap;166 167 171 /** 168 172 * Main VirtualBox data structure. … … 194 198 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 195 199 196 // the following lists all have an RWLockHandle as a member and are locked 197 // individually; getting the VirtualBox object lock is NOT necessary, but 198 // see the remarks which ObjectsList method lock themselves and which require 199 // external locking 200 MachinesOList ollMachines; 201 GuestOSTypesOList ollGuestOSTypes; 202 203 MediaOList ollHardDisks, // only base hard disks; the RWLockHandle in here is also used 204 // for hardDiskTreeLockHandle() 205 ollDVDImages, 206 ollFloppyImages; 207 SharedFoldersOList ollSharedFolders; 208 DHCPServersOList ollDHCPServers; 209 210 // the hard disks map is an additional map sorted by UUID for quick lookup 211 // and contains ALL hard disks (base and differencing); 212 // the map must also be protected by ollHardDisks.getLockHandle()! 200 MachineList llMachines; 201 GuestOSTypeList llGuestOSTypes; 202 203 ProgressMap mapProgressOperations; 204 205 MediaList llHardDisks, 206 llDVDImages, 207 llFloppyImages; 208 SharedFolderList llSharedFolders; 209 DHCPServerList llDHCPServers; 210 211 /// @todo NEWMEDIA do we really need this map? Used only in 212 /// find() it seems 213 213 HardDiskMap mapHardDisks; 214 214 215 ProgressMap mapProgressOperations;216 215 CallbackList llCallbacks; 217 216 218 217 RWLockHandle mtxProgressOperations; 219 218 // protects mutex operations; "leaf" lock, no other lock may be requested after this 219 RWLockHandle mtxHardDiskTree; 220 // protects the hard disk tree; this is implemented here, but only requested through 221 // Medium::treeLock, which returns exactly this 222 RWLockHandle mtxChildrenMap; 223 // used for VirtualBoxWithChildrenNEXT management 220 224 221 225 // the following are data for the client watcher thread … … 369 373 Global::sOSTypes [i].numSerialEnabled); 370 374 if (SUCCEEDED(rc)) 371 m-> ollGuestOSTypes.addChild(guestOSTypeObj);375 m->llGuestOSTypes.push_back (guestOSTypeObj); 372 376 } 373 377 ComAssertComRCThrowRC (rc); … … 529 533 if (FAILED(rc)) return rc; 530 534 531 rc = register Image(pImage, DeviceType_DVD, false /* aSaveRegistry */);535 rc = registerDVDImage(pImage, false /* aSaveRegistry */); 532 536 if (FAILED(rc)) return rc; 533 537 } … … 544 548 if (FAILED(rc)) return rc; 545 549 546 rc = register Image(pImage, DeviceType_Floppy, false /* aSaveRegistry */);550 rc = registerFloppyImage(pImage, false /* aSaveRegistry */); 547 551 if (FAILED(rc)) return rc; 548 552 } … … 564 568 /* tell all our child objects we've been uninitialized */ 565 569 566 LogFlowThisFunc(("Uninitializing machines (%d)...\n", m->ollMachines.size())); 567 m->ollMachines.uninitAll(); 568 m->ollFloppyImages.uninitAll(); 569 m->ollDVDImages.uninitAll(); 570 m->ollHardDisks.uninitAll(); 571 m->ollDHCPServers.uninitAll(); 570 LogFlowThisFunc(("Uninitializing machines (%d)...\n", m->llMachines.size())); 571 if (m->llMachines.size()) 572 { 573 MachineList::iterator it = m->llMachines.begin(); 574 while (it != m->llMachines.end()) 575 (*it++)->uninit(); 576 m->llMachines.clear(); 577 } 578 579 /* Uninit all other children still referenced by clients (unregistered 580 * machines, hard disks, DVD/floppy images, server-side progress 581 * operations). */ 582 uninitDependentChildren(); 583 584 m->mapHardDisks.clear(); 585 586 m->llFloppyImages.clear(); 587 m->llDVDImages.clear(); 588 m->llHardDisks.clear(); 589 m->llDHCPServers.clear(); 572 590 573 591 m->mapProgressOperations.clear(); 574 592 575 m-> ollGuestOSTypes.uninitAll();593 m->llGuestOSTypes.clear(); 576 594 577 595 /* Note that we release singleton children after we've all other children. … … 770 788 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 771 789 772 AutoReadLock al(m->ollMachines.getLockHandle()); 773 SafeIfaceArray<IMachine> machines(m->ollMachines.getList()); 790 AutoReadLock alock(this); 791 792 SafeIfaceArray<IMachine> machines(m->llMachines); 774 793 machines.detachTo(ComSafeArrayOutArg(aMachines)); 775 794 … … 785 804 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 786 805 787 AutoReadLock al(m->ollHardDisks.getLockHandle()); 788 SafeIfaceArray<IMedium> hardDisks(m->ollHardDisks.getList()); 806 AutoReadLock alock(this); 807 808 SafeIfaceArray<IMedium> hardDisks(m->llHardDisks); 789 809 hardDisks.detachTo(ComSafeArrayOutArg(aHardDisks)); 790 810 … … 792 812 } 793 813 794 STDMETHODIMP VirtualBox::COMGETTER(DVDImages) (ComSafeArrayOut(IMedium *, aDVDImages)) 814 STDMETHODIMP 815 VirtualBox::COMGETTER(DVDImages) (ComSafeArrayOut(IMedium *, aDVDImages)) 795 816 { 796 817 if (ComSafeArrayOutIsNull(aDVDImages)) … … 800 821 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 801 822 802 AutoReadLock al(m->ollDVDImages.getLockHandle()); 803 SafeIfaceArray<IMedium> images(m->ollDVDImages.getList()); 823 AutoReadLock alock(this); 824 825 SafeIfaceArray<IMedium> images(m->llDVDImages); 804 826 images.detachTo(ComSafeArrayOutArg(aDVDImages)); 805 827 … … 807 829 } 808 830 809 STDMETHODIMP VirtualBox::COMGETTER(FloppyImages) (ComSafeArrayOut(IMedium *, aFloppyImages)) 831 STDMETHODIMP 832 VirtualBox::COMGETTER(FloppyImages) (ComSafeArrayOut(IMedium *, aFloppyImages)) 810 833 { 811 834 if (ComSafeArrayOutIsNull(aFloppyImages)) … … 815 838 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 816 839 817 AutoReadLock al(m->ollFloppyImages.getLockHandle()); 818 SafeIfaceArray<IMedium> images(m->ollFloppyImages.getList()); 840 AutoReadLock alock(this); 841 842 SafeIfaceArray<IMedium> images(m->llFloppyImages); 819 843 images.detachTo(ComSafeArrayOutArg(aFloppyImages)); 820 844 … … 831 855 /* protect mProgressOperations */ 832 856 AutoReadLock safeLock(m->mtxProgressOperations); 857 833 858 SafeIfaceArray<IProgress> progress(m->mapProgressOperations); 834 859 progress.detachTo(ComSafeArrayOutArg(aOperations)); … … 844 869 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 845 870 846 AutoReadLock al(m->ollGuestOSTypes.getLockHandle()); 847 SafeIfaceArray<IGuestOSType> ostypes(m->ollGuestOSTypes.getList()); 871 AutoReadLock alock(this); 872 873 SafeIfaceArray<IGuestOSType> ostypes(m->llGuestOSTypes); 848 874 ostypes.detachTo(ComSafeArrayOutArg(aGuestOSTypes)); 849 875 … … 851 877 } 852 878 853 STDMETHODIMP VirtualBox::COMGETTER(SharedFolders) (ComSafeArrayOut(ISharedFolder *, aSharedFolders)) 879 STDMETHODIMP 880 VirtualBox::COMGETTER(SharedFolders) (ComSafeArrayOut(ISharedFolder *, aSharedFolders)) 854 881 { 855 882 #ifndef RT_OS_WINDOWS … … 892 919 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 893 920 894 AutoReadLock al(m->ollDHCPServers.getLockHandle()); 895 SafeIfaceArray<IDHCPServer> svrs (m->ollDHCPServers.getList()); 921 AutoReadLock alock(this); 922 923 SafeIfaceArray<IDHCPServer> svrs (m->llDHCPServers); 896 924 svrs.detachTo(ComSafeArrayOutArg(aDHCPServers)); 897 925 … … 1149 1177 1150 1178 /** @note Locks objects! */ 1151 STDMETHODIMP VirtualBox::RegisterMachine (IMachine *aMachine)1179 STDMETHODIMP VirtualBox::RegisterMachine (IMachine *aMachine) 1152 1180 { 1153 1181 CheckComArgNotNull(aMachine); … … 1162 1190 if (FAILED(rc)) return rc; 1163 1191 1192 /* We need the children map lock here to keep the getDependentChild() result 1193 * valid until we finish */ 1194 AutoReadLock chLock (childrenLock()); 1195 1164 1196 /* We can safely cast child to Machine * here because only Machine 1165 1197 * implementations of IMachine can be among our children. */ 1166 Machine *pMachine = static_cast<Machine*>(aMachine); 1167 1168 AutoCaller machCaller(pMachine); 1169 ComAssertComRCRetRC(machCaller.rc()); 1170 1171 rc = registerMachine(pMachine); 1198 Machine *machine = static_cast <Machine *> (getDependentChild (aMachine)); 1199 if (machine == NULL) 1200 { 1201 /* this machine was not created by CreateMachine() or opened by 1202 * OpenMachine() or loaded during startup */ 1203 return setError (VBOX_E_INVALID_OBJECT_STATE, 1204 tr ("The machine named '%ls' is not created within this " 1205 "VirtualBox instance"), name.raw()); 1206 } 1207 1208 AutoCaller machCaller (machine); 1209 ComAssertComRCRetRC (machCaller.rc()); 1210 1211 rc = registerMachine (machine); 1212 1172 1213 /* fire an event */ 1173 1214 if (SUCCEEDED(rc)) 1174 onMachineRegistered( pMachine->getId(), TRUE);1215 onMachineRegistered(machine->getId(), TRUE); 1175 1216 1176 1217 return rc; … … 1178 1219 1179 1220 /** @note Locks objects! */ 1180 STDMETHODIMP VirtualBox::GetMachine (IN_BSTR aId, IMachine **aMachine)1221 STDMETHODIMP VirtualBox::GetMachine (IN_BSTR aId, IMachine **aMachine) 1181 1222 { 1182 1223 CheckComArgOutSafeArrayPointerValid(aMachine); … … 1195 1236 1196 1237 /** @note Locks this object for reading, then some machine objects for reading. */ 1197 STDMETHODIMP VirtualBox::FindMachine (IN_BSTR aName, IMachine **aMachine)1238 STDMETHODIMP VirtualBox::FindMachine (IN_BSTR aName, IMachine **aMachine) 1198 1239 { 1199 1240 LogFlowThisFuncEnter(); … … 1207 1248 1208 1249 /* start with not found */ 1209 ComObjPtr<Machine> pMachineFound; 1210 1211 AutoReadLock al(m->ollMachines.getLockHandle()); 1212 for (MachinesOList::iterator it = m->ollMachines.begin(); 1213 it != m->ollMachines.end(); 1214 ++it) 1250 ComObjPtr<Machine> machine; 1251 MachineList machines; 1252 { 1253 /* take a copy for safe iteration outside the lock */ 1254 AutoReadLock alock(this); 1255 machines = m->llMachines; 1256 } 1257 1258 for (MachineList::iterator it = machines.begin(); 1259 !machine && it != machines.end(); 1260 ++ it) 1215 1261 { 1216 1262 ComObjPtr<Machine> &pMachine2 = *it; … … 1223 1269 AutoReadLock machLock(pMachine2); 1224 1270 if (pMachine2->getName() == aName) 1225 { 1226 pMachineFound = pMachine2; 1227 break; 1228 } 1271 machine = pMachine2; 1229 1272 } 1230 1273 } 1231 1274 1232 1275 /* this will set (*machine) to NULL if machineObj is null */ 1233 pMachineFound.queryInterfaceTo(aMachine);1234 1235 HRESULT rc = pMachineFound1276 machine.queryInterfaceTo(aMachine); 1277 1278 HRESULT rc = machine 1236 1279 ? S_OK 1237 : setError (VBOX_E_OBJECT_NOT_FOUND,1238 tr("Could not find a registered machine named '%ls'"), aName);1280 : setError (VBOX_E_OBJECT_NOT_FOUND, 1281 tr ("Could not find a registered machine named '%ls'"), aName); 1239 1282 1240 1283 LogFlowThisFunc(("aName=\"%ls\", aMachine=%p, rc=%08X\n", aName, *aMachine, rc)); … … 1245 1288 1246 1289 /** @note Locks objects! */ 1247 STDMETHODIMP VirtualBox::UnregisterMachine (IN_BSTR aId,1248 IMachine **aMachine)1290 STDMETHODIMP VirtualBox::UnregisterMachine (IN_BSTR aId, 1291 IMachine **aMachine) 1249 1292 { 1250 1293 Guid id(aId); … … 1255 1298 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1256 1299 1257 // find machine from the given ID 1258 ComObjPtr<Machine> pMachine; 1259 HRESULT rc = findMachine(id, true /* setError */, &pMachine); 1300 AutoWriteLock alock(this); 1301 1302 ComObjPtr<Machine> machine; 1303 1304 HRESULT rc = findMachine (id, true /* setError */, &machine); 1260 1305 if (FAILED(rc)) return rc; 1261 1306 1262 rc = pMachine->trySetRegistered(FALSE);1307 rc = machine->trySetRegistered (FALSE); 1263 1308 if (FAILED(rc)) return rc; 1264 1309 1265 1310 /* remove from the collection of registered machines */ 1266 m-> ollMachines.removeChild(pMachine);1311 m->llMachines.remove (machine); 1267 1312 1268 1313 /* save the global registry */ 1269 AutoWriteLock alock(this);1270 1314 rc = saveSettings(); 1271 1315 1272 1316 /* return the unregistered machine to the caller */ 1273 pMachine.queryInterfaceTo(aMachine);1317 machine.queryInterfaceTo(aMachine); 1274 1318 1275 1319 /* fire an event */ 1276 onMachineRegistered (id, FALSE);1320 onMachineRegistered (id, FALSE); 1277 1321 1278 1322 return rc; … … 1417 1461 if (SUCCEEDED(rc)) 1418 1462 { 1419 rc = register Image(image, DeviceType_DVD);1463 rc = registerDVDImage (image); 1420 1464 1421 1465 if (SUCCEEDED(rc)) … … 1484 1528 if (SUCCEEDED(rc)) 1485 1529 { 1486 rc = register Image(image, DeviceType_Floppy);1530 rc = registerFloppyImage (image); 1487 1531 1488 1532 if (SUCCEEDED(rc)) … … 1572 1616 *aType = NULL; 1573 1617 1574 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle()); 1575 for (GuestOSTypesOList::iterator it = m->ollGuestOSTypes.begin(); 1576 it != m->ollGuestOSTypes.end(); 1577 ++it) 1618 AutoReadLock alock(this); 1619 1620 for (GuestOSTypeList::iterator it = m->llGuestOSTypes.begin(); 1621 it != m->llGuestOSTypes.end(); 1622 ++ it) 1578 1623 { 1579 1624 const Bstr &typeId = (*it)->id(); … … 1592 1637 } 1593 1638 1594 STDMETHODIMP VirtualBox::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL /* aWritable */) 1639 STDMETHODIMP 1640 VirtualBox::CreateSharedFolder (IN_BSTR aName, IN_BSTR aHostPath, BOOL /* aWritable */) 1595 1641 { 1596 1642 CheckComArgNotNull(aName); … … 1603 1649 } 1604 1650 1605 STDMETHODIMP VirtualBox::RemoveSharedFolder (IN_BSTR aName)1651 STDMETHODIMP VirtualBox::RemoveSharedFolder (IN_BSTR aName) 1606 1652 { 1607 1653 CheckComArgNotNull(aName); … … 1960 2006 void VirtualBox::dumpAllBackRefs() 1961 2007 { 1962 { 1963 AutoReadLock al(m->ollHardDisks.getLockHandle()); 1964 for (MediaList::const_iterator mt = m->ollHardDisks.begin(); 1965 mt != m->ollHardDisks.end(); 1966 ++mt) 1967 { 1968 ComObjPtr<Medium> pMedium = *mt; 1969 pMedium->dumpBackRefs(); 1970 } 1971 } 1972 { 1973 AutoReadLock al(m->ollDVDImages.getLockHandle()); 1974 for (MediaList::const_iterator mt = m->ollDVDImages.begin(); 1975 mt != m->ollDVDImages.end(); 1976 ++mt) 1977 { 1978 ComObjPtr<Medium> pMedium = *mt; 1979 pMedium->dumpBackRefs(); 1980 } 2008 for (MediaList::const_iterator mt = m->llHardDisks.begin(); 2009 mt != m->llHardDisks.end(); 2010 ++mt) 2011 { 2012 ComObjPtr<Medium> pMedium = *mt; 2013 pMedium->dumpBackRefs(); 2014 } 2015 for (MediaList::const_iterator mt = m->llDVDImages.begin(); 2016 mt != m->llDVDImages.end(); 2017 ++mt) 2018 { 2019 ComObjPtr<Medium> pMedium = *mt; 2020 pMedium->dumpBackRefs(); 1981 2021 } 1982 2022 } … … 2622 2662 { 2623 2663 ComObjPtr<GuestOSType> type; 2664 2624 2665 AutoCaller autoCaller(this); 2625 2666 AssertComRCReturn(autoCaller.rc(), type); 2626 2667 2668 AutoReadLock alock(this); 2669 2627 2670 /* unknown type must always be the first */ 2628 ComAssertRet(m->ollGuestOSTypes.size() > 0, type); 2629 2630 return m->ollGuestOSTypes.front(); 2671 ComAssertRet (m->llGuestOSTypes.size() > 0, type); 2672 2673 type = m->llGuestOSTypes.front(); 2674 return type; 2631 2675 } 2632 2676 … … 2659 2703 AutoReadLock alock(this); 2660 2704 2661 for (Machine sOList::iterator it = m->ollMachines.begin();2662 it != m-> ollMachines.end();2705 for (MachineList::iterator it = m->llMachines.begin(); 2706 it != m->llMachines.end(); 2663 2707 ++it) 2664 2708 { … … 2695 2739 ComObjPtr<Machine> *aMachine /* = NULL */) 2696 2740 { 2697 HRESULT rc = VBOX_E_OBJECT_NOT_FOUND;2698 2699 2741 AutoCaller autoCaller(this); 2700 2742 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 2701 2743 2702 { 2703 AutoReadLock al(m->ollMachines.getLockHandle()); 2704 2705 for (MachinesOList::iterator it = m->ollMachines.begin(); 2706 it != m->ollMachines.end(); 2707 ++it) 2744 bool found = false; 2745 2746 { 2747 AutoReadLock alock(this); 2748 2749 for (MachineList::iterator it = m->llMachines.begin(); 2750 !found && it != m->llMachines.end(); 2751 ++ it) 2708 2752 { 2709 2753 ComObjPtr<Machine> pMachine2 = *it; … … 2712 2756 AssertComRC(machCaller.rc()); 2713 2757 2714 if (pMachine2->getId() == aId)2715 {2716 rc = S_OK;2717 if (aMachine)2718 *aMachine = pMachine2;2719 break; 2720 }2721 } 2722 }2723 2724 if (aSetError && FAILED(rc))2725 setError(VBOX_E_OBJECT_NOT_FOUND,2726 tr("Could not find a registered machine with UUID {%RTuuid}"),2727 aId.raw());2758 found = pMachine2->getId() == aId; 2759 if (found && aMachine) 2760 *aMachine = pMachine2; 2761 } 2762 } 2763 2764 HRESULT rc = found ? S_OK : VBOX_E_OBJECT_NOT_FOUND; 2765 2766 if (aSetError && !found) 2767 { 2768 setError (VBOX_E_OBJECT_NOT_FOUND, 2769 tr ("Could not find a registered machine with UUID {%RTuuid}"), 2770 aId.raw()); 2771 } 2728 2772 2729 2773 return rc; … … 2752 2796 AssertReturn(aId || aLocation, E_INVALIDARG); 2753 2797 2754 // we use the hard disks map, but it is protected by the 2755 // hard disk _list_ lock handle 2756 AutoReadLock alock(m->ollHardDisks.getLockHandle()); 2798 AutoReadLock alock(this); 2757 2799 2758 2800 /* first, look up by UUID in the map if UUID is provided */ 2759 2801 if (aId) 2760 2802 { 2761 HardDiskMap::const_iterator it = m->mapHardDisks.find (*aId);2803 HardDiskMap::const_iterator it = m->mapHardDisks.find (*aId); 2762 2804 if (it != m->mapHardDisks.end()) 2763 2805 { … … 2845 2887 } 2846 2888 2847 AutoReadLock alock( m->ollDVDImages.getLockHandle());2889 AutoReadLock alock(this); 2848 2890 2849 2891 bool found = false; 2850 2892 2851 for (MediaList::const_iterator it = m-> ollDVDImages.begin();2852 it != m-> ollDVDImages.end();2893 for (MediaList::const_iterator it = m->llDVDImages.begin(); 2894 it != m->llDVDImages.end(); 2853 2895 ++ it) 2854 2896 { … … 2921 2963 } 2922 2964 2923 AutoReadLock alock( m->ollFloppyImages.getLockHandle());2965 AutoReadLock alock(this); 2924 2966 2925 2967 bool found = false; 2926 2968 2927 for (MediaList::const_iterator it = m-> ollFloppyImages.begin();2928 it != m-> ollFloppyImages.end();2969 for (MediaList::const_iterator it = m->llFloppyImages.begin(); 2970 it != m->llFloppyImages.end(); 2929 2971 ++ it) 2930 2972 { … … 2967 3009 GuestOSType*& pGuestOSType) 2968 3010 { 3011 AutoReadLock alock(this); 3012 2969 3013 /* Look for a GuestOSType object */ 2970 AssertMsg(m-> ollGuestOSTypes.size() != 0,3014 AssertMsg(m->llGuestOSTypes.size() != 0, 2971 3015 ("Guest OS types array must be filled")); 2972 3016 … … 2977 3021 } 2978 3022 2979 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle()); 2980 for (GuestOSTypesOList::const_iterator it = m->ollGuestOSTypes.begin(); 2981 it != m->ollGuestOSTypes.end(); 3023 for (GuestOSTypeList::const_iterator it = m->llGuestOSTypes.begin(); 3024 it != m->llGuestOSTypes.end(); 2982 3025 ++it) 2983 3026 { … … 3123 3166 * @note Locks this object and media objects for reading. 3124 3167 */ 3125 HRESULT VirtualBox::checkMediaForConflicts2 (const Guid &aId,3126 const Utf8Str &aLocation,3127 Utf8Str &aConflict)3168 HRESULT VirtualBox::checkMediaForConflicts2 (const Guid &aId, 3169 const Utf8Str &aLocation, 3170 Utf8Str &aConflict) 3128 3171 { 3129 3172 aConflict.setNull(); … … 3196 3239 HRESULT rc = S_OK; 3197 3240 3241 /* serialize file access (prevents concurrent reads and writes) */ 3242 AutoWriteLock alock(this); 3243 3198 3244 try 3199 3245 { 3200 3246 // machines 3201 settings::MachinesRegistry machinesTemp; 3202 { 3203 AutoReadLock al(m->ollMachines.getLockHandle()); 3204 for (MachinesOList::iterator it = m->ollMachines.begin(); 3205 it != m->ollMachines.end(); 3206 ++it) 3207 { 3208 settings::MachineRegistryEntry mre; 3209 rc = (*it)->saveRegistryEntry(mre); 3210 machinesTemp.push_back(mre); 3211 } 3247 m->pMainConfigFile->llMachines.clear(); 3248 for (MachineList::iterator it = m->llMachines.begin(); 3249 it != m->llMachines.end(); 3250 ++it) 3251 { 3252 settings::MachineRegistryEntry mre; 3253 rc = (*it)->saveRegistryEntry(mre); 3254 m->pMainConfigFile->llMachines.push_back(mre); 3212 3255 } 3213 3256 3214 3257 // hard disks 3215 settings::MediaList hardDisksTemp; 3216 { 3217 AutoReadLock al(m->ollHardDisks.getLockHandle()); 3218 for (MediaList::const_iterator it = m->ollHardDisks.begin(); 3219 it != m->ollHardDisks.end(); 3220 ++it) 3221 { 3222 settings::Medium med; 3223 rc = (*it)->saveSettings(med); 3224 if (FAILED(rc)) throw rc; 3225 hardDisksTemp.push_back(med); 3226 } 3258 m->pMainConfigFile->llHardDisks.clear(); 3259 for (MediaList::const_iterator it = m->llHardDisks.begin(); 3260 it != m->llHardDisks.end(); 3261 ++it) 3262 { 3263 settings::Medium med; 3264 rc = (*it)->saveSettings(med); 3265 m->pMainConfigFile->llHardDisks.push_back(med); 3266 if (FAILED(rc)) throw rc; 3227 3267 } 3228 3268 3229 3269 /* CD/DVD images */ 3230 settings::MediaList dvdsTemp; 3231 { 3232 AutoReadLock al(m->ollDVDImages.getLockHandle()); 3233 for (MediaList::const_iterator it = m->ollDVDImages.begin(); 3234 it != m->ollDVDImages.end(); 3235 ++it) 3236 { 3237 settings::Medium med; 3238 rc = (*it)->saveSettings(med); 3239 if (FAILED(rc)) throw rc; 3240 dvdsTemp.push_back(med); 3241 } 3270 m->pMainConfigFile->llDvdImages.clear(); 3271 for (MediaList::const_iterator it = m->llDVDImages.begin(); 3272 it != m->llDVDImages.end(); 3273 ++it) 3274 { 3275 settings::Medium med; 3276 rc = (*it)->saveSettings(med); 3277 if (FAILED(rc)) throw rc; 3278 m->pMainConfigFile->llDvdImages.push_back(med); 3242 3279 } 3243 3280 3244 3281 /* floppy images */ 3245 settings::MediaList floppiesTemp; 3246 { 3247 AutoReadLock al(m->ollFloppyImages.getLockHandle()); 3248 for (MediaList::const_iterator it = m->ollFloppyImages.begin(); 3249 it != m->ollFloppyImages.end(); 3250 ++it) 3251 { 3252 settings::Medium med; 3253 rc = (*it)->saveSettings(med); 3254 if (FAILED(rc)) throw rc; 3255 floppiesTemp.push_back(med); 3256 } 3257 } 3258 3259 settings::DHCPServersList dhcpServersTemp; 3260 { 3261 AutoReadLock al(m->ollDHCPServers.getLockHandle()); 3262 for (DHCPServersOList::const_iterator it = m->ollDHCPServers.begin(); 3263 it != m->ollDHCPServers.end(); 3264 ++it) 3265 { 3266 settings::DHCPServer d; 3267 rc = (*it)->saveSettings(d); 3268 if (FAILED(rc)) throw rc; 3269 dhcpServersTemp.push_back(d); 3270 } 3271 } 3272 3273 /* finally, lock VirtualBox object for writing */ 3274 AutoWriteLock alock(this); 3275 3276 /* now copy the temp data to the config file under the VirtualBox lock */ 3277 m->pMainConfigFile->llMachines = machinesTemp; 3278 m->pMainConfigFile->llHardDisks = hardDisksTemp; 3279 m->pMainConfigFile->llDvdImages = dvdsTemp; 3280 m->pMainConfigFile->llFloppyImages = floppiesTemp; 3281 m->pMainConfigFile->llDhcpServers = dhcpServersTemp; 3282 3283 // leave extra data alone, it's still in the config file 3282 m->pMainConfigFile->llFloppyImages.clear(); 3283 for (MediaList::const_iterator it = m->llFloppyImages.begin(); 3284 it != m->llFloppyImages.end(); 3285 ++it) 3286 { 3287 settings::Medium med; 3288 rc = (*it)->saveSettings(med); 3289 if (FAILED(rc)) throw rc; 3290 m->pMainConfigFile->llFloppyImages.push_back(med); 3291 } 3292 3293 m->pMainConfigFile->llDhcpServers.clear(); 3294 for (DHCPServerList::const_iterator it = 3295 m->llDHCPServers.begin(); 3296 it != m->llDHCPServers.end(); 3297 ++ it) 3298 { 3299 settings::DHCPServer d; 3300 rc = (*it)->saveSettings(d); 3301 if (FAILED(rc)) throw rc; 3302 m->pMainConfigFile->llDhcpServers.push_back(d); 3303 } 3284 3304 3285 3305 /* host data (USB filters) */ … … 3290 3310 if (FAILED(rc)) throw rc; 3291 3311 3292 // and write out the XML, still under the lock3312 // now write out the XML 3293 3313 m->pMainConfigFile->write(m->strSettingsFilePath); 3294 3314 } … … 3328 3348 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 3329 3349 3350 AutoWriteLock alock(this); 3351 3330 3352 HRESULT rc = S_OK; 3331 3353 … … 3357 3379 3358 3380 /* add to the collection of registered machines */ 3359 m-> ollMachines.addChild(aMachine);3381 m->llMachines.push_back(aMachine); 3360 3382 3361 3383 if (autoCaller.state() != InInit) … … 3388 3410 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3389 3411 3390 AutoCaller hardDiskCaller(aHardDisk); 3412 AutoWriteLock alock(this); 3413 3414 AutoCaller hardDiskCaller (aHardDisk); 3391 3415 AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc()); 3392 3416 3393 Guid id; 3394 Utf8Str strLocationFull; 3395 ComObjPtr<Medium> pParent; 3396 { 3397 AutoReadLock hardDiskLock(aHardDisk); 3398 id = aHardDisk->getId(); 3399 strLocationFull = aHardDisk->getLocationFull(); 3400 pParent = aHardDisk->getParent(); 3401 } 3402 3403 HRESULT rc; 3404 { 3405 // lock the hard disk lists (list + map) while checking for conflicts 3406 AutoWriteLock al(m->ollHardDisks.getLockHandle()); 3407 3408 Utf8Str strConflict; 3409 rc = checkMediaForConflicts2(id, 3410 strLocationFull, 3411 strConflict); 3412 if (FAILED(rc)) return rc; 3413 if (strConflict.length()) 3414 return setError(E_INVALIDARG, 3415 tr("Cannot register the hard disk '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"), 3416 strLocationFull.raw(), 3417 id.raw(), 3418 strConflict.raw(), 3419 m->strSettingsFilePath.raw()); 3420 3421 // store base (root) hard disks in the list 3422 if (pParent.isNull()) 3423 m->ollHardDisks.getList().push_back(aHardDisk); 3424 // access the list directly because we already locked the list above 3425 3426 // store all hard disks (even differencing images) in the map 3427 m->mapHardDisks[id] = aHardDisk; 3428 } 3417 AutoReadLock hardDiskLock (aHardDisk); 3418 3419 Utf8Str strConflict; 3420 HRESULT rc = checkMediaForConflicts2(aHardDisk->getId(), 3421 aHardDisk->getLocationFull(), 3422 strConflict); 3423 if (FAILED(rc)) return rc; 3424 3425 if (strConflict.length()) 3426 { 3427 return setError(E_INVALIDARG, 3428 tr("Cannot register the hard disk '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"), 3429 aHardDisk->getLocationFull().raw(), 3430 aHardDisk->getId().raw(), 3431 strConflict.raw(), 3432 m->strSettingsFilePath.raw()); 3433 } 3434 3435 if (aHardDisk->getParent().isNull()) 3436 { 3437 /* base (root) hard disk */ 3438 m->llHardDisks.push_back (aHardDisk); 3439 } 3440 3441 m->mapHardDisks.insert(HardDiskMap::value_type(aHardDisk->getId(), 3442 HardDiskMap::mapped_type(aHardDisk))); 3429 3443 3430 3444 if (aSaveRegistry) 3431 3445 { 3432 3446 rc = saveSettings(); 3433 if (FAILED (rc))3447 if (FAILED (rc)) 3434 3448 unregisterHardDisk(aHardDisk, false /* aSaveRegistry */); 3435 3449 } … … 3461 3475 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3462 3476 3477 AutoWriteLock alock(this); 3478 3463 3479 AutoCaller hardDiskCaller (aHardDisk); 3464 3480 AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc()); 3465 3481 3466 Guid id; 3467 ComObjPtr<Medium> pParent; 3468 { 3469 AutoReadLock hardDiskLock(aHardDisk); 3470 id = aHardDisk->getId(); 3471 pParent = aHardDisk->getParent(); 3472 } 3473 3474 { 3475 // lock the hard disk lists (list + map) 3476 AutoWriteLock al(m->ollHardDisks.getLockHandle()); 3477 3478 // remove base (root) hard disks from the list 3479 if (pParent.isNull()) 3480 m->ollHardDisks.getList().remove(aHardDisk); 3481 // access the list directly because we already locked the list above 3482 3483 // remove all hard disks (even differencing images) from map 3484 size_t cnt = m->mapHardDisks.erase(id); 3485 Assert(cnt == 1); 3486 NOREF(cnt); 3482 AutoReadLock hardDiskLock (aHardDisk); 3483 3484 size_t cnt = m->mapHardDisks.erase(aHardDisk->getId()); 3485 Assert(cnt == 1); 3486 NOREF(cnt); 3487 3488 if (aHardDisk->getParent().isNull()) 3489 { 3490 /* base (root) hard disk */ 3491 m->llHardDisks.remove(aHardDisk); 3487 3492 } 3488 3493 … … 3492 3497 { 3493 3498 rc = saveSettings(); 3494 if (FAILED (rc))3499 if (FAILED (rc)) 3495 3500 registerHardDisk(aHardDisk, false /* aSaveRegistry */); 3496 3501 } … … 3500 3505 3501 3506 /** 3502 * Remembers the given image by storing it in the CD/DVD or floppy image registry. 3503 * 3504 * @param argImage Image object to remember. 3505 * @param argType Either DeviceType_DVD or DeviceType_Floppy. 3507 * Remembers the given image by storing it in the CD/DVD image registry. 3508 * 3509 * @param aImage Image object to remember. 3506 3510 * @param aSaveRegistry @c true to save the image registry to disk (default). 3507 3511 * … … 3515 3519 * @note Locks this object for writing and @a aImage for reading. 3516 3520 */ 3517 HRESULT VirtualBox::registerImage(Medium *argImage, 3518 DeviceType_T argType, 3519 bool argSaveRegistry /*= true*/) 3520 { 3521 AssertReturn(argImage != NULL, E_INVALIDARG); 3521 HRESULT VirtualBox::registerDVDImage (Medium *aImage, 3522 bool aSaveRegistry /*= true*/) 3523 { 3524 AssertReturn(aImage != NULL, E_INVALIDARG); 3522 3525 3523 3526 AutoCaller autoCaller(this); 3524 3527 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3525 3528 3526 AutoCaller imageCaller(argImage); 3529 AutoWriteLock alock(this); 3530 3531 AutoCaller imageCaller (aImage); 3527 3532 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3528 3533 3529 Guid id; 3530 Utf8Str strLocationFull; 3531 ComObjPtr<Medium> pParent; 3532 { 3533 AutoReadLock al(argImage); 3534 id = argImage->getId(); 3535 strLocationFull = argImage->getLocationFull(); 3536 pParent = argImage->getParent(); 3537 } 3538 3539 // work on DVDs or floppies list? 3540 ObjectsList<Medium> &oll = (argType == DeviceType_DVD) ? m->ollDVDImages : m->ollFloppyImages; 3541 3542 HRESULT rc; 3543 { 3544 // lock the images lists (list + map) while checking for conflicts 3545 AutoWriteLock al(oll.getLockHandle()); 3546 3547 Utf8Str strConflict; 3548 rc = checkMediaForConflicts2(id, 3549 strLocationFull, 3550 strConflict); 3551 if (FAILED(rc)) return rc; 3552 3553 if (strConflict.length()) 3554 return setError(VBOX_E_INVALID_OBJECT_STATE, 3555 tr("Cannot register the image '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"), 3556 strLocationFull.raw(), 3557 id.raw(), 3558 strConflict.raw(), 3559 m->strSettingsFilePath.raw()); 3560 3561 // add to the collection 3562 oll.getList().push_back(argImage); 3563 // access the list directly because we already locked the list above 3564 } 3565 3566 if (argSaveRegistry) 3534 AutoReadLock imageLock (aImage); 3535 3536 Utf8Str strConflict; 3537 HRESULT rc = checkMediaForConflicts2(aImage->getId(), 3538 aImage->getLocationFull(), 3539 strConflict); 3540 if (FAILED(rc)) return rc; 3541 3542 if (strConflict.length()) 3543 { 3544 return setError(VBOX_E_INVALID_OBJECT_STATE, 3545 tr("Cannot register the CD/DVD image '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"), 3546 aImage->getLocationFull().raw(), 3547 aImage->getId().raw(), 3548 strConflict.raw(), 3549 m->strSettingsFilePath.raw()); 3550 } 3551 3552 /* add to the collection */ 3553 m->llDVDImages.push_back (aImage); 3554 3555 if (aSaveRegistry) 3567 3556 { 3568 3557 rc = saveSettings(); 3569 if (FAILED (rc))3570 unregister Image(argImage, argType, false /* aSaveRegistry */);3558 if (FAILED (rc)) 3559 unregisterDVDImage (aImage, false /* aSaveRegistry */); 3571 3560 } 3572 3561 … … 3575 3564 3576 3565 /** 3577 * Removes the given image from the CD/DVD or floppy image registry. 3578 * 3579 * @param argImage Image object to remove. 3580 * @param argType Either DeviceType_DVD or DeviceType_Floppy. 3581 * @param argSaveRegistry @c true to save hard disk registry to disk (default). 3566 * Removes the given image from the CD/DVD image registry registry. 3567 * 3568 * @param aImage Image object to remove. 3569 * @param aSaveRegistry @c true to save hard disk registry to disk (default). 3582 3570 * 3583 3571 * When @a aSaveRegistry is @c true, this operation may fail because of the … … 3590 3578 * @note Locks this object for writing and @a aImage for reading. 3591 3579 */ 3592 HRESULT VirtualBox::unregisterImage(Medium *argImage, 3593 DeviceType_T argType, 3594 bool argSaveRegistry /*= true*/) 3595 { 3596 AssertReturn(argImage != NULL, E_INVALIDARG); 3580 HRESULT VirtualBox::unregisterDVDImage (Medium *aImage, 3581 bool aSaveRegistry /*= true*/) 3582 { 3583 AssertReturn(aImage != NULL, E_INVALIDARG); 3597 3584 3598 3585 AutoCaller autoCaller(this); 3599 3586 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3600 3587 3601 AutoCaller imageCaller(argImage); 3588 AutoWriteLock alock(this); 3589 3590 AutoCaller imageCaller (aImage); 3602 3591 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3603 3592 3604 Guid id; 3605 ComObjPtr<Medium> pParent; 3606 { 3607 AutoReadLock al(argImage); 3608 id = argImage->getId(); 3609 pParent = argImage->getParent(); 3610 } 3611 3612 // work on DVDs or floppies list? 3613 ObjectsList<Medium> &oll = (argType == DeviceType_DVD) ? m->ollDVDImages : m->ollFloppyImages; 3614 3615 oll.removeChild(argImage); 3593 AutoReadLock imageLock (aImage); 3594 3595 m->llDVDImages.remove (aImage); 3616 3596 3617 3597 HRESULT rc = S_OK; 3618 3598 3619 if (a rgSaveRegistry)3599 if (aSaveRegistry) 3620 3600 { 3621 3601 rc = saveSettings(); 3622 if (FAILED (rc))3623 register Image(argImage, argType, false /* aSaveRegistry */);3602 if (FAILED (rc)) 3603 registerDVDImage (aImage, false /* aSaveRegistry */); 3624 3604 } 3625 3605 3626 3606 return rc; 3607 } 3608 3609 /** 3610 * Remembers the given image by storing it in the floppy image registry. 3611 * 3612 * @param aImage Image object to remember. 3613 * @param aSaveRegistry @c true to save the image registry to disk (default). 3614 * 3615 * When @a aSaveRegistry is @c true, this operation may fail because of the 3616 * failed #saveSettings() method it calls. In this case, the image object 3617 * will not be remembered. It is therefore the responsibility of the caller to 3618 * call this method as the last step of some action that requires registration 3619 * in order to make sure that only fully functional image objects get 3620 * registered. 3621 * 3622 * @note Locks this object for writing and @a aImage for reading. 3623 */ 3624 HRESULT VirtualBox::registerFloppyImage(Medium *aImage, 3625 bool aSaveRegistry /*= true*/) 3626 { 3627 AssertReturn(aImage != NULL, E_INVALIDARG); 3628 3629 AutoCaller autoCaller(this); 3630 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3631 3632 AutoWriteLock alock(this); 3633 3634 AutoCaller imageCaller (aImage); 3635 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3636 3637 AutoReadLock imageLock (aImage); 3638 3639 Utf8Str strConflict; 3640 HRESULT rc = checkMediaForConflicts2(aImage->getId(), 3641 aImage->getLocationFull(), 3642 strConflict); 3643 if (FAILED(rc)) return rc; 3644 3645 if (strConflict.length()) 3646 { 3647 return setError(VBOX_E_INVALID_OBJECT_STATE, 3648 tr("Cannot register the floppy image '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"), 3649 aImage->getLocationFull().raw(), 3650 aImage->getId().raw(), 3651 strConflict.raw(), 3652 m->strSettingsFilePath.raw()); 3653 } 3654 3655 /* add to the collection */ 3656 m->llFloppyImages.push_back (aImage); 3657 3658 if (aSaveRegistry) 3659 { 3660 rc = saveSettings(); 3661 if (FAILED (rc)) 3662 unregisterFloppyImage(aImage, false /* aSaveRegistry */); 3663 } 3664 3665 return rc; 3666 } 3667 3668 /** 3669 * Removes the given image from the floppy image registry registry. 3670 * 3671 * @param aImage Image object to remove. 3672 * @param aSaveRegistry @c true to save hard disk registry to disk (default). 3673 * 3674 * When @a aSaveRegistry is @c true, this operation may fail because of the 3675 * failed #saveSettings() method it calls. In this case, the image object 3676 * will NOT be removed from the registry when this method returns. It is 3677 * therefore the responsibility of the caller to call this method as the first 3678 * step of some action that requires unregistration, before calling uninit() on 3679 * @a aImage. 3680 * 3681 * @note Locks this object for writing and @a aImage for reading. 3682 */ 3683 HRESULT VirtualBox::unregisterFloppyImage(Medium *aImage, 3684 bool aSaveRegistry /*= true*/) 3685 { 3686 AssertReturn(aImage != NULL, E_INVALIDARG); 3687 3688 AutoCaller autoCaller(this); 3689 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3690 3691 AutoWriteLock alock(this); 3692 3693 AutoCaller imageCaller (aImage); 3694 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3695 3696 AutoReadLock imageLock (aImage); 3697 3698 m->llFloppyImages.remove (aImage); 3699 3700 HRESULT rc = S_OK; 3701 3702 if (aSaveRegistry) 3703 { 3704 rc = saveSettings(); 3705 if (FAILED (rc)) 3706 registerFloppyImage (aImage, false /* aSaveRegistry */); 3707 } 3708 3709 return rc; 3710 } 3711 3712 /** 3713 * Attempts to cast from a raw interface pointer to an underlying object. 3714 * On success, @a aTo will contain the object reference. On failure, @a aTo will 3715 * be set to @c null and an extended error info will be returned. 3716 * 3717 * @param aFrom Interface pointer to cast from. 3718 * @param aTo Where to store a reference to the underlying object. 3719 * 3720 * @note Locks #childrenLock() for reading. 3721 */ 3722 HRESULT VirtualBox::cast (IMedium *aFrom, ComObjPtr<Medium> &aTo) 3723 { 3724 AssertReturn(aFrom != NULL, E_INVALIDARG); 3725 3726 AutoCaller autoCaller(this); 3727 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3728 3729 /* We need the children map lock here to keep the getDependentChild() result 3730 * valid until we finish */ 3731 AutoReadLock chLock (childrenLock()); 3732 3733 VirtualBoxBase *child = getDependentChild (aFrom); 3734 if (!child) 3735 return setError (E_FAIL, tr ("The given hard disk object is not created " 3736 "within this VirtualBox instance")); 3737 3738 /* we can safely cast child to Medium * here because only Medium 3739 * implementations of IMedium can be among our children */ 3740 3741 aTo = static_cast<Medium*>(child); 3742 3743 return S_OK; 3627 3744 } 3628 3745 … … 3637 3754 * @note Locks this object + DVD, Floppy and HardDisk children for writing. 3638 3755 */ 3639 HRESULT VirtualBox::updateSettings (const char *aOldPath, const char *aNewPath)3756 HRESULT VirtualBox::updateSettings (const char *aOldPath, const char *aNewPath) 3640 3757 { 3641 3758 LogFlowThisFunc(("aOldPath={%s} aNewPath={%s}\n", aOldPath, aNewPath)); … … 3647 3764 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3648 3765 3649 ObjectsList<Medium> ollAll; 3650 ollAll.appendOtherList(m->ollDVDImages); 3651 ollAll.appendOtherList(m->ollFloppyImages); 3652 ollAll.appendOtherList(m->ollHardDisks); 3653 3654 for (MediaList::iterator it = ollAll.begin(); 3655 it != ollAll.end(); 3766 AutoWriteLock alock(this); 3767 3768 /* check DVD paths */ 3769 for (MediaList::iterator it = m->llDVDImages.begin(); 3770 it != m->llDVDImages.end(); 3656 3771 ++ it) 3657 3772 { 3658 3773 (*it)->updatePath(aOldPath, aNewPath); 3774 } 3775 3776 /* check Floppy paths */ 3777 for (MediaList::iterator it = m->llFloppyImages.begin(); 3778 it != m->llFloppyImages .end(); 3779 ++ it) 3780 { 3781 (*it)->updatePath(aOldPath, aNewPath); 3782 } 3783 3784 /* check HardDisk paths */ 3785 for (MediaList::const_iterator it = m->llHardDisks.begin(); 3786 it != m->llHardDisks.end(); 3787 ++ it) 3788 { 3789 (*it)->updatePaths(aOldPath, aNewPath); 3659 3790 } 3660 3791 … … 3768 3899 RWLockHandle& VirtualBox::hardDiskTreeLockHandle() 3769 3900 { 3770 return m->ollHardDisks.getLockHandle(); 3901 return m->mtxHardDiskTree; 3902 } 3903 3904 /** 3905 * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a 3906 * dedicated lock instead of the main object lock. The dedicated lock for 3907 * child map operations frees callers of init() methods of these children 3908 * from acquiring a write parent (VirtualBox) lock (which would be mandatory 3909 * otherwise). Since VirtualBox has a lot of heterogenous children which 3910 * init() methods are called here and there, it definitely makes sense. 3911 */ 3912 RWLockHandle* VirtualBox::childrenLock() 3913 { 3914 return &m->mtxChildrenMap; 3771 3915 } 3772 3916 … … 3780 3924 LogFlowFuncEnter(); 3781 3925 3782 VirtualBox *that = (VirtualBox*)pvUser; 3783 Assert(that); 3784 3785 typedef std::vector< ComObjPtr<Machine> > MachineVector; 3786 typedef std::vector< ComObjPtr<SessionMachine> > SessionMachineVector; 3926 VirtualBox *that = (VirtualBox *) pvUser; 3927 Assert (that); 3787 3928 3788 3929 SessionMachineVector machines; … … 3837 3978 { 3838 3979 /* machine mutex is released */ 3839 (machines [rc - WAIT_OBJECT_0 - 1])->checkForDeath();3980 (machines [rc - WAIT_OBJECT_0 - 1])->checkForDeath(); 3840 3981 update = true; 3841 3982 } … … 3843 3984 { 3844 3985 /* machine mutex is abandoned due to client process termination */ 3845 (machines [rc - WAIT_ABANDONED_0 - 1])->checkForDeath();3986 (machines [rc - WAIT_ABANDONED_0 - 1])->checkForDeath(); 3846 3987 update = true; 3847 3988 } … … 3857 3998 { 3858 3999 /* close old process handles */ 3859 for (size_t i = 1 + cnt; i < 1 + cnt + cntSpawned; ++i) 3860 CloseHandle(handles[i]); 3861 3862 // lock the machines list for reading 3863 AutoReadLock thatLock(that->m->ollMachines.getLockHandle()); 4000 for (size_t i = 1 + cnt; i < 1 + cnt + cntSpawned; ++ i) 4001 CloseHandle (handles [i]); 4002 4003 AutoReadLock thatLock (that); 3864 4004 3865 4005 /* obtain a new set of opened machines */ … … 3867 4007 machines.clear(); 3868 4008 3869 for (MachinesOList::iterator it = that->m->ollMachines.begin(); 3870 it != that->m->ollMachines.end(); 3871 ++it) 4009 for (MachineList::iterator it = that->m->llMachines.begin(); 4010 it != that->m->llMachines.end(); ++ it) 3872 4011 { 3873 4012 /// @todo handle situations with more than 64 objects … … 3877 4016 ComObjPtr<SessionMachine> sm; 3878 4017 HANDLE ipcSem; 3879 if ((*it)->isSessionOpenOrClosing (sm, NULL, &ipcSem))4018 if ((*it)->isSessionOpenOrClosing (sm, NULL, &ipcSem)) 3880 4019 { 3881 machines.push_back (sm);3882 handles [1 + cnt] = ipcSem;3883 ++ cnt;4020 machines.push_back (sm); 4021 handles [1 + cnt] = ipcSem; 4022 ++ cnt; 3884 4023 } 3885 4024 } … … 3891 4030 spawnedMachines.clear(); 3892 4031 3893 for (MachinesOList::iterator it = that->m->ollMachines.begin(); 3894 it != that->m->ollMachines.end(); 3895 ++it) 4032 for (MachineList::iterator it = that->m->llMachines.begin(); 4033 it != that->m->llMachines.end(); ++ it) 3896 4034 { 3897 4035 /// @todo handle situations with more than 64 objects … … 3900 4038 3901 4039 RTPROCESS pid; 3902 if ((*it)->isSessionSpawning (&pid))4040 if ((*it)->isSessionSpawning (&pid)) 3903 4041 { 3904 HANDLE ph = OpenProcess (SYNCHRONIZE, FALSE, pid);4042 HANDLE ph = OpenProcess (SYNCHRONIZE, FALSE, pid); 3905 4043 AssertMsg (ph != NULL, ("OpenProcess (pid=%d) failed with %d\n", 3906 4044 pid, GetLastError())); 3907 4045 if (rc == 0) 3908 4046 { 3909 spawnedMachines.push_back (*it);3910 handles [1 + cnt + cntSpawned] = ph;3911 ++ cntSpawned;4047 spawnedMachines.push_back (*it); 4048 handles [1 + cnt + cntSpawned] = ph; 4049 ++ cntSpawned; 3912 4050 } 3913 4051 } … … 3915 4053 3916 4054 LogFlowFunc (("UPDATE: spawned session count = %d\n", cntSpawned)); 3917 3918 // machines lock unwinds here3919 4055 } 3920 4056 } … … 3954 4090 autoCaller.release(); 3955 4091 3956 int vrc = RTSemEventWait (that->m->updateReq, 500);4092 int vrc = RTSemEventWait (that->m->updateReq, 500); 3957 4093 3958 4094 /* Restore the caller before using VirtualBox. If it fails, this … … 3993 4129 #ifdef DEBUG 3994 4130 { 3995 AutoReadLock machineLock (machines[semId]);4131 AutoReadLock machineLock (machines [semId]); 3996 4132 LogFlowFunc (("released mutex: machine='%ls'\n", 3997 machines [semId]->name().raw()));4133 machines [semId]->name().raw())); 3998 4134 } 3999 4135 #endif 4000 machines [semId]->checkForDeath();4136 machines [semId]->checkForDeath(); 4001 4137 } 4002 4138 update = true; … … 4023 4159 #ifdef DEBUG 4024 4160 { 4025 AutoReadLock machineLock (machines[semId]);4026 LogFlowFunc (("mutex owner dead: machine='%ls'\n",4027 machines[i]->name().raw()));4161 AutoReadLock machineLock (machines [semId]); 4162 LogFlowFunc (("mutex owner dead: machine='%ls'\n", 4163 machines [i]->name().raw())); 4028 4164 } 4029 4165 #endif 4030 machines [i]->checkForDeath();4166 machines [i]->checkForDeath(); 4031 4167 } 4032 4168 } … … 4062 4198 machines.clear(); 4063 4199 4064 for (Machine sOList::iterator it = that->m->llMachines.begin();4200 for (MachineList::iterator it = that->m->llMachines.begin(); 4065 4201 it != that->m->llMachines.end(); ++ it) 4066 4202 { … … 4075 4211 { 4076 4212 machines.push_back (sm); 4077 handles [cnt].hsemCur = (HSEM) ipcSem;4078 handles [cnt].ulUser = cnt;4213 handles [cnt].hsemCur = (HSEM) ipcSem; 4214 handles [cnt].ulUser = cnt; 4079 4215 ++ cnt; 4080 4216 } … … 4100 4236 spawnedMachines.clear(); 4101 4237 4102 for (Machine sOList::iterator it = that->m->llMachines.begin();4238 for (MachineList::iterator it = that->m->llMachines.begin(); 4103 4239 it != that->m->llMachines.end(); ++ it) 4104 4240 { … … 4154 4290 /* RT_SUCCESS(rc) means an update event is signaled */ 4155 4291 4156 // lock the machines list for reading 4157 AutoReadLock thatLock(that->m->ollMachines.getLockHandle()); 4292 AutoReadLock thatLock (that); 4158 4293 4159 4294 if (RT_SUCCESS(rc) || update) … … 4162 4297 machines.clear(); 4163 4298 4164 for (MachinesOList::iterator it = that->m->ollMachines.begin(); 4165 it != that->m->ollMachines.end(); 4166 ++it) 4299 for (MachineList::iterator it = that->m->llMachines.begin(); 4300 it != that->m->llMachines.end(); ++ it) 4167 4301 { 4168 4302 ComObjPtr<SessionMachine> sm; 4169 if ((*it)->isSessionOpenOrClosing (sm))4170 machines.push_back (sm);4303 if ((*it)->isSessionOpenOrClosing (sm)) 4304 machines.push_back (sm); 4171 4305 } 4172 4306 4173 4307 cnt = machines.size(); 4174 LogFlowFunc (("UPDATE: direct session count = %d\n", cnt));4308 LogFlowFunc (("UPDATE: direct session count = %d\n", cnt)); 4175 4309 } 4176 4310 … … 4180 4314 spawnedMachines.clear(); 4181 4315 4182 for (MachinesOList::iterator it = that->m->ollMachines.begin(); 4183 it != that->m->ollMachines.end(); 4184 ++it) 4316 for (MachineList::iterator it = that->m->llMachines.begin(); 4317 it != that->m->llMachines.end(); ++ it) 4185 4318 { 4186 4319 if ((*it)->isSessionSpawning()) 4187 spawnedMachines.push_back (*it);4320 spawnedMachines.push_back (*it); 4188 4321 } 4189 4322 4190 4323 cntSpawned = spawnedMachines.size(); 4191 LogFlowFunc (("UPDATE: spawned session count = %d\n", cntSpawned));4324 LogFlowFunc (("UPDATE: spawned session count = %d\n", cntSpawned)); 4192 4325 } 4193 4194 // machines lock unwinds here4195 4326 } 4196 4327 … … 4359 4490 } 4360 4491 4361 STDMETHODIMP VirtualBox::FindDHCPServerByNetworkName(IN_BSTR aName, IDHCPServer ** aServer) 4492 //STDMETHODIMP VirtualBox::FindDHCPServerForInterface (IHostNetworkInterface * aIinterface, IDHCPServer ** aServer) 4493 //{ 4494 // return E_NOTIMPL; 4495 //} 4496 4497 STDMETHODIMP VirtualBox::FindDHCPServerByNetworkName (IN_BSTR aName, IDHCPServer ** aServer) 4362 4498 { 4363 4499 CheckComArgNotNull(aName); … … 4366 4502 AutoCaller autoCaller(this); 4367 4503 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 4504 4505 AutoWriteLock alock(this); 4368 4506 4369 4507 HRESULT rc; … … 4371 4509 ComPtr<DHCPServer> found; 4372 4510 4373 AutoReadLock alock(m->ollDHCPServers.getLockHandle()); 4374 4375 for (DHCPServersOList::const_iterator it = m->ollDHCPServers.begin(); 4376 it != m->ollDHCPServers.end(); 4377 ++it) 4378 { 4379 rc = (*it)->COMGETTER(NetworkName)(bstr.asOutParam()); 4511 for (DHCPServerList::const_iterator it = 4512 m->llDHCPServers.begin(); 4513 it != m->llDHCPServers.end(); 4514 ++ it) 4515 { 4516 rc = (*it)->COMGETTER(NetworkName) (bstr.asOutParam()); 4380 4517 if (FAILED(rc)) throw rc; 4381 4518 4382 if 4519 if(bstr == aName) 4383 4520 { 4384 4521 found = *it; … … 4421 4558 */ 4422 4559 HRESULT VirtualBox::registerDHCPServer(DHCPServer *aDHCPServer, 4423 4560 bool aSaveRegistry /*= true*/) 4424 4561 { 4425 4562 AssertReturn(aDHCPServer != NULL, E_INVALIDARG); … … 4428 4565 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 4429 4566 4430 AutoCaller dhcpServerCaller(aDHCPServer); 4567 AutoWriteLock alock(this); 4568 4569 AutoCaller dhcpServerCaller (aDHCPServer); 4431 4570 AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc()); 4571 4572 AutoReadLock dhcpServerLock (aDHCPServer); 4432 4573 4433 4574 Bstr name; 4434 4575 HRESULT rc; 4435 rc = aDHCPServer->COMGETTER(NetworkName) (name.asOutParam());4576 rc = aDHCPServer->COMGETTER(NetworkName) (name.asOutParam()); 4436 4577 if (FAILED(rc)) return rc; 4437 4578 4438 4579 ComPtr<IDHCPServer> existing; 4439 4580 rc = FindDHCPServerByNetworkName(name.mutableRaw(), existing.asOutParam()); 4440 if 4581 if(SUCCEEDED(rc)) 4441 4582 { 4442 4583 return E_INVALIDARG; 4443 4584 } 4444 4445 4585 rc = S_OK; 4446 4586 4447 m-> ollDHCPServers.addChild(aDHCPServer);4587 m->llDHCPServers.push_back (aDHCPServer); 4448 4588 4449 4589 if (aSaveRegistry) … … 4485 4625 AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc()); 4486 4626 4487 m->ollDHCPServers.removeChild(aDHCPServer); 4627 AutoReadLock dhcpServerLock (aDHCPServer); 4628 4629 m->llDHCPServers.remove (aDHCPServer); 4488 4630 4489 4631 HRESULT rc = S_OK; -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r25170 r25182 31 31 32 32 class ATL_NO_VTABLE SharedFolder : 33 public VirtualBoxBase WithChildrenNEXT,33 public VirtualBoxBase, 34 34 public VirtualBoxSupportErrorInfoImpl<SharedFolder, ISharedFolder>, 35 35 public VirtualBoxSupportTranslation<SharedFolder>, … … 94 94 protected: 95 95 96 HRESULT protectedInit (VirtualBoxBase*aParent,97 CBSTR aName, CBSTR aHostPath, BOOL aWritable);96 HRESULT protectedInit (VirtualBoxBaseWithChildrenNEXT *aParent, 97 CBSTR aName, CBSTR aHostPath, BOOL aWritable); 98 98 99 99 private: 100 100 101 VirtualBoxBase *const mParent;101 VirtualBoxBaseWithChildrenNEXT *const mParent; 102 102 103 103 /* weak parents (only one of them is not null) */ -
trunk/src/VBox/Main/include/StorageControllerImpl.h
r25170 r25182 32 32 33 33 class ATL_NO_VTABLE StorageController : 34 public VirtualBoxBase ,34 public VirtualBoxBaseWithChildrenNEXT, 35 35 public VirtualBoxSupportErrorInfoImpl<StorageController, IStorageController>, 36 36 public VirtualBoxSupportTranslation<StorageController>, -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r25170 r25182 60 60 61 61 class ATL_NO_VTABLE VirtualBox : 62 public VirtualBoxBase ,62 public VirtualBoxBaseWithChildrenNEXT, 63 63 public VirtualBoxSupportErrorInfoImpl<VirtualBox, IVirtualBox>, 64 64 public VirtualBoxSupportTranslation<VirtualBox>, … … 257 257 HRESULT unregisterHardDisk(Medium *aHardDisk, bool aSaveRegistry = true); 258 258 259 HRESULT registerImage(Medium *aImage, DeviceType_T argType, bool aSaveRegistry = true); 260 HRESULT unregisterImage(Medium *aImage, DeviceType_T argType, bool aSaveRegistry = true); 259 HRESULT registerDVDImage(Medium *aImage, bool aSaveRegistry = true); 260 HRESULT unregisterDVDImage(Medium *aImage, bool aSaveRegistry = true); 261 262 HRESULT registerFloppyImage (Medium *aImage, bool aSaveRegistry = true); 263 HRESULT unregisterFloppyImage (Medium *aImage, bool aSaveRegistry = true); 264 265 HRESULT cast (IMedium *aFrom, ComObjPtr<Medium> &aTo); 261 266 262 267 HRESULT saveSettings(); … … 270 275 271 276 RWLockHandle& hardDiskTreeLockHandle(); 277 RWLockHandle* childrenLock(); 272 278 273 279 /* for VirtualBoxSupportErrorInfoImpl */ -
trunk/src/VBox/Main/xml/VirtualBox-settings-common.xsd
r24551 r25182 489 489 <xsd:element name="PAE" type="TPAEType" minOccurs="0"/> 490 490 <xsd:element name="SyntheticCpu" type="TSyntheticCpuType" minOccurs="0"/> 491 <xsd:element name="CpuIdTree" type="TCpuIdTree" minOccurs="0">491 <xsd:element name="CpuIdTree" type="TCpuIdTree"> 492 492 <xsd:unique name="TCPU-CpuIdTree-CpuIdLeaf"> 493 493 <xsd:selector xpath="vb:CpuIdLeaf"/>
Note:
See TracChangeset
for help on using the changeset viewer.