VirtualBox

Changeset 63800 in vbox


Ignore:
Timestamp:
Sep 12, 2016 1:44:06 PM (8 years ago)
Author:
vboxsync
Message:

Storage/VMDK: Cleanup (part 2, get rid of unused code for ESX type sparse images)

File:
1 edited

Legend:

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

    r63799 r63800  
    154154
    155155
    156 #ifdef VBOX_WITH_VMDK_ESX
    157 
    158 /** @todo the ESX code is not tested, not used, and lacks error messages. */
    159 
    160 /**
    161  * Magic number for images created by VMware GSX Server 3 or ESX Server 3.
    162  */
    163 #define VMDK_ESX_SPARSE_MAGICNUMBER 0x44574f43 /* 'C' 'O' 'W' 'D' */
    164 
    165 #pragma pack(1)
    166 typedef struct COWDisk_Header
    167 {
    168     uint32_t    magicNumber;
    169     uint32_t    version;
    170     uint32_t    flags;
    171     uint32_t    numSectors;
    172     uint32_t    grainSize;
    173     uint32_t    gdOffset;
    174     uint32_t    numGDEntries;
    175     uint32_t    freeSector;
    176     /* The spec incompletely documents quite a few further fields, but states
    177      * that they are unused by the current format. Replace them by padding. */
    178     char        reserved1[1604];
    179     uint32_t    savedGeneration;
    180     char        reserved2[8];
    181     uint32_t    uncleanShutdown;
    182     char        padding[396];
    183 } COWDisk_Header;
    184 #pragma pack()
    185 #endif /* VBOX_WITH_VMDK_ESX */
    186 
    187 
    188156/** Convert sector number/size to byte offset/size. */
    189157#define VMDK_SECTOR2BYTE(u) ((uint64_t)(u) << 9)
     
    205173    /** VMFS extent, used by ESX. */
    206174    VMDKETYPE_VMFS
    207 #ifdef VBOX_WITH_VMDK_ESX
    208     ,
    209     /** ESX sparse extent. */
    210     VMDKETYPE_ESX_SPARSE
    211 #endif /* VBOX_WITH_VMDK_ESX */
    212175} VMDKETYPE, *PVMDKETYPE;
    213176
     
    21702133
    21712134        /* Type of the extent. */
    2172 #ifdef VBOX_WITH_VMDK_ESX
    2173         /** @todo Add the ESX extent types. Not necessary for now because
    2174          * the ESX extent types are only used inside an ESX server. They are
    2175          * automatically converted if the VMDK is exported. */
    2176 #endif /* VBOX_WITH_VMDK_ESX */
    21772135        if (!strncmp(pszLine, "SPARSE", 6))
    21782136        {
     
    28332791}
    28342792
    2835 #ifdef VBOX_WITH_VMDK_ESX
    2836 /**
    2837  * Internal: unused code to read the metadata of a sparse ESX extent.
    2838  *
    2839  * Such extents never leave ESX server, so this isn't ever used.
    2840  */
    2841 static int vmdkReadMetaESXSparseExtent(PVMDKEXTENT pExtent)
    2842 {
    2843     COWDisk_Header Header;
    2844 
    2845     int rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage, 0,
    2846                                    &Header, sizeof(Header));
    2847     if (RT_SUCCESS(rc))
    2848     {
    2849         if (    RT_LE2H_U32(Header.magicNumber) == VMDK_ESX_SPARSE_MAGICNUMBER
    2850             &&  RT_LE2H_U32(Header.version) == 1
    2851             &&  RT_LE2H_U32(Header.flags) == 3)
    2852         {
    2853             pExtent->enmType = VMDKETYPE_ESX_SPARSE;
    2854             pExtent->cSectors = RT_LE2H_U32(Header.numSectors);
    2855             pExtent->cSectorsPerGrain = RT_LE2H_U32(Header.grainSize);
    2856             pExtent->uDescriptorSector = 0;
    2857             pExtent->cDescriptorSectors = 0;
    2858             pExtent->uSectorGD = RT_LE2H_U32(Header.gdOffset);
    2859             pExtent->uSectorRGD = 0;
    2860             pExtent->cOverheadSectors = 0;
    2861             pExtent->cGTEntries = 4096;
    2862             pExtent->cSectorsPerGDE = cSectorsPerGDE;
    2863             pExtent->cGDEntries = (pExtent->cSectors + cSectorsPerGDE - 1) / cSectorsPerGDE;
    2864             pExtent->uFreeSector = RT_LE2H_U32(Header.freeSector);
    2865             pExtent->fUncleanShutdown = !!Header.uncleanShutdown;
    2866 
    2867             uint64_t cSectorsPerGDE = pExtent->cGTEntries * pExtent->cSectorsPerGrain;
    2868 
    2869             /*
    2870              * The spec says that this must be between 1 sector and 1MB. This code
    2871              * assumes it's a power of two, so check that requirement, too.
    2872              *
    2873              * Check that the number of computed GD entries matches the
    2874              * stored value. Better be safe than sorry.
    2875              */
    2876             if (    (pExtent->cSectorsPerGrain & (pExtent->cSectorsPerGrain - 1))
    2877                 ||  pExtent->cSectorsPerGrain == 0
    2878                 ||  pExtent->cSectorsPerGrain > 2048
    2879                 ||  !cSectorsPerGDE
    2880                 || cSectorsPerGDE > UINT32_MAX)
    2881                 || pExtent->cGDEntries != RT_LE2H_U32(Header.numGDEntries))
    2882                 rc = VERR_VD_VMDK_INVALID_HEADER;
    2883             else
    2884                 rc = vmdkReadGrainDirectory(pImage, pExtent);
    2885         }
    2886         else
    2887             rc = VERR_VD_VMDK_INVALID_HEADER;
    2888     }
    2889     else
    2890     {
    2891         vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("VMDK: error reading ESX sparse extent header in '%s'"), pExtent->pszFullname);
    2892         rc = VERR_VD_VMDK_INVALID_HEADER;
    2893     }
    2894 
    2895     if (RT_FAILURE(rc))
    2896         vmdkFreeExtentData(pImage, pExtent, false);
    2897 
    2898     return rc;
    2899 }
    2900 #endif /* VBOX_WITH_VMDK_ESX */
    2901 
    29022793/**
    29032794 * Internal: free the buffers used for streamOptimized images.
     
    29722863    {
    29732864        pExtent = &pImage->pExtents[i];
    2974         if (    pExtent->enmType == VMDKETYPE_HOSTED_SPARSE
    2975 #ifdef VBOX_WITH_VMDK_ESX
    2976             ||  pExtent->enmType == VMDKETYPE_ESX_SPARSE
    2977 #endif /* VBOX_WITH_VMDK_ESX */
    2978            )
     2865        if (pExtent->enmType == VMDKETYPE_HOSTED_SPARSE)
    29792866        {
    29802867            /* Allocate grain table cache. */
     
    33613248    {
    33623249        pExtent = &pImage->pExtents[i];
    3363         if (    pExtent->enmType == VMDKETYPE_HOSTED_SPARSE
    3364 #ifdef VBOX_WITH_VMDK_ESX
    3365             ||  pExtent->enmType == VMDKETYPE_ESX_SPARSE
    3366 #endif /* VBOX_WITH_VMDK_ESX */
    3367            )
     3250        if (pExtent->enmType == VMDKETYPE_HOSTED_SPARSE)
    33683251        {
    33693252            /* Here used to be a check whether the nominal size of an extent
     
    42544137                for (unsigned i = 0; i < pImage->cExtents; i++)
    42554138                {
    4256                     if (   (   pImage->pExtents[i].enmType == VMDKETYPE_HOSTED_SPARSE
    4257 #ifdef VBOX_WITH_VMDK_ESX
    4258                             || pImage->pExtents[i].enmType == VMDKETYPE_ESX_SPARSE
    4259 #endif /* VBOX_WITH_VMDK_ESX */
    4260                            )
     4139                    if (   pImage->pExtents[i].enmType == VMDKETYPE_HOSTED_SPARSE
    42614140                        && pImage->pExtents[i].fUncleanShutdown)
    42624141                    {
     
    44304309                    }
    44314310                    break;
    4432 #ifdef VBOX_WITH_VMDK_ESX
    4433                 case VMDKETYPE_ESX_SPARSE:
    4434                     /** @todo update the header. */
    4435                     break;
    4436 #endif /* VBOX_WITH_VMDK_ESX */
    44374311                case VMDKETYPE_VMFS:
    44384312                case VMDKETYPE_FLAT:
     
    44494323        {
    44504324            case VMDKETYPE_HOSTED_SPARSE:
    4451 #ifdef VBOX_WITH_VMDK_ESX
    4452             case VMDKETYPE_ESX_SPARSE:
    4453 #endif /* VBOX_WITH_VMDK_ESX */
    44544325            case VMDKETYPE_VMFS:
    44554326            case VMDKETYPE_FLAT:
     
    47754646            return vdIfError(pImage->pIfError, rc, RT_SRC_POS, N_("VMDK: cannot write updated backup grain table in '%s'"), pExtent->pszFullname);
    47764647    }
    4777 #ifdef VBOX_WITH_VMDK_ESX
    4778     if (RT_SUCCESS(rc) && pExtent->enmType == VMDKETYPE_ESX_SPARSE)
    4779     {
    4780         pExtent->uFreeSector = uGTSector + VMDK_BYTE2SECTOR(cbWrite);
    4781         pExtent->fMetaDirty = true;
    4782     }
    4783 #endif /* VBOX_WITH_VMDK_ESX */
    47844648
    47854649    LogFlowFunc(("leaving rc=%Rrc\n", rc));
    4786 
    47874650    return rc;
    47884651}
     
    53895252        || !VALID_PTR(pPCHSGeometry)
    53905253        || !VALID_PTR(pLCHSGeometry)
    5391 #ifndef VBOX_WITH_VMDK_ESX
    5392         || (    uImageFlags & VD_VMDK_IMAGE_FLAGS_ESX
    5393             &&  !(uImageFlags & VD_IMAGE_FLAGS_FIXED))
    5394 #endif
    53955254        || (   (uImageFlags & VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED)
    53965255            && (uImageFlags & ~(VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED | VD_IMAGE_FLAGS_DIFF))))
     
    57675626    {
    57685627        case VMDKETYPE_HOSTED_SPARSE:
    5769 #ifdef VBOX_WITH_VMDK_ESX
    5770         case VMDKETYPE_ESX_SPARSE:
    5771 #endif /* VBOX_WITH_VMDK_ESX */
    57725628            rc = vmdkGetSector(pImage, pIoCtx, pExtent, uSectorExtentRel, &uSectorExtentAbs);
    57735629            if (RT_FAILURE(rc))
     
    59035759    {
    59045760        case VMDKETYPE_HOSTED_SPARSE:
    5905 #ifdef VBOX_WITH_VMDK_ESX
    5906         case VMDKETYPE_ESX_SPARSE:
    5907 #endif /* VBOX_WITH_VMDK_ESX */
    59085761            rc = vmdkGetSector(pImage, pIoCtx, pExtent, uSectorExtentRel, &uSectorExtentAbs);
    59095762            if (RT_FAILURE(rc))
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