Changeset 31333 in vbox
- Timestamp:
- Aug 3, 2010 1:00:54 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 64371
- Location:
- trunk/src/VBox
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r31220 r31333 159 159 if (machine) 160 160 { 161 SafeArray<BSTR> abstrFiles; 162 CHECK_ERROR(machine, Unregister(fDelete /* fAutoCleanup */, 163 ComSafeArrayAsOutParam(abstrFiles))); 161 SafeIfaceArray<IMedium> aMedia; 162 CleanupMode_T cleanupMode = CleanupMode_DetachAllReturnNone; 163 if (fDelete) 164 cleanupMode = CleanupMode_DetachAllReturnHardDisksOnly; 165 CHECK_ERROR(machine, Unregister(cleanupMode, 166 ComSafeArrayAsOutParam(aMedia))); 164 167 if (SUCCEEDED(rc)) 165 168 { 166 for (size_t u = 0;167 u < abstrFiles.size();168 ++u)169 {170 Utf8Str strFile(abstrFiles[u]);171 if (fDelete)172 {173 RTPrintf("Deleting '%s'\n", strFile.c_str());174 RTFileDelete(strFile.c_str());175 }176 else177 RTPrintf("File '%s' is now obsolete and can be deleted\n", strFile.c_str());178 }179 180 169 if (fDelete) 181 170 { 182 CHECK_ERROR(machine, Delete()); 171 ComPtr<IProgress> pProgress; 172 CHECK_ERROR(machine, Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam())); 173 CHECK_ERROR(pProgress, WaitForCompletion(-1)); 183 174 } 184 175 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r31240 r31333 680 680 { 681 681 CMachine machine = item->machine(); 682 QVector< QString> files = machine.Unregister(false /*fDetachMedia*/);682 QVector<CMedium> aMedia = machine.Unregister(KCleanupMode_UnregisterOnly); // @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below 683 683 if (machine.isOk() && item->accessible()) 684 684 { 685 685 /* delete machine settings */ 686 machine.Delete(); 686 CProgress progress = machine.Delete(aMedia); 687 progress.WaitForCompletion(-1); // @todo do this nicely with a progress dialog, this can delete many files! 688 687 689 /* remove the item shortly: cmachine it refers to is no longer valid! */ 688 690 int row = mVMModel->rowById (item->id()); -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r31070 r31333 782 782 { 783 783 /* Unregister on failure */ 784 QVector< QString> files = m_Machine.Unregister(false /*fDetachMedia*/);784 QVector<CMedium> aMedia = m_Machine.Unregister(KCleanupMode_UnregisterOnly); // @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below 785 785 if (vbox.isOk()) 786 m_Machine.Delete(); 786 { 787 CProgress progress = m_Machine.Delete(aMedia); 788 progress.WaitForCompletion(-1); // @todo do this nicely with a progress dialog, this can delete lots of files 789 } 787 790 return false; 788 791 } -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r31070 r31333 1223 1223 { 1224 1224 // with _whatever_ error we've had, do a complete roll-back of 1225 // machines and disks we've created; unfortunately this is 1226 // not so trivially done... 1227 1228 HRESULT rc2; 1229 // detach all hard disks from all machines we created 1230 for (list<MyHardDiskAttachment>::iterator itM = stack.llHardDiskAttachments.begin(); 1231 itM != stack.llHardDiskAttachments.end(); 1232 ++itM) 1233 { 1234 const MyHardDiskAttachment &mhda = *itM; 1235 rc2 = mhda.pMachine->LockMachine(stack.pSession, LockType_Write); 1236 if (SUCCEEDED(rc2)) 1237 { 1238 ComPtr<IMachine> sMachine; 1239 rc2 = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); 1240 if (SUCCEEDED(rc2)) 1241 { 1242 rc2 = sMachine->DetachDevice(Bstr(mhda.controllerType), mhda.lControllerPort, mhda.lDevice); 1243 rc2 = sMachine->SaveSettings(); 1244 } 1245 stack.pSession->UnlockMachine(); 1246 } 1247 } 1248 1249 // now clean up all hard disks we created 1250 for (list< ComPtr<IMedium> >::iterator itHD = stack.llHardDisksCreated.begin(); 1251 itHD != stack.llHardDisksCreated.end(); 1252 ++itHD) 1253 { 1254 ComPtr<IMedium> pDisk = *itHD; 1255 ComPtr<IProgress> pProgress2; 1256 rc2 = pDisk->DeleteStorage(pProgress2.asOutParam()); 1257 rc2 = pProgress2->WaitForCompletion(-1); 1258 } 1259 1260 // finally, deregister and remove all machines 1225 // machines and disks we've created 1226 1261 1227 for (list<Guid>::iterator itID = m->llGuidsMachinesCreated.begin(); 1262 1228 itID != m->llGuidsMachinesCreated.end(); … … 1266 1232 Bstr bstrGuid = guid.toUtf16(); 1267 1233 ComPtr<IMachine> failedMachine; 1268 SafeArray<BSTR> abstrPaths; 1269 rc2 = mVirtualBox->GetMachine(bstrGuid, failedMachine.asOutParam()); 1234 HRESULT rc2 = mVirtualBox->GetMachine(bstrGuid, failedMachine.asOutParam()); 1270 1235 if (SUCCEEDED(rc2)) 1271 1236 { 1272 rc2 = failedMachine->Unregister(false, ComSafeArrayAsOutParam(abstrPaths)); 1273 rc2 = failedMachine->Delete(); 1237 SafeIfaceArray<IMedium> aMedia; 1238 rc2 = failedMachine->Unregister(CleanupMode_DetachAllReturnHardDisksOnly, ComSafeArrayAsOutParam(aMedia)); 1239 ComPtr<IProgress> pProgress2; 1240 rc2 = failedMachine->Delete(ComSafeArrayAsInParam(aMedia), pProgress2.asOutParam()); 1241 pProgress2->WaitForCompletion(-1); 1274 1242 } 1275 1243 } -
trunk/src/VBox/Main/MachineImpl.cpp
r31332 r31333 3974 3974 3975 3975 /** @note Locks objects! */ 3976 STDMETHODIMP Machine::Unregister( BOOL fAutoCleanup,3977 ComSafeArrayOut( BSTR, aFiles))3976 STDMETHODIMP Machine::Unregister(CleanupMode_T cleanupMode, 3977 ComSafeArrayOut(IMedium*, aMedia)) 3978 3978 { 3979 3979 AutoCaller autoCaller(this); … … 3989 3989 HRESULT rc = S_OK; 3990 3990 3991 // this list collects the files that should be reported3992 // as to be deleted to the caller in aFiles (this includes the3993 // media files in llMedia below)3994 std::list<Utf8Str> llFilesForCaller;3995 3996 3991 // discard saved state 3997 3992 if (mData->mMachineState == MachineState_Saved) … … 3999 3994 // add the saved state file to the list of files the caller should delete 4000 3995 Assert(!mSSData->mStateFilePath.isEmpty()); 4001 llFilesForCaller.push_back(mSSData->mStateFilePath);3996 mData->llFilesToDelete.push_back(mSSData->mStateFilePath); 4002 3997 4003 3998 mSSData->mStateFilePath.setNull(); … … 4011 4006 if (mData->mFirstSnapshot) 4012 4007 cSnapshots = mData->mFirstSnapshot->getAllChildrenCount() + 1; 4013 if (cSnapshots && !fAutoCleanup)4008 if (cSnapshots && cleanupMode == CleanupMode_UnregisterOnly) 4014 4009 // fail now before we start detaching media 4015 4010 return setError(VBOX_E_INVALID_OBJECT_STATE, … … 4034 4029 { 4035 4030 // we have media attachments: detach them all and add the Medium objects to our list 4036 if ( fAutoCleanup)4037 detachAllMedia(alock, NULL /* pSnapshot */, llMedia);4031 if (cleanupMode != CleanupMode_UnregisterOnly) 4032 detachAllMedia(alock, NULL /* pSnapshot */, cleanupMode, llMedia); 4038 4033 else 4039 4034 return setError(VBOX_E_INVALID_OBJECT_STATE, … … 4061 4056 4062 4057 // GO! 4063 pFirstSnapshot->uninitRecursively(alock, llMedia, llFilesForCaller);4058 pFirstSnapshot->uninitRecursively(alock, cleanupMode, llMedia, mData->llFilesToDelete); 4064 4059 4065 4060 mData->mMachineState = oldState; 4066 4061 } 4067 4068 4062 4069 4063 if (FAILED(rc)) … … 4081 4075 alock.release(); 4082 4076 4083 if (fAutoCleanup) 4084 { 4085 // now go thru the list of attached media reported by prepareUnregister() and close them all 4086 for (MediaList::const_iterator it = llMedia.begin(); 4087 it != llMedia.end(); 4088 ++it) 4089 { 4090 ComObjPtr<Medium> pMedium = *it; 4091 Utf8Str strFile = pMedium->getLocationFull(); 4092 4093 AutoCaller autoCaller2(pMedium); 4094 if (FAILED(autoCaller2.rc())) return autoCaller2.rc(); 4095 4096 ErrorInfoKeeper eik; 4097 rc = pMedium->close(NULL /*fNeedsSaveSettings*/, // we'll call saveSettings() in any case below 4098 autoCaller2); 4099 // this uninitializes the medium 4100 4101 LogFlowThisFunc(("Medium::close() on %s yielded rc (%Rhra)\n", strFile.c_str(), rc)); 4102 4103 if (rc == VBOX_E_OBJECT_IN_USE) 4104 // can happen if the medium was still attached to another machine; 4105 // do not report the file to the caller then, but don't report 4106 // an error either 4107 eik.setNull(); 4108 else if (SUCCEEDED(rc)) 4109 // report the path to the caller 4110 llFilesForCaller.push_back(strFile); 4111 } 4112 } 4113 4114 // report all paths to the caller 4115 SafeArray<BSTR> sfaFiles(llFilesForCaller.size()); 4116 size_t i = 0; 4117 for (std::list<Utf8Str>::iterator it = llFilesForCaller.begin(); 4118 it != llFilesForCaller.end(); 4119 ++it) 4120 Bstr(*it).detachTo(&sfaFiles[i++]); 4121 sfaFiles.detachTo(ComSafeArrayOutArg(aFiles)); 4077 // return media to caller 4078 SafeIfaceArray<IMedium> sfaMedia(llMedia); 4079 sfaMedia.detachTo(ComSafeArrayOutArg(aMedia)); 4122 4080 4123 4081 mParent->unregisterMachine(this); … … 4127 4085 } 4128 4086 4129 STDMETHODIMP Machine::Delete() 4130 { 4087 struct Machine::DeleteTask 4088 { 4089 ComObjPtr<Machine> pMachine; 4090 std::list<Utf8Str> llFilesToDelete; 4091 ComObjPtr<Progress> pProgress; 4092 }; 4093 4094 STDMETHODIMP Machine::Delete(ComSafeArrayIn(IMedium*, aMedia), IProgress **aProgress) 4095 { 4096 LogFlowFuncEnter(); 4097 4131 4098 AutoCaller autoCaller(this); 4132 4099 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 4133 4100 4134 4101 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4102 4103 bool fNeedsGlobalSaveSettings = false; 4135 4104 4136 4105 HRESULT rc = checkStateDependency(MutableStateDep); … … 4140 4109 return setError(VBOX_E_INVALID_VM_STATE, 4141 4110 tr("Cannot delete settings of a registered machine")); 4111 4112 DeleteTask *pTask = new DeleteTask; 4113 pTask->pMachine = this; 4114 com::SafeIfaceArray<IMedium> sfaMedia(ComSafeArrayInArg(aMedia)); 4115 4116 // collect files to delete 4117 pTask->llFilesToDelete = mData->llFilesToDelete; // saved states pushed here by Unregister() 4118 for (size_t i = 0; i < sfaMedia.size(); ++i) 4119 { 4120 IMedium *pIMedium(sfaMedia[i]); 4121 Medium *pMedium = static_cast<Medium*>(pIMedium); 4122 AutoCaller mediumAutoCaller(pMedium); 4123 if (FAILED(mediumAutoCaller.rc())) return mediumAutoCaller.rc(); 4124 4125 Utf8Str bstrLocation = pMedium->getLocationFull(); 4126 // close the medium now; if that succeeds, then that means the medium is no longer 4127 // in use and we can add it to the list of files to delete 4128 rc = pMedium->close(&fNeedsGlobalSaveSettings, mediumAutoCaller); 4129 if (SUCCEEDED(rc)) 4130 pTask->llFilesToDelete.push_back(bstrLocation); 4131 } 4132 if (mData->pMachineConfigFile->fileExists()) 4133 pTask->llFilesToDelete.push_back(mData->m_strConfigFileFull); 4134 4135 pTask->pProgress.createObject(); 4136 pTask->pProgress->init(getVirtualBox(), 4137 this /* aInitiator */, 4138 Bstr(tr("Deleting files")), 4139 true /* fCancellable */, 4140 pTask->llFilesToDelete.size() + 1, // cOperations 4141 BstrFmt(tr("Deleting '%s'"), pTask->llFilesToDelete.front().c_str())); 4142 4143 int vrc = RTThreadCreate(NULL, 4144 Machine::deleteThread, 4145 (void*)pTask, 4146 0, 4147 RTTHREADTYPE_MAIN_WORKER, 4148 0, 4149 "MachineDelete"); 4150 4151 alock.release(); 4152 4153 if (fNeedsGlobalSaveSettings) 4154 { 4155 AutoWriteLock vboxlock(mParent COMMA_LOCKVAL_SRC_POS); 4156 mParent->saveSettings(); 4157 } 4158 4159 if (RT_FAILURE(vrc)) 4160 { 4161 delete pTask; 4162 return setError(E_FAIL, "Could not create MachineDelete thread (%Rrc)", vrc); 4163 } 4164 4165 pTask->pProgress.queryInterfaceTo(aProgress); 4166 4167 LogFlowFuncLeave(); 4168 4169 return S_OK; 4170 } 4171 4172 /** 4173 * Static task wrapper passed to RTThreadCreate() in Machine::Delete() which then 4174 * calls Machine::deleteTaskWorker() on the actual machine object. 4175 * @param Thread 4176 * @param pvUser 4177 * @return 4178 */ 4179 /*static*/ 4180 DECLCALLBACK(int) Machine::deleteThread(RTTHREAD Thread, void *pvUser) 4181 { 4182 LogFlowFuncEnter(); 4183 4184 DeleteTask *pTask = (DeleteTask*)pvUser; 4185 Assert(pTask); 4186 Assert(pTask->pMachine); 4187 Assert(pTask->pProgress); 4188 4189 HRESULT rc = pTask->pMachine->deleteTaskWorker(*pTask); 4190 pTask->pProgress->notifyComplete(rc); 4191 4192 delete pTask; 4193 4194 LogFlowFuncLeave(); 4195 4196 NOREF(Thread); 4197 4198 return VINF_SUCCESS; 4199 } 4200 4201 /** 4202 * Task thread implementation for Machine::Delete(), called from Machine::deleteThread(). 4203 * @param task 4204 * @return 4205 */ 4206 HRESULT Machine::deleteTaskWorker(DeleteTask &task) 4207 { 4208 AutoCaller autoCaller(this); 4209 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 4210 4211 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4142 4212 4143 4213 ULONG uLogHistoryCount = 3; … … 4147 4217 systemProperties->COMGETTER(LogHistoryCount)(&uLogHistoryCount); 4148 4218 4219 // delete the files pushed on the task list by Machine::Delete() 4220 // (this includes saved states of the machine and snapshots and 4221 // medium storage files from the IMedium list passed in, and the 4222 // machine XML file) 4223 std::list<Utf8Str>::const_iterator it = task.llFilesToDelete.begin(); 4224 while (it != task.llFilesToDelete.end()) 4225 { 4226 const Utf8Str &strFile = *it; 4227 LogFunc(("Deleting file %s\n", strFile.c_str())); 4228 RTFileDelete(strFile.c_str()); 4229 4230 ++it; 4231 if (it == task.llFilesToDelete.end()) 4232 { 4233 task.pProgress->SetNextOperation(Bstr(tr("Cleaning up machine directory")), 1); 4234 break; 4235 } 4236 4237 task.pProgress->SetNextOperation(BstrFmt(tr("Deleting '%s'"), it->c_str()), 1); 4238 } 4239 4149 4240 /* delete the settings only when the file actually exists */ 4150 4241 if (mData->pMachineConfigFile->fileExists()) 4151 4242 { 4152 int vrc = RTFileDelete(mData->m_strConfigFileFull.c_str());4153 if (RT_FAILURE(vrc))4154 return setError(VBOX_E_IPRT_ERROR,4155 tr("Could not delete the settings file '%s' (%Rrc)"),4156 mData->m_strConfigFileFull.raw(),4157 vrc);4158 4159 4243 /* Delete any backup or uncommitted XML files. Ignore failures. 4160 4244 See the fSafe parameter of xml::XmlFileWriter::write for details. */ … … 8652 8736 /** 8653 8737 * Goes thru all medium attachments of the list and calls detachDevice() on each 8654 * of them and attaches all Medium objects found in the process to the given list. 8738 * of them and attaches all Medium objects found in the process to the given list, 8739 * depending on cleanupMode. 8655 8740 * 8656 8741 * This gets called from Machine::Unregister, both for the actual Machine and … … 8660 8745 * 8661 8746 * @param writeLock Machine lock from top-level caller; this gets passed to detachDevice. 8662 * @param llMedia Caller's list to receive Medium objects which got detached so caller can close() them.8663 8747 * @param pSnapshot Must be NULL when called for a "real" Machine or a snapshot object if called for a SnapshotMachine. 8748 * @param cleanupMode If DetachAllReturnHardDisksOnly, only hard disk media get added to llMedia; if Full, then all media get added; 8749 * otherwise no media get added. 8750 * @param llMedia Caller's list to receive Medium objects which got detached so caller can close() them, depending on cleanupMode. 8664 8751 * @return 8665 8752 */ 8666 8753 HRESULT Machine::detachAllMedia(AutoWriteLock &writeLock, 8667 8754 Snapshot *pSnapshot, 8755 CleanupMode_T cleanupMode, 8668 8756 MediaList &llMedia) 8669 8757 { … … 8684 8772 8685 8773 if (!pMedium.isNull()) 8686 llMedia.push_back(pMedium); 8774 { 8775 DeviceType_T devType = pMedium->getDeviceType(); 8776 if ( ( cleanupMode == CleanupMode_DetachAllReturnHardDisksOnly 8777 && devType == DeviceType_HardDisk) 8778 || (cleanupMode == CleanupMode_Full) 8779 ) 8780 llMedia.push_back(pMedium); 8781 } 8687 8782 8688 8783 // real machine: then we need to use the proper method -
trunk/src/VBox/Main/MediumImpl.cpp
r31308 r31333 3867 3867 // we're accessing parent/child and backrefs, so lock the tree first, then ourselves 3868 3868 AutoMultiWriteLock2 multilock(&m->pVirtualBox->getMediaTreeLockHandle(), 3869 this->lockHandle() 3870 COMMA_LOCKVAL_SRC_POS); 3869 this->lockHandle() 3870 COMMA_LOCKVAL_SRC_POS); 3871 3872 LogFlowFunc(("ENTER for %s\n", getLocationFull().c_str())); 3871 3873 3872 3874 bool wasCreated = true; … … 3886 3888 if (m->backRefs.size() != 0) 3887 3889 return setError(VBOX_E_OBJECT_IN_USE, 3888 tr("Medium '%s' isattached to %d virtual machines"),3890 tr("Medium '%s' cannot be closed because it is still attached to %d virtual machines"), 3889 3891 m->strLocationFull.raw(), m->backRefs.size()); 3890 3892 … … 3908 3910 // of the medium tree cannot be guaranteed. 3909 3911 uninit(); 3912 3913 LogFlowFuncLeave(); 3910 3914 3911 3915 return rc; -
trunk/src/VBox/Main/ProgressImpl.cpp
r30714 r31333 1084 1084 AssertReturn(mCompleted == FALSE, E_FAIL); 1085 1085 1086 LogFunc(("aResultCode=%d\n", aResultCode)); 1087 1086 1088 if (mCanceled && SUCCEEDED(aResultCode)) 1087 1089 aResultCode = E_FAIL; … … 1105 1107 /* wake up all waiting threads */ 1106 1108 if (mWaitersCount > 0) 1107 RTSemEventMultiSignal 1109 RTSemEventMultiSignal(mCompletedSem); 1108 1110 1109 1111 return rc; -
trunk/src/VBox/Main/SnapshotImpl.cpp
r31307 r31333 828 828 * Caller must hold the machine write lock (which protects the snapshots tree!) 829 829 * 830 * @param writeLock Machine write lock, which can get released temporarily here. 831 * @param cleanupMode Cleanup mode; see Machine::detachAllMedia(). 832 * @param llMedia List of media returned to caller, depending on cleanupMode. 830 833 * @param llFilenames 831 834 * @return 832 835 */ 833 836 HRESULT Snapshot::uninitRecursively(AutoWriteLock &writeLock, 837 CleanupMode_T cleanupMode, 834 838 MediaList &llMedia, 835 839 std::list<Utf8Str> &llFilenames) … … 858 862 { 859 863 Snapshot *pChild = *it; 860 rc = pChild->uninitRecursively(writeLock, llMedia, llFilenames);864 rc = pChild->uninitRecursively(writeLock, cleanupMode, llMedia, llFilenames); 861 865 if (FAILED(rc)) 862 866 return rc; … … 866 870 rc = m->pMachine->detachAllMedia(writeLock, 867 871 this /* pSnapshot */, 872 cleanupMode, 868 873 llMedia); 869 874 if (FAILED(rc)) -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31332 r31333 2784 2784 </param> 2785 2785 <param name="aProgress" type="IProgress" dir="return"> 2786 <desc> </desc>2786 <desc>Progress object to track the operation completion.</desc> 2787 2787 </param> 2788 2788 </method> … … 2824 2824 2825 2825 <param name="aProgress" type="IProgress" dir="return"> 2826 <desc> </desc>2826 <desc>Progress object to track the operation completion.</desc> 2827 2827 </param> 2828 2828 </method> … … 3222 3222 to signal the completion of the progress object. 3223 3223 </desc> 3224 <param name=" progress" type="IProgress" dir="in"/>3224 <param name="aProgress" type="IProgress" dir="in" /> 3225 3225 </method> 3226 3226 … … 3636 3636 </interface> 3637 3637 3638 <enum name="CleanupMode" 3639 uuid="67897c50-7cca-47a9-83f6-ce8fd8eb5441"> 3640 <desc>Cleanup mode, used with <link to="IMachine::unregister" />. 3641 </desc> 3642 <const name="UnregisterOnly" value="1"> 3643 <desc>Unregister only the machine, but neither delete snapshots nor detach media.</desc> 3644 </const> 3645 <const name="DetachAllReturnNone" value="2"> 3646 <desc>Delete all snapshots and detach all media but return none; this will keep all media registered.</desc> 3647 </const> 3648 <const name="DetachAllReturnHardDisksOnly" value="3"> 3649 <desc>Delete all snapshots, detach all media and return hard disks for closing, but not removeable media.</desc> 3650 </const> 3651 <const name="Full" value="4"> 3652 <desc>Delete all snapshots, detach all media and return all media for closing.</desc> 3653 </const> 3654 </enum> 3655 3638 3656 <interface 3639 3657 name="IMachine" extends="$unknown" 3640 uuid=" e2d8679e-b144-41d9-9dfa-bbe2fd0ab2d1"3658 uuid="082c38ff-d9b3-4b12-b540-01516a931f17" 3641 3659 wsmap="managed" 3642 3660 > … … 3839 3857 Priority of the virtual CPUs. Means to limit the number of CPU cycles 3840 3858 a guest can use. The unit is percentage of host CPU cycles per second. 3841 The valid range is 1 - 100. 100 (the default) implies no limit. 3859 The valid range is 1 - 100. 100 (the default) implies no limit. 3842 3860 </desc> 3843 3861 </attribute> … … 5186 5204 <desc> 5187 5205 Unregisters the machine, which must have been previously registered using 5188 <link to="IVirtualBox::registerMachine"/>. 5189 5190 This method will succeed even if the machine currently has media attachments or 5191 is in the <link to="MachineState::Saved">Saved</link> state. In those cases, 5192 the caller receives the names of all files that have been made obsolete by the 5193 call in the @a aFiles array parameter. This list will consist of the saved 5194 state file and all storage files by media that were detached from the machine. 5195 5196 <note> 5197 The @a fAutoCleanup parameter is temporary to avoid substantial changes to the 5198 frontends in SVN trunk.It will go away before the 3.3 release and 5199 always be true then. If fAutoCleanup is false, the API currently behaves like 5200 the old VirtualBox::UnregisterMachine API. Cleaning up snapshots does not work 5201 yet, so the method will still fail if the machine has snapshots. 5202 </note> 5203 5204 The settings XML file of the machine object itself will not be included in that 5205 list; call <link to="#delete" /> for that. 5206 <link to="IVirtualBox::registerMachine"/>, and optionally do additional 5207 cleanup before the machine is unregistered. 5208 5209 This method does not delete any files. It only changes the machine configuration and 5210 the list of registered machines in the VirtualBox object. To delete the files which 5211 belonged to the machine, including the XML file of the machine itself, call 5212 <link to="#delete"/>, optionally with the array of IMedium objects that have been 5213 returned from this method. 5214 5215 Depending on the @a cleanupMode argument, the thoroughness with with this 5216 method cleans up the machine configuration before unregistering the machine 5217 will vary. 5218 5219 <ul> 5220 <li>With "UnregisterOnly", the machine will only be unregistered, but no additional 5221 cleanup will be performed. The call will fail if the machine is in "Saved" state 5222 or has any snapshots or any media attached (see <link to="IMediumAttachment" />. 5223 It is the responsibility of the caller to delete all such configuration in this mode. 5224 In this mode, the API behaves like the former @c IVirtualBox::unregisterMachine() API 5225 which it replaces.</li> 5226 <li>With "DetachAllReturnNone", the call will succeed even if the machine is in "Saved" 5227 state or if it has snapshots or media attached. All media attached to the current machine 5228 state or in snapshots will be detached. No medium objects will be closed or returned; all 5229 of the machine's media will remain opened.</li> 5230 <li>With "DetachAllReturnHardDisksOnly", the call will behave like with "DetachAllReturnNone", 5231 except that all the hard disk medium objects which were detached from the machine will 5232 be returned as an array. This allows for quickly passing them to the <link to="#delete" /> 5233 API for closing and deletion.</li> 5234 <li>With "Full", the call will behave like with "DetachAllReturnHardDisksOnly", except 5235 that all media will be returned in the array, including removeable media like DVDs and 5236 floppies. This might be useful if the user wants to inspect in detail which media were 5237 attached to the machine.</li> 5238 </ul> 5206 5239 5207 5240 The call will fail if the machine is currently locked (see <link to="ISession" />). … … 5209 5242 before unregistering it. 5210 5243 5211 After successful method invocation, 5212 the <link to="IMachineRegisteredEvent"/> eventis fired.5244 After successful method invocation, the <link to="IMachineRegisteredEvent"/> event 5245 is fired. 5213 5246 5214 5247 <note> … … 5220 5253 5221 5254 <result name="VBOX_E_INVALID_OBJECT_STATE"> 5222 Machine has snapshot or is locked. 5223 </result> 5224 </desc> 5225 5226 <param name="fAutoCleanup" type="boolean" dir="in"> 5227 <desc>If true, the method will automatically detach all media from the 5228 machine and its snapshots, call <link to="IMedium::close" /> on each 5229 medium, and the paths of all media files involved will be reported to 5230 the caller in the @a aFiles array so the caller can then delete the 5231 image files. 5232 If false, the method will fail if media attachments are present. 5233 </desc> 5234 </param> 5235 <param name="aFiles" type="wstring" safearray="yes" dir="return"> 5236 <desc> 5237 List of all files detached from medium attachments of the machine, if 5238 @a fCloseMedia is true. 5239 </desc> 5255 Machine is currently locked for a session. 5256 </result> 5257 </desc> 5258 5259 <param name="cleanupMode" type="CleanupMode" dir="in"> 5260 <desc>How to clean up after the machine has been unregistered.</desc> 5261 </param> 5262 <param name="aMedia" type="IMedium" safearray="yes" dir="return"> 5263 <desc>List of media detached from the machine, depending on the @a cleanupMode parameter.</desc> 5240 5264 </param> 5241 5265 </method> … … 5243 5267 <method name="delete"> 5244 5268 <desc> 5245 Deletes the settings (machine XML) file of this machine from disk. The machine 5246 must not be registered in order for this operation to succeed. 5269 Deletes the files associated with this machine from disk. If medium objects are passed 5270 in with the @a aMedia argument, they are closed and their storage files are deleted as well. 5271 For convenience, this array of media files can be the same as the one returned from 5272 a previous <a link="#unregister" /> call. 5273 5274 This method must only be called on machines which are either write-locked (i.e. on instances 5275 returned by <link to="ISession::machine"/>) or on unregistered machines (i.e. not yet 5276 registered machines created by <link to="IVirtualBox::createMachine"/> or opened by 5277 <link to="IVirtualBox::openMachine"/>, or after having called <link to="#unregister"/>). 5278 5279 The following files will be deleted by this method: 5280 <ul> 5281 <li>If <link to="#unregister" /> had been previously called with a @a cleanupMode 5282 argument other than "UnregisterOnly", this will delete all saved state files that 5283 the machine had in use; possibly one if the machine was in "Saved" state and one 5284 for each online snapshot that the machine had.</li> 5285 <li>On each medium object passed in the @a aMedia array, this will call 5286 <link to="IMedium::close" /> and then attempt to delete the medium's storage 5287 on disk. The close() call will fail if the medium is still in use, e.g. because 5288 it is still attached to a second machine.</li> 5289 <li>Finally, the machine's own XML file will be deleted.</li> 5290 </ul> 5291 5292 Since deleting large disk image files can be a time-consuming I/O operation, this 5293 method operates asynchronously and returns an IProgress object to allow the caller 5294 to monitor the progress. There will be one sub-operation for each file that is 5295 being deleted (saved state or medium storage file). 5296 5247 5297 <note> 5248 5298 <link to="#settingsModified"/> will return @c true after this 5249 5299 method successfully returns. 5250 5300 </note> 5251 <note>5252 Calling this method is only valid on instances returned5253 by <link to="ISession::machine"/> and on new machines5254 created by <link to="IVirtualBox::createMachine"/> or5255 opened by <link to="IVirtualBox::openMachine"/> but not5256 yet registered, or on unregistered machines after calling5257 <link to="IMachine::unregister"/>.5258 </note>5259 <note>5260 The deleted machine settings file can be restored (saved again)5261 by calling <link to="#saveSettings"/>.5262 </note>5263 5301 5264 5302 <result name="VBOX_E_INVALID_VM_STATE"> 5265 Cannot delete settings of a registered machine or 5266 machine not mutable. 5303 Machine is registered but not write-locked. 5267 5304 </result> 5268 5305 <result name="VBOX_E_IPRT_ERROR"> 5269 5306 Could not delete the settings file. 5270 5307 </result> 5271 5272 </desc> 5308 </desc> 5309 <param name="aMedia" type="IMedium" safearray="yes" dir="in"> 5310 <desc>List of media to be closed and whose storage files will be deleted.</desc> 5311 </param> 5312 <param name="aProgress" type="IProgress" dir="return"> 5313 <desc>Progress object to track the operation completion.</desc> 5314 </param> 5273 5315 </method> 5274 5316 5275 5317 <method name="export"> 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5318 <desc>Exports the machine to an OVF appliance. See <link to="IAppliance" /> for the 5319 steps required to export VirtualBox machines to OVF. 5320 </desc> 5321 5322 <param name="aAppliance" type="IAppliance" dir="in"> 5323 <desc>Appliance to export this machine to.</desc> 5324 </param> 5325 <param name="aDescription" type="IVirtualSystemDescription" dir="return"> 5326 <desc>VirtualSystemDescription object which is created for this machine.</desc> 5327 </param> 5286 5328 </method > 5287 5329 -
trunk/src/VBox/Main/include/MachineImpl.h
r31332 r31333 181 181 ComObjPtr<Snapshot> mFirstSnapshot; 182 182 ComObjPtr<Snapshot> mCurrentSnapshot; 183 184 // list of files to delete in Delete(); this list is filled by Unregister() 185 std::list<Utf8Str> llFilesToDelete; 183 186 }; 184 187 … … 484 487 STDMETHOD(SaveSettings)(); 485 488 STDMETHOD(DiscardSettings)(); 486 STDMETHOD(Unregister) (BOOL fAutoCleanup, ComSafeArrayOut(BSTR, aFiles));487 STDMETHOD(Delete)( );489 STDMETHOD(Unregister)(CleanupMode_T cleanupMode, ComSafeArrayOut(IMedium*, aMedia)); 490 STDMETHOD(Delete)(ComSafeArrayIn(IMedium*, aMedia), IProgress **aProgress); 488 491 STDMETHOD(Export)(IAppliance *aAppliance, IVirtualSystemDescription **aDescription); 489 492 STDMETHOD(GetSnapshot)(IN_BSTR aId, ISnapshot **aSnapshot); … … 782 785 HRESULT detachAllMedia(AutoWriteLock &writeLock, 783 786 Snapshot *pSnapshot, 787 CleanupMode_T cleanupMode, 784 788 MediaList &llMedia); 785 789 … … 792 796 void commit(); 793 797 void copyFrom(Machine *aThat); 798 799 struct DeleteTask; 800 static DECLCALLBACK(int) deleteThread(RTTHREAD Thread, void *pvUser); 801 HRESULT deleteTaskWorker(DeleteTask &task); 794 802 795 803 #ifdef VBOX_WITH_GUEST_PROPS -
trunk/src/VBox/Main/include/SnapshotImpl.h
r31228 r31333 125 125 126 126 HRESULT uninitRecursively(AutoWriteLock &writeLock, 127 CleanupMode_T cleanupMode, 127 128 MediaList &llMedia, 128 129 std::list<Utf8Str> &llFilenames); -
trunk/src/VBox/Main/testcase/tstOVF.cpp
r30956 r31333 349 349 350 350 RTPrintf(" Deleting machine %ls...\n", bstrUUID.raw()); 351 Safe Array<BSTR> sfaFiles;352 rc = pMachine->Unregister( true /* fDetachMedia */,353 ComSafeArrayAsOutParam(sfa Files));351 SafeIfaceArray<IMedium> sfaMedia; 352 rc = pMachine->Unregister(CleanupMode_DetachAllReturnHardDisksOnly, 353 ComSafeArrayAsOutParam(sfaMedia)); 354 354 if (FAILED(rc)) throw MyError(rc, "Machine::Unregister() failed\n"); 355 355 356 for (size_t u = 0; 357 u < sfaFiles.size(); 358 ++u) 359 { 360 RTPrintf(" UnregisterMachine reported disk image %ls\n", sfaFiles[u]); 361 llFiles2Delete.push_back(sfaFiles[u]); 362 } 363 364 rc = pMachine->Delete(); 356 ComPtr<IProgress> pProgress; 357 rc = pMachine->Delete(ComSafeArrayAsInParam(sfaMedia), pProgress.asOutParam()); 365 358 if (FAILED(rc)) throw MyError(rc, "Machine::DeleteSettings() failed\n"); 359 rc = pProgress->WaitForCompletion(-1); 360 if (FAILED(rc)) throw MyError(rc, "Progress::WaitForCompletion() failed\n"); 366 361 } 367 362 } -
trunk/src/VBox/Main/webservice/websrv-cpp.xsl
r30577 r31333 568 568 <xsl:call-template name="emitNewlineIndent8" /> 569 569 <xsl:value-of select="concat(' IUnknown *tmpObject2(tmpObject); tmpObject2->AddRef(); comcall_', $name, '[i] = tmpObject;')" /> 570 </xsl:when> 571 <xsl:when test="//interface[@name=$type]"> 572 <xsl:value-of select="concat(' ComPtr<', $type, '> tmpObject;')" /> 573 <xsl:call-template name="emitNewlineIndent8" /> 574 <xsl:value-of select="concat(' if ((rc = findComPtrFromId(soap, ', $structprefix, $name, '[i], tmpObject, true)))')" /> 575 <xsl:call-template name="emitNewlineIndent8" /> 576 <xsl:text> break;</xsl:text> 577 <xsl:call-template name="emitNewlineIndent8" /> 578 <xsl:value-of select="concat(' ', $type, ' *tmpObject2(tmpObject); tmpObject2->AddRef(); comcall_', $name, '[i] = tmpObject;')" /> 570 579 </xsl:when> 571 580 <xsl:when test="$type='wstring'">
Note:
See TracChangeset
for help on using the changeset viewer.