VirtualBox

Changeset 79742 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 12, 2019 4:11:19 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132104
Message:

Changes per #5899 / Comment #14

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r77857 r79742  
    350350    static DECLCALLBACK(int) i_vdConfigQuerySize(void *pvUser, const char *pszName,
    351351                                                 size_t *pcbValue);
     352    static DECLCALLBACK(int) i_vdConfigUpdate(void *pvUser, bool fCreate,
     353                                            const char *pszName, const char *pszValue);
     354
    352355    static DECLCALLBACK(int) i_vdConfigQuery(void *pvUser, const char *pszName,
    353356                                             char *pszValue, size_t cchValue);
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r79479 r79742  
    847847    m->vdIfConfig.pfnQuerySize = i_vdConfigQuerySize;
    848848    m->vdIfConfig.pfnQuery = i_vdConfigQuery;
     849    m->vdIfConfig.pfnUpdate = i_vdConfigUpdate;
    849850    m->vdIfConfig.pfnQueryBytes = NULL;
    850851
     
    46744675            const Utf8Str &name = it->first;
    46754676            const Utf8Str &value = it->second;
    4676             /* do NOT store the plain InitiatorSecret */
    4677             if (   !fHaveInitiatorSecretEncrypted
    4678                 || !name.equals("InitiatorSecret"))
    4679                 data.properties[name] = value;
    4680         }
     4677            bool fCreateOnly = false;
     4678            for (MediumFormat::PropertyArray::const_iterator itf = m->formatObj->i_getProperties().begin();
     4679                 itf != m->formatObj->i_getProperties().end();
     4680                 ++itf)
     4681             {
     4682                if (itf->strName.equals(name) &&
     4683                    (itf->flags & VD_CFGKEY_CREATEONLY))
     4684                {
     4685                        fCreateOnly = true;
     4686                        break;
     4687                }
     4688            }
     4689            if (!fCreateOnly)
     4690                /* do NOT store the plain InitiatorSecret */
     4691                if (   !fHaveInitiatorSecretEncrypted
     4692                    || !name.equals("InitiatorSecret"))
     4693                            data.properties[name] = value;        }
    46814694    }
    46824695    if (fHaveInitiatorSecretEncrypted)
     
    80188031    memcpy(pszValue, psz, cch + 1);
    80198032    return VINF_SUCCESS;
     8033}
     8034
     8035DECLCALLBACK(int) Medium::i_vdConfigUpdate(void *pvUser,
     8036                                                bool fCreate,
     8037                                                const char *pszName,
     8038                                                const char *pszValue)
     8039{
     8040    int rv = VINF_SUCCESS;
     8041    Utf8Str pName = Utf8Str(pszName);
     8042    Medium *that = (Medium *)pvUser;
     8043    AutoWriteLock mlock(that COMMA_LOCKVAL_SRC_POS);
     8044    settings::StringsMap::const_iterator it = that->m->mapProperties.find(pName);
     8045    if (it == that->m->mapProperties.end() && !fCreate)
     8046        rv = VERR_CFGM_VALUE_NOT_FOUND;
     8047    else
     8048        that->m->mapProperties[pName] = Utf8Str(pszValue);
     8049    mlock.release();
     8050    return rv;
    80208051}
    80218052
  • trunk/src/VBox/Storage/VDI.cpp

    r77622 r79742  
    4444static const VDCONFIGINFO vdiConfigInfo[] =
    4545{
    46     { "AllocationBlockSize",            vdiAllocationBlockSize,           VDCFGVALUETYPE_INTEGER,      0 },
     46    { "AllocationBlockSize",            vdiAllocationBlockSize,           VDCFGVALUETYPE_INTEGER,      VD_CFGKEY_CREATEONLY },
    4747    { NULL,                             NULL,                             VDCFGVALUETYPE_INTEGER,      0 }
    4848};
     
    541541    pImage->uShiftOffset2Index = getPowerOfTwo(getImageBlockSize(&pImage->Header));
    542542    pImage->offStartBlockData  = getImageExtraBlockSize(&pImage->Header);
    543     pImage->cbTotalBlockData   =   pImage->offStartBlockData
     543    pImage->cbAllocationBlock  = getImageBlockSize(&pImage->Header);
     544    pImage->cbTotalBlockData   = pImage->offStartBlockData
    544545                                 + getImageBlockSize(&pImage->Header);
    545546}
     
    706707    int rc = VINF_SUCCESS;
    707708    uint32_t cbDataAlign = VDI_DATA_ALIGN;
    708     uint32_t cbAllocationBlock = VDI_IMAGE_DEFAULT_BLOCK_SIZE;
    709709    AssertPtr(pPCHSGeometry);
    710710    AssertPtr(pLCHSGeometry);
     
    723723    if (pImgCfg)
    724724    {
    725         rc = VDCFGQueryU32Def(pImgCfg, "AllocationBlockSize", &cbAllocationBlock, VDI_IMAGE_DEFAULT_BLOCK_SIZE);
     725        rc = VDCFGQueryU32Def(pImgCfg, "AllocationBlockSize",
     726                &pImage->cbAllocationBlock, VDI_IMAGE_DEFAULT_BLOCK_SIZE);
    726727        if (RT_FAILURE(rc))
    727728            rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS,
     
    741742
    742743        rc = vdiSetupImageState(pImage, uImageFlags, pszComment, cbSize,
    743                 cbAllocationBlock, cbDataAlign, pPCHSGeometry, pLCHSGeometry);
     744                pImage->cbAllocationBlock, cbDataAlign, pPCHSGeometry, pLCHSGeometry);
     745
    744746        if (RT_SUCCESS(rc))
    745747        {
     
    10131015        pRegion->cbMetadata           = 0;
    10141016        pRegion->cRegionBlocksOrBytes = getImageDiskSize(&pImage->Header);
     1017        if (uOpenFlags & VD_OPEN_FLAGS_INFO)
     1018        {
     1019            PVDINTERFACECONFIG pImgCfg = VDIfConfigGet(pImage->pVDIfsImage);
     1020            if (pImgCfg)
     1021            {
     1022                rc = VDCFGUpdateU64(pImgCfg, true, "AllocationBlockSize", pImage->cbAllocationBlock);
     1023                if (RT_FAILURE(rc))
     1024                    return rc;
     1025            }
     1026        }
    10151027    }
    10161028    else
  • trunk/src/VBox/Storage/VDICore.h

    r76578 r79742  
    554554    /** Total size of image block (including the extra data). */
    555555    unsigned                cbTotalBlockData;
     556    /** Allocation Block Size */
     557    unsigned                cbAllocationBlock;
    556558    /** Container filename. (UTF-8) */
    557559    const char             *pszFilename;
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