Changeset 30929 in vbox
- Timestamp:
- Jul 20, 2010 2:11:51 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 12 edited
-
Frontends/VBoxManage/VBoxManageMisc.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp (modified) (1 diff)
-
Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp (modified) (1 diff)
-
Main/ApplianceImplImport.cpp (modified) (3 diffs)
-
Main/MachineImpl.cpp (modified) (5 diffs)
-
Main/MediumImpl.cpp (modified) (6 diffs)
-
Main/VirtualBoxImpl.cpp (modified) (3 diffs)
-
Main/idl/VirtualBox.xidl (modified) (1 diff)
-
Main/include/MachineImpl.h (modified) (1 diff)
-
Main/include/MediumImpl.h (modified) (2 diffs)
-
Main/include/VirtualBoxImpl.h (modified) (2 diffs)
-
Main/testcase/tstOVF.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r30681 r30929 162 162 machine->COMGETTER(Id)(uuid.asOutParam()); 163 163 machine = NULL; 164 CHECK_ERROR(a->virtualBox, UnregisterMachine(uuid, machine.asOutParam())); 164 SafeArray<BSTR> abstrFiles; 165 CHECK_ERROR(a->virtualBox, UnregisterMachine(uuid, 166 false /* fDetachMedia */, 167 ComSafeArrayAsOutParam(abstrFiles), 168 machine.asOutParam())); 165 169 if (SUCCEEDED(rc) && machine && fDelete) 166 170 CHECK_ERROR(machine, DeleteSettings()); -
trunk/src/VBox/Frontends/VirtualBox/src/selector/VBoxSelectorWnd.cpp
r30868 r30929 679 679 if (ok) 680 680 { 681 CMachine machine = item->machine(); 682 vbox.UnregisterMachine (id); 681 QVector<QString> files; 682 CMachine machine; 683 vbox.UnregisterMachine(id, false /*fDetachMedia*/, files, machine); 683 684 if (vbox.isOk() && item->accessible()) 684 685 { -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UINewVMWzd.cpp
r30210 r30929 782 782 { 783 783 /* Unregister on failure */ 784 vbox.UnregisterMachine(machineId); 784 QVector<QString> files; 785 CMachine machine; 786 vbox.UnregisterMachine(machineId, false /*fDetachMedia*/, files, machine); 785 787 if (vbox.isOk()) 786 788 m_Machine.DeleteSettings(); -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r30881 r30929 1228 1228 HRESULT rc2; 1229 1229 // detach all hard disks from all machines we created 1230 list<MyHardDiskAttachment>::iterator itM; 1231 for (itM = stack.llHardDiskAttachments.begin(); 1230 for (list<MyHardDiskAttachment>::iterator itM = stack.llHardDiskAttachments.begin(); 1232 1231 itM != stack.llHardDiskAttachments.end(); 1233 1232 ++itM) … … 1250 1249 1251 1250 // now clean up all hard disks we created 1252 list< ComPtr<IMedium> >::iterator itHD; 1253 for (itHD = stack.llHardDisksCreated.begin(); 1251 for (list< ComPtr<IMedium> >::iterator itHD = stack.llHardDisksCreated.begin(); 1254 1252 itHD != stack.llHardDisksCreated.end(); 1255 1253 ++itHD) … … 1269 1267 Bstr bstrGuid = guid.toUtf16(); 1270 1268 ComPtr<IMachine> failedMachine; 1271 rc2 = mVirtualBox->UnregisterMachine(bstrGuid, failedMachine.asOutParam()); 1269 SafeArray<BSTR> abstrPaths; 1270 rc2 = mVirtualBox->UnregisterMachine(bstrGuid, false, ComSafeArrayAsOutParam(abstrPaths), failedMachine.asOutParam()); 1272 1271 if (SUCCEEDED(rc2)) 1273 1272 rc2 = failedMachine->DeleteSettings(); -
trunk/src/VBox/Main/MachineImpl.cpp
r30882 r30929 5919 5919 5920 5920 /** 5921 * Checks that the registered flag of the machine can be set according to 5922 * the argument and sets it. On success, commits and saves all settings. 5923 * 5924 * @note When this machine is inaccessible, the only valid value for \a 5925 * aRegistered is FALSE (i.e. unregister the machine) because unregistered 5926 * inaccessible machines are not currently supported. Note that unregistering 5927 * an inaccessible machine will \b uninitialize this machine object. Therefore, 5928 * the caller must make sure there are no active Machine::addCaller() calls 5929 * on the current thread because this will block Machine::uninit(). 5921 * Checks whether the machine can be registered. If so, commits and saves 5922 * all settings. 5930 5923 * 5931 5924 * @note Must be called from mParent's write lock. Locks this object and 5932 5925 * children for writing. 5933 5926 */ 5934 HRESULT Machine:: trySetRegistered(BOOL argNewRegistered)5927 HRESULT Machine::prepareRegister() 5935 5928 { 5936 5929 AssertReturn(mParent->isWriteLockOnCurrentThread(), E_FAIL); … … 5944 5937 ensureNoStateDependencies(); 5945 5938 5946 ComAssertRet(mData->mRegistered != argNewRegistered, E_FAIL);5947 5948 5939 if (!mData->mAccessible) 5949 { 5950 /* A special case: the machine is not accessible. */ 5951 5952 /* inaccessible machines can only be unregistered */ 5953 AssertReturn(!argNewRegistered, E_FAIL); 5954 5955 /* Uninitialize ourselves here because currently there may be no 5956 * unregistered that are inaccessible (this state combination is not 5957 * supported). Note releasing the caller and leaving the lock before 5958 * calling uninit() */ 5959 5960 alock.leave(); 5961 autoCaller.release(); 5962 5963 uninit(); 5964 5965 return S_OK; 5966 } 5940 return setError(VBOX_E_INVALID_OBJECT_STATE, 5941 tr("The machine '%ls' with UUID {%s} is inaccessible and cannot be registered"), 5942 mUserData->mName.raw(), 5943 mData->mUuid.toString().raw()); 5967 5944 5968 5945 AssertReturn(autoCaller.state() == Ready, E_FAIL); 5969 5946 5970 if (argNewRegistered) 5971 { 5972 if (mData->mRegistered) 5973 return setError(VBOX_E_INVALID_OBJECT_STATE, 5974 tr("The machine '%ls' with UUID {%s} is already registered"), 5975 mUserData->mName.raw(), 5976 mData->mUuid.toString().raw()); 5977 } 5978 else 5979 { 5980 if (mData->mMachineState == MachineState_Saved) 5981 return setError(VBOX_E_INVALID_VM_STATE, 5982 tr("Cannot unregister the machine '%ls' because it is in the Saved state"), 5983 mUserData->mName.raw()); 5984 5985 size_t snapshotCount = 0; 5986 if (mData->mFirstSnapshot) 5987 snapshotCount = mData->mFirstSnapshot->getAllChildrenCount() + 1; 5988 if (snapshotCount) 5989 return setError(VBOX_E_INVALID_OBJECT_STATE, 5990 tr("Cannot unregister the machine '%ls' because it has %d snapshots"), 5991 mUserData->mName.raw(), snapshotCount); 5992 5993 if (mData->mSession.mState != SessionState_Closed) 5994 return setError(VBOX_E_INVALID_OBJECT_STATE, 5995 tr("Cannot unregister the machine '%ls' because it has an open session"), 5996 mUserData->mName.raw()); 5997 5998 if (mMediaData->mAttachments.size() != 0) 5999 return setError(VBOX_E_INVALID_OBJECT_STATE, 6000 tr("Cannot unregister the machine '%ls' because it has %d medium attachments"), 6001 mUserData->mName.raw(), 6002 mMediaData->mAttachments.size()); 6003 6004 /* Note that we do not prevent unregistration of a DVD or Floppy image 6005 * is attached: as opposed to hard disks detaching such an image 6006 * implicitly in this method (which we will do below) won't have any 6007 * side effects (like detached orphan base and diff hard disks etc).*/ 6008 } 5947 if (mData->mRegistered) 5948 return setError(VBOX_E_INVALID_OBJECT_STATE, 5949 tr("The machine '%ls' with UUID {%s} is already registered"), 5950 mUserData->mName.raw(), 5951 mData->mUuid.toString().raw()); 6009 5952 6010 5953 HRESULT rc = S_OK; … … 6013 5956 // no config file exists yet, create it by calling saveSettings() too. 6014 5957 if ( (mData->flModifications) 6015 || ( argNewRegistered &&!mData->pMachineConfigFile->fileExists())5958 || (!mData->pMachineConfigFile->fileExists()) 6016 5959 ) 6017 5960 { … … 6029 5972 commit(); 6030 5973 6031 mData->mRegistered = argNewRegistered;5974 mData->mRegistered = true; 6032 5975 } 6033 5976 else … … 6038 5981 6039 5982 return rc; 5983 } 5984 5985 /** 5986 * Called from VirtualBox::UnregisterMachine() with the flags given there to 5987 * give the machine a chance to clean up for itself. 5988 * @param fDetachMedia As passed to VirtualBox::UnregisterMachine(). If true, all 5989 * media are detached from the machine and its snapshots. 5990 * @param llFiles 5991 * @return 5992 */ 5993 HRESULT Machine::prepareUnregister(bool fCloseMedia, 5994 MediaList &llMedia) 5995 { 5996 AutoLimitedCaller autoCaller(this); 5997 AssertComRCReturnRC(autoCaller.rc()); 5998 5999 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 6000 6001 if (mData->mSession.mState != SessionState_Closed) 6002 return setError(VBOX_E_INVALID_OBJECT_STATE, 6003 tr("Cannot unregister the machine '%ls' because it has an open session"), 6004 mUserData->mName.raw()); 6005 6006 // @todo optionally discard saved state 6007 if (mData->mMachineState == MachineState_Saved) 6008 return setError(VBOX_E_INVALID_VM_STATE, 6009 tr("Cannot unregister the machine '%ls' because it is in the Saved state"), 6010 mUserData->mName.raw()); 6011 6012 // @todo optionally nuke snapshots 6013 size_t snapshotCount = 0; 6014 if (mData->mFirstSnapshot) 6015 snapshotCount = mData->mFirstSnapshot->getAllChildrenCount() + 1; 6016 if (snapshotCount) 6017 return setError(VBOX_E_INVALID_OBJECT_STATE, 6018 tr("Cannot unregister the machine '%ls' because it has %d snapshots"), 6019 mUserData->mName.raw(), snapshotCount); 6020 6021 if (fCloseMedia) 6022 { 6023 // caller wants automatic detachment: then do that and report all media to the array 6024 MediaData::AttachmentList::iterator it = mMediaData->mAttachments.begin(); 6025 while (it != mMediaData->mAttachments.end()) 6026 { 6027 ComObjPtr<MediumAttachment> pAttach = *it; 6028 ComObjPtr<Medium> pMedium = pAttach->getMedium(); 6029 6030 if (!pMedium.isNull()) 6031 llMedia.push_back(pMedium); 6032 6033 setModified(IsModified_Storage); 6034 mMediaData.backup(); 6035 6036 // for non-hard disk media, detach straight away 6037 // (same logic as in DetachDevice()) 6038 if (!pMedium.isNull()) 6039 pMedium->detachFrom(mData->mUuid); 6040 6041 // remove this attachment; erase() returns the iterator of the next element 6042 it = mMediaData->mAttachments.erase(it); 6043 } 6044 } 6045 else 6046 // caller wants no automatic detachment: then fail if there are any 6047 if (mMediaData->mAttachments.size()) 6048 return setError(VBOX_E_INVALID_OBJECT_STATE, 6049 tr("Cannot unregister the machine '%ls' because it has %d media attachments"), 6050 mMediaData->mAttachments.size()); 6051 6052 mData->mRegistered = false; 6053 6054 return S_OK; 6040 6055 } 6041 6056 -
trunk/src/VBox/Main/MediumImpl.cpp
r30764 r30929 1904 1904 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1905 1905 1906 // we're accessing parent/child and backrefs, so lock the tree first, then ourselves1907 AutoMultiWriteLock2 multilock(&m->pVirtualBox->getMediaTreeLockHandle(),1908 this->lockHandle()1909 COMMA_LOCKVAL_SRC_POS);1910 1911 bool wasCreated = true;1912 bool fNeedsSaveSettings = false;1913 1914 switch (m->state)1915 {1916 case MediumState_NotCreated:1917 wasCreated = false;1918 break;1919 case MediumState_Created:1920 case MediumState_Inaccessible:1921 break;1922 default:1923 return setStateError();1924 }1925 1926 if (m->backRefs.size() != 0)1927 return setError(VBOX_E_OBJECT_IN_USE,1928 tr("Medium '%s' is attached to %d virtual machines"),1929 m->strLocationFull.raw(), m->backRefs.size());1930 1931 /* perform extra media-dependent close checks */1932 HRESULT rc = canClose();1933 if (FAILED(rc)) return rc;1934 1935 if (wasCreated)1936 {1937 /* remove from the list of known media before performing actual1938 * uninitialization (to keep the media registry consistent on1939 * failure to do so) */1940 rc = unregisterWithVirtualBox(&fNeedsSaveSettings);1941 if (FAILED(rc)) return rc;1942 }1943 1944 1906 // make a copy of VirtualBox pointer which gets nulled by uninit() 1945 1907 ComObjPtr<VirtualBox> pVirtualBox(m->pVirtualBox); 1946 1908 1947 // leave the AutoCaller, as otherwise uninit() will simply hang 1948 autoCaller.release(); 1949 1950 /* Keep the locks held until after uninit, as otherwise the consistency 1951 * of the medium tree cannot be guaranteed. */ 1952 uninit(); 1953 1954 multilock.release(); 1909 bool fNeedsSaveSettings = false; 1910 HRESULT rc = close(&fNeedsSaveSettings, autoCaller); 1955 1911 1956 1912 if (fNeedsSaveSettings) … … 1960 1916 } 1961 1917 1962 return S_OK;1918 return rc; 1963 1919 } 1964 1920 … … 3820 3776 } 3821 3777 } 3778 3779 return rc; 3780 } 3781 3782 /** 3783 * Implementation for the public Medium::Close() with the exception of calling 3784 * VirtualBox::saveSettings(), in case someone wants to call this for several 3785 * media. 3786 * 3787 * After this returns with success, uninit() has been called on the medium, and 3788 * the object is no longer usable ("not ready" state). 3789 * 3790 * @param pfNeedsSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3791 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3792 * This only works in "wait" mode; otherwise saveSettings gets called automatically by the thread that was created, 3793 * and this parameter is ignored. 3794 * @param autoCaller AutoCaller instance which must have been created on the caller's stack for this medium. This gets released here 3795 * upon which the Medium instance gets uninitialized. 3796 * @return 3797 */ 3798 HRESULT Medium::close(bool *pfNeedsSaveSettings, AutoCaller &autoCaller) 3799 { 3800 // we're accessing parent/child and backrefs, so lock the tree first, then ourselves 3801 AutoMultiWriteLock2 multilock(&m->pVirtualBox->getMediaTreeLockHandle(), 3802 this->lockHandle() 3803 COMMA_LOCKVAL_SRC_POS); 3804 3805 bool wasCreated = true; 3806 3807 switch (m->state) 3808 { 3809 case MediumState_NotCreated: 3810 wasCreated = false; 3811 break; 3812 case MediumState_Created: 3813 case MediumState_Inaccessible: 3814 break; 3815 default: 3816 return setStateError(); 3817 } 3818 3819 if (m->backRefs.size() != 0) 3820 return setError(VBOX_E_OBJECT_IN_USE, 3821 tr("Medium '%s' is attached to %d virtual machines"), 3822 m->strLocationFull.raw(), m->backRefs.size()); 3823 3824 // perform extra media-dependent close checks 3825 HRESULT rc = canClose(); 3826 if (FAILED(rc)) return rc; 3827 3828 if (wasCreated) 3829 { 3830 // remove from the list of known media before performing actual 3831 // uninitialization (to keep the media registry consistent on 3832 // failure to do so) 3833 rc = unregisterWithVirtualBox(pfNeedsSaveSettings); 3834 if (FAILED(rc)) return rc; 3835 } 3836 3837 // leave the AutoCaller, as otherwise uninit() will simply hang 3838 autoCaller.release(); 3839 3840 // Keep the locks held until after uninit, as otherwise the consistency 3841 // of the medium tree cannot be guaranteed. 3842 uninit(); 3822 3843 3823 3844 return rc; … … 4789 4810 4790 4811 /** 4812 * Performs extra checks if the medium can be closed and returns S_OK in 4813 * this case. Otherwise, returns a respective error message. Called by 4814 * Close() under the medium tree lock and the medium lock. 4815 * 4791 4816 * @note Also reused by Medium::Reset(). 4792 4817 * … … 4806 4831 4807 4832 /** 4808 * Calls either VirtualBox::unregisterImage or VirtualBox::unregisterHardDisk depending 4833 * Unregisters this medium with mVirtualBox. Called by close() under the medium tree lock. 4834 * 4835 * This calls either VirtualBox::unregisterImage or VirtualBox::unregisterHardDisk depending 4809 4836 * on the device type of this medium. 4810 4837 * … … 4850 4877 if (pParentBackup) 4851 4878 { 4852 /* re-associate with the parent as we are still relatives in the 4853 * registry */ 4879 // re-associate with the parent as we are still relatives in the registry 4854 4880 m->pParent = pParentBackup; 4855 4881 m->pParent->m->llChildren.push_back(this); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r30882 r30929 1367 1367 1368 1368 /** @note Locks objects! */ 1369 STDMETHODIMP VirtualBox::UnregisterMachine(IN_BSTR aId, 1369 STDMETHODIMP VirtualBox::UnregisterMachine(IN_BSTR aId, 1370 BOOL fCloseMedia, 1371 ComSafeArrayOut(BSTR, aFiles), 1370 1372 IMachine **aMachine) 1371 1373 { … … 1382 1384 if (FAILED(rc)) return rc; 1383 1385 1384 // trySetRegistered needs VirtualBox object write lock1385 1386 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1386 rc = pMachine->trySetRegistered(FALSE); 1387 1388 MediaList llMedia; 1389 rc = pMachine->prepareUnregister(fCloseMedia, llMedia); 1387 1390 if (FAILED(rc)) return rc; 1388 1391 1389 / * remove from the collection of registered machines */1392 // remove from the collection of registered machines 1390 1393 m->allMachines.removeChild(pMachine); 1391 1394 1392 /* save the global registry */ 1395 if (fCloseMedia) 1396 { 1397 // now go thru the list of attached media reported by prepareUnregister() and close them all 1398 SafeArray<BSTR> sfaFiles(llMedia.size()); 1399 size_t u = 0; 1400 for (MediaList::const_iterator it = llMedia.begin(); 1401 it != llMedia.end(); 1402 ++it) 1403 { 1404 ComObjPtr<Medium> pMedium = *it; 1405 Bstr bstrFile = pMedium->getLocationFull(); 1406 1407 AutoCaller autoCaller2(pMedium); 1408 if (FAILED(autoCaller2.rc())) return autoCaller2.rc(); 1409 1410 pMedium->close(NULL /*fNeedsSaveSettings*/, // we'll call saveSettings() in any case below 1411 autoCaller2); 1412 // this uninitializes the medium 1413 1414 // report the path to the caller 1415 bstrFile.detachTo(&sfaFiles[u]); 1416 ++u; 1417 } 1418 // report all paths to the caller 1419 sfaFiles.detachTo(ComSafeArrayOutArg(aFiles)); 1420 } 1421 1422 // save the global registry 1393 1423 rc = saveSettings(); 1394 1424 … … 3544 3574 if (autoCaller.state() != InInit) 3545 3575 { 3546 rc = aMachine-> trySetRegistered(TRUE);3576 rc = aMachine->prepareRegister(); 3547 3577 if (FAILED(rc)) return rc; 3548 3578 } -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r30881 r30929 1742 1742 Machine has snapshot or open session or medium attached. 1743 1743 </result> 1744 1745 </desc> 1744 </desc> 1745 1746 1746 <param name="id" type="uuid" mod="string" dir="in"> 1747 1747 <desc>UUID of the machine to unregister.</desc> 1748 1748 </param> 1749 <param name="machine" type="IMachine" dir="return"> 1749 <param name="fCloseMedia" type="boolean" dir="in"> 1750 <desc>If true, the method will automatically detach all media from the 1751 machine and its snapshots, call <link to="IMedium::close" /> on each 1752 medium, and the paths of all media files involved will be reported to 1753 the caller in the @a aFiles array so the caller can then delete the 1754 image files. 1755 If false, the method will fail if media attachments are present.</desc> 1756 </param> 1757 <param name="aFiles" type="wstring" safearray="yes" dir="out"> 1758 <desc> 1759 List of all files detached from medium attachments of the machine, if 1760 @a fDetachMedia is true. 1761 </desc> 1762 </param> 1763 <param name="machine" type="IMachine" dir="out"> 1750 1764 <desc>Unregistered machine object.</desc> 1751 1765 </param> -
trunk/src/VBox/Main/include/MachineImpl.h
r30847 r30929 682 682 bool checkForSpawnFailure(); 683 683 684 HRESULT trySetRegistered(BOOL aRegistered); 684 HRESULT prepareRegister(); 685 HRESULT prepareUnregister(bool fDetachMedia, MediaList &llMedia); 685 686 686 687 HRESULT getSharedFolder(CBSTR aName, -
trunk/src/VBox/Main/include/MediumImpl.h
r30764 r30929 198 198 bool *pfNeedsSaveSettings); 199 199 200 HRESULT close(bool *pfNeedsSaveSettings, AutoCaller &autoCaller); 200 201 HRESULT deleteStorage(ComObjPtr<Progress> *aProgress, bool aWait, bool *pfNeedsSaveSettings); 201 202 HRESULT markForDeletion(); … … 232 233 HRESULT queryInfo(); 233 234 234 /**235 * Performs extra checks if the medium can be closed and returns S_OK in236 * this case. Otherwise, returns a respective error message. Called by237 * Close() under the medium tree lock and the medium lock.238 */239 235 HRESULT canClose(); 240 241 /**242 * Unregisters this medium with mVirtualBox. Called by Close() under243 * the medium tree lock.244 */245 236 HRESULT unregisterWithVirtualBox(bool *pfNeedsSaveSettings); 246 237 -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r30847 r30929 100 100 101 101 /* IVirtualBox properties */ 102 STDMETHOD(COMGETTER(Version)) (BSTR *aVersion);103 STDMETHOD(COMGETTER(Revision)) (ULONG *aRevision);104 STDMETHOD(COMGETTER(PackageType)) (BSTR *aPackageType);105 STDMETHOD(COMGETTER(HomeFolder)) (BSTR *aHomeFolder);106 STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aSettingsFilePath);107 STDMETHOD(COMGETTER(Host)) (IHost **aHost);108 STDMETHOD(COMGETTER(SystemProperties)) (ISystemProperties **aSystemProperties);109 STDMETHOD(COMGETTER(Machines)) (ComSafeArrayOut(IMachine *, aMachines));110 STDMETHOD(COMGETTER(HardDisks)) (ComSafeArrayOut(IMedium *, aHardDisks));111 STDMETHOD(COMGETTER(DVDImages)) (ComSafeArrayOut(IMedium *, aDVDImages));112 STDMETHOD(COMGETTER(FloppyImages)) (ComSafeArrayOut(IMedium *, aFloppyImages));113 STDMETHOD(COMGETTER(ProgressOperations)) (ComSafeArrayOut(IProgress *, aOperations));114 STDMETHOD(COMGETTER(GuestOSTypes)) (ComSafeArrayOut(IGuestOSType *, aGuestOSTypes));115 STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut(ISharedFolder *, aSharedFolders));116 STDMETHOD(COMGETTER(PerformanceCollector)) (IPerformanceCollector **aPerformanceCollector);117 STDMETHOD(COMGETTER(DHCPServers)) (ComSafeArrayOut(IDHCPServer *, aDHCPServers));118 STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource);102 STDMETHOD(COMGETTER(Version)) (BSTR *aVersion); 103 STDMETHOD(COMGETTER(Revision)) (ULONG *aRevision); 104 STDMETHOD(COMGETTER(PackageType)) (BSTR *aPackageType); 105 STDMETHOD(COMGETTER(HomeFolder)) (BSTR *aHomeFolder); 106 STDMETHOD(COMGETTER(SettingsFilePath)) (BSTR *aSettingsFilePath); 107 STDMETHOD(COMGETTER(Host)) (IHost **aHost); 108 STDMETHOD(COMGETTER(SystemProperties)) (ISystemProperties **aSystemProperties); 109 STDMETHOD(COMGETTER(Machines)) (ComSafeArrayOut(IMachine *, aMachines)); 110 STDMETHOD(COMGETTER(HardDisks)) (ComSafeArrayOut(IMedium *, aHardDisks)); 111 STDMETHOD(COMGETTER(DVDImages)) (ComSafeArrayOut(IMedium *, aDVDImages)); 112 STDMETHOD(COMGETTER(FloppyImages)) (ComSafeArrayOut(IMedium *, aFloppyImages)); 113 STDMETHOD(COMGETTER(ProgressOperations)) (ComSafeArrayOut(IProgress *, aOperations)); 114 STDMETHOD(COMGETTER(GuestOSTypes)) (ComSafeArrayOut(IGuestOSType *, aGuestOSTypes)); 115 STDMETHOD(COMGETTER(SharedFolders)) (ComSafeArrayOut(ISharedFolder *, aSharedFolders)); 116 STDMETHOD(COMGETTER(PerformanceCollector)) (IPerformanceCollector **aPerformanceCollector); 117 STDMETHOD(COMGETTER(DHCPServers)) (ComSafeArrayOut(IDHCPServer *, aDHCPServers)); 118 STDMETHOD(COMGETTER(EventSource)) (IEventSource ** aEventSource); 119 119 120 120 /* IVirtualBox methods */ … … 128 128 STDMETHOD(GetMachine) (IN_BSTR aId, IMachine **aMachine); 129 129 STDMETHOD(FindMachine) (IN_BSTR aName, IMachine **aMachine); 130 STDMETHOD(UnregisterMachine) (IN_BSTR aId, IMachine **aMachine);130 STDMETHOD(UnregisterMachine) (IN_BSTR aId, BOOL fCloseMedia, ComSafeArrayOut(BSTR, aFiles), IMachine **aMachine); 131 131 STDMETHOD(CreateAppliance) (IAppliance **anAppliance); 132 132 -
trunk/src/VBox/Main/testcase/tstOVF.cpp
r30883 r30929 238 238 if (FAILED(rc)) throw MyError(rc, "Progress::WaitForCompletion() failed\n"); 239 239 pProgress->COMGETTER(ResultCode)(&rc2); 240 if (FAILED(rc2)) throw MyError(rc2, " Progress::GetResultCode() failed\n");240 if (FAILED(rc2)) throw MyError(rc2, "Appliance::ImportMachines() failed\n", pProgress); 241 241 242 242 com::SafeArray<BSTR> aMachineUUIDs; … … 262 262 * @param pcszDest Target for dummy VMDK. 263 263 */ 264 void copyDummyDiskImage(std::list<Utf8Str> &llFiles2Delete, const char *pcszDest) 264 void copyDummyDiskImage(const char *pcszPrefix, 265 std::list<Utf8Str> &llFiles2Delete, 266 const char *pcszDest) 265 267 { 268 RTPrintf("%s: copying ovf-dummy.vmdk to \"%s\"...\n", pcszPrefix, pcszDest); 269 266 270 int vrc = RTFileCopy("ovf-testcases/ovf-dummy.vmdk", pcszDest); 267 271 if (RT_FAILURE(vrc)) throw MyError(0, Utf8StrFmt("Cannot copy ovf-dummy.vmdk to %s: %Rra\n", pcszDest, vrc).c_str()); … … 306 310 307 311 // testcase 1: import ovf-joomla-0.9/joomla-1.1.4-ovf.ovf 308 copyDummyDiskImage( llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk");309 copyDummyDiskImage( llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-1.vmdk");312 copyDummyDiskImage("joomla-0.9", llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-0.vmdk"); 313 copyDummyDiskImage("joomla-0.9", llFiles2Delete, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf-1.vmdk"); 310 314 importOVF("joomla-0.9", pVirtualBox, "ovf-testcases/ovf-joomla-0.9/joomla-1.1.4-ovf.ovf", llMachinesCreated); 311 315 312 316 // testcase 2: import ovf-winxp-vbox-sharedfolders/winxp.ovf 313 copyDummyDiskImage( llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/Windows 5.1 XP 1 merged.vmdk");314 copyDummyDiskImage( llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/smallvdi.vmdk");317 copyDummyDiskImage("winxp-vbox-sharedfolders", llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/Windows 5.1 XP 1 merged.vmdk"); 318 copyDummyDiskImage("winxp-vbox-sharedfolders", llFiles2Delete, "ovf-testcases/ovf-winxp-vbox-sharedfolders/smallvdi.vmdk"); 315 319 importOVF("winxp-vbox-sharedfolders", pVirtualBox, "ovf-testcases/ovf-winxp-vbox-sharedfolders/winxp.ovf", llMachinesCreated); 316 320 … … 330 334 ++it) 331 335 { 332 // const Guid &uuid = *it; 333 // Bstr bstrUUID(uuid.toUtf16()); 334 // ComPtr<IMachine> pMachine; 335 // rc = pVirtualBox->GetMachine(bstrUUID, pMachine.asOutParam()); 336 // if (FAILED(rc)) throw MyError(rc, "VirtualBox::FindMachine() failed\n"); 337 // 338 // SafeIfaceArray<IMediumAttachment> aMediumAttachments; 339 // rc = pMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(aMediumAttachments)); 340 // if (FAILED(rc)) throw MyError(rc, "Machine::MediumAttachments() failed\n"); 341 // 342 // for (size_t u2 = 0; 343 // u2 < aMediumAttachments.size(); 344 // ++u2) 345 // { 346 // ComPtr<IMediumAttachment> pMediumAttachment(aMediumAttachments[u2]); 347 // ComPtr<IMedium> pMedium; 348 // rc = pMediumAttachment->COMGETTER(Medium)(pMedium.asOutParam()); 349 // if (FAILED(rc)) throw MyError(rc, "MediumAttachment::GetMedium() failed\n"); 350 // 351 // if (!pMedium.isNull()) 352 // { 353 // Bstr bstrLocation; 354 // rc = pMedium->COMGETTER(Location)(bstrLocation.asOutParam()); 355 // if (FAILED(rc)) throw MyError(rc, "Medium::GetLocation() failed\n"); 356 // 357 // llFiles2Delete.push_back(bstrLocation); 358 // } 359 // } 360 361 // RTPrintf(" Deleting machine %ls...\n", bstrUUID.raw()); 362 // pVirtualBox->UnregisterMachine(bstrUUID, pMachine.asOutParam()); 363 // if (FAILED(rc)) throw MyError(rc, "VirtualBox::UnregisterMachine() failed\n"); 364 // 365 // if (!pMachine.isNull()) 366 // { 367 // rc = pMachine->DeleteSettings(); 368 // if (FAILED(rc)) throw MyError(rc, "Machine::DeleteSettings() failed\n"); 369 // } 336 const Guid &uuid = *it; 337 Bstr bstrUUID(uuid.toUtf16()); 338 ComPtr<IMachine> pMachine; 339 rc = pVirtualBox->GetMachine(bstrUUID, pMachine.asOutParam()); 340 if (FAILED(rc)) throw MyError(rc, "VirtualBox::FindMachine() failed\n"); 341 342 RTPrintf(" Deleting machine %ls...\n", bstrUUID.raw()); 343 SafeArray<BSTR> sfaFiles; 344 rc = pVirtualBox->UnregisterMachine(bstrUUID, 345 true /* fDetachMedia */, 346 ComSafeArrayAsOutParam(sfaFiles), 347 pMachine.asOutParam()); 348 if (FAILED(rc)) throw MyError(rc, "VirtualBox::UnregisterMachine() failed\n"); 349 350 for (size_t u = 0; 351 u < sfaFiles.size(); 352 ++u) 353 { 354 RTPrintf(" UnregisterMachine reported disk image %ls\n", sfaFiles[u]); 355 llFiles2Delete.push_back(sfaFiles[u]); 356 } 357 358 rc = pMachine->DeleteSettings(); 359 if (FAILED(rc)) throw MyError(rc, "Machine::DeleteSettings() failed\n"); 370 360 } 371 361 } … … 382 372 { 383 373 const Utf8Str &strFile = *it; 374 RTPrintf("Deleting file %s...\n", strFile.c_str()); 384 375 RTFileDelete(strFile.c_str()); 385 376 }
Note:
See TracChangeset
for help on using the changeset viewer.

