- Timestamp:
- Aug 23, 2021 7:31:36 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/VD.cpp
r90806 r90807 7228 7228 pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation)); 7229 7229 7230 /* Check arguments. */ 7231 AssertReturn(pDiskFrom, VERR_INVALID_POINTER); 7232 AssertMsg(pDiskFrom->u32Signature == VDISK_SIGNATURE, 7233 ("u32Signature=%08x\n", pDiskFrom->u32Signature)); 7234 7230 7235 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 7231 7236 PVDINTERFACEPROGRESS pDstIfProgress = VDIfProgressGet(pDstVDIfsOperation); 7232 7237 7233 7238 do { 7234 /* Check arguments. */7235 AssertMsgBreakStmt(VALID_PTR(pDiskFrom), ("pDiskFrom=%#p\n", pDiskFrom),7236 rc = VERR_INVALID_PARAMETER);7237 AssertMsg(pDiskFrom->u32Signature == VDISK_SIGNATURE,7238 ("u32Signature=%08x\n", pDiskFrom->u32Signature));7239 7240 7239 rc2 = vdThreadStartRead(pDiskFrom); 7241 7240 AssertRC(rc2); … … 7243 7242 PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImage); 7244 7243 AssertPtrBreakStmt(pImageFrom, rc = VERR_VD_IMAGE_NOT_FOUND); 7245 AssertMsgBreakStmt(VALID_PTR(pDiskTo), ("pDiskTo=%#p\n", pDiskTo), 7246 rc = VERR_INVALID_PARAMETER); 7244 AssertPtrBreakStmt(pDiskTo, rc = VERR_INVALID_POINTER); 7247 7245 AssertMsg(pDiskTo->u32Signature == VDISK_SIGNATURE, 7248 7246 ("u32Signature=%08x\n", pDiskTo->u32Signature)); … … 7282 7280 7283 7281 /* pszFilename is allowed to be NULL, as this indicates copy to the existing image. */ 7284 AssertMsgBreakStmt(pszFilename == NULL || (VALID_PTR(pszFilename) && *pszFilename), 7285 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename), 7286 rc = VERR_INVALID_PARAMETER); 7282 if (pszFilename) 7283 { 7284 AssertPtrBreakStmt(pszFilename, rc = VERR_INVALID_POINTER); 7285 AssertBreakStmt(*pszFilename != '\0', rc = VERR_INVALID_PARAMETER); 7286 } 7287 7287 7288 7288 uint64_t cbSizeFrom; … … 7538 7538 LogFlowFunc(("pDisk=%#p nImage=%u pVDIfsOperation=%#p\n", 7539 7539 pDisk, nImage, pVDIfsOperation)); 7540 /* Check arguments. */ 7541 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 7542 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, 7543 ("u32Signature=%08x\n", pDisk->u32Signature)); 7540 7544 7541 7545 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 7542 7546 7543 7547 do { 7544 /* Check arguments. */7545 AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),7546 rc = VERR_INVALID_PARAMETER);7547 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,7548 ("u32Signature=%08x\n", pDisk->u32Signature));7549 7550 7548 rc2 = vdThreadStartRead(pDisk); 7551 7549 AssertRC(rc2); … … 7635 7633 LogFlowFunc(("pDisk=%#p cbSize=%llu pVDIfsOperation=%#p\n", 7636 7634 pDisk, cbSize, pVDIfsOperation)); 7635 /* Check arguments. */ 7636 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 7637 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, 7638 ("u32Signature=%08x\n", pDisk->u32Signature)); 7637 7639 7638 7640 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 7639 7641 7640 7642 do { 7641 /* Check arguments. */7642 AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),7643 rc = VERR_INVALID_PARAMETER);7644 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,7645 ("u32Signature=%08x\n", pDisk->u32Signature));7646 7647 7643 rc2 = vdThreadStartRead(pDisk); 7648 7644 AssertRC(rc2); … … 7752 7748 7753 7749 LogFlowFunc(("pDisk=%#p pVDIfsOperation=%#p\n", pDisk, pVDIfsOperation)); 7750 /* Check arguments. */ 7751 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 7752 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, 7753 ("u32Signature=%08x\n", pDisk->u32Signature)); 7754 7754 7755 7755 PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation); 7756 7756 7757 7757 do { 7758 /* Check arguments. */7759 AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),7760 rc = VERR_INVALID_PARAMETER);7761 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,7762 ("u32Signature=%08x\n", pDisk->u32Signature));7763 7764 7758 rc2 = vdThreadStartRead(pDisk); 7765 7759 AssertRC(rc2); … … 8136 8130 { 8137 8131 int rc = VINF_SUCCESS; 8132 8133 LogFlowFunc(("pDisk=%#p\n", pDisk)); 8134 /* sanity check */ 8135 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 8136 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 8137 8138 /* Lock the entire operation. */ 8139 int rc2 = vdThreadStartWrite(pDisk); 8140 AssertRC(rc2); 8141 bool fLockWrite = true; 8142 8143 PVDCACHE pCache = pDisk->pCache; 8144 if (pCache) 8145 { 8146 rc2 = pCache->Backend->pfnClose(pCache->pBackendData, false); 8147 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 8148 rc = rc2; 8149 8150 if (pCache->pszFilename) 8151 RTStrFree(pCache->pszFilename); 8152 RTMemFree(pCache); 8153 } 8154 8155 PVDIMAGE pImage = pDisk->pLast; 8156 while (RT_VALID_PTR(pImage)) 8157 { 8158 PVDIMAGE pPrev = pImage->pPrev; 8159 /* Remove image from list of opened images. */ 8160 vdRemoveImageFromList(pDisk, pImage); 8161 /* Close image. */ 8162 rc2 = pImage->Backend->pfnClose(pImage->pBackendData, false); 8163 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 8164 rc = rc2; 8165 /* Free remaining resources related to the image. */ 8166 RTStrFree(pImage->pszFilename); 8167 RTMemFree(pImage); 8168 pImage = pPrev; 8169 } 8170 Assert(!RT_VALID_PTR(pDisk->pLast)); 8171 8172 if (RT_UNLIKELY(fLockWrite)) 8173 { 8174 rc2 = vdThreadFinishWrite(pDisk); 8175 AssertRC(rc2); 8176 } 8177 8178 LogFlowFunc(("returns %Rrc\n", rc)); 8179 return rc; 8180 } 8181 8182 8183 VBOXDDU_DECL(int) VDFilterRemoveAll(PVDISK pDisk) 8184 { 8185 int rc = VINF_SUCCESS; 8138 8186 int rc2; 8139 8187 bool fLockWrite = false; … … 8151 8199 fLockWrite = true; 8152 8200 8153 PVDCACHE pCache = pDisk->pCache;8154 if (pCache)8155 {8156 rc2 = pCache->Backend->pfnClose(pCache->pBackendData, false);8157 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))8158 rc = rc2;8159 8160 if (pCache->pszFilename)8161 RTStrFree(pCache->pszFilename);8162 RTMemFree(pCache);8163 }8164 8165 PVDIMAGE pImage = pDisk->pLast;8166 while (VALID_PTR(pImage))8167 {8168 PVDIMAGE pPrev = pImage->pPrev;8169 /* Remove image from list of opened images. */8170 vdRemoveImageFromList(pDisk, pImage);8171 /* Close image. */8172 rc2 = pImage->Backend->pfnClose(pImage->pBackendData, false);8173 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))8174 rc = rc2;8175 /* Free remaining resources related to the image. */8176 RTStrFree(pImage->pszFilename);8177 RTMemFree(pImage);8178 pImage = pPrev;8179 }8180 Assert(!VALID_PTR(pDisk->pLast));8181 } while (0);8182 8183 if (RT_UNLIKELY(fLockWrite))8184 {8185 rc2 = vdThreadFinishWrite(pDisk);8186 AssertRC(rc2);8187 }8188 8189 LogFlowFunc(("returns %Rrc\n", rc));8190 return rc;8191 }8192 8193 8194 VBOXDDU_DECL(int) VDFilterRemoveAll(PVDISK pDisk)8195 {8196 int rc = VINF_SUCCESS;8197 int rc2;8198 bool fLockWrite = false;8199 8200 LogFlowFunc(("pDisk=%#p\n", pDisk));8201 do8202 {8203 /* sanity check */8204 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);8205 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));8206 8207 /* Lock the entire operation. */8208 rc2 = vdThreadStartWrite(pDisk);8209 AssertRC(rc2);8210 fLockWrite = true;8211 8212 8201 PVDFILTER pFilter, pFilterNext; 8213 8202 RTListForEachSafe(&pDisk->ListFilterChainWrite, pFilter, pFilterNext, VDFILTER, ListNodeChainWrite) … … 8246 8235 LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbRead=%zu\n", 8247 8236 pDisk, uOffset, pvBuf, cbRead)); 8237 /* sanity check */ 8238 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 8239 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 8240 8241 /* Check arguments. */ 8242 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 8243 AssertReturn(cbRead > 0, VERR_INVALID_PARAMETER); 8244 8248 8245 do 8249 8246 { 8250 /* sanity check */8251 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);8252 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));8253 8254 /* Check arguments. */8255 AssertMsgBreakStmt(VALID_PTR(pvBuf),8256 ("pvBuf=%#p\n", pvBuf),8257 rc = VERR_INVALID_PARAMETER);8258 AssertMsgBreakStmt(cbRead,8259 ("cbRead=%zu\n", cbRead),8260 rc = VERR_INVALID_PARAMETER);8261 8262 8247 rc2 = vdThreadStartRead(pDisk); 8263 8248 AssertRC(rc2); … … 8311 8296 LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbWrite=%zu\n", 8312 8297 pDisk, uOffset, pvBuf, cbWrite)); 8298 /* sanity check */ 8299 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 8300 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 8301 8302 /* Check arguments. */ 8303 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 8304 AssertReturn(cbWrite > 0, VERR_INVALID_PARAMETER); 8305 8313 8306 do 8314 8307 { 8315 /* sanity check */8316 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);8317 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));8318 8319 /* Check arguments. */8320 AssertMsgBreakStmt(VALID_PTR(pvBuf),8321 ("pvBuf=%#p\n", pvBuf),8322 rc = VERR_INVALID_PARAMETER);8323 AssertMsgBreakStmt(cbWrite,8324 ("cbWrite=%zu\n", cbWrite),8325 rc = VERR_INVALID_PARAMETER);8326 8327 8308 rc2 = vdThreadStartWrite(pDisk); 8328 8309 AssertRC(rc2); … … 8605 8586 LogFlowFunc(("pDisk=%#p nImage=%u pPCHSGeometry=%#p\n", 8606 8587 pDisk, nImage, pPCHSGeometry)); 8588 /* sanity check */ 8589 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 8590 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 8591 8592 /* Check arguments. */ 8593 AssertPtrReturn(pPCHSGeometry, VERR_INVALID_POINTER); 8594 8607 8595 do 8608 8596 { 8609 /* sanity check */8610 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);8611 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));8612 8613 /* Check arguments. */8614 AssertMsgBreakStmt(VALID_PTR(pPCHSGeometry),8615 ("pPCHSGeometry=%#p\n", pPCHSGeometry),8616 rc = VERR_INVALID_PARAMETER);8617 8618 8597 rc2 = vdThreadStartRead(pDisk); 8619 8598 AssertRC(rc2); … … 8659 8638 pDisk, nImage, pPCHSGeometry, pPCHSGeometry->cCylinders, 8660 8639 pPCHSGeometry->cHeads, pPCHSGeometry->cSectors)); 8640 /* sanity check */ 8641 AssertPtrReturn(pDisk, VERR_INVALID_POINTER); 8642 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 8643 8644 /* Check arguments. */ 8645 AssertPtrReturn(pPCHSGeometry, VERR_INVALID_POINTER); 8646 AssertMsgReturn( pPCHSGeometry->cHeads <= 16 8647 && pPCHSGeometry->cSectors <= 63, 8648 ("PCHS=%u/%u/%u\n", pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors), 8649 VERR_INVALID_PARAMETER); 8661 8650 do 8662 8651 { 8663 /* sanity check */8664 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);8665 AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));8666 8667 /* Check arguments. */8668 AssertMsgBreakStmt( VALID_PTR(pPCHSGeometry)8669 && pPCHSGeometry->cHeads <= 168670 && pPCHSGeometry->cSectors <= 63,8671 ("pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pPCHSGeometry,8672 pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads,8673 pPCHSGeometry->cSectors),8674 rc = VERR_INVALID_PARAMETER);8675 8676 8652 rc2 = vdThreadStartWrite(pDisk); 8677 8653 AssertRC(rc2);
Note:
See TracChangeset
for help on using the changeset viewer.