VirtualBox

Ignore:
Timestamp:
Jun 13, 2013 10:07:09 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
86374
Message:

Export/import OVA/OVF package supports ISO images. The problem with the wrong search files in the archive has been resolved. (see #5429). 2 new elements SASD and EPASD were added in the OVF XML file structure (see #6022).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r46341 r46518  
    1919#include <iprt/path.h>
    2020#include <iprt/cpp/utils.h>
    21 
    2221#include <VBox/com/array.h>
     22#include <map>
    2323
    2424#include "ApplianceImpl.h"
     
    2929#include "ProgressImpl.h"
    3030#include "MachineImpl.h"
    31 
     31#include "MediumFormatImpl.h"
     32#include "SystemPropertiesImpl.h"
    3233#include "AutoCaller.h"
    3334#include "Logging.h"
     
    4243//
    4344////////////////////////////////////////////////////////////////////////////////
     45
     46static const char* const strISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm";
     47static const char* const strVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized";
     48static const char* const strVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse";
     49static const char* const strVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed";
     50static const char* const strVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed";
     51static const char* const strVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171";
     52
     53static std::map<Utf8Str, Utf8Str> supportedStandardsURI;
     54
     55static const char* const applianceIOTarName = "Appliance::IOTar";
     56static const char* const applianceIOFileName = "Appliance::IOFile";
     57
     58static std::map<APPLIANCEIONAME, Utf8Str> applianceIONameMap;
    4459
    4560static const struct
     
    304319}
    305320
     321
    306322////////////////////////////////////////////////////////////////////////////////
    307323//
     
    355371HRESULT Appliance::init(VirtualBox *aVirtualBox)
    356372{
     373    HRESULT rc = S_OK;
    357374    /* Enclose the state transition NotReady->InInit->Ready */
    358375    AutoInitSpan autoInitSpan(this);
     
    365382    m = new Data;
    366383
     384    initApplianceIONameMap();
     385
     386    rc = initSetOfSupportedStandardsURI();
     387
    367388    /* Confirm a successful initialization */
    368389    autoInitSpan.setSucceeded();
    369390
    370     return S_OK;
     391    return rc;
    371392}
    372393
     
    604625////////////////////////////////////////////////////////////////////////////////
    605626
     627HRESULT Appliance::initSetOfSupportedStandardsURI()
     628{
     629    HRESULT rc = S_OK;
     630    if (!supportedStandardsURI.empty())
     631        return rc;
     632
     633    /* Get the system properties. */
     634    SystemProperties *pSysProps = mVirtualBox->getSystemProperties();
     635    {
     636        ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("iso");
     637        if (trgFormat.isNull())
     638            return setError(E_FAIL, tr("Can't find appropriate medium format for ISO type of a virtual disk."));
     639
     640        Bstr bstrFormatName;
     641        rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());
     642        if (FAILED(rc)) return rc;
     643
     644        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
     645
     646        supportedStandardsURI.insert(std::make_pair(Utf8Str(strISOURI), strTrgFormat));
     647    }
     648
     649    {
     650        ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("vmdk");
     651        if (trgFormat.isNull())
     652            return setError(E_FAIL, tr("Can't find appropriate medium format for VMDK type of a virtual disk."));
     653
     654        Bstr bstrFormatName;
     655        rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());
     656        if (FAILED(rc)) return rc;
     657
     658        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
     659
     660        supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKStreamURI), strTrgFormat));
     661        supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKSparseURI), strTrgFormat));
     662        supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI), strTrgFormat));
     663        supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI2), strTrgFormat));
     664    }
     665
     666    {
     667        ComObjPtr<MediumFormat> trgFormat = pSysProps->mediumFormatFromExtension("vhd");
     668        if (trgFormat.isNull())
     669            return setError(E_FAIL, tr("Can't find appropriate medium format for VHD type of a virtual disk."));
     670
     671        Bstr bstrFormatName;
     672        rc = trgFormat->COMGETTER(Name)(bstrFormatName.asOutParam());
     673        if (FAILED(rc)) return rc;
     674
     675        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
     676
     677        supportedStandardsURI.insert(std::make_pair(Utf8Str(strVHDURI), strTrgFormat));
     678    }
     679
     680    return rc;
     681}
     682
     683Utf8Str Appliance::typeOfVirtualDiskFormatFromURI(Utf8Str uri) const
     684{
     685    Utf8Str type;
     686    std::map<Utf8Str, Utf8Str>::const_iterator cit = supportedStandardsURI.find(uri);
     687    if (cit != supportedStandardsURI.end())
     688    {
     689        type = cit->second;
     690    }
     691
     692    return type;
     693}
     694
     695std::set<Utf8Str> Appliance::URIFromTypeOfVirtualDiskFormat(Utf8Str type)
     696{
     697    std::set<Utf8Str> uri;
     698    std::map<Utf8Str, Utf8Str>::const_iterator cit = supportedStandardsURI.begin();
     699    while(cit != supportedStandardsURI.end())
     700    {
     701        if (cit->second.compare(type,Utf8Str::CaseInsensitive) == 0)
     702            uri.insert(cit->first);
     703        ++cit;
     704    }
     705
     706    return uri;
     707}
     708
     709HRESULT Appliance::initApplianceIONameMap()
     710{
     711    HRESULT rc = S_OK;
     712    if (!applianceIONameMap.empty())
     713        return rc;
     714
     715        applianceIONameMap.insert(std::make_pair(applianceIOTar, applianceIOTarName));
     716        applianceIONameMap.insert(std::make_pair(applianceIOFile, applianceIOFileName));
     717
     718    return rc;
     719}
     720
     721Utf8Str Appliance::applianceIOName(APPLIANCEIONAME type) const
     722{
     723    Utf8Str name;
     724    std::map<APPLIANCEIONAME, Utf8Str>::const_iterator cit = applianceIONameMap.find(type);
     725    if (cit != applianceIONameMap.end())
     726    {
     727        name = cit->second;
     728    }
     729
     730    return name;
     731}
     732
    606733/**
    607734 * Returns true if the appliance is in "idle" state. This should always be the
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette