VirtualBox

Ignore:
Timestamp:
Nov 22, 2013 10:37:17 AM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
90839
Message:

pr7072. Search an appropriate medium format using, firstly, URL given in the OVF description file and, secondly, using an image extension.

File:
1 edited

Legend:

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

    r49408 r49620  
    2929#include "ProgressImpl.h"
    3030#include "MachineImpl.h"
    31 #include "MediumFormatImpl.h"
    3231#include "SystemPropertiesImpl.h"
    3332#include "AutoCaller.h"
     
    728727}
    729728
     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 */
     739HRESULT 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
    730777/**
    731778 * 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