Changeset 31814 in vbox
- Timestamp:
- Aug 20, 2010 12:38:56 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 65012
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r31746 r31814 755 755 } 756 756 757 // uninit media from this machine's media registry 758 mParent->unregisterMachineMedia(getId()); 759 757 760 /* the lock is no more necessary (SessionMachine is uninitialized) */ 758 761 alock.leave(); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31615 r31814 3347 3347 3348 3348 if (strConflict.length()) 3349 {3350 3349 return setError(E_INVALIDARG, 3351 3350 tr("Cannot register the hard disk '%s' {%RTuuid} because a %s already exists"), … … 3354 3353 strConflict.c_str(), 3355 3354 m->strSettingsFilePath.c_str()); 3356 }3357 3355 3358 3356 // store base (root) hard disks in the list … … 3537 3535 3538 3536 return rc; 3537 } 3538 3539 /** 3540 * Little helper called from unregisterMachineMedia() to recursively add media to the given list, 3541 * with children appearing before their parents. 3542 * @param llMedia 3543 * @param pMedium 3544 */ 3545 void VirtualBox::pushMediumToListWithChildren(MediaList &llMedia, Medium *pMedium) 3546 { 3547 // recurse first, then add ourselves; this way children end up on the 3548 // list before their parents 3549 3550 const MediaList &llChildren = pMedium->getChildren(); 3551 for (MediaList::const_iterator it = llChildren.begin(); 3552 it != llChildren.end(); 3553 ++it) 3554 { 3555 Medium *pChild = *it; 3556 pushMediumToListWithChildren(llMedia, pChild); 3557 } 3558 3559 Log(("Pushing medium %RTuuid\n", pMedium->getId().raw())); 3560 llMedia.push_back(pMedium); 3561 } 3562 3563 /** 3564 * Unregisters all Medium objects which belong to the given machine registry. 3565 * Gets called from Machine::uninit() just before the machine object dies 3566 * and must only be called with a machine UUID as the registry ID. 3567 * 3568 * Locks the media tree. 3569 * 3570 * @param uuidMachine Medium registry ID (always a machine UUID) 3571 * @return 3572 */ 3573 HRESULT VirtualBox::unregisterMachineMedia(const Guid &uuidMachine) 3574 { 3575 Assert(!uuidMachine.isEmpty()); 3576 3577 LogFlowFuncEnter(); 3578 3579 AutoCaller autoCaller(this); 3580 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3581 3582 MediaList llMedia2Close; 3583 3584 { 3585 AutoWriteLock mlock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 3586 for (MediaOList::iterator it = m->allHardDisks.getList().begin(); 3587 it != m->allHardDisks.getList().end(); 3588 ++it) 3589 { 3590 ComObjPtr<Medium> pMedium = *it; 3591 3592 const Guid &uuidRegistryThis = pMedium->getRegistryId(); 3593 if ( !uuidRegistryThis.isEmpty() 3594 && (uuidRegistryThis == uuidMachine) 3595 ) 3596 { 3597 // recursively with children first 3598 pushMediumToListWithChildren(llMedia2Close, pMedium); 3599 } 3600 } 3601 } 3602 3603 for (MediaList::iterator it = llMedia2Close.begin(); 3604 it != llMedia2Close.end(); 3605 ++it) 3606 { 3607 ComObjPtr<Medium> pMedium = *it; 3608 Log(("Closing medium %RTuuid\n", pMedium->getId().raw())); 3609 AutoCaller mac(pMedium); 3610 pMedium->close(NULL /* pfNeedsGlobalSaveSettings*/, mac); 3611 } 3612 3613 LogFlowFuncLeave(); 3614 3615 return S_OK; 3539 3616 } 3540 3617 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31725 r31814 253 253 HRESULT unregisterImage(Medium *aImage, DeviceType_T argType, bool *pfNeedsGlobalSaveSettings); 254 254 255 void pushMediumToListWithChildren(MediaList &llMedia, Medium *pMedium); 256 HRESULT unregisterMachineMedia(const Guid &id); 257 255 258 HRESULT unregisterMachine(Machine *pMachine, const Guid &id); 256 259
Note:
See TracChangeset
for help on using the changeset viewer.