Changeset 32571 in vbox
- Timestamp:
- Sep 16, 2010 4:09:05 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 65964
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r32568 r32571 154 154 ComObjPtr<VirtualSystemDescription> pNewDesc; 155 155 rc = pNewDesc.createObject(); 156 if (FAILED(rc)) DebugBreakThrow(rc);156 if (FAILED(rc)) throw rc; 157 157 rc = pNewDesc->init(); 158 if (FAILED(rc)) DebugBreakThrow(rc);158 if (FAILED(rc)) throw rc; 159 159 160 160 // if the virtual system in OVF had a <vbox:Machine> element, have the … … 236 236 ComPtr<IGuestOSType> pGuestOSType; 237 237 rc = mVirtualBox->GetGuestOSType(Bstr(strOsTypeVBox), pGuestOSType.asOutParam()); 238 if (FAILED(rc)) DebugBreakThrow(rc);238 if (FAILED(rc)) throw rc; 239 239 240 240 /* CPU count */ … … 272 272 ULONG memSizeVBox2; 273 273 rc = pGuestOSType->COMGETTER(RecommendedRAM)(&memSizeVBox2); 274 if (FAILED(rc)) DebugBreakThrow(rc);274 if (FAILED(rc)) throw rc; 275 275 /* VBox stores that in MByte */ 276 276 ullMemSizeVBox = (uint64_t)memSizeVBox2; … … 308 308 NetworkAdapterType_T defaultAdapterVBox = NetworkAdapterType_Am79C970A; 309 309 rc = pGuestOSType->COMGETTER(AdapterType)(&defaultAdapterVBox); 310 if (FAILED(rc)) DebugBreakThrow(rc);310 if (FAILED(rc)) throw rc; 311 311 312 312 ovf::EthernetAdaptersList::const_iterator itEA; … … 510 510 const VirtualSystemDescriptionEntry *pController; 511 511 if (!(pController = pNewDesc->findControllerFromID(hd.idController))) 512 DebugBreakThrow(setError(E_FAIL,512 throw setError(E_FAIL, 513 513 tr("Cannot find hard disk controller with OVF instance ID %RI32 to which disk \"%s\" should be attached"), 514 514 hd.idController, 515 di.strHref.c_str()) );515 di.strHref.c_str()); 516 516 517 517 /* controller to attach to, and the bus within that controller */ … … 527 527 } 528 528 else 529 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,530 tr("Unsupported format for virtual disk image in OVF: \"%s\"", di.strFormat.c_str())) );529 throw setError(VBOX_E_FILE_ERROR, 530 tr("Unsupported format for virtual disk image in OVF: \"%s\"", di.strFormat.c_str())); 531 531 } 532 532 } … … 637 637 aLocInfo.strPath.c_str()), // CBSTR bstrFirstOperationDescription, 638 638 4); // ULONG ulFirstOperationWeight, 639 if (FAILED(rc)) DebugBreakThrow(rc);639 if (FAILED(rc)) throw rc; 640 640 641 641 /* Initialize our worker task */ … … 643 643 644 644 rc = task->startThread(); 645 if (FAILED(rc)) DebugBreakThrow(rc);645 if (FAILED(rc)) throw rc; 646 646 647 647 /* Don't destruct on success */ … … 693 693 int vrc = RTSha1DigestFromFile(locInfo.strPath.c_str(), &pszDigest, NULL, NULL); 694 694 if (RT_FAILURE(vrc)) 695 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,695 throw setError(VBOX_E_FILE_ERROR, 696 696 tr("Couldn't calculate SHA1 digest for file '%s' (%Rrc)"), 697 RTPathFilename(locInfo.strPath.c_str()), vrc) );697 RTPathFilename(locInfo.strPath.c_str()), vrc); 698 698 m->strOVFSHA1Digest = pszDigest; 699 699 RTStrFree(pszDigest); … … 822 822 vrc = RTDirCreateTemp(pszTmpDir); 823 823 if (RT_FAILURE(vrc)) 824 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,825 tr("Cannot create temporary directory '%s'"), pszTmpDir) );824 throw setError(VBOX_E_FILE_ERROR, 825 tr("Cannot create temporary directory '%s'"), pszTmpDir); 826 826 827 827 /* The temporary name of the target OVF file */ … … 831 831 vrc = RTS3Create(&hS3, pTask->locInfo.strUsername.c_str(), pTask->locInfo.strPassword.c_str(), pTask->locInfo.strHostname.c_str(), "virtualbox-agent/"VBOX_VERSION_STRING); 832 832 if (RT_FAILURE(vrc)) 833 DebugBreakThrow(setError(VBOX_E_IPRT_ERROR,834 tr("Cannot create S3 service handler")) );833 throw setError(VBOX_E_IPRT_ERROR, 834 tr("Cannot create S3 service handler")); 835 835 RTS3SetProgressCallback(hS3, pTask->updateProgress, &pTask); 836 836 … … 843 843 throw S_OK; /* todo: !!!!!!!!!!!!! */ 844 844 else if (vrc == VERR_S3_ACCESS_DENIED) 845 DebugBreakThrow(setError(E_ACCESSDENIED,845 throw setError(E_ACCESSDENIED, 846 846 tr("Cannot download file '%s' from S3 storage server (Access denied). Make sure that your credentials are right." 847 847 "Also check that your host clock is properly synced"), 848 pszFilename) );848 pszFilename); 849 849 else if (vrc == VERR_S3_NOT_FOUND) 850 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,851 tr("Cannot download file '%s' from S3 storage server (File not found)"), pszFilename) );850 throw setError(VBOX_E_FILE_ERROR, 851 tr("Cannot download file '%s' from S3 storage server (File not found)"), pszFilename); 852 852 else 853 DebugBreakThrow(setError(VBOX_E_IPRT_ERROR,854 tr("Cannot download file '%s' from S3 storage server (%Rrc)"), pszFilename, vrc) );853 throw setError(VBOX_E_IPRT_ERROR, 854 tr("Cannot download file '%s' from S3 storage server (%Rrc)"), pszFilename, vrc); 855 855 } 856 856 … … 867 867 /* Start the reading from the fs */ 868 868 rc = readImpl(li, progress); 869 if (FAILED(rc)) DebugBreakThrow(rc);869 if (FAILED(rc)) throw rc; 870 870 871 871 /* Unlock the appliance for the reading thread */ … … 980 980 981 981 default: 982 DebugBreakThrow(setError(VBOX_E_NOT_SUPPORTED,983 984 ulAddressOnParent));982 throw setError(VBOX_E_NOT_SUPPORTED, 983 tr("Invalid channel %RI16 specified; IDE controllers support only 0, 1 or 2"), 984 ulAddressOnParent); 985 985 break; 986 986 } … … 1049 1049 BstrFmt(tr("Importing appliance '%s'"), locInfo.strPath.c_str()), 1050 1050 mode); 1051 if (FAILED(rc)) DebugBreakThrow(rc);1051 if (FAILED(rc)) throw rc; 1052 1052 1053 1053 /* Initialize our worker task */ … … 1055 1055 1056 1056 rc = task->startThread(); 1057 if (FAILED(rc)) DebugBreakThrow(rc);1057 if (FAILED(rc)) throw rc; 1058 1058 1059 1059 /* Don't destruct on success */ … … 1218 1218 // if a manifest file exists, verify the content; we then need all files which are referenced by the OVF & the OVF itself 1219 1219 rc = manifestVerify(pTask->locInfo, reader, pTask->pProgress); 1220 if (FAILED(rc)) DebugBreakThrow(rc);1220 if (FAILED(rc)) throw rc; 1221 1221 1222 1222 // create a session for the machine + disks we manipulate below 1223 1223 rc = stack.pSession.createInprocObject(CLSID_Session); 1224 if (FAILED(rc)) DebugBreakThrow(rc);1224 if (FAILED(rc)) throw rc; 1225 1225 1226 1226 list<ovf::VirtualSystem>::const_iterator it; … … 1251 1251 std::list<VirtualSystemDescriptionEntry*> vsdeName = vsdescThis->findByType(VirtualSystemDescriptionType_Name); 1252 1252 if (vsdeName.size() < 1) 1253 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1254 tr("Missing VM name")));1253 throw setError(VBOX_E_FILE_ERROR, 1254 tr("Missing VM name")); 1255 1255 stack.strNameVBox = vsdeName.front()->strVboxCurrent; 1256 1256 … … 1259 1259 vsdeOS = vsdescThis->findByType(VirtualSystemDescriptionType_OS); 1260 1260 if (vsdeOS.size() < 1) 1261 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1262 tr("Missing guest OS type")));1261 throw setError(VBOX_E_FILE_ERROR, 1262 tr("Missing guest OS type")); 1263 1263 stack.strOsTypeVBox = vsdeOS.front()->strVboxCurrent; 1264 1264 … … 1266 1266 std::list<VirtualSystemDescriptionEntry*> vsdeCPU = vsdescThis->findByType(VirtualSystemDescriptionType_CPU); 1267 1267 if (vsdeCPU.size() != 1) 1268 DebugBreakThrow(setError(VBOX_E_FILE_ERROR, tr("CPU count missing")));1268 throw setError(VBOX_E_FILE_ERROR, tr("CPU count missing")); 1269 1269 1270 1270 const Utf8Str &cpuVBox = vsdeCPU.front()->strVboxCurrent; … … 1280 1280 std::list<VirtualSystemDescriptionEntry*> vsdeRAM = vsdescThis->findByType(VirtualSystemDescriptionType_Memory); 1281 1281 if (vsdeRAM.size() != 1) 1282 DebugBreakThrow(setError(VBOX_E_FILE_ERROR, tr("RAM size missing")));1282 throw setError(VBOX_E_FILE_ERROR, tr("RAM size missing")); 1283 1283 const Utf8Str &memoryVBox = vsdeRAM.front()->strVboxCurrent; 1284 1284 stack.ulMemorySizeMB = (uint32_t)RTStrToUInt64(memoryVBox.c_str()); … … 1384 1384 vrc = RTDirCreateTemp(pszTmpDir); 1385 1385 if (RT_FAILURE(vrc)) 1386 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1387 tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc));1386 throw setError(VBOX_E_FILE_ERROR, 1387 tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc); 1388 1388 1389 1389 /* Provide a OVF file (haven't to exist) so the import routine can … … 1442 1442 li.strPath = strTmpOvf; 1443 1443 rc = importImpl(li, progress); 1444 if (FAILED(rc)) DebugBreakThrow(rc);1444 if (FAILED(rc)) throw rc; 1445 1445 1446 1446 /* Unlock the appliance for the fs import thread */ … … 1526 1526 || RTPathExists(strTargetPath.c_str()) 1527 1527 ) 1528 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1529 1530 strTargetPath.c_str()));1528 throw setError(VBOX_E_FILE_ERROR, 1529 tr("Destination file '%s' exists"), 1530 strTargetPath.c_str()); 1531 1531 1532 1532 const Utf8Str &strSourceOVF = di.strHref; … … 1534 1534 // Make sure target directory exists 1535 1535 HRESULT rc = VirtualBox::ensureFilePathExists(strTargetPath.c_str()); 1536 if (FAILED(rc)) DebugBreakThrow(rc);1536 if (FAILED(rc)) throw rc; 1537 1537 1538 1538 // subprogress object for hard disk … … 1554 1554 Bstr(strTargetPath), 1555 1555 pTargetHD.asOutParam()); 1556 if (FAILED(rc)) DebugBreakThrow(rc);1556 if (FAILED(rc)) throw rc; 1557 1557 1558 1558 // create a dynamic growing disk image with the given capacity 1559 1559 rc = pTargetHD->CreateBaseStorage(di.iCapacity / _1M, MediumVariant_Standard, pProgress2.asOutParam()); 1560 if (FAILED(rc)) DebugBreakThrow(rc);1560 if (FAILED(rc)) throw rc; 1561 1561 1562 1562 // advance to the next operation … … 1570 1570 // source path must exist 1571 1571 if (!RTPathExists(strSrcFilePath.c_str())) 1572 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1573 1574 strSrcFilePath.c_str()));1572 throw setError(VBOX_E_FILE_ERROR, 1573 tr("Source virtual disk image file '%s' doesn't exist"), 1574 strSrcFilePath.c_str()); 1575 1575 1576 1576 // Clone the disk image (this is necessary cause the id has … … 1583 1583 AccessMode_ReadOnly, 1584 1584 pSourceHD.asOutParam()); 1585 if (FAILED(rc)) DebugBreakThrow(rc);1585 if (FAILED(rc)) throw rc; 1586 1586 fSourceHdNeedsClosing = true; 1587 1587 … … 1589 1589 Bstr srcFormat; 1590 1590 rc = pSourceHD->COMGETTER(Format)(srcFormat.asOutParam()); 1591 if (FAILED(rc)) DebugBreakThrow(rc);1591 if (FAILED(rc)) throw rc; 1592 1592 /* Create a new hard disk interface for the destination disk image */ 1593 1593 rc = mVirtualBox->CreateHardDisk(srcFormat, 1594 1594 Bstr(strTargetPath), 1595 1595 pTargetHD.asOutParam()); 1596 if (FAILED(rc)) DebugBreakThrow(rc);1596 if (FAILED(rc)) throw rc; 1597 1597 /* Clone the source disk image */ 1598 1598 rc = pSourceHD->CloneTo(pTargetHD, MediumVariant_Standard, NULL, pProgress2.asOutParam()); 1599 if (FAILED(rc)) DebugBreakThrow(rc);1599 if (FAILED(rc)) throw rc; 1600 1600 1601 1601 /* Advance to the next operation */ … … 1610 1610 { 1611 1611 rc = pSourceHD->Close(); 1612 if (FAILED(rc)) DebugBreakThrow(rc);1612 if (FAILED(rc)) throw rc; 1613 1613 fSourceHdNeedsClosing = false; 1614 1614 } … … 1649 1649 ComPtr<IGuestOSType> osType; 1650 1650 rc = mVirtualBox->GetGuestOSType(Bstr(stack.strOsTypeVBox), osType.asOutParam()); 1651 if (FAILED(rc)) DebugBreakThrow(rc);1651 if (FAILED(rc)) throw rc; 1652 1652 1653 1653 /* Create the machine */ … … 1658 1658 FALSE, 1659 1659 pNewMachine.asOutParam()); 1660 if (FAILED(rc)) DebugBreakThrow(rc);1660 if (FAILED(rc)) throw rc; 1661 1661 1662 1662 // set the description … … 1664 1664 { 1665 1665 rc = pNewMachine->COMSETTER(Description)(Bstr(stack.strDescription)); 1666 if (FAILED(rc)) DebugBreakThrow(rc);1666 if (FAILED(rc)) throw rc; 1667 1667 } 1668 1668 1669 1669 // CPU count 1670 1670 rc = pNewMachine->COMSETTER(CPUCount)(stack.cCPUs); 1671 if (FAILED(rc)) DebugBreakThrow(rc);1671 if (FAILED(rc)) throw rc; 1672 1672 1673 1673 if (stack.fForceHWVirt) 1674 1674 { 1675 1675 rc = pNewMachine->SetHWVirtExProperty(HWVirtExPropertyType_Enabled, TRUE); 1676 if (FAILED(rc)) DebugBreakThrow(rc);1676 if (FAILED(rc)) throw rc; 1677 1677 } 1678 1678 1679 1679 // RAM 1680 1680 rc = pNewMachine->COMSETTER(MemorySize)(stack.ulMemorySizeMB); 1681 if (FAILED(rc)) DebugBreakThrow(rc);1681 if (FAILED(rc)) throw rc; 1682 1682 1683 1683 /* VRAM */ … … 1685 1685 ULONG vramVBox; 1686 1686 rc = osType->COMGETTER(RecommendedVRAM)(&vramVBox); 1687 if (FAILED(rc)) DebugBreakThrow(rc);1687 if (FAILED(rc)) throw rc; 1688 1688 1689 1689 /* Set the VRAM */ 1690 1690 rc = pNewMachine->COMSETTER(VRAMSize)(vramVBox); 1691 if (FAILED(rc)) DebugBreakThrow(rc);1691 if (FAILED(rc)) throw rc; 1692 1692 1693 1693 // I/O APIC: Generic OVF has no setting for this. Enable it if we … … 1699 1699 Bstr bstrFamilyId; 1700 1700 rc = osType->COMGETTER(FamilyId)(bstrFamilyId.asOutParam()); 1701 if (FAILED(rc)) DebugBreakThrow(rc);1701 if (FAILED(rc)) throw rc; 1702 1702 if (bstrFamilyId == "Windows") 1703 1703 stack.fForceIOAPIC = true; … … 1708 1708 ComPtr<IBIOSSettings> pBIOSSettings; 1709 1709 rc = pNewMachine->COMGETTER(BIOSSettings)(pBIOSSettings.asOutParam()); 1710 if (FAILED(rc)) DebugBreakThrow(rc);1710 if (FAILED(rc)) throw rc; 1711 1711 1712 1712 rc = pBIOSSettings->COMSETTER(IOAPICEnabled)(TRUE); 1713 if (FAILED(rc)) DebugBreakThrow(rc);1713 if (FAILED(rc)) throw rc; 1714 1714 } 1715 1715 … … 1720 1720 ComPtr<IAudioAdapter> audioAdapter; 1721 1721 rc = pNewMachine->COMGETTER(AudioAdapter)(audioAdapter.asOutParam()); 1722 if (FAILED(rc)) DebugBreakThrow(rc);1722 if (FAILED(rc)) throw rc; 1723 1723 rc = audioAdapter->COMSETTER(Enabled)(true); 1724 if (FAILED(rc)) DebugBreakThrow(rc);1724 if (FAILED(rc)) throw rc; 1725 1725 rc = audioAdapter->COMSETTER(AudioController)(static_cast<AudioControllerType_T>(audio)); 1726 if (FAILED(rc)) DebugBreakThrow(rc);1726 if (FAILED(rc)) throw rc; 1727 1727 } 1728 1728 … … 1731 1731 ComPtr<IUSBController> usbController; 1732 1732 rc = pNewMachine->COMGETTER(USBController)(usbController.asOutParam()); 1733 if (FAILED(rc)) DebugBreakThrow(rc);1733 if (FAILED(rc)) throw rc; 1734 1734 rc = usbController->COMSETTER(Enabled)(stack.fUSBEnabled); 1735 if (FAILED(rc)) DebugBreakThrow(rc);1735 if (FAILED(rc)) throw rc; 1736 1736 #endif /* VBOX_WITH_USB */ 1737 1737 … … 1743 1743 ComPtr<INetworkAdapter> nwVBox; 1744 1744 rc = pNewMachine->GetNetworkAdapter(0, nwVBox.asOutParam()); 1745 if (FAILED(rc)) DebugBreakThrow(rc);1745 if (FAILED(rc)) throw rc; 1746 1746 rc = nwVBox->COMSETTER(Enabled)(false); 1747 if (FAILED(rc)) DebugBreakThrow(rc);1747 if (FAILED(rc)) throw rc; 1748 1748 } 1749 1749 else if (vsdeNW.size() > SchemaDefs::NetworkAdapterCount) 1750 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1751 1752 vsdeNW.size(), SchemaDefs::NetworkAdapterCount));1750 throw setError(VBOX_E_FILE_ERROR, 1751 tr("Too many network adapters: OVF requests %d network adapters, but VirtualBox only supports %d"), 1752 vsdeNW.size(), SchemaDefs::NetworkAdapterCount); 1753 1753 else 1754 1754 { … … 1765 1765 ComPtr<INetworkAdapter> pNetworkAdapter; 1766 1766 rc = pNewMachine->GetNetworkAdapter((ULONG)a, pNetworkAdapter.asOutParam()); 1767 if (FAILED(rc)) DebugBreakThrow(rc);1767 if (FAILED(rc)) throw rc; 1768 1768 /* Enable the network card & set the adapter type */ 1769 1769 rc = pNetworkAdapter->COMSETTER(Enabled)(true); 1770 if (FAILED(rc)) DebugBreakThrow(rc);1770 if (FAILED(rc)) throw rc; 1771 1771 rc = pNetworkAdapter->COMSETTER(AdapterType)(static_cast<NetworkAdapterType_T>(tt1)); 1772 if (FAILED(rc)) DebugBreakThrow(rc);1772 if (FAILED(rc)) throw rc; 1773 1773 1774 1774 // default is NAT; change to "bridged" if extra conf says so … … 1777 1777 /* Attach to the right interface */ 1778 1778 rc = pNetworkAdapter->AttachToBridgedInterface(); 1779 if (FAILED(rc)) DebugBreakThrow(rc);1779 if (FAILED(rc)) throw rc; 1780 1780 ComPtr<IHost> host; 1781 1781 rc = mVirtualBox->COMGETTER(Host)(host.asOutParam()); 1782 if (FAILED(rc)) DebugBreakThrow(rc);1782 if (FAILED(rc)) throw rc; 1783 1783 com::SafeIfaceArray<IHostNetworkInterface> nwInterfaces; 1784 1784 rc = host->COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(nwInterfaces)); 1785 if (FAILED(rc)) DebugBreakThrow(rc);1785 if (FAILED(rc)) throw rc; 1786 1786 // We search for the first host network interface which 1787 1787 // is usable for bridged networking … … 1792 1792 HostNetworkInterfaceType_T itype; 1793 1793 rc = nwInterfaces[j]->COMGETTER(InterfaceType)(&itype); 1794 if (FAILED(rc)) DebugBreakThrow(rc);1794 if (FAILED(rc)) throw rc; 1795 1795 if (itype == HostNetworkInterfaceType_Bridged) 1796 1796 { 1797 1797 Bstr name; 1798 1798 rc = nwInterfaces[j]->COMGETTER(Name)(name.asOutParam()); 1799 if (FAILED(rc)) DebugBreakThrow(rc);1799 if (FAILED(rc)) throw rc; 1800 1800 /* Set the interface name to attach to */ 1801 1801 pNetworkAdapter->COMSETTER(HostInterface)(name); 1802 if (FAILED(rc)) DebugBreakThrow(rc);1802 if (FAILED(rc)) throw rc; 1803 1803 break; 1804 1804 } … … 1810 1810 /* Attach to the right interface */ 1811 1811 rc = pNetworkAdapter->AttachToHostOnlyInterface(); 1812 if (FAILED(rc)) DebugBreakThrow(rc);1812 if (FAILED(rc)) throw rc; 1813 1813 ComPtr<IHost> host; 1814 1814 rc = mVirtualBox->COMGETTER(Host)(host.asOutParam()); 1815 if (FAILED(rc)) DebugBreakThrow(rc);1815 if (FAILED(rc)) throw rc; 1816 1816 com::SafeIfaceArray<IHostNetworkInterface> nwInterfaces; 1817 1817 rc = host->COMGETTER(NetworkInterfaces)(ComSafeArrayAsOutParam(nwInterfaces)); 1818 if (FAILED(rc)) DebugBreakThrow(rc);1818 if (FAILED(rc)) throw rc; 1819 1819 // We search for the first host network interface which 1820 1820 // is usable for host only networking … … 1825 1825 HostNetworkInterfaceType_T itype; 1826 1826 rc = nwInterfaces[j]->COMGETTER(InterfaceType)(&itype); 1827 if (FAILED(rc)) DebugBreakThrow(rc);1827 if (FAILED(rc)) throw rc; 1828 1828 if (itype == HostNetworkInterfaceType_HostOnly) 1829 1829 { 1830 1830 Bstr name; 1831 1831 rc = nwInterfaces[j]->COMGETTER(Name)(name.asOutParam()); 1832 if (FAILED(rc)) DebugBreakThrow(rc);1832 if (FAILED(rc)) throw rc; 1833 1833 /* Set the interface name to attach to */ 1834 1834 pNetworkAdapter->COMSETTER(HostInterface)(name); 1835 if (FAILED(rc)) DebugBreakThrow(rc);1835 if (FAILED(rc)) throw rc; 1836 1836 break; 1837 1837 } … … 1847 1847 uint32_t cIDEControllers = vsdeHDCIDE.size(); 1848 1848 if (cIDEControllers > 2) 1849 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1850 tr("Too many IDE controllers in OVF; import facility only supports two")));1849 throw setError(VBOX_E_FILE_ERROR, 1850 tr("Too many IDE controllers in OVF; import facility only supports two")); 1851 1851 if (vsdeHDCIDE.size() > 0) 1852 1852 { … … 1854 1854 ComPtr<IStorageController> pController; 1855 1855 rc = pNewMachine->AddStorageController(Bstr("IDE Controller"), StorageBus_IDE, pController.asOutParam()); 1856 if (FAILED(rc)) DebugBreakThrow(rc);1856 if (FAILED(rc)) throw rc; 1857 1857 1858 1858 const char *pcszIDEType = vsdeHDCIDE.front()->strVboxCurrent.c_str(); … … 1864 1864 rc = pController->COMSETTER(ControllerType)(StorageControllerType_ICH6); 1865 1865 else 1866 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1867 1868 pcszIDEType));1869 if (FAILED(rc)) DebugBreakThrow(rc);1866 throw setError(VBOX_E_FILE_ERROR, 1867 tr("Invalid IDE controller type \"%s\""), 1868 pcszIDEType); 1869 if (FAILED(rc)) throw rc; 1870 1870 } 1871 1871 … … 1873 1873 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSATA = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerSATA); 1874 1874 if (vsdeHDCSATA.size() > 1) 1875 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1876 tr("Too many SATA controllers in OVF; import facility only supports one")));1875 throw setError(VBOX_E_FILE_ERROR, 1876 tr("Too many SATA controllers in OVF; import facility only supports one")); 1877 1877 if (vsdeHDCSATA.size() > 0) 1878 1878 { … … 1882 1882 { 1883 1883 rc = pNewMachine->AddStorageController(Bstr("SATA Controller"), StorageBus_SATA, pController.asOutParam()); 1884 if (FAILED(rc)) DebugBreakThrow(rc);1884 if (FAILED(rc)) throw rc; 1885 1885 } 1886 1886 else 1887 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1888 1889 hdcVBox.c_str()));1887 throw setError(VBOX_E_FILE_ERROR, 1888 tr("Invalid SATA controller type \"%s\""), 1889 hdcVBox.c_str()); 1890 1890 } 1891 1891 … … 1893 1893 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSCSI = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerSCSI); 1894 1894 if (vsdeHDCSCSI.size() > 1) 1895 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1896 tr("Too many SCSI controllers in OVF; import facility only supports one")));1895 throw setError(VBOX_E_FILE_ERROR, 1896 tr("Too many SCSI controllers in OVF; import facility only supports one")); 1897 1897 if (vsdeHDCSCSI.size() > 0) 1898 1898 { … … 1914 1914 controllerType = StorageControllerType_BusLogic; 1915 1915 else 1916 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1917 1918 hdcVBox.c_str()));1916 throw setError(VBOX_E_FILE_ERROR, 1917 tr("Invalid SCSI controller type \"%s\""), 1918 hdcVBox.c_str()); 1919 1919 1920 1920 rc = pNewMachine->AddStorageController(bstrName, busType, pController.asOutParam()); 1921 if (FAILED(rc)) DebugBreakThrow(rc);1921 if (FAILED(rc)) throw rc; 1922 1922 rc = pController->COMSETTER(ControllerType)(controllerType); 1923 if (FAILED(rc)) DebugBreakThrow(rc);1923 if (FAILED(rc)) throw rc; 1924 1924 } 1925 1925 … … 1927 1927 std::list<VirtualSystemDescriptionEntry*> vsdeHDCSAS = vsdescThis->findByType(VirtualSystemDescriptionType_HardDiskControllerSAS); 1928 1928 if (vsdeHDCSAS.size() > 1) 1929 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1930 tr("Too many SAS controllers in OVF; import facility only supports one")));1929 throw setError(VBOX_E_FILE_ERROR, 1930 tr("Too many SAS controllers in OVF; import facility only supports one")); 1931 1931 if (vsdeHDCSAS.size() > 0) 1932 1932 { 1933 1933 ComPtr<IStorageController> pController; 1934 1934 rc = pNewMachine->AddStorageController(Bstr(L"SAS Controller"), StorageBus_SAS, pController.asOutParam()); 1935 if (FAILED(rc)) DebugBreakThrow(rc);1935 if (FAILED(rc)) throw rc; 1936 1936 rc = pController->COMSETTER(ControllerType)(StorageControllerType_LsiLogicSas); 1937 if (FAILED(rc)) DebugBreakThrow(rc);1937 if (FAILED(rc)) throw rc; 1938 1938 } 1939 1939 1940 1940 /* Now its time to register the machine before we add any hard disks */ 1941 1941 rc = mVirtualBox->RegisterMachine(pNewMachine); 1942 if (FAILED(rc)) DebugBreakThrow(rc);1942 if (FAILED(rc)) throw rc; 1943 1943 1944 1944 // store new machine for roll-back in case of errors 1945 1945 Bstr bstrNewMachineId; 1946 1946 rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam()); 1947 if (FAILED(rc)) DebugBreakThrow(rc);1947 if (FAILED(rc)) throw rc; 1948 1948 Guid uuidNewMachine(bstrNewMachineId); 1949 1949 m->llGuidsMachinesCreated.push_back(uuidNewMachine); … … 1952 1952 std::list<VirtualSystemDescriptionEntry*> vsdeFloppy = vsdescThis->findByType(VirtualSystemDescriptionType_Floppy); 1953 1953 if (vsdeFloppy.size() > 1) 1954 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,1955 tr("Too many floppy controllers in OVF; import facility only supports one")));1954 throw setError(VBOX_E_FILE_ERROR, 1955 tr("Too many floppy controllers in OVF; import facility only supports one")); 1956 1956 std::list<VirtualSystemDescriptionEntry*> vsdeCDROM = vsdescThis->findByType(VirtualSystemDescriptionType_CDROM); 1957 1957 if ( (vsdeFloppy.size() > 0) … … 1966 1966 // to attach things we need to open a session for the new machine 1967 1967 rc = pNewMachine->LockMachine(stack.pSession, LockType_Write); 1968 if (FAILED(rc)) DebugBreakThrow(rc);1968 if (FAILED(rc)) throw rc; 1969 1969 stack.fSessionOpen = true; 1970 1970 1971 1971 ComPtr<IMachine> sMachine; 1972 1972 rc = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); 1973 if (FAILED(rc)) DebugBreakThrow(rc);1973 if (FAILED(rc)) throw rc; 1974 1974 1975 1975 // floppy first … … 1978 1978 ComPtr<IStorageController> pController; 1979 1979 rc = sMachine->AddStorageController(Bstr("Floppy Controller"), StorageBus_Floppy, pController.asOutParam()); 1980 if (FAILED(rc)) DebugBreakThrow(rc);1980 if (FAILED(rc)) throw rc; 1981 1981 1982 1982 Bstr bstrName; 1983 1983 rc = pController->COMGETTER(Name)(bstrName.asOutParam()); 1984 if (FAILED(rc)) DebugBreakThrow(rc);1984 if (FAILED(rc)) throw rc; 1985 1985 1986 1986 // this is for rollback later … … 1998 1998 DeviceType_Floppy, 1999 1999 NULL); 2000 if (FAILED(rc)) DebugBreakThrow(rc);2000 if (FAILED(rc)) throw rc; 2001 2001 2002 2002 stack.llHardDiskAttachments.push_back(mhda); … … 2026 2026 2027 2027 if (!pController) 2028 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,2029 tr("OVF wants a CD-ROM drive but cannot find IDE controller, which is required in this version of VirtualBox")));2028 throw setError(VBOX_E_FILE_ERROR, 2029 tr("OVF wants a CD-ROM drive but cannot find IDE controller, which is required in this version of VirtualBox")); 2030 2030 2031 2031 // this is for rollback later … … 2046 2046 DeviceType_DVD, 2047 2047 NULL); 2048 if (FAILED(rc)) DebugBreakThrow(rc);2048 if (FAILED(rc)) throw rc; 2049 2049 2050 2050 stack.llHardDiskAttachments.push_back(mhda); … … 2052 2052 2053 2053 rc = sMachine->SaveSettings(); 2054 if (FAILED(rc)) DebugBreakThrow(rc);2054 if (FAILED(rc)) throw rc; 2055 2055 2056 2056 // only now that we're done with all disks, close the session 2057 2057 rc = stack.pSession->UnlockMachine(); 2058 if (FAILED(rc)) DebugBreakThrow(rc);2058 if (FAILED(rc)) throw rc; 2059 2059 stack.fSessionOpen = false; 2060 2060 } … … 2078 2078 // to attach things we need to open a session for the new machine 2079 2079 rc = pNewMachine->LockMachine(stack.pSession, LockType_Write); 2080 if (FAILED(rc)) DebugBreakThrow(rc);2080 if (FAILED(rc)) throw rc; 2081 2081 stack.fSessionOpen = true; 2082 2082 … … 2097 2097 || (itDiskImage == stack.mapDisks.end()) 2098 2098 ) 2099 DebugBreakThrow(setError(E_FAIL,2100 2101 vsdeHD->strRef.c_str()));2099 throw setError(E_FAIL, 2100 tr("Internal inconsistency looking up disk image '%s'"), 2101 vsdeHD->strRef.c_str()); 2102 2102 2103 2103 const ovf::DiskImage &ovfDiskImage = itDiskImage->second; … … 2113 2113 ComPtr<IMachine> sMachine; 2114 2114 rc = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); 2115 if (FAILED(rc)) DebugBreakThrow(rc);2115 if (FAILED(rc)) throw rc; 2116 2116 2117 2117 // find the hard disk controller to which we should attach … … 2135 2135 DeviceType_HardDisk, // DeviceType_T type 2136 2136 pTargetHD); 2137 if (FAILED(rc)) DebugBreakThrow(rc);2137 if (FAILED(rc)) throw rc; 2138 2138 2139 2139 stack.llHardDiskAttachments.push_back(mhda); 2140 2140 2141 2141 rc = sMachine->SaveSettings(); 2142 if (FAILED(rc)) DebugBreakThrow(rc);2142 if (FAILED(rc)) throw rc; 2143 2143 } // end for (itHD = avsdeHDs.begin(); 2144 2144 2145 2145 // only now that we're done with all disks, close the session 2146 2146 rc = stack.pSession->UnlockMachine(); 2147 if (FAILED(rc)) DebugBreakThrow(rc);2147 if (FAILED(rc)) throw rc; 2148 2148 stack.fSessionOpen = false; 2149 2149 } … … 2197 2197 Utf8Str strDefaultHardDiskFolder; 2198 2198 HRESULT rc = getDefaultHardDiskFolder(strDefaultHardDiskFolder); 2199 if (FAILED(rc)) DebugBreakThrow(rc);2199 if (FAILED(rc)) throw rc; 2200 2200 2201 2201 /* … … 2308 2308 Bstr hdId; 2309 2309 rc = pTargetHD->COMGETTER(Id)(hdId.asOutParam()); 2310 if (FAILED(rc)) DebugBreakThrow(rc);2310 if (FAILED(rc)) throw rc; 2311 2311 2312 2312 d.uuid = hdId; … … 2319 2319 // no disk with such a UUID found: 2320 2320 if (!fFound) 2321 DebugBreakThrow(setError(E_FAIL,2322 2323 strUuid.c_str()));2321 throw setError(E_FAIL, 2322 tr("<vbox:Machine> element in OVF contains a medium attachment for the disk image %s but the OVF describes no such image"), 2323 strUuid.c_str()); 2324 2324 } // for (settings::AttachedDevicesList::const_iterator dit = sc.llAttachedDevices.begin(); 2325 2325 } // for (settings::StorageControllersList::const_iterator sit = config.storageMachine.llStorageControllers.begin(); … … 2333 2333 ComObjPtr<Machine> pNewMachine; 2334 2334 rc = pNewMachine.createObject(); 2335 if (FAILED(rc)) DebugBreakThrow(rc);2335 if (FAILED(rc)) throw rc; 2336 2336 2337 2337 // this magic constructor fills the new machine object with the MachineConfig … … 2340 2340 stack.strNameVBox, // name from OVF preparations; can be suffixed to avoid duplicates, or changed by user 2341 2341 config); // the whole machine config 2342 if (FAILED(rc)) DebugBreakThrow(rc);2342 if (FAILED(rc)) throw rc; 2343 2343 2344 2344 // return the new machine as an IMachine 2345 2345 IMachine *p; 2346 2346 rc = pNewMachine.queryInterfaceTo(&p); 2347 if (FAILED(rc)) DebugBreakThrow(rc);2347 if (FAILED(rc)) throw rc; 2348 2348 pReturnNewMachine = p; 2349 2349 2350 2350 // and register it 2351 2351 rc = mVirtualBox->RegisterMachine(pNewMachine); 2352 if (FAILED(rc)) DebugBreakThrow(rc);2352 if (FAILED(rc)) throw rc; 2353 2353 2354 2354 // store new machine for roll-back in case of errors 2355 2355 Bstr bstrNewMachineId; 2356 2356 rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam()); 2357 if (FAILED(rc)) DebugBreakThrow(rc);2357 if (FAILED(rc)) throw rc; 2358 2358 m->llGuidsMachinesCreated.push_back(Guid(bstrNewMachineId)); 2359 2359 } … … 2397 2397 vrc = RTDirCreateTemp(pszTmpDir); 2398 2398 if (RT_FAILURE(vrc)) 2399 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,2400 tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc));2399 throw setError(VBOX_E_FILE_ERROR, 2400 tr("Cannot create temporary directory '%s' (%Rrc)"), pszTmpDir, vrc); 2401 2401 2402 2402 /* Add every disks of every virtual system to an internal list */ … … 2426 2426 vrc = RTS3Create(&hS3, pTask->locInfo.strUsername.c_str(), pTask->locInfo.strPassword.c_str(), pTask->locInfo.strHostname.c_str(), "virtualbox-agent/"VBOX_VERSION_STRING); 2427 2427 if (RT_FAILURE(vrc)) 2428 DebugBreakThrow(setError(VBOX_E_IPRT_ERROR,2429 tr("Cannot create S3 service handler")));2428 throw setError(VBOX_E_IPRT_ERROR, 2429 tr("Cannot create S3 service handler")); 2430 2430 RTS3SetProgressCallback(hS3, pTask->updateProgress, &pTask); 2431 2431 … … 2447 2447 throw S_OK; /* todo: !!!!!!!!!!!!! */ 2448 2448 else if (vrc == VERR_S3_ACCESS_DENIED) 2449 DebugBreakThrow(setError(E_ACCESSDENIED,2450 2451 2452 pszFilename));2449 throw setError(E_ACCESSDENIED, 2450 tr("Cannot download file '%s' from S3 storage server (Access denied). " 2451 "Make sure that your credentials are right. Also check that your host clock is properly synced"), 2452 pszFilename); 2453 2453 else if (vrc == VERR_S3_NOT_FOUND) 2454 DebugBreakThrow(setError(VBOX_E_FILE_ERROR,2455 2456 pszFilename));2454 throw setError(VBOX_E_FILE_ERROR, 2455 tr("Cannot download file '%s' from S3 storage server (File not found)"), 2456 pszFilename); 2457 2457 else 2458 DebugBreakThrow(setError(VBOX_E_IPRT_ERROR,2459 2460 pszFilename, vrc));2458 throw setError(VBOX_E_IPRT_ERROR, 2459 tr("Cannot download file '%s' from S3 storage server (%Rrc)"), 2460 pszFilename, vrc); 2461 2461 } 2462 2462 } … … 2482 2482 vrc = VINF_SUCCESS; /* Not found is ok */ 2483 2483 else if (vrc == VERR_S3_ACCESS_DENIED) 2484 DebugBreakThrow(setError(E_ACCESSDENIED,2485 2486 2487 pszFilename));2484 throw setError(E_ACCESSDENIED, 2485 tr("Cannot download file '%s' from S3 storage server (Access denied)." 2486 "Make sure that your credentials are right. Also check that your host clock is properly synced"), 2487 pszFilename); 2488 2488 else 2489 DebugBreakThrow(setError(VBOX_E_IPRT_ERROR,2490 2491 pszFilename, vrc));2489 throw setError(VBOX_E_IPRT_ERROR, 2490 tr("Cannot download file '%s' from S3 storage server (%Rrc)"), 2491 pszFilename, vrc); 2492 2492 } 2493 2493 … … 2503 2503 li.strPath = strTmpOvf; 2504 2504 rc = importImpl(li, progress); 2505 if (FAILED(rc)) DebugBreakThrow(rc);2505 if (FAILED(rc)) throw rc; 2506 2506 2507 2507 /* Unlock the appliance for the fs import thread */
Note:
See TracChangeset
for help on using the changeset viewer.