Changeset 49620 in vbox
- Timestamp:
- Nov 22, 2013 10:37:17 AM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ApplianceImpl.h
r49103 r49620 23 23 /* VBox includes */ 24 24 #include "VirtualBoxBase.h" 25 #include "MediumFormatImpl.h" 25 26 26 27 /* Todo: This file needs massive cleanup. Split IAppliance in a public and … … 154 155 155 156 Utf8Str applianceIOName(APPLIANCEIONAME type) const; 157 158 HRESULT findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf); 156 159 157 160 /******************************************************************************* -
trunk/src/VBox/Main/src-server/ApplianceImpl.cpp
r49408 r49620 29 29 #include "ProgressImpl.h" 30 30 #include "MachineImpl.h" 31 #include "MediumFormatImpl.h"32 31 #include "SystemPropertiesImpl.h" 33 32 #include "AutoCaller.h" … … 728 727 } 729 728 729 730 /** 731 * Returns a medium format object corresponding to the given 732 * disk image or null if no such format. 733 * 734 * @param di Disk Image 735 * @param mf Medium Format 736 * 737 * @return ComObjPtr<MediumFormat> 738 */ 739 HRESULT Appliance::findMediumFormatFromDiskImage(const ovf::DiskImage &di, ComObjPtr<MediumFormat>& mf) 740 { 741 HRESULT rc = S_OK; 742 743 /* Get the system properties. */ 744 SystemProperties *pSysProps = mVirtualBox->getSystemProperties(); 745 746 /* We need a proper source format description */ 747 /* Which format to use? */ 748 Utf8Str strSrcFormat = typeOfVirtualDiskFormatFromURI(di.strFormat); 749 750 /* 751 * fallback, if we can't determine virtual disk format using URI from the attribute ovf:format 752 * in the corresponding section <Disk> in the OVF file. 753 */ 754 if (strSrcFormat.isEmpty()) 755 { 756 /* Figure out from extension which format the image of disk has. */ 757 { 758 char *pszExt = RTPathSuffix(di.strHref.c_str()); 759 if (pszExt) 760 pszExt++; 761 mf = pSysProps->mediumFormatFromExtension(pszExt); 762 } 763 } 764 else 765 mf = pSysProps->mediumFormat(strSrcFormat); 766 767 if (mf.isNull()) 768 { 769 rc = setError(E_FAIL, 770 tr("Internal inconsistency looking up medium format for the disk image '%s'"), 771 di.strHref.c_str()); 772 } 773 774 return rc; 775 } 776 730 777 /** 731 778 * Returns true if the appliance is in "idle" state. This should always be the -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r49594 r49620 631 631 * So possibly, we aren't able to recognize some URIs. 632 632 */ 633 Utf8Str vdf = typeOfVirtualDiskFormatFromURI(di.strFormat); 634 635 /* 636 * fallback, if we can't determine virtual disk format using URI from the attribute ovf:format 637 * in the corresponding section <Disk> in the OVF file. 638 */ 639 if (vdf.isEmpty()) 640 { 641 /* Figure out from extension which format the image of disk has. */ 642 { 643 char *pszExt = RTPathSuffix(di.strHref.c_str()); 644 if (pszExt) 645 pszExt++; 646 /* Get the system properties. */ 647 SystemProperties *pSysProps = mVirtualBox->getSystemProperties(); 648 ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension(pszExt); 649 if (trgFormat.isNull()) 650 { 651 throw setError(E_FAIL, 652 tr("Internal inconsistency looking up medium format for the disk image '%s'"), 653 di.strHref.c_str()); 654 } 655 656 Bstr bstrFormatName; 657 rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 658 if (FAILED(rc)) 659 throw rc; 660 661 vdf = Utf8Str(bstrFormatName); 662 } 663 } 633 634 ComObjPtr<MediumFormat> mediumFormat; 635 rc = findMediumFormatFromDiskImage(di, mediumFormat); 636 if (FAILED(rc)) 637 throw rc; 638 639 Bstr bstrFormatName; 640 rc = mediumFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 641 if (FAILED(rc)) 642 throw rc; 643 644 Utf8Str vdf = Utf8Str(bstrFormatName); 664 645 665 646 // @todo: … … 2301 2282 strTempTargetFilename = strTempTargetFilename.stripPath(); 2302 2283 strTempTargetFilename = strTempTargetFilename.stripSuffix(); 2303 Utf8Str vdf = typeOfVirtualDiskFormatFromURI(di.strFormat);2304 2284 2305 2285 strTargetDir.append(strTempTargetFilename); … … 2462 2442 /* We need a proper source format description */ 2463 2443 /* Which format to use? */ 2464 Utf8Str strSrcFormat = typeOfVirtualDiskFormatFromURI(di.strFormat); 2465 2466 ComObjPtr<MediumFormat> srcFormat = pSysProps->mediumFormat(strSrcFormat); 2467 if (srcFormat.isNull()) 2444 ComObjPtr<MediumFormat> srcFormat; 2445 rc = findMediumFormatFromDiskImage(di, srcFormat); 2446 if (FAILED(rc)) 2468 2447 throw setError(VBOX_E_NOT_SUPPORTED, 2469 2448 tr("Could not find a valid medium format for the source disk '%s' " 2470 "Check correctness of the image format URL in the OVF description file."), 2449 "Check correctness of the image format URL in the OVF description file " 2450 "or extension of the image"), 2471 2451 RTPathFilename(strSourceOVF.c_str())); 2472 2452 … … 3184 3164 vsdeTargetHD->strVboxCurrent.c_str(), mhda.lControllerPort, mhda.lDevice)); 3185 3165 3186 Utf8Str vdf = typeOfVirtualDiskFormatFromURI(diCurrent.strFormat); 3166 ComObjPtr<MediumFormat> mediumFormat; 3167 rc = findMediumFormatFromDiskImage(diCurrent, mediumFormat); 3168 if (FAILED(rc)) 3169 throw rc; 3170 3171 Bstr bstrFormatName; 3172 rc = mediumFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 3173 if (FAILED(rc)) 3174 throw rc; 3175 3176 Utf8Str vdf = Utf8Str(bstrFormatName); 3187 3177 3188 3178 if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0) … … 3699 3689 Bstr hdId; 3700 3690 3701 Utf8Str vdf = typeOfVirtualDiskFormatFromURI(diCurrent.strFormat); 3691 ComObjPtr<MediumFormat> mediumFormat; 3692 rc = findMediumFormatFromDiskImage(diCurrent, mediumFormat); 3693 if (FAILED(rc)) 3694 throw rc; 3695 3696 Bstr bstrFormatName; 3697 rc = mediumFormat->COMGETTER(Name)(bstrFormatName.asOutParam()); 3698 if (FAILED(rc)) 3699 throw rc; 3700 3701 Utf8Str vdf = Utf8Str(bstrFormatName); 3702 3702 3703 3703 if (vdf.compare("RAW", Utf8Str::CaseInsensitive) == 0)
Note:
See TracChangeset
for help on using the changeset viewer.