VirtualBox

Changeset 37586 in vbox


Ignore:
Timestamp:
Jun 22, 2011 11:49:40 AM (14 years ago)
Author:
vboxsync
Message:

Main/Medium: Fix incorrect forcing of absolute paths for non-file based media. Triggered with iSCSI, causing strange full location values. Also clean up code a bit which checks backend capabilities.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MediumFormatImpl.h

    r35638 r37586  
    77
    88/*
    9  * Copyright (C) 2008-2010 Oracle Corporation
     9 * Copyright (C) 2008-2011 Oracle Corporation
    1010 *
    1111 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6565        const StrList        llFileExtensions;
    6666        const DeviceTypeList llDeviceTypes;
    67         const uint64_t      capabilities;
     67        const MediumFormatCapabilities_T capabilities;
    6868        const PropertyList   llProperties;
    6969    };
     
    112112    const StrList& getFileExtensions() const { return m.llFileExtensions; }
    113113    /** Const, no need to lock */
    114     uint64_t getCapabilities() const { return m.capabilities; }
     114    MediumFormatCapabilities_T getCapabilities() const { return m.capabilities; }
    115115    /** Const, no need to lock */
    116116    const PropertyList& getProperties() const { return m.llProperties; }
  • trunk/src/VBox/Main/src-server/MediumFormatImpl.cpp

    r37423 r37586  
    66
    77/*
    8  * Copyright (C) 2008-2010 Oracle Corporation
     8 * Copyright (C) 2008-2011 Oracle Corporation
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6666     * name/description field. */
    6767    unconst(m.strName) = aVDInfo->pszBackend;
    68     /* The capabilities of the backend */
     68    /* The capabilities of the backend. Assumes 1:1 mapping! */
    6969    unconst(m.capabilities) = aVDInfo->uBackendCaps;
    7070    /* Save the supported file extensions in a list */
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r37525 r37586  
    923923 * file.
    924924 *
    925  * For hard disks that don't have the VD_CAP_CREATE_FIXED or
    926  * VD_CAP_CREATE_DYNAMIC capability (and therefore cannot be created or deleted
     925 * For hard disks that don't have the MediumFormatCapabilities_CreateFixed or
     926 * MediumFormatCapabilities_CreateDynamic capability (and therefore cannot be created or deleted
    927927 * with the means of VirtualBox) the associated storage unit is assumed to be
    928928 * ready for use so the state of the hard disk object will be set to Created.
     
    11851185    }
    11861186
    1187     // compose full path of the medium, if it's not fully qualified...
    1188     // slightly convoluted logic here. If the caller has given us a
    1189     // machine folder, then a relative path will be relative to that:
    11901187    Utf8Str strFull;
    1191     if (    !strMachineFolder.isEmpty()
    1192          && !RTPathStartsWithRoot(data.strLocation.c_str())
    1193        )
    1194     {
    1195         strFull = strMachineFolder;
    1196         strFull += RTPATH_SLASH;
    1197         strFull += data.strLocation;
     1188    if (m->formatObj->getCapabilities() & MediumFormatCapabilities_File)
     1189    {
     1190        // compose full path of the medium, if it's not fully qualified...
     1191        // slightly convoluted logic here. If the caller has given us a
     1192        // machine folder, then a relative path will be relative to that:
     1193        if (    !strMachineFolder.isEmpty()
     1194             && !RTPathStartsWithRoot(data.strLocation.c_str())
     1195           )
     1196        {
     1197            strFull = strMachineFolder;
     1198            strFull += RTPATH_SLASH;
     1199            strFull += data.strLocation;
     1200        }
     1201        else
     1202        {
     1203            // Otherwise use the old VirtualBox "make absolute path" logic:
     1204            rc = m->pVirtualBox->calculateFullPath(data.strLocation, strFull);
     1205            if (FAILED(rc)) return rc;
     1206        }
    11981207    }
    11991208    else
    1200     {
    1201         // Otherwise use the old VirtualBox "make absolute path" logic:
    1202         rc = m->pVirtualBox->calculateFullPath(data.strLocation, strFull);
    1203         if (FAILED(rc)) return rc;
    1204     }
     1209        strFull = data.strLocation;
    12051210
    12061211    rc = setLocation(strFull);
     
    56785683        }
    56795684
    5680         // we must always have full paths now
    5681         if (!RTPathStartsWithRoot(locationFull.c_str()))
     5685        // we must always have full paths now (if it refers to a file)
     5686        if (   (m->formatObj->getCapabilities() & MediumFormatCapabilities_File)
     5687            && !RTPathStartsWithRoot(locationFull.c_str()))
    56825688            return setError(VBOX_E_FILE_ERROR,
    56835689                            tr("The given path '%s' is not fully qualified"),
     
    61986204        Utf8Str location(m->strLocationFull);
    61996205        uint64_t capabilities = m->formatObj->getCapabilities();
    6200         ComAssertThrow(capabilities & (  VD_CAP_CREATE_FIXED
    6201                                        | VD_CAP_CREATE_DYNAMIC), E_FAIL);
     6206        ComAssertThrow(capabilities & (  MediumFormatCapabilities_CreateFixed
     6207                                       | MediumFormatCapabilities_CreateDynamic), E_FAIL);
    62026208        Assert(m->state == MediumState_Creating);
    62036209
     
    62126218        {
    62136219            /* ensure the directory exists */
    6214             if (capabilities & VD_CAP_FILE)
     6220            if (capabilities & MediumFormatCapabilities_File)
    62156221            {
    62166222                rc = VirtualBox::ensureFilePathExists(location);
     
    63296335        Utf8Str targetLocation(pTarget->m->strLocationFull);
    63306336        uint64_t capabilities = pTarget->m->formatObj->getCapabilities();
    6331         ComAssertThrow(capabilities & VD_CAP_CREATE_DYNAMIC, E_FAIL);
     6337        ComAssertThrow(capabilities & MediumFormatCapabilities_CreateDynamic, E_FAIL);
    63326338
    63336339        Assert(pTarget->m->state == MediumState_Creating);
     
    63796385
    63806386            /* ensure the target directory exists */
    6381             if (capabilities & VD_CAP_FILE)
     6387            if (capabilities & MediumFormatCapabilities_File)
    63826388            {
    63836389                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
     
    68826888
    68836889            /* ensure the target directory exists */
    6884             if (capabilities & VD_CAP_FILE)
     6890            if (capabilities & MediumFormatCapabilities_File)
    68856891            {
    68866892                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
     
    75317537
    75327538            /* ensure the target directory exists */
    7533             if (capabilities & VD_CAP_FILE)
     7539            if (capabilities & MediumFormatCapabilities_File)
    75347540            {
    75357541                rc = VirtualBox::ensureFilePathExists(targetLocation);
     
    76567662
    76577663            /* ensure the target directory exists */
    7658             if (capabilities & VD_CAP_FILE)
     7664            if (capabilities & MediumFormatCapabilities_File)
    76597665            {
    76607666                HRESULT rc = VirtualBox::ensureFilePathExists(targetLocation);
Note: See TracChangeset for help on using the changeset viewer.

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