Changeset 33353 in vbox
- Timestamp:
- Oct 22, 2010 1:29:33 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33348 r33353 1661 1661 */ 1662 1662 void Appliance::importOneDiskImage(const ovf::DiskImage &di, 1663 const Utf8Str &strTargetPath,1663 Utf8Str strTargetPath, 1664 1664 ComObjPtr<Medium> &pTargetHD, 1665 1665 ImportStack &stack, … … 1672 1672 if (FAILED(rc)) throw rc; 1673 1673 1674 Utf8Str strTrgFormat = "VMDK";1674 /* Get the system properties. */ 1675 1675 SystemProperties *pSysProps = mVirtualBox->getSystemProperties(); 1676 if (RTPathHaveExt(strTargetPath.c_str())) 1677 { 1678 char *pszExt = RTPathExt(strTargetPath.c_str()); 1679 /* Figure out which format the user like to have. Default is VMDK. */ 1680 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]); 1681 if (trgFormat.isNull()) 1682 throw setError(VBOX_E_NOT_SUPPORTED, 1683 tr("Could not find a valid medium format for the target disk '%s'"), 1684 strTargetPath.c_str()); 1685 /* Check the capabilities. We need create capabilities. */ 1686 ULONG lCabs = 0; 1687 rc = trgFormat->COMGETTER(Capabilities)(&lCabs); 1676 1677 // strTargetPath = "8d5193b2-82a0-4d53-be95-b7557238b000"; 1678 /* First of all check if the path is an UUID. If so, the user like to 1679 * import the disk into an existing path. This is useful for iSCSI for 1680 * example. */ 1681 RTUUID uuid; 1682 int vrc = RTUuidFromStr(&uuid, strTargetPath.c_str()); 1683 if (vrc == VINF_SUCCESS) 1684 { 1685 rc = mVirtualBox->findHardDiskById(Guid(uuid), true, &pTargetHD); 1688 1686 if (FAILED(rc)) throw rc; 1689 if (!( ((lCabs & MediumFormatCapabilities_CreateFixed) == MediumFormatCapabilities_CreateFixed) 1690 || ((lCabs & MediumFormatCapabilities_CreateDynamic) == MediumFormatCapabilities_CreateDynamic))) 1691 throw setError(VBOX_E_NOT_SUPPORTED, 1692 tr("Could not find a valid medium format for the target disk '%s'"), 1693 strTargetPath.c_str()); 1694 Bstr bstrFormatName; 1695 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 1687 } 1688 else 1689 { 1690 Utf8Str strTrgFormat = "VMDK"; 1691 if (RTPathHaveExt(strTargetPath.c_str())) 1692 { 1693 char *pszExt = RTPathExt(strTargetPath.c_str()); 1694 /* Figure out which format the user like to have. Default is VMDK. */ 1695 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(&pszExt[1]); 1696 if (trgFormat.isNull()) 1697 throw setError(VBOX_E_NOT_SUPPORTED, 1698 tr("Could not find a valid medium format for the target disk '%s'"), 1699 strTargetPath.c_str()); 1700 /* Check the capabilities. We need create capabilities. */ 1701 ULONG lCabs = 0; 1702 rc = trgFormat->COMGETTER(Capabilities)(&lCabs); 1703 if (FAILED(rc)) throw rc; 1704 if (!( ((lCabs & MediumFormatCapabilities_CreateFixed) == MediumFormatCapabilities_CreateFixed) 1705 || ((lCabs & MediumFormatCapabilities_CreateDynamic) == MediumFormatCapabilities_CreateDynamic))) 1706 throw setError(VBOX_E_NOT_SUPPORTED, 1707 tr("Could not find a valid medium format for the target disk '%s'"), 1708 strTargetPath.c_str()); 1709 Bstr bstrFormatName; 1710 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 1711 if (FAILED(rc)) throw rc; 1712 strTrgFormat = Utf8Str(bstrFormatName); 1713 } 1714 1715 bool fNeedsGlobalSaveSettings; 1716 /* Create an IMedium object. */ 1717 pTargetHD.createObject(); 1718 rc = pTargetHD->init(mVirtualBox, 1719 strTrgFormat, 1720 strTargetPath, 1721 Guid::Empty, // media registry 1722 &fNeedsGlobalSaveSettings); 1696 1723 if (FAILED(rc)) throw rc; 1697 strTrgFormat = Utf8Str(bstrFormatName); 1698 } 1699 1700 bool fNeedsGlobalSaveSettings; 1701 /* Create an IMedium object. */ 1702 pTargetHD.createObject(); 1703 rc = pTargetHD->init(mVirtualBox, 1704 strTrgFormat, 1705 strTargetPath, 1706 Guid::Empty, // media registry 1707 &fNeedsGlobalSaveSettings); 1708 if (FAILED(rc)) throw rc; 1709 1710 /* Now create an empty hard disk. */ 1711 rc = mVirtualBox->CreateHardDisk(NULL, 1712 Bstr(strTargetPath).raw(), 1713 ComPtr<IMedium>(pTargetHD).asOutParam()); 1714 if (FAILED(rc)) throw rc; 1724 1725 /* Now create an empty hard disk. */ 1726 rc = mVirtualBox->CreateHardDisk(NULL, 1727 Bstr(strTargetPath).raw(), 1728 ComPtr<IMedium>(pTargetHD).asOutParam()); 1729 if (FAILED(rc)) throw rc; 1730 } 1715 1731 1716 1732 const Utf8Str &strSourceOVF = di.strHref; -
trunk/src/VBox/Main/include/ApplianceImpl.h
r33289 r33353 178 178 179 179 void importOneDiskImage(const ovf::DiskImage &di, 180 const Utf8Str &strTargetPath,180 Utf8Str strTargetPath, 181 181 ComObjPtr<Medium> &pTargetHD, 182 182 ImportStack &stack,
Note:
See TracChangeset
for help on using the changeset viewer.