VirtualBox

Changeset 100078 in vbox for trunk/src/VBox/Storage/VD.cpp


Ignore:
Timestamp:
Jun 6, 2023 5:15:22 AM (18 months ago)
Author:
vboxsync
Message:

Main/src-server and Storage: Immutable media handling flexibility added bugref:5995

File:
1 edited

Legend:

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

    r99739 r100078  
    20532053 * to speed up the copy process if possible.
    20542054 */
    2055 static int vdCopyHelper(PVDISK pDiskFrom, PVDIMAGE pImageFrom, PVDISK pDiskTo,
     2055static int vdCopyHelper(PVDISK pDiskFrom, PVDIMAGE pImageFrom, PVDISK pDiskTo, PVDIMAGE pImageTo,
    20562056                        uint64_t cbSize, unsigned cImagesFromRead, unsigned cImagesToRead,
    20572057                        bool fSuppressRedundantIo, PVDINTERFACEPROGRESS pIfProgress,
     
    20682068    unsigned uProgressOld = 0;
    20692069
    2070     LogFlowFunc(("pDiskFrom=%#p pImageFrom=%#p pDiskTo=%#p cbSize=%llu cImagesFromRead=%u cImagesToRead=%u fSuppressRedundantIo=%RTbool pIfProgress=%#p pDstIfProgress=%#p\n",
    2071                  pDiskFrom, pImageFrom, pDiskTo, cbSize, cImagesFromRead, cImagesToRead, fSuppressRedundantIo, pDstIfProgress, pDstIfProgress));
     2070    LogFlowFunc(("pDiskFrom=%#p pImageFrom=%#p pDiskTo=%#p pImageTo=%#p cbSize=%llu cImagesFromRead=%u cImagesToRead=%u fSuppressRedundantIo=%RTbool pIfProgress=%#p pDstIfProgress=%#p\n",
     2071                 pDiskFrom, pImageFrom, pDiskTo, pImageTo, cbSize, cImagesFromRead, cImagesToRead, fSuppressRedundantIo, pDstIfProgress, pDstIfProgress));
    20722072
    20732073    if (   (fSuppressRedundantIo || (cImagesFromRead > 0))
     
    21472147
    21482148            /* Only do collapsed I/O if we are copying the data blockwise. */
    2149             rc = vdWriteHelperEx(pDiskTo, pDiskTo->pLast, NULL, uOffset, pvBuf,
     2149            rc = vdWriteHelperEx(pDiskTo, pImageTo, NULL, uOffset, pvBuf,
    21502150                                 cbThisRead, VDIOCTX_FLAGS_DONT_SET_MODIFIED_FLAG /* fFlags */,
    21512151                                 fBlockwiseCopy ? cImagesToRead : 0);
     
    71837183
    71847184
    7185 VBOXDDU_DECL(int) VDCopyEx(PVDISK pDiskFrom, unsigned nImage, PVDISK pDiskTo,
     7185VBOXDDU_DECL(int) VDCopyEx(PVDISK pDiskFrom, unsigned nImageFrom, PVDISK pDiskTo, unsigned nImageTo,
    71867186                           const char *pszBackend, const char *pszFilename,
    71877187                           bool fMoveByRename, uint64_t cbSize,
     
    71977197    PVDIMAGE pImageTo = NULL;
    71987198
    7199     LogFlowFunc(("pDiskFrom=%#p nImage=%u pDiskTo=%#p pszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu nImageFromSame=%u nImageToSame=%u uImageFlags=%#x pDstUuid=%#p uOpenFlags=%#x pVDIfsOperation=%#p pDstVDIfsImage=%#p pDstVDIfsOperation=%#p\n",
    7200                  pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation));
     7199    LogFlowFunc(("pDiskFrom=%#p nImageFrom=%u pDiskTo=%#p nImageTo=%u pszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu nImageFromSame=%u nImageToSame=%u uImageFlags=%#x pDstUuid=%#p uOpenFlags=%#x pVDIfsOperation=%#p pDstVDIfsImage=%#p pDstVDIfsOperation=%#p\n",
     7200                 pDiskFrom, nImageFrom, nImageTo, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation));
    72017201
    72027202    /* Check arguments. */
     
    72127212        AssertRC(rc2);
    72137213        fLockReadFrom = true;
    7214         PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImage);
     7214        PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImageFrom);
    72157215        AssertPtrBreakStmt(pImageFrom, rc = VERR_VD_IMAGE_NOT_FOUND);
    72167216        AssertPtrBreakStmt(pDiskTo, rc = VERR_INVALID_POINTER);
    72177217        AssertMsg(pDiskTo->u32Signature == VDISK_SIGNATURE,
    72187218                  ("u32Signature=%08x\n", pDiskTo->u32Signature));
    7219         AssertMsgBreakStmt(   (nImageFromSame < nImage || nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN)
     7219        AssertMsgBreakStmt(   (nImageFromSame < nImageFrom || nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN)
    72207220                           && (nImageToSame < pDiskTo->cImages || nImageToSame == VD_IMAGE_CONTENT_UNKNOWN)
    72217221                           && (   (nImageFromSame == VD_IMAGE_CONTENT_UNKNOWN && nImageToSame == VD_IMAGE_CONTENT_UNKNOWN)
     
    72257225
    72267226        /* Move the image. */
    7227         if (pDiskFrom == pDiskTo)
     7227        if (fMoveByRename)
    72287228        {
    72297229            /* Rename only works when backends are the same, are file based
     
    73457345                fLockWriteTo = true;
    73467346
     7347                pImageTo = vdGetImageByNumber(pDiskTo, nImageTo);
     7348                AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND);
    73477349                if (RT_SUCCESS(rc) && !RTUuidIsNull(&ImageUuid))
    7348                      pDiskTo->pLast->Backend->pfnSetUuid(pDiskTo->pLast->pBackendData, &ImageUuid);
     7350                     pImageTo->Backend->pfnSetUuid(pImageTo->pBackendData, &ImageUuid);
    73497351            }
    73507352            if (RT_FAILURE(rc))
    73517353                break;
    73527354
    7353             pImageTo = pDiskTo->pLast;
     7355            pImageTo = vdGetImageByNumber(pDiskTo, nImageTo);
    73547356            AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND);
    73557357
     
    73587360        else
    73597361        {
    7360             pImageTo = pDiskTo->pLast;
     7362            pImageTo = vdGetImageByNumber(pDiskTo, nImageTo);
    73617363            AssertPtrBreakStmt(pImageTo, rc = VERR_VD_IMAGE_NOT_FOUND);
    73627364
     
    73877389         * Don't optimize if the image existed or if it is a child image. */
    73887390        bool fSuppressRedundantIo = (   !(pszFilename == NULL || cImagesTo > 0)
    7389                                      || (nImageToSame != VD_IMAGE_CONTENT_UNKNOWN));
     7391                                     || (nImageToSame != VD_IMAGE_CONTENT_UNKNOWN)
     7392                                     || (pDiskTo == pDiskFrom));
    73907393        unsigned cImagesFromReadBack, cImagesToReadBack;
    73917394
     
    73947397        else
    73957398        {
    7396             if (nImage == VD_LAST_IMAGE)
     7399            if (nImageFrom == VD_LAST_IMAGE)
    73977400                cImagesFromReadBack = pDiskFrom->cImages - nImageFromSame - 1;
    73987401            else
    7399                 cImagesFromReadBack = nImage - nImageFromSame;
     7402                cImagesFromReadBack = nImageFrom - nImageFromSame;
    74007403        }
    74017404
     
    74067409
    74077410        /* Copy the data. */
    7408         rc = vdCopyHelper(pDiskFrom, pImageFrom, pDiskTo, cbSize,
     7411        rc = vdCopyHelper(pDiskFrom, pImageFrom, pDiskTo, pImageTo, cbSize,
    74097412                          cImagesFromReadBack, cImagesToReadBack,
    74107413                          fSuppressRedundantIo, pIfProgress, pDstIfProgress);
     
    74927495                         PVDINTERFACE pDstVDIfsOperation)
    74937496{
    7494     return VDCopyEx(pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename,
     7497    return VDCopyEx(pDiskFrom, nImage, pDiskTo, VD_IMAGE_CONTENT_UNKNOWN, pszBackend, pszFilename, fMoveByRename,
    74957498                    cbSize, VD_IMAGE_CONTENT_UNKNOWN, VD_IMAGE_CONTENT_UNKNOWN,
    74967499                    uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation,
     
    96749677    return VINF_SUCCESS;
    96759678}
    9676 
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