VirtualBox

Changeset 24916 in vbox for trunk/src


Ignore:
Timestamp:
Nov 24, 2009 3:21:07 PM (15 years ago)
Author:
vboxsync
Message:

Storage/VMDK: fix buffers for really huge VMDK files split into 2G pieces, includes changelog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r24778 r24916  
    343343/**
    344344 * Maximum number of lines in a descriptor file. Not worth the effort of
    345  * making it variable. Descriptor files are generally very short (~20 lines).
     345 * making it variable. Descriptor files are generally very short (~20 lines),
     346 * with the exception of sparse files split in 2G chunks, which need for the
     347 * maximum size (almost 2T) exactly 1025 lines for the disk database.
    346348 */
    347 #define VMDK_DESCRIPTOR_LINES_MAX   100U
     349#define VMDK_DESCRIPTOR_LINES_MAX   1100U
    348350
    349351/**
     
    29932995    else
    29942996    {
    2995         pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20);
     2997        /* Allocate at least 10K, and make sure that there is 5K free space
     2998         * in case new entries need to be added to the descriptor. Never
     2999         * alocate more than 128K, because that's no valid descriptor file
     3000         * and will result in the correct "truncated read" error handling. */
     3001        uint64_t cbSize;
     3002        rc = vmdkFileGetSize(pFile, &cbSize);
     3003        if (RT_FAILURE(rc))
     3004            goto out;
     3005        if (cbSize % VMDK_SECTOR2BYTE(10))
     3006            cbSize += VMDK_SECTOR2BYTE(20) - cbSize % VMDK_SECTOR2BYTE(10);
     3007        else
     3008            cbSize += VMDK_SECTOR2BYTE(10);
     3009        cbSize = RT_MIN(cbSize, _128K);
     3010        pImage->cbDescAlloc = RT_MAX(VMDK_SECTOR2BYTE(20), cbSize);
    29963011        pImage->pDescData = (char *)RTMemAllocZ(pImage->cbDescAlloc);
    29973012        if (!pImage->pDescData)
     
    45494564    pImage->pDescData = NULL;
    45504565    pImage->pVDIfsDisk = NULL;
    4551     pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20);
     4566    /* Descriptors for split images can be pretty large, especially if the
     4567     * filename is long. So prepare for the worst, and allocate quite some
     4568     * memory for the descriptor in this case. */
     4569    if (uImageFlags & VD_VMDK_IMAGE_FLAGS_SPLIT_2G)
     4570        pImage->cbDescAlloc = VMDK_SECTOR2BYTE(200);
     4571    else
     4572        pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20);
    45524573    pImage->pDescData = (char *)RTMemAllocZ(pImage->cbDescAlloc);
    45534574    if (!pImage->pDescData)
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