VirtualBox

Changeset 14225 in vbox for trunk


Ignore:
Timestamp:
Nov 14, 2008 5:55:28 PM (16 years ago)
Author:
vboxsync
Message:

Main: Use the parent's hard disk format when implicitly creating differencing hard disks (or the default hard disk format if the parent format doesn't support differencing).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HardDisk2Impl.cpp

    r14224 r14225  
    16531653    /* delegate the rest to the profi */
    16541654    cancelMergeTo (aChain);
     1655}
     1656
     1657/**
     1658 * Returns a preferred format for differencing hard disks.
     1659 */
     1660Bstr HardDisk2::preferredDiffFormat()
     1661{
     1662    Bstr format;
     1663
     1664    AutoCaller autoCaller (this);
     1665    AssertComRCReturn (autoCaller.rc(), format);
     1666
     1667    /* mm.format is const, no need to lock */
     1668    format = mm.format;
     1669
     1670    /* check that our own format supports diffs */
     1671
     1672    /* lock system properties now to make the format check atomic with
     1673     * defaultHardDiskFormat() */
     1674    AutoReadLock propsLock (mVirtualBox->systemProperties());
     1675
     1676    ComObjPtr <HardDiskFormat> formatObj =
     1677        mVirtualBox->systemProperties()->hardDiskFormat (format);
     1678    AssertReturn (!formatObj.isNull(), format);
     1679
     1680    if (!(formatObj->capabilities() & HardDiskFormatCapabilities_Differencing))
     1681        format = mVirtualBox->systemProperties()->defaultHardDiskFormat();
     1682
     1683    return format;
    16551684}
    16561685
  • trunk/src/VBox/Main/HardDiskFormatImpl.cpp

    r14009 r14225  
    6161
    6262    /* The ID of the backend */
    63     unconst (mData.id) = aVDInfo->pszBackend;
     63    unconst (m.id) = aVDInfo->pszBackend;
    6464    /* The Name of the backend */
    6565    /* Use id for now as long as VDBACKENDINFO hasn't any extra
    6666     * name/description field. */
    67     unconst (mData.name) = aVDInfo->pszBackend;
     67    unconst (m.name) = aVDInfo->pszBackend;
    6868    /* The capabilities of the backend */
    69     unconst (mData.capabilities) = aVDInfo->uBackendCaps;
     69    unconst (m.capabilities) = aVDInfo->uBackendCaps;
    7070    /* Save the supported file extensions in a list */
    7171    if (aVDInfo->papszFileExtensions)
     
    7474        while (*papsz != NULL)
    7575        {
    76             unconst (mData.fileExtensions).push_back (*papsz);
     76            unconst (m.fileExtensions).push_back (*papsz);
    7777            ++ papsz;
    7878        }
     
    137137                                    flags,
    138138                                    defaultValue };
    139             unconst (mData.properties).push_back (prop);
     139            unconst (m.properties).push_back (prop);
    140140            ++ pa;
    141141        }
     
    161161        return;
    162162
    163     unconst (mData.properties).clear();
    164     unconst (mData.fileExtensions).clear();
    165     unconst (mData.capabilities) = 0;
    166     unconst (mData.name).setNull();
    167     unconst (mData.id).setNull();
     163    unconst (m.properties).clear();
     164    unconst (m.fileExtensions).clear();
     165    unconst (m.capabilities) = 0;
     166    unconst (m.name).setNull();
     167    unconst (m.id).setNull();
    168168}
    169169
     
    180180
    181181    /* this is const, no need to lock */
    182     mData.id.cloneTo (aId);
     182    m.id.cloneTo (aId);
    183183
    184184    return S_OK;
     
    194194
    195195    /* this is const, no need to lock */
    196     mData.name.cloneTo (aName);
     196    m.name.cloneTo (aName);
    197197
    198198    return S_OK;
     
    209209
    210210    /* this is const, no need to lock */
    211     com::SafeArray <BSTR> fileExtentions (mData.fileExtensions.size());
     211    com::SafeArray <BSTR> fileExtentions (m.fileExtensions.size());
    212212    int i = 0;
    213     for (BstrList::const_iterator it = mData.fileExtensions.begin();
    214         it != mData.fileExtensions.end(); ++ it, ++ i)
     213    for (BstrList::const_iterator it = m.fileExtensions.begin();
     214        it != m.fileExtensions.end(); ++ it, ++ i)
    215215        (*it).cloneTo (&fileExtentions [i]);
    216216    fileExtentions.detachTo (ComSafeArrayOutArg (aFileExtensions));
     
    227227    CheckComRCReturnRC (autoCaller.rc());
    228228
    229     /* mData.capabilities is const, no need to lock */
     229    /* m.capabilities is const, no need to lock */
    230230
    231231    /// @todo add COMGETTER(ExtendedCapabilities) when we reach the 32 bit
     
    233233    /// of defining enums (used to represent bit flags) that contain 64-bit
    234234    /// values)
    235     ComAssertRet (mData.capabilities == ((ULONG) mData.capabilities), E_FAIL);
    236 
    237     *aCaps = (ULONG) mData.capabilities;
     235    ComAssertRet (m.capabilities == ((ULONG) m.capabilities), E_FAIL);
     236
     237    *aCaps = (ULONG) m.capabilities;
    238238
    239239    return S_OK;
     
    257257
    258258    /* this is const, no need to lock */
    259     com::SafeArray <BSTR> propertyNames (mData.properties.size());
    260     com::SafeArray <BSTR> propertyDescriptions (mData.properties.size());
    261     com::SafeArray <DataType_T> propertyTypes (mData.properties.size());
    262     com::SafeArray <ULONG> propertyFlags (mData.properties.size());
    263     com::SafeArray <BSTR> propertyDefaults (mData.properties.size());
     259    com::SafeArray <BSTR> propertyNames (m.properties.size());
     260    com::SafeArray <BSTR> propertyDescriptions (m.properties.size());
     261    com::SafeArray <DataType_T> propertyTypes (m.properties.size());
     262    com::SafeArray <ULONG> propertyFlags (m.properties.size());
     263    com::SafeArray <BSTR> propertyDefaults (m.properties.size());
    264264
    265265    int i = 0;
    266     for (PropertyList::const_iterator it = mData.properties.begin();
    267          it != mData.properties.end(); ++ it, ++ i)
     266    for (PropertyList::const_iterator it = m.properties.begin();
     267         it != m.properties.end(); ++ it, ++ i)
    268268    {
    269269        const Property &prop = (*it);
  • trunk/src/VBox/Main/MachineImpl.cpp

    r14142 r14225  
    21312131        }
    21322132
    2133         /// @todo NEWMEDIA use the proper storage format (either the parent
    2134         /// storage type or the ISystemProperties::defaultHardDiskFormat)
    21352133        ComObjPtr <HardDisk2> diff;
    21362134        diff.createObject();
    2137         rc = diff->init (mParent, Bstr ("VDI"),
     2135        rc = diff->init (mParent, hd->preferredDiffFormat(),
    21382136                         BstrFmt ("%ls"RTPATH_SLASH_STR,
    21392137                                  mUserData->mSnapshotFolderFull.raw()));
     
    68626860            CheckComRCThrowRC (rc);
    68636861
    6864             /// @todo NEWMEDIA use the proper storage format (either the parent
    6865             /// storage type or the ISystemProperties::defaultHardDiskFormat)
    68666862            ComObjPtr <HardDisk2> diff;
    68676863            diff.createObject();
    6868             rc = diff->init (mParent, Bstr ("VDI"),
     6864            rc = diff->init (mParent, hd->preferredDiffFormat(),
    68696865                             BstrFmt ("%ls"RTPATH_SLASH_STR,
    68706866                                      mUserData->mSnapshotFolderFull.raw()));
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r14224 r14225  
    602602}
    603603
     604/**
     605 * Rerurns a hard disk format object corresponding to the given format
     606 * identifier or null if no such format.
     607 *
     608 * @param aFormat   Format identifier.
     609 *
     610 * @return ComObjPtr<HardDiskFormat>
     611 */
     612ComObjPtr <HardDiskFormat> SystemProperties::hardDiskFormat (const BSTR aFormat)
     613{
     614    ComObjPtr <HardDiskFormat> format;
     615
     616    AutoCaller autoCaller (this);
     617    AssertComRCReturn (autoCaller.rc(), format);
     618
     619    AutoReadLock alock (this);
     620
     621    for (HardDiskFormatList::const_iterator it = mHardDiskFormats.begin();
     622         it != mHardDiskFormats.end(); ++ it)
     623    {
     624        /* HardDiskFormat is all const, no need to lock */
     625
     626        if ((*it)->id() == aFormat)
     627        {
     628            format = *it;
     629            break;
     630        }
     631    }
     632
     633    return format;
     634}
     635
    604636// private methods
    605637/////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/include/HardDisk2Impl.h

    r14143 r14225  
    180180    void cancelDiscard (MergeChain *aChain);
    181181
     182    /** Returns a preferred format for a differencing hard disk. */
     183    Bstr preferredDiffFormat();
     184
    182185    // unsafe inline public methods for internal purposes only (ensure there is
    183186    // a caller and a read lock before calling them!)
  • trunk/src/VBox/Main/include/HardDiskFormatImpl.h

    r13956 r14225  
    8181    // (ensure there is a caller and a read lock before calling them!)
    8282
     83    /** Const, no need to lock */
     84    const Bstr &id() { return m.id; }
     85    /** Const, no need to lock */
     86    uint64_t capabilities() { return m.capabilities; }
     87
    8388    // for VirtualBoxSupportErrorInfoImpl
    8489    static const wchar_t *getComponentName() { return L"HardDiskFormat"; }
     
    109114    };
    110115
    111     Data mData;
     116    Data m;
    112117};
    113118
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r14224 r14225  
    9696    HRESULT saveSettings (settings::Key &aGlobal);
    9797
     98    ComObjPtr <HardDiskFormat> hardDiskFormat (const BSTR aFormat);
     99
     100    // public methods for internal purposes only
     101    // (ensure there is a caller and a read lock before calling them!)
     102
    98103    /** Default Machine path (as is, not full). Not thread safe (use object lock). */
    99104    const Bstr &defaultMachineFolder() const { return mDefaultMachineFolder; }
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