VirtualBox

Changeset 2590 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 11, 2007 12:18:06 PM (18 years ago)
Author:
vboxsync
Message:

Optimize writes to a so far unallocated blocks in the VMDK which don't
change the data. This catches zero block writes for the base image and
redundant writes for diff images (whenever we get create support and
Main support for non-writethrough operation).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp

    r2564 r2590  
    4444 * VBox HDD Container image descriptor.
    4545 */
    46 typedef struct VBOXHDDIMAGEDESC
     46typedef struct VDIMAGE
    4747{
    4848    /** Link to parent image descriptor, if any. */
    49     struct VBOXHDDIMAGEDESC *pPrev;
     49    struct VDIMAGE *pPrev;
    5050    /** Link to child image descriptor, if any. */
    51     struct VBOXHDDIMAGEDESC *pNext;
     51    struct VDIMAGE *pNext;
    5252    /** Container base filename. (UTF-8) */
    53     char                    *pszFilename;
     53    char            *pszFilename;
    5454    /** Data managed by the backend which keeps the actual info. */
    55     void                    *pvBackendData;
    56 } VBOXHDDIMAGEDESC, *PVBOXHDDIMAGEDESC;
     55    void            *pvBackendData;
     56    /** Image open flags (only those handled generically in this code and which
     57     * the backends will never ever see). */
     58    unsigned        uOpenFlags;
     59} VDIMAGE, *PVDIMAGE;
    5760
    5861/**
     
    7679
    7780    /** Base image. */
    78     PVBOXHDDIMAGEDESC   pBase;
     81    PVDIMAGE            pBase;
    7982
    8083    /** Last opened image in the chain.
    81      * The same as pBase if only one image is used or the last opened diff image. */
    82     PVBOXHDDIMAGEDESC   pLast;
     84     * The same as pBase if only one image is used. */
     85    PVDIMAGE            pLast;
    8386
    8487    /** Flags representing the modification state. */
     
    126129 * internal: issue early error message.
    127130 */
    128 static int vdEarlyError(PFNVDERROR pfnError, void *pvErrorUser, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
     131static int vdEarlyError(PFNVDERROR pfnError, void *pvErrorUser, int rc,
     132                        RT_SRC_POS_DECL, const char *pszFormat, ...)
    129133{
    130134    va_list va;
     
    138142 * internal: issue error message.
    139143 */
    140 static int vdError(PVBOXHDD pDisk, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...)
     144static int vdError(PVBOXHDD pDisk, int rc, RT_SRC_POS_DECL,
     145                   const char *pszFormat, ...)
    141146{
    142147    va_list va;
     
    150155 * internal: add image structure to the end of images list.
    151156 */
    152 static void vdAddImageToList(PVBOXHDD pDisk, PVBOXHDDIMAGEDESC pImage)
     157static void vdAddImageToList(PVBOXHDD pDisk, PVDIMAGE pImage)
    153158{
    154159    pImage->pPrev = NULL;
     
    175180 * internal: remove image structure from the images list.
    176181 */
    177 static void vdRemoveImageFromList(PVBOXHDD pDisk, PVBOXHDDIMAGEDESC pImage)
     182static void vdRemoveImageFromList(PVBOXHDD pDisk, PVDIMAGE pImage)
    178183{
    179184    Assert(pDisk->cImages > 0);
     
    198203 * internal: find image by index into the images list.
    199204 */
    200 static PVBOXHDDIMAGEDESC vdGetImageByNumber(PVBOXHDD pDisk, unsigned nImage)
    201 {
    202     PVBOXHDDIMAGEDESC pImage = pDisk->pBase;
     205static PVDIMAGE vdGetImageByNumber(PVBOXHDD pDisk, unsigned nImage)
     206{
     207    PVDIMAGE pImage = pDisk->pBase;
    203208    while (pImage && nImage)
    204209    {
     
    213218 * will give us.
    214219 */
    215 static int vdReadHelper(PVBOXHDD pDisk, PVBOXHDDIMAGEDESC pImage, uint64_t uOffset, void *pvBuf, size_t cbRead)
     220static int vdReadHelper(PVBOXHDD pDisk, PVDIMAGE pImage, uint64_t uOffset,
     221                        void *pvBuf, size_t cbRead)
    216222{
    217223    int rc;
    218224    size_t cbThisRead;
    219     PVBOXHDDIMAGEDESC pCurrImage;
     225    PVDIMAGE pCurrImage;
    220226
    221227    /* Loop until all read. */
     
    227233        cbThisRead = cbRead;
    228234        rc = VINF_VDI_BLOCK_FREE;
    229         for (pCurrImage = pImage; pCurrImage != NULL && rc == VINF_VDI_BLOCK_FREE; pCurrImage = pCurrImage->pPrev)
     235        for (pCurrImage = pImage;
     236             pCurrImage != NULL && rc == VINF_VDI_BLOCK_FREE;
     237             pCurrImage = pCurrImage->pPrev)
    230238        {
    231             rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, uOffset, pvBuf, cbThisRead, &cbThisRead);
     239            rc = pDisk->Backend->pfnRead(pCurrImage->pvBackendData, uOffset,
     240                                         pvBuf, cbThisRead, &cbThisRead);
    232241        }
    233242
     
    260269
    261270            RTUuidCreate(&Uuid);
    262             pDisk->Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData, &Uuid);
     271            pDisk->Backend->pfnSetModificationUuid(pDisk->pLast->pvBackendData,
     272                                                   &Uuid);
    263273        }
    264274
     
    283293            pDisk->Backend->pfnFlush(pDisk->pLast->pvBackendData);
    284294    }
     295}
     296
     297/**
     298 * internal: write a complete block (only used for diff images), taking the
     299 * remaining data from parent images. This implementation does not optimize
     300 * anything (except that it tries to read only that portions from parent
     301 * images that are really needed).
     302 */
     303static int vdWriteHelperStandard(PVBOXHDD pDisk, PVDIMAGE pImage,
     304                                 uint64_t uOffset, size_t cbWrite,
     305                                 size_t cbThisWrite, size_t cbPreRead,
     306                                 size_t cbPostRead, const void *pvBuf,
     307                                 void *pvTmp)
     308{
     309    int rc;
     310
     311    /* Read the data that goes before the write to fill the block. */
     312    if (cbPreRead)
     313    {
     314        rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead,
     315                          pvTmp, cbPreRead);
     316        if (VBOX_FAILURE(rc))
     317            return rc;
     318    }
     319
     320    /* Copy the data to the right place in the buffer. */
     321    memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite);
     322
     323    /* Read the data that goes after the write to fill the block. */
     324    if (cbPostRead)
     325    {
     326        /* If we have data to be written, use that instead of reading
     327         * data from the image. */
     328        size_t cbWriteCopy;
     329        if (cbWrite > cbThisWrite)
     330            cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead);
     331        else
     332            cbWriteCopy = 0;
     333        /* Figure out how much we cannnot read from the image, because
     334         * the last block to write might exceed the nominal size of the
     335         * image for technical reasons. */
     336        size_t cbFill;
     337        if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize)
     338            cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize;
     339        else
     340            cbFill = 0;
     341        /* The rest must be read from the image. */
     342        size_t cbReadImage = cbPostRead - cbWriteCopy - cbFill;
     343
     344        /* Now assemble the remaining data. */
     345        if (cbWriteCopy)
     346            memcpy((char *)pvTmp + cbPreRead + cbThisWrite,
     347                   (char *)pvBuf + cbThisWrite, cbWriteCopy);
     348        if (cbReadImage)
     349            rc = vdReadHelper(pDisk, pImage->pPrev,
     350                              uOffset + cbThisWrite + cbWriteCopy,
     351                              (char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy,
     352                              cbReadImage);
     353        if (VBOX_FAILURE(rc))
     354            return rc;
     355        /* Zero out the remainder of this block. Will never be visible, as this
     356         * is beyond the limit of the image. */
     357        if (cbFill)
     358            memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage,
     359                   '\0', cbFill);
     360    }
     361
     362    /* Write the full block to the virtual disk. */
     363    rc = pDisk->Backend->pfnWrite(pImage->pvBackendData,
     364                                  uOffset - cbPreRead, pvTmp,
     365                                  cbPreRead + cbThisWrite + cbPostRead,
     366                                  NULL,
     367                                  &cbPreRead, &cbPostRead);
     368    Assert(rc != VINF_VDI_BLOCK_FREE);
     369    Assert(cbPreRead == 0);
     370    Assert(cbPostRead == 0);
     371
     372    return rc;
     373}
     374
     375/**
     376 * internal: write a complete block (only used for diff images), taking the
     377 * remaining data from parent images. This implementation optimized out writes
     378 * that do not change the data relative to the state as of the parent images.
     379 * All backends which support differential/growing images support this.
     380 */
     381static int vdWriteHelperOptimized(PVBOXHDD pDisk, PVDIMAGE pImage,
     382                                  uint64_t uOffset, size_t cbWrite,
     383                                  size_t cbThisWrite, size_t cbPreRead,
     384                                  size_t cbPostRead, const void *pvBuf,
     385                                  void *pvTmp)
     386{
     387    size_t cbFill = 0;
     388    size_t cbWriteCopy = 0;
     389    size_t cbReadImage = 0;
     390    int rc;
     391
     392    if (cbPostRead)
     393    {
     394        /* Figure out how much we cannnot read from the image, because
     395         * the last block to write might exceed the nominal size of the
     396         * image for technical reasons. */
     397        if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize)
     398            cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize;
     399
     400        /* If we have data to be written, use that instead of reading
     401         * data from the image. */
     402        if (cbWrite > cbThisWrite)
     403            cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead);
     404
     405        /* The rest must be read from the image. */
     406        cbReadImage = cbPostRead - cbWriteCopy - cbFill;
     407    }
     408
     409    /* Read the entire data of the block so that we can compare whether it will
     410     * be modified by the write or not. */
     411    rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead,
     412                      pvTmp, cbPreRead + cbThisWrite + cbPostRead - cbFill);
     413    if (VBOX_FAILURE(rc))
     414        return rc;
     415
     416    /* Check if the write would modify anything in this block. */
     417    if (   !memcmp((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite)
     418        && (!cbWriteCopy || !memcmp((char *)pvTmp + cbPreRead + cbThisWrite,
     419                                    (char *)pvBuf + cbThisWrite, cbWriteCopy)))
     420    {
     421        /* Block is completely unchanged, so no need to write anything. */
     422        return VINF_SUCCESS;
     423    }
     424
     425    /* Copy the data to the right place in the buffer. */
     426    memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite);
     427
     428    /* Handle the data that goes after the write to fill the block. */
     429    if (cbPostRead)
     430    {
     431        /* Now assemble the remaining data. */
     432        if (cbWriteCopy)
     433            memcpy((char *)pvTmp + cbPreRead + cbThisWrite,
     434                   (char *)pvBuf + cbThisWrite, cbWriteCopy);
     435        /* Zero out the remainder of this block. Will never be visible, as this
     436         * is beyond the limit of the image. */
     437        if (cbFill)
     438            memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage,
     439                   '\0', cbFill);
     440    }
     441
     442    /* Write the full block to the virtual disk. */
     443    rc = pDisk->Backend->pfnWrite(pImage->pvBackendData,
     444                                  uOffset - cbPreRead, pvTmp,
     445                                  cbPreRead + cbThisWrite + cbPostRead,
     446                                  NULL,
     447                                  &cbPreRead, &cbPostRead);
     448    Assert(rc != VINF_VDI_BLOCK_FREE);
     449    Assert(cbPreRead == 0);
     450    Assert(cbPostRead == 0);
     451
     452    return rc;
    285453}
    286454
     
    295463 * @param   ppDisk          Where to store the reference to the VBox HDD container.
    296464 */
    297 VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError, void *pvErrorUser, PVBOXHDD *ppDisk)
     465VBOXDDU_DECL(int) VDCreate(const char *pszBackend, PFNVDERROR pfnError,
     466                           void *pvErrorUser, PVBOXHDD *ppDisk)
    298467{
    299468    int rc = VINF_SUCCESS;
     
    332501    }
    333502    else
    334         rc = vdEarlyError(pfnError, pvErrorUser, VERR_INVALID_PARAMETER, RT_SRC_POS, "VD: unknown backend name '%s'", pszBackend);
     503        rc = vdEarlyError(pfnError, pvErrorUser, VERR_INVALID_PARAMETER,
     504                          RT_SRC_POS, "VD: unknown backend name '%s'",
     505                          pszBackend);
    335506
    336507    LogFlow(("%s: returns %vrc (pDisk=%#p)\n", __FUNCTION__, rc, pDisk));
     
    376547 * @param   uOpenFlags      Image file open mode, see VD_OPEN_FLAGS_* constants.
    377548 */
    378 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename, unsigned uOpenFlags)
     549VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszFilename,
     550                         unsigned uOpenFlags)
    379551{
    380552    int rc = VINF_SUCCESS;
    381     LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, pszFilename, uOpenFlags));
     553    LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__,
     554             pszFilename, uOpenFlags));
    382555    /* sanity check */
    383556    Assert(pDisk);
     
    394567
    395568    /* Set up image descriptor. */
    396     PVBOXHDDIMAGEDESC pImage = (PVBOXHDDIMAGEDESC)RTMemAllocZ(sizeof(VBOXHDDIMAGEDESC));
     569    PVDIMAGE pImage = (PVDIMAGE)RTMemAllocZ(sizeof(VDIMAGE));
    397570    if (!pImage)
    398571        return VERR_NO_MEMORY;
     
    402575
    403576    if (VBOX_SUCCESS(rc))
    404         rc = pDisk->Backend->pfnOpen(pImage->pszFilename, uOpenFlags, pDisk->pfnError, pDisk->pvErrorUser, &pImage->pvBackendData);
     577    {
     578        pImage->uOpenFlags = uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME;
     579        rc = pDisk->Backend->pfnOpen(pImage->pszFilename,
     580                                     uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME,
     581                                     pDisk->pfnError, pDisk->pvErrorUser,
     582                                     &pImage->pvBackendData);
     583    }
    405584    /* If the open in read-write mode failed, retry in read-only mode. */
    406585    if (VBOX_FAILURE(rc))
     
    412591                 || rc == VERR_SHARING_VIOLATION
    413592                 || rc == VERR_FILE_LOCK_FAILED))
    414             rc = pDisk->Backend->pfnOpen(pImage->pszFilename, uOpenFlags | VD_OPEN_FLAGS_READONLY, pDisk->pfnError, pDisk->pvErrorUser, &pImage->pvBackendData);
     593            rc = pDisk->Backend->pfnOpen(pImage->pszFilename,
     594                                           (uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME)
     595                                         | VD_OPEN_FLAGS_READONLY,
     596                                         pDisk->pfnError, pDisk->pvErrorUser,
     597                                         &pImage->pvBackendData);
    415598        if (VBOX_FAILURE(rc))
    416             rc = vdError(pDisk, rc, RT_SRC_POS, N_("VD: error opening image file '%s'"), pszFilename);
     599            rc = vdError(pDisk, rc, RT_SRC_POS,
     600                         N_("VD: error opening image file '%s'"), pszFilename);
    417601    }
    418602
     
    420604    {
    421605        VDIMAGETYPE enmImageType;
    422         rc = pDisk->Backend->pfnGetImageType(pImage->pvBackendData, &enmImageType);
     606        rc = pDisk->Backend->pfnGetImageType(pImage->pvBackendData,
     607                                             &enmImageType);
    423608        /* Check image type. As the image itself has no idea whether it's a
    424609         * base image or not, this info is derived here. Image 0 can be fixed
     
    535720{
    536721    int rc = VINF_SUCCESS;
    537     LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__, pszFilename, uOpenFlags));
     722    LogFlow(("%s: pszFilename=\"%s\" uOpenFlags=%#x\n", __FUNCTION__,
     723             pszFilename, uOpenFlags));
    538724    /* sanity check */
    539725    Assert(pDisk);
     
    559745
    560746    /* Set up image descriptor. */
    561     PVBOXHDDIMAGEDESC pImage = (PVBOXHDDIMAGEDESC)RTMemAllocZ(sizeof(VBOXHDDIMAGEDESC));
     747    PVDIMAGE pImage = (PVDIMAGE)RTMemAllocZ(sizeof(VDIMAGE));
    562748    if (!pImage)
    563749        return VERR_NO_MEMORY;
     
    615801 * @param   pvUser          User argument for the progress callback.
    616802 */
    617 VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, unsigned nImageTo,
    618                           PFNVMPROGRESS pfnProgress, void *pvUser)
     803VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom,
     804                          unsigned nImageTo, PFNVMPROGRESS pfnProgress,
     805                          void *pvUser)
    619806{
    620807    return VERR_NOT_IMPLEMENTED;
     
    711898    AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    712899
    713     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     900    PVDIMAGE pImage = pDisk->pLast;
    714901    int rc = VINF_SUCCESS;
    715902    while (pImage)
    716903    {
    717         PVBOXHDDIMAGEDESC pPrev = pImage->pPrev;
     904        PVDIMAGE pPrev = pImage->pPrev;
    718905        /* Remove image from list of opened images. */
    719906        vdRemoveImageFromList(pDisk, pImage);
     
    749936
    750937    int rc = VINF_SUCCESS;
    751     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     938    PVDIMAGE pImage = pDisk->pLast;
    752939    if (RT_UNLIKELY(!pImage))
    753940    {
     
    788975    size_t cbThisWrite;
    789976    size_t cbPreRead, cbPostRead;
    790     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     977    PVDIMAGE pImage = pDisk->pLast;
    791978    if (RT_UNLIKELY(!pImage))
    792979    {
     
    8141001         * block if needed. */
    8151002        cbThisWrite = cbWrite;
    816         rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf, cbThisWrite, &cbThisWrite, &cbPreRead, &cbPostRead);
     1003        rc = pDisk->Backend->pfnWrite(pImage->pvBackendData, uOffset, pvBuf,
     1004                                      cbThisWrite, &cbThisWrite,
     1005                                      &cbPreRead, &cbPostRead);
    8171006        if (rc == VINF_VDI_BLOCK_FREE)
    8181007        {
    819             /* Partial block write to an unallocated block. Read the rest of
    820              * this block and then do a full-block (allocating) write. */
    8211008            void *pvTmp = RTMemTmpAlloc(cbPreRead + cbThisWrite + cbPostRead);
    8221009            if (!pvBuf)
     
    8271014            }
    8281015
    829             /* Read the data that goes before the write to fill the block. */
    830             if (cbPreRead)
     1016            if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_HONOR_SAME))
    8311017            {
    832                 rc = vdReadHelper(pDisk, pImage->pPrev, uOffset - cbPreRead,
    833                                   pvTmp, cbPreRead);
    834                 if (VBOX_FAILURE(rc))
    835                     break;
     1018                /* Optimized write, suppress writing to a so far unallocated
     1019                 * block when the data is identical than as of the parent. */
     1020                rc = vdWriteHelperOptimized(pDisk, pImage, uOffset,
     1021                                            cbWrite, cbThisWrite,
     1022                                            cbPreRead, cbPostRead,
     1023                                            pvBuf, pvTmp);
    8361024            }
    837 
    838             /* Copy the data to the right place in the buffer. */
    839             memcpy((char *)pvTmp + cbPreRead, pvBuf, cbThisWrite);
    840 
    841             /* Read the data that goes after the write to fill the block. */
    842             if (cbPostRead)
     1025            else
    8431026            {
    844                 /* If we have data to be written, use that instead of reading
    845                  * data from the image. */
    846                 size_t cbWriteCopy;
    847                 if (cbWrite > cbThisWrite)
    848                     cbWriteCopy = RT_MIN(cbWrite - cbThisWrite, cbPostRead);
    849                 else
    850                     cbWriteCopy = 0;
    851                 /* Figure out how much we cannnot read from the image, because
    852                  * the last block to write might exceed the nominal size of the
    853                  * image for technical reasons. */
    854                 size_t cbFill;
    855                 if (uOffset + cbThisWrite + cbPostRead > pDisk->cbSize)
    856                     cbFill = uOffset + cbThisWrite + cbPostRead - pDisk->cbSize;
    857                 else
    858                     cbFill = 0;
    859                 /* The rest must be read from the image. */
    860                 size_t cbReadImage = cbPostRead - cbWriteCopy - cbFill;
    861 
    862                 /* Now assemble the remaining data. */
    863                 if (cbWriteCopy)
    864                     memcpy((char *)pvTmp + cbPreRead + cbThisWrite, (char *)pvBuf + cbThisWrite, cbWriteCopy);
    865                 if (cbReadImage)
    866                     rc = vdReadHelper(pDisk, pImage->pPrev, uOffset + cbThisWrite + cbWriteCopy,
    867                                       (void *)((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy),
    868                                       cbReadImage);
    869                 if (VBOX_FAILURE(rc))
    870                     break;
    871                 if (cbFill)
    872                     memset((char *)pvTmp + cbPreRead + cbThisWrite + cbWriteCopy + cbReadImage, '\0', cbFill);
     1027                /* Normal write, not optimized in any way. The block will be
     1028                 * written no matter what. This will usually (unless the
     1029                 * backend has some further optimization enabled) cause the
     1030                 * block to be allocated. */
     1031                rc = vdWriteHelperStandard(pDisk, pImage, uOffset,
     1032                                           cbWrite, cbThisWrite,
     1033                                           cbPreRead, cbPostRead,
     1034                                           pvBuf, pvTmp);
    8731035            }
    874 
    875             /* Write the full block to the virtual disk. */
    876             rc = pDisk->Backend->pfnWrite(pImage->pvBackendData,
    877                                           uOffset - cbPreRead, pvTmp,
    878                                           cbPreRead + cbThisWrite + cbPostRead,
    879                                           NULL,
    880                                           &cbPreRead, &cbPostRead);
    881             Assert(rc != VINF_VDI_BLOCK_FREE);
     1036            if (VBOX_FAILURE(rc))
     1037                break;
    8821038        }
    8831039
     
    9051061
    9061062    int rc = VINF_SUCCESS;
    907     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     1063    PVDIMAGE pImage = pDisk->pLast;
    9081064    if (RT_UNLIKELY(!pImage))
    9091065    {
     
    9971153 * @param   pcSectors       Where to store the number of sectors. NULL is ok.
    9981154 */
    999 VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk,
    1000                                 unsigned *pcCylinders, unsigned *pcHeads, unsigned *pcSectors)
     1155VBOXDDU_DECL(int) VDGetGeometry(PVBOXHDD pDisk, unsigned *pcCylinders,
     1156                                unsigned *pcHeads, unsigned *pcSectors)
    10011157{
    10021158    /* sanity check */
     
    10051161
    10061162    int rc = VINF_SUCCESS;
    1007     PVBOXHDDIMAGEDESC pImage = pDisk->pBase;
     1163    PVDIMAGE pImage = pDisk->pBase;
    10081164    if (RT_UNLIKELY(!pImage))
    10091165    {
     
    10421198 * @param   cSectors        Number of sectors.
    10431199 */
    1044 VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk,
    1045                                 unsigned cCylinders, unsigned cHeads, unsigned cSectors)
     1200VBOXDDU_DECL(int) VDSetGeometry(PVBOXHDD pDisk, unsigned cCylinders,
     1201                                unsigned cHeads, unsigned cSectors)
    10461202{
    10471203    /* sanity check */
     
    10501206
    10511207    int rc = VINF_SUCCESS;
    1052     PVBOXHDDIMAGEDESC pImage = pDisk->pBase;
     1208    PVDIMAGE pImage = pDisk->pBase;
    10531209    if (RT_UNLIKELY(!pImage))
    10541210    {
     
    11041260 * @param   penmTranslation Where to store the translation mode (see pdm.h).
    11051261 */
    1106 VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk, PPDMBIOSTRANSLATION penmTranslation)
     1262VBOXDDU_DECL(int) VDGetTranslation(PVBOXHDD pDisk,
     1263                                   PPDMBIOSTRANSLATION penmTranslation)
    11071264{
    11081265    /* sanity check */
     
    11111268
    11121269    int rc = VINF_SUCCESS;
    1113     PVBOXHDDIMAGEDESC pImage = pDisk->pBase;
     1270    PVDIMAGE pImage = pDisk->pBase;
    11141271    if (RT_UNLIKELY(!pImage))
    11151272    {
     
    11391296 * @param   enmTranslation  Translation mode (see pdm.h).
    11401297 */
    1141 VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk, PDMBIOSTRANSLATION enmTranslation)
     1298VBOXDDU_DECL(int) VDSetTranslation(PVBOXHDD pDisk,
     1299                                   PDMBIOSTRANSLATION enmTranslation)
    11421300{
    11431301    /* sanity check */
     
    11461304
    11471305    int rc = VINF_SUCCESS;
    1148     PVBOXHDDIMAGEDESC pImage = pDisk->pBase;
     1306    PVDIMAGE pImage = pDisk->pBase;
    11491307    if (RT_UNLIKELY(!pImage))
    11501308    {
     
    11871345 * @param   puVersion       Where to store the image version.
    11881346 */
    1189 VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage, unsigned *puVersion)
     1347VBOXDDU_DECL(int) VDGetVersion(PVBOXHDD pDisk, unsigned nImage,
     1348                               unsigned *puVersion)
    11901349{
    11911350    return VERR_NOT_IMPLEMENTED;
     
    12011360 * @param   penmType        Where to store the image type.
    12021361 */
    1203 VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage, PVDIMAGETYPE penmType)
     1362VBOXDDU_DECL(int) VDGetImageType(PVBOXHDD pDisk, unsigned nImage,
     1363                                 PVDIMAGETYPE penmType)
    12041364{
    12051365    return VERR_NOT_IMPLEMENTED;
     
    12151375 * @param   puImageFlags    Where to store the image flags.
    12161376 */
    1217 VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage, unsigned *puImageFlags)
     1377VBOXDDU_DECL(int) VDGetImageFlags(PVBOXHDD pDisk, unsigned nImage,
     1378                                  unsigned *puImageFlags)
    12181379{
    12191380    return VERR_NOT_IMPLEMENTED;
     
    12361397    unsigned uOpenFlags = 0;
    12371398    int rc = VINF_SUCCESS;
    1238     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     1399    PVDIMAGE pImage = pDisk->pLast;
    12391400    if (RT_UNLIKELY(!pImage))
    12401401    {
     
    12691430
    12701431    int rc = VINF_SUCCESS;
    1271     PVBOXHDDIMAGEDESC pImage = pDisk->pLast;
     1432    PVDIMAGE pImage = pDisk->pLast;
    12721433    if (RT_UNLIKELY(!pImage))
    12731434    {
     
    12761437    }
    12771438    else
    1278         rc = pDisk->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, uOpenFlags);
     1439        rc = pDisk->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData,
     1440                                             uOpenFlags);
    12791441    LogFlow(("%s: returns %Vrc\n", __FUNCTION__, rc));
    12801442    return rc;
     
    12941456 * @param   cbFilename      Size of buffer pszFilename points to.
    12951457 */
    1296 VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage, char *pszFilename, unsigned cbFilename)
     1458VBOXDDU_DECL(int) VDGetFilename(PVBOXHDD pDisk, unsigned nImage,
     1459                                char *pszFilename, unsigned cbFilename)
    12971460{
    12981461    return VERR_NOT_IMPLEMENTED;
     
    13101473 * @param   cbComment       The size of pszComment buffer. 0 is ok.
    13111474 */
    1312 VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage, char *pszComment, unsigned cbComment)
     1475VBOXDDU_DECL(int) VDGetComment(PVBOXHDD pDisk, unsigned nImage,
     1476                               char *pszComment, unsigned cbComment)
    13131477{
    13141478    return VERR_NOT_IMPLEMENTED;
     
    13161480
    13171481/**
    1318  *  * Changes the comment line of image in HDD container.
    1319  *   *
    1320  *    * @returns VBox status code.
    1321  *     * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
    1322  *      * @param   pDisk           Pointer to VBox HDD container.
    1323  *       * @param   nImage          Image number, counts from 0. 0 is always base image of container.
    1324  *        * @param   pszComment      New comment string (UTF-8). NULL is allowed to reset the comment.
    1325  *         */
    1326 VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage, const char *pszComment)
     1482 * Changes the comment line of image in HDD container.
     1483 *
     1484 * @returns VBox status code.
     1485 * @returns VERR_VDI_IMAGE_NOT_FOUND if image with specified number was not opened.
     1486 * @param   pDisk           Pointer to VBox HDD container.
     1487 * @param   nImage          Image number, counts from 0. 0 is always base image of container.
     1488 * @param   pszComment      New comment string (UTF-8). NULL is allowed to reset the comment.
     1489 */
     1490VBOXDDU_DECL(int) VDSetComment(PVBOXHDD pDisk, unsigned nImage,
     1491                               const char *pszComment)
    13271492{
    13281493    return VERR_NOT_IMPLEMENTED;
     
    13461511    Assert(pUuid);
    13471512
    1348     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1513    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    13491514    int rc;
    13501515    if (pImage)
     
    13751540    Assert(pUuid);
    13761541
    1377     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1542    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    13781543    int rc;
    13791544    if (pImage)
     
    14021567    Assert(pUuid);
    14031568
    1404     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1569    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    14051570    int rc;
    14061571    if (pImage)
     
    14311596    Assert(pUuid);
    14321597
    1433     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1598    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    14341599    int rc;
    14351600    if (pImage)
     
    14511616 * @param   pUuid           Where to store the parent image UUID.
    14521617 */
    1453 VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage, PRTUUID pUuid)
     1618VBOXDDU_DECL(int) VDGetParentUuid(PVBOXHDD pDisk, unsigned nImage,
     1619                                  PRTUUID pUuid)
    14541620{
    14551621    /* sanity check */
     
    14581624    Assert(pUuid);
    14591625
    1460     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1626    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    14611627    int rc;
    14621628    if (pImage)
     
    14781644 * @param   pUuid           Optional parameter, new parent UUID of the image.
    14791645 */
    1480 VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage, PCRTUUID pUuid)
     1646VBOXDDU_DECL(int) VDSetParentUuid(PVBOXHDD pDisk, unsigned nImage,
     1647                                  PCRTUUID pUuid)
    14811648{
    14821649    LogFlow(("%s: uuid={%Vuuid} nImage=%u\n", __FUNCTION__, pUuid, nImage));
     
    14861653    Assert(pUuid);
    14871654
    1488     PVBOXHDDIMAGEDESC pImage = vdGetImageByNumber(pDisk, nImage);
     1655    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    14891656    int rc;
    14901657    if (pImage)
     
    15101677
    15111678    RTLogPrintf("--- Dumping VDI Disk, Images=%u\n", pDisk->cImages);
    1512     for (PVBOXHDDIMAGEDESC pImage = pDisk->pBase; pImage; pImage = pImage->pNext)
     1679    for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext)
    15131680    {
    15141681        RTLogPrintf("Dumping VDI image \"%s\" file=%#p\n", pImage->pszFilename);
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