VirtualBox

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


Ignore:
Timestamp:
Mar 8, 2019 2:55:07 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
129234
Message:

Added AllocationBlockSize property to VDI backend, and ability to set properties with VBoxManage --property key=value

File:
1 edited

Legend:

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

    r76553 r77606  
    3939#define SET_ENDIAN_U32(conv, u32) (conv == VDIECONV_H2F ? RT_H2LE_U32(u32) : RT_LE2H_U32(u32))
    4040#define SET_ENDIAN_U64(conv, u64) (conv == VDIECONV_H2F ? RT_H2LE_U64(u64) : RT_LE2H_U64(u64))
     41
     42static const char *vdiAllocationBlockSize = "1048576";
     43
     44static const VDCONFIGINFO vdiConfigInfo[] = {
     45    { "AllocationBlockSize",            vdiAllocationBlockSize,           VDCFGVALUETYPE_INTEGER,      0 }
     46};
    4147
    4248
     
    178184}
    179185
     186
    180187/**
    181188 * Internal: Set the appropriate endianess on all the Blocks pointed.
     
    549556 */
    550557static int vdiSetupImageState(PVDIIMAGEDESC pImage, unsigned uImageFlags, const char *pszComment,
    551                               uint64_t cbSize, uint32_t cbDataAlign, PCVDGEOMETRY pPCHSGeometry,
     558                              uint64_t cbSize, uint32_t cbAllocationBlock, uint32_t cbDataAlign, PCVDGEOMETRY pPCHSGeometry,
    552559                              PCVDGEOMETRY pLCHSGeometry)
    553560{
     
    555562
    556563    vdiInitPreHeader(&pImage->PreHeader);
    557     vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0,
     564    vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, cbAllocationBlock, 0,
    558565                  cbDataAlign);
    559566    /* Save PCHS geometry. Not much work, and makes the flow of information
     
    696703    int rc = VINF_SUCCESS;
    697704    uint32_t cbDataAlign = VDI_DATA_ALIGN;
    698 
     705    uint32_t cbAllocationBlock = VDI_IMAGE_DEFAULT_BLOCK_SIZE;
    699706    AssertPtr(pPCHSGeometry);
    700707    AssertPtr(pLCHSGeometry);
     
    710717                       N_("VDI: comment is too long for '%s'"), pImage->pszFilename);
    711718
     719    PVDINTERFACECONFIG pImgCfg = VDIfConfigGet(pImage->pVDIfsImage);
     720    if (pImgCfg) {
     721        rc = VDCFGQueryU32Def(pImgCfg, "AllocationBlockSize", &cbAllocationBlock, VDI_IMAGE_DEFAULT_BLOCK_SIZE);
     722        if (RT_FAILURE(rc))
     723            rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS,
     724                           N_("VDI: Getting AllocationBlockSize for '%s' failed (%Rrc)"), pImage->pszFilename, rc);
     725    }
     726
    712727    if (pIfCfg)
    713728    {
     
    720735    if (RT_SUCCESS(rc))
    721736    {
    722         rc = vdiSetupImageState(pImage, uImageFlags, pszComment, cbSize, cbDataAlign,
    723                                 pPCHSGeometry, pLCHSGeometry);
     737
     738        rc = vdiSetupImageState(pImage, uImageFlags, pszComment, cbSize,
     739                cbAllocationBlock, cbDataAlign, pPCHSGeometry, pLCHSGeometry);
    724740        if (RT_SUCCESS(rc))
    725741        {
     
    14841500        PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);
    14851501        PVDINTERFACECONFIG pIfCfg = VDIfConfigGet(pVDIfsOperation);
    1486 
    14871502        pImage->pszFilename = pszFilename;
    14881503        pImage->pStorage = NULL;
     
    31323147    s_aVdiFileExtensions,
    31333148    /* paConfigInfo */
    3134     NULL,
     3149    vdiConfigInfo,
    31353150    /* pfnProbe */
    31363151    vdiProbe,
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