VirtualBox

Changeset 18566 in vbox


Ignore:
Timestamp:
Mar 31, 2009 12:28:49 PM (15 years ago)
Author:
vboxsync
Message:

Storage/API/VBoxManage/...: add maximum size check to prevent creation of invalid images, implement fixed-size ESX variants, update VBoxManage and docs accordingly

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxHDD.h

    r18558 r18566  
    8484/** VMDK: stream optimized image, read only. */
    8585#define VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED    (0x0004)
     86/** VMDK: ESX variant, use in addition to other flags. */
     87#define VD_VMDK_IMAGE_FLAGS_ESX                 (0x0008)
    8688/** VDI: Fill new blocks with zeroes while expanding image file. Only valid
    8789 * for newly created images, never set for opened existing images. */
     
    8991
    9092/** Mask of valid image flags for VMDK. */
    91 #define VD_VMDK_IMAGE_FLAGS_MASK            (VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE | VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK | VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED)
     93#define VD_VMDK_IMAGE_FLAGS_MASK            (   VD_IMAGE_FLAGS_FIXED | VD_IMAGE_FLAGS_DIFF | VD_IMAGE_FLAGS_NONE \
     94                                             |  VD_VMDK_IMAGE_FLAGS_SPLIT_2G | VD_VMDK_IMAGE_FLAGS_RAWDISK \
     95                                             | VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED | VD_VMDK_IMAGE_FLAGS_ESX)
    9296
    9397/** Mask of valid image flags for VDI. */
  • trunk/include/VBox/err.h

    r18230 r18566  
    10821082/** Asynchronous I/O is not finished yet. */
    10831083#define VERR_VD_ASYNC_IO_IN_PROGRESS                (-3210)
     1084/** The image is too small or too large for this format. */
     1085#define VERR_VD_INVALID_SIZE                        (-3211)
    10841086/** Generic: Invalid image file header. Use this for plugins. */
    10851087#define VERR_VD_GEN_INVALID_HEADER                  (-3220)
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r18505 r18566  
    198198    VMDKETYPE_FLAT,
    199199    /** Zero extent. */
    200     VMDKETYPE_ZERO
     200    VMDKETYPE_ZERO,
     201    /** VMFS extent, used by ESX. */
     202    VMDKETYPE_VMFS
    201203#ifdef VBOX_WITH_VMDK_ESX
    202204    ,
     
    16491651{
    16501652    static const char *apszAccess[] = { "NOACCESS", "RDONLY", "RW" };
    1651     static const char *apszType[] = { "", "SPARSE", "FLAT", "ZERO" };
     1653    static const char *apszType[] = { "", "SPARSE", "FLAT", "ZERO", "VMFS" };
    16521654    char *pszTmp;
    16531655    unsigned uStart = pDescriptor->uFirstExtent, uLast = 0;
    16541656    char szExt[1024];
    16551657    ssize_t cbDiff;
     1658
     1659    Assert((int)enmAccess < RT_ELEMENTS(apszAccess));
     1660    Assert((int)enmType < RT_ELEMENTS(apszType));
    16561661
    16571662    /* Find last entry in extent description. */
     
    20732078    else if (!strcmp(pszCreateType, "streamOptimized"))
    20742079        pImage->uImageFlags |= VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED;
     2080    else if (!strcmp(pszCreateType, "vmfs"))
     2081        pImage->uImageFlags |= VD_IMAGE_FLAGS_FIXED | VD_VMDK_IMAGE_FLAGS_ESX;
    20752082    RTStrFree((char *)(void *)pszCreateType);
    20762083
     
    21482155        {
    21492156            pImage->pExtents[i].enmType = VMDKETYPE_ZERO;
     2157            pszLine += 4;
     2158        }
     2159        else if (!strncmp(pszLine, "VMFS", 4))
     2160        {
     2161            pImage->pExtents[i].enmType = VMDKETYPE_VMFS;
    21502162            pszLine += 4;
    21512163        }
     
    30103022                PVMDKEXTENT pExtent = &pImage->pExtents[i];
    30113023
    3012                 if (   (pExtent->enmType != VMDKETYPE_FLAT)
    3013                     && (pExtent->enmType != VMDKETYPE_ZERO))
     3024                if (    pExtent->enmType != VMDKETYPE_FLAT
     3025                    &&  pExtent->enmType != VMDKETYPE_ZERO
     3026                    &&  pExtent->enmType != VMDKETYPE_VMFS)
    30143027                {
    30153028                    /*
     
    30943107                    }
    30953108                    break;
     3109                case VMDKETYPE_VMFS:
    30963110                case VMDKETYPE_FLAT:
    30973111                    rc = vmdkFileOpen(pImage, &pExtent->pFile, pExtent->pszFullname,
     
    36173631        }
    36183632        else
    3619             pExtent->enmType = VMDKETYPE_FLAT;
     3633        {
     3634            if (uImageFlags & VD_VMDK_IMAGE_FLAGS_ESX)
     3635                pExtent->enmType = VMDKETYPE_VMFS;
     3636            else
     3637                pExtent->enmType = VMDKETYPE_FLAT;
     3638        }
    36203639
    36213640        pExtent->enmAccess = VMDKACCESS_READWRITE;
     
    36483667    if (uImageFlags & VD_IMAGE_FLAGS_FIXED)
    36493668    {
    3650         pszDescType =   (cExtents == 1)
    3651                       ? "monolithicFlat" : "twoGbMaxExtentFlat";
     3669        if (pImage->uImageFlags & VD_VMDK_IMAGE_FLAGS_ESX)
     3670            pszDescType = "vmfs";
     3671        else
     3672            pszDescType =   (cExtents == 1)
     3673                          ? "monolithicFlat" : "twoGbMaxExtentFlat";
    36523674    }
    36533675    else
     
    39423964                    break;
    39433965#endif /* VBOX_WITH_VMDK_ESX */
     3966                case VMDKETYPE_VMFS:
    39443967                case VMDKETYPE_FLAT:
    39453968                    /* Nothing to do. */
     
    39583981            case VMDKETYPE_ESX_SPARSE:
    39593982#endif /* VBOX_WITH_VMDK_ESX */
     3983            case VMDKETYPE_VMFS:
    39603984            case VMDKETYPE_FLAT:
    39613985                /** @todo implement proper path absolute check. */
     
    44624486    }
    44634487
     4488    /* Check size. Maximum 2TB-64K for sparse images, otherwise unlimited. */
     4489    if (    !cbSize
     4490        ||  (!(uImageFlags & VD_IMAGE_FLAGS_FIXED) && cbSize >= _1T * 2 - _64K))
     4491    {
     4492        rc = VERR_VD_INVALID_SIZE;
     4493        goto out;
     4494    }
     4495
    44644496    /* Check remaining arguments. */
    44654497    if (   !VALID_PTR(pszFilename)
     
    49024934            }
    49034935            break;
     4936        case VMDKETYPE_VMFS:
    49044937        case VMDKETYPE_FLAT:
    49054938            rc = vmdkFileReadAt(pExtent->pFile,
     
    50765109            }
    50775110            break;
     5111        case VMDKETYPE_VMFS:
    50785112        case VMDKETYPE_FLAT:
    50795113            /* Clip write range to remain in this extent. */
     
    56845718        for (unsigned i = 0; i < pImage->cExtents; i++)
    56855719        {
    5686             if (   (pImage->pExtents[i].enmType != VMDKETYPE_FLAT)
    5687                 && (pImage->pExtents[i].enmType != VMDKETYPE_ZERO))
     5720            if (    pImage->pExtents[i].enmType != VMDKETYPE_FLAT
     5721                &&  pImage->pExtents[i].enmType != VMDKETYPE_ZERO
     5722                &&  pImage->pExtents[i].enmType != VMDKETYPE_VMFS)
    56885723            {
    56895724                fAsyncIOSupported = false;
     
    57425777        switch (pExtent->enmType)
    57435778        {
     5779            case VMDKETYPE_VMFS:
    57445780            case VMDKETYPE_FLAT:
    57455781            {
     
    58785914        switch (pExtent->enmType)
    58795915        {
     5916            case VMDKETYPE_VMFS:
    58805917            case VMDKETYPE_FLAT:
    58815918            {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp

    r18388 r18566  
    8585                     || !RTStrNICmp(psz, "streamoptimized", len))
    8686                DiskVariant |= HardDiskVariant_VmdkStreamOptimized;
     87            else if (!RTStrNICmp(psz, "esx", len))
     88                DiskVariant |= HardDiskVariant_VmdkESX;
    8789            else
    8890                rc = VERR_PARSE_ERROR;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r18403 r18566  
    324324                 "                            --size <megabytes>\n"
    325325                 "                            [--format VDI|VMDK|VHD] (default: VDI)\n"
    326                  "                            [--variant Standard,Fixed,Split2G,StreamOptimized]\n"
     326                 "                            [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
    327327                 "                            [--type normal|writethrough] (default: normal)\n"
    328328                 "                            [--comment <comment>]\n"
     
    343343        RTPrintf("VBoxManage clonehd          <uuid>|<filename> <outputfile>\n"
    344344                 "                            [--format VDI|VMDK|VHD|RAW|<other>]\n"
    345                  "                            [--variant Standard,Fixed,Split2G,StreamOptimized]\n"
     345                 "                            [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
    346346                 "                            [--type normal|writethrough|immutable]\n"
    347347                 "                            [--remember]\n"
     
    353353        RTPrintf("VBoxManage convertfromraw   <filename> <outputfile>\n"
    354354                 "                            [--format VDI|VMDK|VHD]\n"
    355                  "                            [--variant Standard,Fixed,Split2G,StreamOptimized]\n"
     355                 "                            [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
    356356                 "VBoxManage convertfromraw   stdin <outputfile> <bytes>\n"
    357357                 "                            [--format VDI|VMDK|VHD]\n"
    358                  "                            [--variant Standard,Fixed,Split2G,StreamOptimized]\n"
     358                 "                            [--variant Standard,Fixed,Split2G,Stream,ESX]\n"
    359359                 "\n");
    360360    }
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r18412 r18566  
    87468746  <enum
    87478747    name="HardDiskVariant"
    8748     uuid="99334b63-7ed0-4f61-8a7e-7ec3e20dd912"
     8748    uuid="eb7fc6b3-ae23-4c5d-a1f6-e3522dd1efb0"
    87498749   >
    87508750    <desc>
     
    87698769      </desc>
    87708770    </const>
    8771     <const name="Fixed" value="0x1000">
     8771    <const name="VmdkESX" value="0x08">
     8772      <desc>
     8773        VMDK format variant used on ESX products.
     8774      </desc>
     8775    </const>
     8776    <const name="Fixed" value="0x10000">
    87728777      <desc>
    87738778        Fixed image. Only allowed for base images.
    87748779      </desc>
    87758780    </const>
    8776     <const name="Diff" value="0x2000">
     8781    <const name="Diff" value="0x20000">
    87778782      <desc>
    87788783        Fixed image. Only allowed for base images.
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