Changeset 49749 in vbox for trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
- Timestamp:
- Dec 3, 2013 12:29:19 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r49742 r49749 1488 1488 void *pvCertBuf = NULL; 1489 1489 writeLock.release(); 1490 1491 /* Create the import stack for the rollback on errors. */ 1492 ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress); 1493 1490 1494 try 1491 1495 { … … 1507 1511 if (RT_FAILURE(vrc)) 1508 1512 throw setError(VBOX_E_IPRT_ERROR, "Creation of the VD interface failed (%Rrc)", vrc); 1509 1510 /* Create the import stack for the rollback on errors. */1511 ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress);1512 1513 1513 1514 if (RTFileExists(strMfFile.c_str())) … … 1563 1564 { 1564 1565 rc = rc2; 1566 /* 1567 * Restoring original UUID from OVF description file. 1568 * During import VB creates new UUIDs for imported images and 1569 * assigns them to the images. In case of failure we have to restore 1570 * the original UUIDs because those new UUIDs are obsolete now and 1571 * won't be used anymore. 1572 */ 1573 { 1574 list< ComObjPtr<VirtualSystemDescription> >::const_iterator itvsd; 1575 /* Iterate through all virtual systems of that appliance */ 1576 for (itvsd = m->virtualSystemDescriptions.begin(); 1577 itvsd != m->virtualSystemDescriptions.end(); 1578 ++itvsd) 1579 { 1580 ComObjPtr<VirtualSystemDescription> vsdescThis = (*itvsd); 1581 settings::MachineConfigFile *pConfig = vsdescThis->m->pConfig; 1582 if(vsdescThis->m->pConfig!=NULL) 1583 stack.restoreOriginalUUIDOfAttachedDevice(pConfig); 1584 } 1585 } 1565 1586 } 1566 1587 writeLock.acquire(); … … 1605 1626 1606 1627 writeLock.release(); 1628 1629 /* Create the import stack for the rollback on errors. */ 1630 ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress); 1631 1607 1632 try 1608 1633 { … … 1685 1710 pStorage->fCreateDigest = true; 1686 1711 1687 /* Create the import stack for the rollback on errors. */1688 ImportStack stack(pTask->locInfo, m->pReader->m_mapDisks, pTask->pProgress);1689 1712 /* 1690 1713 * Try to read the manifest file. First try. … … 1766 1789 { 1767 1790 rc = rc2; 1791 1792 /* 1793 * Restoring original UUID from OVF description file. 1794 * During import VB creates new UUIDs for imported images and 1795 * assigns them to the images. In case of failure we have to restore 1796 * the original UUIDs because those new UUIDs are obsolete now and 1797 * won't be used anymore. 1798 */ 1799 { 1800 list< ComObjPtr<VirtualSystemDescription> >::const_iterator itvsd; 1801 /* Iterate through all virtual systems of that appliance */ 1802 for (itvsd = m->virtualSystemDescriptions.begin(); 1803 itvsd != m->virtualSystemDescriptions.end(); 1804 ++itvsd) 1805 { 1806 ComObjPtr<VirtualSystemDescription> vsdescThis = (*itvsd); 1807 settings::MachineConfigFile *pConfig = vsdescThis->m->pConfig; 1808 if(vsdescThis->m->pConfig!=NULL) 1809 stack.restoreOriginalUUIDOfAttachedDevice(pConfig); 1810 } 1811 } 1768 1812 } 1769 1813 writeLock.acquire(); … … 3719 3763 vsdeTargetHD->strVboxCurrent = savedVboxCurrent; 3720 3764 3721 d.uuid = hdId; 3765 /* 3766 * 1. saving original UUID for restoring in case of failure. 3767 * 2. replacement of original UUID by new UUID in the current VM config (settings::MachineConfigFile). 3768 */ 3769 { 3770 rc = stack.saveOriginalUUIDOfAttachedDevice(d, Utf8Str(hdId)); 3771 d.uuid = hdId; 3772 } 3773 3722 3774 fFound = true; 3723 3775 break; … … 3894 3946 } 3895 3947 3948 HRESULT Appliance::ImportStack::saveOriginalUUIDOfAttachedDevice(settings::AttachedDevice &device, 3949 const Utf8Str &newlyUuid) 3950 { 3951 HRESULT rc = S_OK; 3952 3953 /* save for restoring */ 3954 mapNewUUIDsToOriginalUUIDs.insert(std::make_pair(newlyUuid, device.uuid.toString())); 3955 3956 return rc; 3957 } 3958 3959 HRESULT Appliance::ImportStack::restoreOriginalUUIDOfAttachedDevice(settings::MachineConfigFile *config) 3960 { 3961 HRESULT rc = S_OK; 3962 3963 settings::StorageControllersList &llControllers = config->storageMachine.llStorageControllers; 3964 settings::StorageControllersList::iterator itscl; 3965 for (itscl = llControllers.begin(); 3966 itscl != llControllers.end(); 3967 ++itscl) 3968 { 3969 settings::AttachedDevicesList &llAttachments = itscl->llAttachedDevices; 3970 settings::AttachedDevicesList::iterator itadl = llAttachments.begin(); 3971 while (itadl != llAttachments.end()) 3972 { 3973 std::map<Utf8Str , Utf8Str>::const_iterator cit = 3974 mapNewUUIDsToOriginalUUIDs.find(itadl->uuid.toString()); 3975 if(cit!=mapNewUUIDsToOriginalUUIDs.end()) 3976 { 3977 Utf8Str uuidOriginal = cit->second; 3978 itadl->uuid = Guid(uuidOriginal); 3979 mapNewUUIDsToOriginalUUIDs.erase(cit); 3980 } 3981 ++itadl; 3982 } 3983 } 3984 3985 return rc; 3986 } 3987
Note:
See TracChangeset
for help on using the changeset viewer.