VirtualBox

Changeset 43602 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Oct 10, 2012 3:57:27 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
81297
Message:

Storage/VDI: Make the block data alignment configurable

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VDI.cpp

    r42915 r43602  
    326326static void vdiInitHeader(PVDIHEADER pHeader, uint32_t uImageFlags,
    327327                          const char *pszComment, uint64_t cbDisk,
    328                           uint32_t cbBlock, uint32_t cbBlockExtra)
     328                          uint32_t cbBlock, uint32_t cbBlockExtra,
     329                          uint32_t cbDataAlign)
    329330{
    330331    pHeader->uVersion = VDI_IMAGE_VERSION;
     
    360361
    361362    /* Init offsets. */
    362     pHeader->u.v1plus.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1PLUS), VDI_DATA_ALIGN);
    363     pHeader->u.v1plus.offData = RT_ALIGN_32(pHeader->u.v1plus.offBlocks + (pHeader->u.v1plus.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), VDI_DATA_ALIGN);
     363    pHeader->u.v1plus.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1PLUS), cbDataAlign);
     364    pHeader->u.v1plus.offData = RT_ALIGN_32(pHeader->u.v1plus.offBlocks + (pHeader->u.v1plus.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), cbDataAlign);
    364365
    365366    /* Init uuids. */
     
    521522                          unsigned uOpenFlags, PFNVDPROGRESS pfnProgress,
    522523                          void *pvUser, unsigned uPercentStart,
    523                           unsigned uPercentSpan)
     524                          unsigned uPercentSpan, PVDINTERFACECONFIG pIfCfg)
    524525{
    525526    int rc;
     
    527528    uint64_t cbFill;
    528529    uint64_t uOff;
     530    uint32_t cbDataAlign = VDI_DATA_ALIGN;
    529531
    530532    AssertPtr(pPCHSGeometry);
     
    544546    }
    545547
     548    if (pIfCfg)
     549    {
     550        rc = VDCFGQueryU32Def(pIfCfg, "DataAlignment", &cbDataAlign, VDI_DATA_ALIGN);
     551        if (RT_FAILURE(rc))
     552        {
     553            rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS,
     554                           N_("VDI: Getting data alignment for '%s' failed (%Rrc)"), pImage->pszFilename);
     555            goto out;
     556        }
     557    }
     558
    546559    vdiInitPreHeader(&pImage->PreHeader);
    547     vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0);
     560    vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0,
     561                  cbDataAlign);
    548562    /* Save PCHS geometry. Not much work, and makes the flow of information
    549563     * quite a bit clearer - relying on the higher level isn't obvious. */
     
    14761490    }
    14771491
     1492    PVDINTERFACECONFIG pIfCfg = VDIfConfigGet(pVDIfsOperation);
     1493
    14781494    /* Check the image flags. */
    14791495    if ((uImageFlags & ~VD_VDI_IMAGE_FLAGS_MASK) != 0)
     
    15251541    rc = vdiCreateImage(pImage, cbSize, uImageFlags, pszComment,
    15261542                        pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags,
    1527                         pfnProgress, pvUser, uPercentStart, uPercentSpan);
     1543                        pfnProgress, pvUser, uPercentStart, uPercentSpan,
     1544                        pIfCfg);
    15281545    if (RT_SUCCESS(rc))
    15291546    {
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