VirtualBox

vbox的更動 61852 路徑 trunk/src/VBox/Storage


忽略:
時間撮記:
2016-6-23 下午01:01:12 (8 年 以前)
作者:
vboxsync
訊息:

Storage/VMDK: Addendum for r108253, make sure to always increase the size of the descriptor to read even if opened readonly (but don't write the new value back)

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Storage/VMDK.cpp

    r61844 r61852  
    30793079        /* HACK: extend the descriptor if it is unusually small and it fits in
    30803080         * the unused space after the image header. Allows opening VMDK files
    3081          * with extremely small descriptor in read/write mode. */
    3082         if (    !(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY)
    3083             &&  pExtent->cDescriptorSectors < 3
     3081         * with extremely small descriptor in read/write mode.
     3082         *
     3083         * The previous version introduced a possible regression for VMDK stream
     3084         * optimized images from VMware which tend to have only a single sector sized
     3085         * descriptor. Increasing the descriptor size resulted in adding the various uuid
     3086         * entries required to make it work with VBox but for stream optimized images
     3087         * the updated binary header wasn't written to the disk creating a mismatch
     3088         * between advertised and real descriptor size.
     3089         *
     3090         * The descriptor size will be increased even if opened readonly now if there
     3091         * enough room but the new value will not be written back to the image.
     3092         */
     3093        if (    pExtent->cDescriptorSectors < 3
    30843094            &&  (int64_t)pExtent->uSectorGD - pExtent->uDescriptorSector >= 4
    30853095            &&  (!pExtent->uSectorRGD || (int64_t)pExtent->uSectorRGD - pExtent->uDescriptorSector >= 4))
     
    30883098
    30893099            pExtent->cDescriptorSectors = 4;
    3090             /*
    3091              * Update the on disk number now to make sure we don't introduce inconsistencies
    3092              * in case of stream optimized images from VMware where the descriptor is just
    3093              * one sector big (the binary header is not written to disk for complete
    3094              * stream optimized images in vmdkFlushImage()).
    3095              */
    3096             uint64_t u64DescSizeNew = RT_H2LE_U64(pExtent->cDescriptorSectors);
    3097             rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pFile->pStorage, RT_OFFSETOF(SparseExtentHeader, descriptorSize),
    3098                                         &u64DescSizeNew, sizeof(u64DescSizeNew));
    3099             if (RT_FAILURE(rc))
     3100            if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    31003101            {
    3101                 LogFlowFunc(("Increasing the descriptor size failed with %Rrc\n", rc));
    3102                 /* Restore the old size and carry on. */
    3103                 pExtent->cDescriptorSectors = cDescriptorSectorsOld;
     3102                /*
     3103                 * Update the on disk number now to make sure we don't introduce inconsistencies
     3104                 * in case of stream optimized images from VMware where the descriptor is just
     3105                 * one sector big (the binary header is not written to disk for complete
     3106                 * stream optimized images in vmdkFlushImage()).
     3107                 */
     3108                uint64_t u64DescSizeNew = RT_H2LE_U64(pExtent->cDescriptorSectors);
     3109                rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pFile->pStorage, RT_OFFSETOF(SparseExtentHeader, descriptorSize),
     3110                                            &u64DescSizeNew, sizeof(u64DescSizeNew));
     3111                if (RT_FAILURE(rc))
     3112                {
     3113                    LogFlowFunc(("Increasing the descriptor size failed with %Rrc\n", rc));
     3114                    /* Restore the old size and carry on. */
     3115                    pExtent->cDescriptorSectors = cDescriptorSectorsOld;
     3116                }
    31043117            }
    31053118        }
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette