Changeset 31242 in vbox
- Timestamp:
- Jul 30, 2010 1:06:39 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
-
MachineImpl.cpp (modified) (4 diffs)
-
SnapshotImpl.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r31239 r31242 4070 4070 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4071 4071 4072 MediaList llMedia;4073 4072 if (mData->mSession.mState != SessionState_Unlocked) 4074 4073 return setError(VBOX_E_INVALID_OBJECT_STATE, 4075 4074 tr("Cannot unregister the machine '%ls' while it is locked"), 4076 mUserData->mName.raw());4075 mUserData->mName.raw()); 4077 4076 4078 4077 HRESULT rc = S_OK; 4079 4078 4080 4079 // this list collects the files that should be reported 4081 // as to be deleted to the caller in aFiles 4080 // as to be deleted to the caller in aFiles (this includes the 4081 // media files in llMedia below) 4082 4082 std::list<Utf8Str> llFilesForCaller; 4083 4083 … … 4096 4096 } 4097 4097 4098 size_t snapshotCount= 0;4098 size_t cSnapshots = 0; 4099 4099 if (mData->mFirstSnapshot) 4100 snapshotCount = mData->mFirstSnapshot->getAllChildrenCount() + 1; 4101 if (snapshotCount) 4102 { 4103 if (fAutoCleanup) 4104 { 4105 // caller wants automatic detachment: then do that and report all media to the array 4106 4107 // Snapshot::beginDeletingSnapshot() needs the machine state to be this 4108 MachineState_T oldState = mData->mMachineState; 4109 mData->mMachineState = MachineState_DeletingSnapshot; 4110 4111 // make a copy of the first snapshot so the refcount does not drop to 0 4112 // in beginDeletingSnapshot, which sets pFirstSnapshot to 0 (that hangs 4113 // because of the AutoCaller voodoo) 4114 ComObjPtr<Snapshot> pFirstSnapshot = mData->mFirstSnapshot; 4115 4116 // go! 4117 pFirstSnapshot->uninitRecursively(alock, llMedia, llFilesForCaller); 4118 4119 mData->mMachineState = oldState; 4120 } 4121 else 4122 return setError(VBOX_E_INVALID_OBJECT_STATE, 4123 tr("Cannot unregister the machine '%ls' because it has %d snapshots"), 4124 mUserData->mName.raw(), snapshotCount); 4125 } 4100 cSnapshots = mData->mFirstSnapshot->getAllChildrenCount() + 1; 4101 if (cSnapshots && !fAutoCleanup) 4102 // fail now before we start detaching media 4103 return setError(VBOX_E_INVALID_OBJECT_STATE, 4104 tr("Cannot unregister the machine '%ls' because it has %d snapshots"), 4105 mUserData->mName.raw(), cSnapshots); 4106 4107 // this list collects the medium objects from all medium attachments 4108 // which got detached from the machine and its snapshots, in the following 4109 // order: 4110 // 1) media from machine attachments (these have the "leaf" attachments with snapshots 4111 // and must be closed first, or closing the parents will fail because they will 4112 // children); 4113 // 2) media from the youngest snapshots followed those from the parent snapshots until 4114 // the root ("first") snapshot of the machine 4115 // This order allows for closing the media on this list from the beginning to the end 4116 // without getting "media in use" errors. 4117 MediaList llMedia; 4126 4118 4127 4119 if ( !mMediaData.isNull() // can be NULL if machine is inaccessible … … 4137 4129 mUserData->mName.raw(), mMediaData->mAttachments.size()); 4138 4130 } 4131 4132 if (cSnapshots) 4133 { 4134 // autoCleanup must be true here, or we would have failed above 4135 4136 // add the media from the medium attachments of the snapshots to llMedia 4137 // as well, after the "main" machine media; Snapshot::uninitRecursively() 4138 // calls Machine::detachAllMedia() for the snapshot machine, recursing 4139 // into the children first 4140 4141 // Snapshot::beginDeletingSnapshot() asserts if the machine state is not this 4142 MachineState_T oldState = mData->mMachineState; 4143 mData->mMachineState = MachineState_DeletingSnapshot; 4144 4145 // make a copy of the first snapshot so the refcount does not drop to 0 4146 // in beginDeletingSnapshot, which sets pFirstSnapshot to 0 (that hangs 4147 // because of the AutoCaller voodoo) 4148 ComObjPtr<Snapshot> pFirstSnapshot = mData->mFirstSnapshot; 4149 4150 // GO! 4151 pFirstSnapshot->uninitRecursively(alock, llMedia, llFilesForCaller); 4152 4153 mData->mMachineState = oldState; 4154 } 4155 4139 4156 4140 4157 if (FAILED(rc)) … … 8721 8738 ComObjPtr<Medium> oldmedium = pAttach->getMedium(); 8722 8739 DeviceType_T mediumType = pAttach->getType(); 8740 8741 LogFlowThisFunc(("Entering, medium of attachment is %s\n", oldmedium ? oldmedium->getLocationFull().c_str() : "NULL")); 8723 8742 8724 8743 if (pAttach->isImplicit()) -
trunk/src/VBox/Main/SnapshotImpl.cpp
r31236 r31242 839 839 HRESULT rc = S_OK; 840 840 841 // make a copy of the Guid for logging before we uninit ourselfs 842 #ifdef LOG_ENABLED 843 Guid uuid = getId(); 844 Utf8Str name = getName(); 845 LogFlowThisFunc(("Entering for snapshot '%s' {%RTuuid}\n", name.c_str(), uuid.raw())); 846 #endif 847 841 848 // recurse into children first so that the child media appear on 842 849 // the list first; this way caller can close the media from the … … 869 876 this->beginSnapshotDelete(); 870 877 this->uninit(); 878 879 #ifdef LOG_ENABLED 880 LogFlowThisFunc(("Leaving for snapshot '%s' {%RTuuid}\n", name.c_str(), uuid.raw())); 881 #endif 871 882 872 883 return S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.

