Changeset 33745 in vbox
- Timestamp:
- Nov 3, 2010 6:31:53 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r33567 r33745 188 188 /** Bandwidth group the disk is assigned to. */ 189 189 char *pszBwGroup; 190 191 /** I/O interface for a cache image. */ 192 VDINTERFACE VDIIOCache; 193 /** Interface list for the cache image. */ 194 PVDINTERFACE pVDIfsCache; 190 195 } VBOXDISK, *PVBOXDISK; 191 196 … … 1931 1936 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 1932 1937 int rc = VINF_SUCCESS; 1933 char *pszName = NULL; /**< The path of the disk image file. */ 1934 char *pszFormat = NULL; /**< The format backed to use for this image. */ 1935 bool fReadOnly; /**< True if the media is read-only. */ 1936 bool fMaybeReadOnly; /**< True if the media may or may not be read-only. */ 1937 bool fHonorZeroWrites; /**< True if zero blocks should be written. */ 1938 char *pszName = NULL; /**< The path of the disk image file. */ 1939 char *pszFormat = NULL; /**< The format backed to use for this image. */ 1940 char *pszCachePath = NULL; /**< The path to the cache image. */ 1941 char *pszCacheFormat = NULL; /**< The format backend to use for the cache image. */ 1942 bool fReadOnly; /**< True if the media is read-only. */ 1943 bool fMaybeReadOnly; /**< True if the media may or may not be read-only. */ 1944 bool fHonorZeroWrites; /**< True if zero blocks should be written. */ 1938 1945 PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns); 1939 1946 … … 2018 2025 "ReadOnly\0MaybeReadOnly\0TempReadOnly\0Shareable\0HonorZeroWrites\0" 2019 2026 "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0" 2020 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0"); 2027 "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0" 2028 "CachePath\0CacheFormat\0"); 2021 2029 } 2022 2030 else … … 2155 2163 } 2156 2164 MMR3HeapFree(psz); psz = NULL; 2165 2166 rc = CFGMR3QueryStringAlloc(pCurNode, "CachePath", &pszCachePath); 2167 if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND) 2168 { 2169 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 2170 N_("DrvVD: Configuration error: Querying \"CachePath\" as string failed")); 2171 break; 2172 } 2173 else 2174 rc = VINF_SUCCESS; 2175 2176 if (pszCachePath) 2177 { 2178 rc = CFGMR3QueryStringAlloc(pCurNode, "CacheFormat", &pszCacheFormat); 2179 if (RT_FAILURE(rc)) 2180 { 2181 rc = PDMDRV_SET_ERROR(pDrvIns, rc, 2182 N_("DrvVD: Configuration error: Querying \"CacheFormat\" as string failed")); 2183 break; 2184 } 2185 } 2157 2186 } 2158 2187 … … 2456 2485 pCurNode = CFGMR3GetParent(pCurNode); 2457 2486 } 2487 2488 /* Open the cache image if set. */ 2489 if ( RT_SUCCESS(rc) 2490 && VALID_PTR(pszCachePath)) 2491 { 2492 /* Insert the custom I/O interface only if we're told to use new IO. 2493 * Since the I/O interface is per image we could make this more 2494 * flexible in the future if we want to. */ 2495 if (fUseNewIo) 2496 { 2497 rc = VDInterfaceAdd(&pThis->VDIIOCache, "DrvVD_IO", VDINTERFACETYPE_IO, 2498 &pThis->VDIIOCallbacks, pThis, 2499 &pThis->pVDIfsCache); 2500 AssertRC(rc); 2501 } 2502 2503 rc = VDCacheOpen(pThis->pDisk, pszCacheFormat, pszCachePath, VD_OPEN_FLAGS_NORMAL, pThis->pVDIfsCache); 2504 if (RT_FAILURE(rc)) 2505 rc = PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvVD: Could not open cache image")); 2506 } 2507 2508 if (VALID_PTR(pszCachePath)) 2509 MMR3HeapFree(pszCachePath); 2510 if (VALID_PTR(pszCacheFormat)) 2511 MMR3HeapFree(pszCacheFormat); 2458 2512 2459 2513 if ( RT_SUCCESS(rc) -
trunk/src/VBox/Storage/VCICache.cpp
r33567 r33745 82 82 83 83 /** VCI signature to identify a valid image. */ 84 #define VCI_HDR_SIGNATURE UINT32_C(0x 56434900) /* VCI\0*/84 #define VCI_HDR_SIGNATURE UINT32_C(0x00494356) /* \0ICV */ 85 85 /** Current version we support. */ 86 86 #define VCI_HDR_VERSION UINT32_C(0x00000001) … … 193 193 194 194 /** The magic which identifies a block map. */ 195 #define VCI_BLKMAP_MAGIC UINT32_C(0x 56424c4b) /* VBLK*/195 #define VCI_BLKMAP_MAGIC UINT32_C(0x4b4c4256) /* KLBV */ 196 196 /** Current version. */ 197 197 #define VCI_BLKMAP_VERSION UINT32_C(0x00000001) … … 466 466 { 467 467 return pCache->pInterfaceIOCallbacks->pfnWriteSync(pCache->pInterfaceIO->pvUser, 468 pCache->pStorage, uOffset,469 pvBuffer, cbBuffer, NULL);468 pCache->pStorage, VCI_BLOCK2BYTE(uOffset), 469 pvBuffer, VCI_BLOCK2BYTE(cbBuffer), NULL); 470 470 } 471 471 … … 474 474 { 475 475 return pCache->pInterfaceIOCallbacks->pfnReadSync(pCache->pInterfaceIO->pvUser, 476 pCache->pStorage, uOffset,477 pvBuffer, cbBuffer, NULL);476 pCache->pStorage, VCI_BLOCK2BYTE(uOffset), 477 pvBuffer, VCI_BLOCK2BYTE(cbBuffer), NULL); 478 478 } 479 479 … … 596 596 pBlkMap->pRangesTail = pFree; 597 597 598 Assert(!((cbBlkMap + sizeof(VciBlkMap) % VCI_BLOCK_SIZE)));598 Assert(!((cbBlkMap + sizeof(VciBlkMap)) % VCI_BLOCK_SIZE)); 599 599 *ppBlkMap = pBlkMap; 600 *pcBlkMap = (cbBlkMap + sizeof(VciBlkMap)) / VCI_BLOCK_SIZE;600 *pcBlkMap = VCI_BYTE2BLOCK(cbBlkMap + sizeof(VciBlkMap)); 601 601 } 602 602 else … … 662 662 cBlkMap -= VCI_BYTE2BLOCK(sizeof(VciBlkMap)); 663 663 664 rc = vciFileReadSync(pStorage, VCI_BLOCK2BYTE(offBlkMap), &BlkMap, VCI_BYTE2BLOCK(sizeof(VciBlkMap)));664 rc = vciFileReadSync(pStorage, offBlkMap, &BlkMap, VCI_BYTE2BLOCK(sizeof(VciBlkMap))); 665 665 if (RT_SUCCESS(rc)) 666 666 { … … 677 677 && BlkMap.u32Version == VCI_BLKMAP_VERSION 678 678 && BlkMap.cBlocks == BlkMap.cBlocksFree + BlkMap.cBlocksAllocMeta + BlkMap.cBlocksAllocData 679 && BlkMap.cBlocks / 8== cBlkMap)679 && VCI_BYTE2BLOCK(BlkMap.cBlocks / 8) == cBlkMap) 680 680 { 681 681 PVCIBLKMAP pBlkMap = (PVCIBLKMAP)RTMemAllocZ(sizeof(VCIBLKMAP)); … … 696 696 uint8_t abBitmapBuffer[16 * _1K]; 697 697 uint32_t cBlocksRead = 0; 698 int iBit = 0; 699 uint64_t cBlocksLeft = pBlkMap->cBlocks; 698 uint64_t cBlocksLeft = VCI_BYTE2BLOCK(pBlkMap->cBlocks / 8); 700 699 701 700 cBlocksRead = RT_MIN(VCI_BYTE2BLOCK(sizeof(abBitmapBuffer)), cBlocksLeft); 702 rc = vciFileReadSync(pStorage, VCI_BLOCK2BYTE(offBlkMap), abBitmapBuffer,703 VCI_BLOCK2BYTE(cBlocksRead));701 rc = vciFileReadSync(pStorage, offBlkMap, abBitmapBuffer, 702 cBlocksRead); 704 703 705 704 if (RT_SUCCESS(rc)) … … 717 716 && cBlocksLeft) 718 717 { 719 #if 0 720 while (cBlocksRead) 718 int iBit = 0; 719 uint32_t cBits = VCI_BLOCK2BYTE(cBlocksRead) * 8; 720 uint32_t iBitPrev = 0xffffffff; 721 722 while (cBits) 721 723 { 722 724 if (pRangeCur->fFree) 723 725 { 724 726 /* Check for the first set bit. */ 727 iBit = ASMBitNextSet(abBitmapBuffer, cBits, iBitPrev); 725 728 } 726 729 else 727 730 { 728 731 /* Check for the first free bit. */ 732 iBit = ASMBitNextClear(abBitmapBuffer, cBits, iBitPrev); 729 733 } 730 734 … … 732 736 { 733 737 /* No change. */ 734 pRangeCur->cBlocks += cB locksRead;735 cB locksRead= 0;738 pRangeCur->cBlocks += cBits; 739 cBits = 0; 736 740 } 737 741 else 738 742 { 743 Assert((uint32_t)iBit < cBits); 744 pRangeCur->cBlocks += iBit; 745 739 746 /* Create a new range descriptor. */ 747 PVCIBLKRANGEDESC pRangeNew = (PVCIBLKRANGEDESC)RTMemAllocZ(sizeof(VCIBLKRANGEDESC)); 748 if (!pRangeNew) 749 { 750 rc = VERR_NO_MEMORY; 751 break; 752 } 753 754 pRangeNew->fFree = !pRangeCur->fFree; 755 pRangeNew->offAddrStart = pRangeCur->offAddrStart + pRangeCur->cBlocks; 756 pRangeNew->cBlocks = 0; 757 pRangeNew->pPrev = pRangeCur; 758 pRangeCur->pNext = pRangeNew; 759 pBlkMap->pRangesTail = pRangeNew; 760 pRangeCur = pRangeNew; 761 cBits -= iBit; 762 iBitPrev = iBit; 740 763 } 741 764 } 742 #endif 765 743 766 cBlocksLeft -= cBlocksRead; 744 767 offBlkMap += cBlocksRead; 745 768 746 if (cBlocksLeft) 769 if ( RT_SUCCESS(rc) 770 && cBlocksLeft) 747 771 { 748 772 /* Read next chunk. */ 773 cBlocksRead = RT_MIN(VCI_BYTE2BLOCK(sizeof(abBitmapBuffer)), cBlocksLeft); 774 rc = vciFileReadSync(pStorage, offBlkMap, abBitmapBuffer, cBlocksRead); 749 775 } 750 776 } … … 797 823 798 824 /* Make sure the number of blocks allocated for us match our expectations. */ 799 if ( (pBlkMap->cBlocks / 8) + VCI_BYTE2BLOCK(sizeof(VciBlkMap)) == cBlkMap)825 if (VCI_BYTE2BLOCK(pBlkMap->cBlocks / 8) + VCI_BYTE2BLOCK(sizeof(VciBlkMap)) == cBlkMap) 800 826 { 801 827 /* Setup the header */ … … 809 835 BlkMap.cBlocksAllocData = RT_H2LE_U32(pBlkMap->cBlocksAllocData); 810 836 811 rc = vciFileWriteSync(pStorage, VCI_BLOCK2BYTE(offBlkMap), &BlkMap, VCI_BYTE2BLOCK(sizeof(VciBlkMap)));837 rc = vciFileWriteSync(pStorage, offBlkMap, &BlkMap, VCI_BYTE2BLOCK(sizeof(VciBlkMap))); 812 838 if (RT_SUCCESS(rc)) 813 839 { … … 838 864 { 839 865 /* Buffer is full, write to file and reset. */ 840 rc = vciFileWriteSync(pStorage, offBlkMap, abBitmapBuffer, sizeof(abBitmapBuffer));866 rc = vciFileWriteSync(pStorage, offBlkMap, abBitmapBuffer, VCI_BYTE2BLOCK(sizeof(abBitmapBuffer))); 841 867 if (RT_FAILURE(rc)) 842 868 break; … … 853 879 854 880 if (RT_SUCCESS(rc) && iBit) 855 rc = vciFileWriteSync(pStorage, offBlkMap, abBitmapBuffer, iBit / 8);881 rc = vciFileWriteSync(pStorage, offBlkMap, abBitmapBuffer, VCI_BYTE2BLOCK(iBit / 8)); 856 882 } 857 883 } … … 932 958 pFree->fFree = true; 933 959 pFree->cBlocks = pBestFit->cBlocks - cBlocks; 960 pBestFit->cBlocks -= pFree->cBlocks; 934 961 pFree->offAddrStart = pBestFit->offAddrStart + cBlocks; 935 962 … … 1280 1307 } 1281 1308 1282 rc = vciFileReadSync(pCache, 0, &Hdr, sizeof(Hdr));1309 rc = vciFileReadSync(pCache, 0, &Hdr, VCI_BYTE2BLOCK(sizeof(Hdr))); 1283 1310 if (RT_FAILURE(rc)) 1284 1311 { … … 1302 1329 1303 1330 /* Load the block map. */ 1304 rc = vciBlkMapLoad(pCache, VCI_BLOCK2BYTE(pCache->offBlksBitmap), Hdr.cBlkMap, &pCache->pBlkMap);1331 rc = vciBlkMapLoad(pCache, pCache->offBlksBitmap, Hdr.cBlkMap, &pCache->pBlkMap); 1305 1332 if (RT_SUCCESS(rc)) 1306 1333 { … … 1308 1335 VciTreeNode RootNode; 1309 1336 1310 rc = vciFileReadSync(pCache, VCI_BLOCK2BYTE(pCache->offTreeRoot), &RootNode, sizeof(VciTreeNode));1337 rc = vciFileReadSync(pCache, pCache->offTreeRoot, &RootNode, VCI_BYTE2BLOCK(sizeof(VciTreeNode))); 1311 1338 if (RT_SUCCESS(rc)) 1312 1339 { … … 1742 1769 Assert(cbToWrite % 512 == 0); 1743 1770 1771 *pcbWriteProcess = cbToWrite; /** @todo: Implement. */ 1744 1772 out: 1745 1773 LogFlowFunc(("returns %Rrc\n", rc)); -
trunk/src/VBox/Storage/VD.cpp
r33595 r33745 66 66 67 67 /** 68 * Structure containing everything I/O related 69 * for the image and cache descriptors. 70 */ 71 typedef struct VDIO 72 { 73 /** I/O interface to the upper layer. */ 74 PVDINTERFACE pInterfaceIO; 75 /** I/O interface callback table. */ 76 PVDINTERFACEIO pInterfaceIOCallbacks; 77 78 /** Per image internal I/O interface. */ 79 VDINTERFACE VDIIOInt; 80 81 /** Fallback I/O interface, only used if the caller doesn't provide it. */ 82 VDINTERFACE VDIIO; 83 84 /** Opaque backend data. */ 85 void *pBackendData; 86 /** Disk this image is part of */ 87 PVBOXHDD pDisk; 88 } VDIO, *PVDIO; 89 90 /** 68 91 * VBox HDD Container image descriptor. 69 92 */ … … 86 109 /** Function pointers for the various backend methods. */ 87 110 PCVBOXHDDBACKEND Backend; 88 89 111 /** Pointer to list of VD interfaces, per-image. */ 90 112 PVDINTERFACE pVDIfsImage; 91 92 /** I/O interface to the upper layer. */ 93 PVDINTERFACE pInterfaceIO; 94 /** I/O interface callback table. */ 95 PVDINTERFACEIO pInterfaceIOCallbacks; 96 97 /** Per image internal I/O interface. */ 98 VDINTERFACE VDIIOInt; 99 100 /** Fallback I/O interface, only used if the caller doesn't provide it. */ 101 VDINTERFACE VDIIO; 102 103 /** Disk this image is part of */ 104 PVBOXHDD pDisk; 113 /** I/O related things. */ 114 VDIO VDIo; 105 115 } VDIMAGE, *PVDIMAGE; 106 116 … … 133 143 /** Pointer to list of VD interfaces, per-cache. */ 134 144 PVDINTERFACE pVDIfsCache; 135 136 /** I/O interface to the upper layer. */ 137 PVDINTERFACE pInterfaceIO; 138 /** I/O interface callback table. */ 139 PVDINTERFACEIO pInterfaceIOCallbacks; 140 141 /** Per image internal I/O interface. */ 142 VDINTERFACE VDIIOInt; 143 144 /** Fallback I/O interface, only used if the caller doesn't provide it. */ 145 VDINTERFACE VDIIO; 146 147 /** Disk this image is part of */ 148 PVBOXHDD pDisk; 145 /** I/O related things. */ 146 VDIO VDIo; 149 147 } VDCACHE, *PVDCACHE; 150 148 … … 392 390 typedef struct VDIOSTORAGE 393 391 { 394 /** Image this storage handle belongs to. */395 PVDI MAGE pImage;392 /** Image I/O state this storage handle belongs to. */ 393 PVDIO pVDIo; 396 394 /** AVL tree for pending async metadata transfers. */ 397 395 PAVLRFOFFTREE pTreeMetaXfers; … … 799 797 } 800 798 801 if (RT_SUCCESS(rc) )799 if (RT_SUCCESS(rc) || rc == VERR_VD_BLOCK_FREE) 802 800 *pcbThisRead = cbThisRead; 803 801 … … 991 989 PVDIOTASK pIoTask = NULL; 992 990 993 pIoTask = (PVDIOTASK)RTMemCacheAlloc(pIoStorage->p Image->pDisk->hMemCacheIoTask);991 pIoTask = (PVDIOTASK)RTMemCacheAlloc(pIoStorage->pVDIo->pDisk->hMemCacheIoTask); 994 992 if (pIoTask) 995 993 { … … 1009 1007 PVDIOTASK pIoTask = NULL; 1010 1008 1011 pIoTask = (PVDIOTASK)RTMemCacheAlloc(pIoStorage->p Image->pDisk->hMemCacheIoTask);1009 pIoTask = (PVDIOTASK)RTMemCacheAlloc(pIoStorage->pVDIo->pDisk->hMemCacheIoTask); 1012 1010 if (pIoTask) 1013 1011 { … … 1047 1045 } 1048 1046 1049 DECLINLINE(PVDMETAXFER) vdMetaXferAlloc(PVDI MAGE pImage, PVDIOSTORAGE pIoStorage, uint64_t uOffset, size_t cb)1047 DECLINLINE(PVDMETAXFER) vdMetaXferAlloc(PVDIOSTORAGE pIoStorage, uint64_t uOffset, size_t cb) 1050 1048 { 1051 1049 PVDMETAXFER pMetaXfer = (PVDMETAXFER)RTMemAlloc(RT_OFFSETOF(VDMETAXFER, abData[cb])); … … 2603 2601 { 2604 2602 RTCritSectEnter(&pDisk->CritSect); 2605 rc = pfnComplete(pIoStorage->p Image->pBackendData, pIoCtx, pvUser, rcReq);2603 rc = pfnComplete(pIoStorage->pVDIo->pBackendData, pIoCtx, pvUser, rcReq); 2606 2604 RTCritSectLeave(&pDisk->CritSect); 2607 2605 } … … 2621 2619 PVDMETAXFER pMetaXfer, int rcReq) 2622 2620 { 2623 PVBOXHDD pDisk = pIoStorage->p Image->pDisk;2621 PVBOXHDD pDisk = pIoStorage->pVDIo->pDisk; 2624 2622 RTLISTNODE ListIoCtxWaiting; 2625 2623 bool fFlush; … … 2669 2667 { 2670 2668 RTCritSectEnter(&pDisk->CritSect); 2671 rc = pfnComplete(pIoStorage->p Image->pBackendData, pIoCtx, pvUser, rcReq);2669 rc = pfnComplete(pIoStorage->pVDIo->pBackendData, pIoCtx, pvUser, rcReq); 2672 2670 RTCritSectLeave(&pDisk->CritSect); 2673 2671 } … … 2721 2719 pIoTask->Type.Meta.pMetaXfer, rcReq); 2722 2720 2723 vdIoTaskFree(pIoStorage->p Image->pDisk, pIoTask);2721 vdIoTaskFree(pIoStorage->pVDIo->pDisk, pIoTask); 2724 2722 2725 2723 return rc; … … 2733 2731 { 2734 2732 int rc = VINF_SUCCESS; 2735 PVDI MAGE pImage = (PVDIMAGE)pvUser;2733 PVDIO pVDIo = (PVDIO)pvUser; 2736 2734 PVDIOSTORAGE pIoStorage = (PVDIOSTORAGE)RTMemAllocZ(sizeof(VDIOSTORAGE)); 2737 2735 2738 2736 if (!pIoStorage) 2739 2737 return VERR_NO_MEMORY; 2740 2741 pIoStorage->pImage = pImage;2742 2738 2743 2739 /* Create the AVl tree. */ … … 2745 2741 if (pIoStorage->pTreeMetaXfers) 2746 2742 { 2747 rc = p Image->pInterfaceIOCallbacks->pfnOpen(pImage->pInterfaceIO->pvUser,2748 2749 2750 2743 rc = pVDIo->pInterfaceIOCallbacks->pfnOpen(pVDIo->pInterfaceIO->pvUser, 2744 pszLocation, uOpenFlags, 2745 vdIOIntReqCompleted, 2746 &pIoStorage->pStorage); 2751 2747 if (RT_SUCCESS(rc)) 2752 2748 { 2749 pIoStorage->pVDIo = pVDIo; 2753 2750 *ppIoStorage = pIoStorage; 2754 2751 return VINF_SUCCESS; … … 2772 2769 static int vdIOIntClose(void *pvUser, PVDIOSTORAGE pIoStorage) 2773 2770 { 2774 PVDI MAGE pImage = (PVDIMAGE)pvUser;2775 2776 int rc = p Image->pInterfaceIOCallbacks->pfnClose(pImage->pInterfaceIO->pvUser,2777 2771 PVDIO pVDIo = (PVDIO)pvUser; 2772 2773 int rc = pVDIo->pInterfaceIOCallbacks->pfnClose(pVDIo->pInterfaceIO->pvUser, 2774 pIoStorage->pStorage); 2778 2775 AssertRC(rc); 2779 2776 … … 2786 2783 static int vdIOIntDelete(void *pvUser, const char *pcszFilename) 2787 2784 { 2788 PVDI MAGE pImage = (PVDIMAGE)pvUser;2789 return p Image->pInterfaceIOCallbacks->pfnDelete(pImage->pInterfaceIO->pvUser,2790 2785 PVDIO pVDIo = (PVDIO)pvUser; 2786 return pVDIo->pInterfaceIOCallbacks->pfnDelete(pVDIo->pInterfaceIO->pvUser, 2787 pcszFilename); 2791 2788 } 2792 2789 … … 2794 2791 unsigned fMove) 2795 2792 { 2796 PVDI MAGE pImage = (PVDIMAGE)pvUser;2797 return p Image->pInterfaceIOCallbacks->pfnMove(pImage->pInterfaceIO->pvUser,2798 2793 PVDIO pVDIo = (PVDIO)pvUser; 2794 return pVDIo->pInterfaceIOCallbacks->pfnMove(pVDIo->pInterfaceIO->pvUser, 2795 pcszSrc, pcszDst, fMove); 2799 2796 } 2800 2797 … … 2802 2799 int64_t *pcbFreeSpace) 2803 2800 { 2804 PVDI MAGE pImage = (PVDIMAGE)pvUser;2805 return p Image->pInterfaceIOCallbacks->pfnGetFreeSpace(pImage->pInterfaceIO->pvUser,2806 2807 2801 PVDIO pVDIo = (PVDIO)pvUser; 2802 return pVDIo->pInterfaceIOCallbacks->pfnGetFreeSpace(pVDIo->pInterfaceIO->pvUser, 2803 pcszFilename, 2804 pcbFreeSpace); 2808 2805 } 2809 2806 … … 2811 2808 PRTTIMESPEC pModificationTime) 2812 2809 { 2813 PVDI MAGE pImage = (PVDIMAGE)pvUser;2814 return p Image->pInterfaceIOCallbacks->pfnGetModificationTime(pImage->pInterfaceIO->pvUser,2815 2816 2810 PVDIO pVDIo = (PVDIO)pvUser; 2811 return pVDIo->pInterfaceIOCallbacks->pfnGetModificationTime(pVDIo->pInterfaceIO->pvUser, 2812 pcszFilename, 2813 pModificationTime); 2817 2814 } 2818 2815 … … 2820 2817 uint64_t *pcbSize) 2821 2818 { 2822 PVDIMAGE pImage = (PVDIMAGE)pvUser; 2823 2824 return pImage->pInterfaceIOCallbacks->pfnGetSize(pImage->pInterfaceIO->pvUser, 2819 PVDIO pVDIo = (PVDIO)pvUser; 2820 return pVDIo->pInterfaceIOCallbacks->pfnGetSize(pVDIo->pInterfaceIO->pvUser, 2825 2821 pIoStorage->pStorage, 2826 2822 pcbSize); … … 2830 2826 uint64_t cbSize) 2831 2827 { 2832 PVDI MAGE pImage = (PVDIMAGE)pvUser;2833 2834 return p Image->pInterfaceIOCallbacks->pfnSetSize(pImage->pInterfaceIO->pvUser,2835 2836 2828 PVDIO pVDIo = (PVDIO)pvUser; 2829 2830 return pVDIo->pInterfaceIOCallbacks->pfnSetSize(pVDIo->pInterfaceIO->pvUser, 2831 pIoStorage->pStorage, 2832 cbSize); 2837 2833 } 2838 2834 … … 2841 2837 size_t cbWrite, size_t *pcbWritten) 2842 2838 { 2843 PVDI MAGE pImage = (PVDIMAGE)pvUser;2844 2845 return p Image->pInterfaceIOCallbacks->pfnWriteSync(pImage->pInterfaceIO->pvUser,2846 2847 2848 2839 PVDIO pVDIo = (PVDIO)pvUser; 2840 2841 return pVDIo->pInterfaceIOCallbacks->pfnWriteSync(pVDIo->pInterfaceIO->pvUser, 2842 pIoStorage->pStorage, 2843 uOffset, pvBuf, cbWrite, 2844 pcbWritten); 2849 2845 } 2850 2846 … … 2853 2849 size_t *pcbRead) 2854 2850 { 2855 PVDIMAGE pImage = (PVDIMAGE)pvUser; 2856 2857 return pImage->pInterfaceIOCallbacks->pfnReadSync(pImage->pInterfaceIO->pvUser, 2858 pIoStorage->pStorage, 2859 uOffset, pvBuf, cbRead, 2860 pcbRead); 2851 PVDIO pVDIo = (PVDIO)pvUser; 2852 return pVDIo->pInterfaceIOCallbacks->pfnReadSync(pVDIo->pInterfaceIO->pvUser, 2853 pIoStorage->pStorage, 2854 uOffset, pvBuf, cbRead, 2855 pcbRead); 2861 2856 } 2862 2857 2863 2858 static int vdIOIntFlushSync(void *pvUser, PVDIOSTORAGE pIoStorage) 2864 2859 { 2865 PVDIMAGE pImage = (PVDIMAGE)pvUser; 2866 2867 return pImage->pInterfaceIOCallbacks->pfnFlushSync(pImage->pInterfaceIO->pvUser, 2868 pIoStorage->pStorage); 2860 PVDIO pVDIo = (PVDIO)pvUser; 2861 return pVDIo->pInterfaceIOCallbacks->pfnFlushSync(pVDIo->pInterfaceIO->pvUser, 2862 pIoStorage->pStorage); 2869 2863 } 2870 2864 … … 2874 2868 { 2875 2869 int rc = VINF_SUCCESS; 2876 PVDI MAGE pImage = (PVDIMAGE)pvUser;2877 PVBOXHDD pDisk = pImage->pDisk;2870 PVDIO pVDIo = (PVDIO)pvUser; 2871 PVBOXHDD pDisk = pVDIo->pDisk; 2878 2872 2879 2873 LogFlowFunc(("pvUser=%#p pIoStorage=%#p uOffset=%llu pIoCtx=%#p cbRead=%u\n", … … 2909 2903 2910 2904 void *pvTask; 2911 rc = p Image->pInterfaceIOCallbacks->pfnReadAsync(pImage->pInterfaceIO->pvUser,2912 2913 2914 2915 2905 rc = pVDIo->pInterfaceIOCallbacks->pfnReadAsync(pVDIo->pInterfaceIO->pvUser, 2906 pIoStorage->pStorage, 2907 uOffset, aSeg, cSegments, 2908 cbTaskRead, pIoTask, 2909 &pvTask); 2916 2910 if (RT_SUCCESS(rc)) 2917 2911 { … … 2942 2936 { 2943 2937 int rc = VINF_SUCCESS; 2944 PVDI MAGE pImage = (PVDIMAGE)pvUser;2945 PVBOXHDD pDisk = pImage->pDisk;2938 PVDIO pVDIo = (PVDIO)pvUser; 2939 PVBOXHDD pDisk = pVDIo->pDisk; 2946 2940 2947 2941 LogFlowFunc(("pvUser=%#p pIoStorage=%#p uOffset=%llu pIoCtx=%#p cbWrite=%u\n", … … 2977 2971 2978 2972 void *pvTask; 2979 rc = p Image->pInterfaceIOCallbacks->pfnWriteAsync(pImage->pInterfaceIO->pvUser,2980 2981 2982 2983 2973 rc = pVDIo->pInterfaceIOCallbacks->pfnWriteAsync(pVDIo->pInterfaceIO->pvUser, 2974 pIoStorage->pStorage, 2975 uOffset, aSeg, cSegments, 2976 cbTaskWrite, pIoTask, 2977 &pvTask); 2984 2978 if (RT_SUCCESS(rc)) 2985 2979 { … … 3009 3003 void *pvCompleteUser) 3010 3004 { 3011 PVDI MAGE pImage = (PVDIMAGE)pvUser;3012 PVBOXHDD pDisk = p Image->pDisk;3005 PVDIO pVDIo = (PVDIO)pvUser; 3006 PVBOXHDD pDisk = pVDIo->pDisk; 3013 3007 int rc = VINF_SUCCESS; 3014 3008 RTSGSEG Seg; … … 3032 3026 3033 3027 /* Allocate a new meta transfer. */ 3034 pMetaXfer = vdMetaXferAlloc(pI mage, pIoStorage, uOffset, cbRead);3028 pMetaXfer = vdMetaXferAlloc(pIoStorage, uOffset, cbRead); 3035 3029 if (!pMetaXfer) 3036 3030 return VERR_NO_MEMORY; … … 3047 3041 3048 3042 VDMETAXFER_TXDIR_SET(pMetaXfer->fFlags, VDMETAXFER_TXDIR_READ); 3049 rc = p Image->pInterfaceIOCallbacks->pfnReadAsync(pImage->pInterfaceIO->pvUser,3050 3051 3052 3053 3043 rc = pVDIo->pInterfaceIOCallbacks->pfnReadAsync(pVDIo->pInterfaceIO->pvUser, 3044 pIoStorage->pStorage, 3045 uOffset, &Seg, 1, 3046 cbRead, pIoTask, 3047 &pvTask); 3054 3048 3055 3049 if (RT_SUCCESS(rc) || rc == VERR_VD_ASYNC_IO_IN_PROGRESS) … … 3107 3101 void *pvCompleteUser) 3108 3102 { 3109 PVDI MAGE pImage = (PVDIMAGE)pvUser;3110 PVBOXHDD pDisk = pImage->pDisk;3103 PVDIO pVDIo = (PVDIO)pvUser; 3104 PVBOXHDD pDisk = pVDIo->pDisk; 3111 3105 int rc = VINF_SUCCESS; 3112 3106 RTSGSEG Seg; … … 3125 3119 { 3126 3120 /* Allocate a new meta transfer. */ 3127 pMetaXfer = vdMetaXferAlloc(pI mage, pIoStorage, uOffset, cbWrite);3121 pMetaXfer = vdMetaXferAlloc(pIoStorage, uOffset, cbWrite); 3128 3122 if (!pMetaXfer) 3129 3123 return VERR_NO_MEMORY; … … 3152 3146 3153 3147 VDMETAXFER_TXDIR_SET(pMetaXfer->fFlags, VDMETAXFER_TXDIR_WRITE); 3154 rc = p Image->pInterfaceIOCallbacks->pfnWriteAsync(pImage->pInterfaceIO->pvUser,3155 3156 3157 3158 3148 rc = pVDIo->pInterfaceIOCallbacks->pfnWriteAsync(pVDIo->pInterfaceIO->pvUser, 3149 pIoStorage->pStorage, 3150 uOffset, &Seg, 1, 3151 cbWrite, pIoTask, 3152 &pvTask); 3159 3153 if (RT_SUCCESS(rc)) 3160 3154 { … … 3198 3192 static void vdIOIntMetaXferRelease(void *pvUser, PVDMETAXFER pMetaXfer) 3199 3193 { 3200 PVDI MAGE pImage = (PVDIMAGE)pvUser;3201 PVBOXHDD pDisk = pImage->pDisk;3194 PVDIO pVDIo = (PVDIO)pvUser; 3195 PVBOXHDD pDisk = pVDIo->pDisk; 3202 3196 PVDIOSTORAGE pIoStorage = pMetaXfer->pIoStorage; 3203 3197 … … 3226 3220 void *pvCompleteUser) 3227 3221 { 3228 PVDI MAGE pImage = (PVDIMAGE)pvUser;3229 PVBOXHDD pDisk = pImage->pDisk;3222 PVDIO pVDIo = (PVDIO)pvUser; 3223 PVBOXHDD pDisk = pVDIo->pDisk; 3230 3224 int rc = VINF_SUCCESS; 3231 3225 PVDIOTASK pIoTask; … … 3239 3233 3240 3234 /* Allocate a new meta transfer. */ 3241 pMetaXfer = vdMetaXferAlloc(pI mage, pIoStorage, 0, 0);3235 pMetaXfer = vdMetaXferAlloc(pIoStorage, 0, 0); 3242 3236 if (!pMetaXfer) 3243 3237 return VERR_NO_MEMORY; … … 3260 3254 RTListAppend(&pMetaXfer->ListIoCtxWaiting, &pDeferred->NodeDeferred); 3261 3255 VDMETAXFER_TXDIR_SET(pMetaXfer->fFlags, VDMETAXFER_TXDIR_FLUSH); 3262 rc = p Image->pInterfaceIOCallbacks->pfnFlushAsync(pImage->pInterfaceIO->pvUser,3263 3264 3256 rc = pVDIo->pInterfaceIOCallbacks->pfnFlushAsync(pVDIo->pInterfaceIO->pvUser, 3257 pIoStorage->pStorage, 3258 pIoTask, &pvTask); 3265 3259 if (RT_SUCCESS(rc)) 3266 3260 { … … 3280 3274 void *pvBuf, size_t cbBuf) 3281 3275 { 3282 PVDI MAGE pImage = (PVDIMAGE)pvUser;3283 PVBOXHDD pDisk = pImage->pDisk;3276 PVDIO pVDIo = (PVDIO)pvUser; 3277 PVBOXHDD pDisk = pVDIo->pDisk; 3284 3278 size_t cbCopied = 0; 3285 3279 … … 3297 3291 void *pvBuf, size_t cbBuf) 3298 3292 { 3299 PVDI MAGE pImage = (PVDIMAGE)pvUser;3300 PVBOXHDD pDisk = pImage->pDisk;3293 PVDIO pVDIo = (PVDIO)pvUser; 3294 PVBOXHDD pDisk = pVDIo->pDisk; 3301 3295 size_t cbCopied = 0; 3302 3296 … … 3313 3307 static size_t vdIOIntIoCtxSet(void *pvUser, PVDIOCTX pIoCtx, int ch, size_t cb) 3314 3308 { 3315 PVDI MAGE pImage = (PVDIMAGE)pvUser;3316 PVBOXHDD pDisk = pImage->pDisk;3309 PVDIO pVDIo = (PVDIO)pvUser; 3310 PVBOXHDD pDisk = pVDIo->pDisk; 3317 3311 size_t cbSet = 0; 3318 3312 … … 3331 3325 size_t cbData) 3332 3326 { 3333 PVDI MAGE pImage = (PVDIMAGE)pvUser;3334 PVBOXHDD pDisk = pImage->pDisk;3327 PVDIO pVDIo = (PVDIO)pvUser; 3328 PVBOXHDD pDisk = pVDIo->pDisk; 3335 3329 size_t cbCreated = 0; 3336 3330 … … 4011 4005 } 4012 4006 4013 pImage-> pDisk= pDisk;4007 pImage->VDIo.pDisk = pDisk; 4014 4008 pImage->pVDIfsImage = pVDIfsImage; 4015 4009 … … 4025 4019 4026 4020 /* Set up the I/O interface. */ 4027 pImage-> pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO);4028 if (pImage-> pInterfaceIO)4029 pImage-> pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);4021 pImage->VDIo.pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO); 4022 if (pImage->VDIo.pInterfaceIO) 4023 pImage->VDIo.pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->VDIo.pInterfaceIO); 4030 4024 else 4031 4025 { 4032 rc = VDInterfaceAdd(&pImage->VDI IO, "VD_IO", VDINTERFACETYPE_IO,4026 rc = VDInterfaceAdd(&pImage->VDIo.VDIIO, "VD_IO", VDINTERFACETYPE_IO, 4033 4027 &pDisk->VDIIOCallbacks, pDisk, &pVDIfsImage); 4034 pImage-> pInterfaceIO = &pImage->VDIIO;4035 pImage-> pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks;4028 pImage->VDIo.pInterfaceIO = &pImage->VDIo.VDIIO; 4029 pImage->VDIo.pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks; 4036 4030 } 4037 4031 … … 4039 4033 AssertBreakStmt(!VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT), 4040 4034 rc = VERR_INVALID_PARAMETER); 4041 rc = VDInterfaceAdd(&pImage->VDI IOInt, "VD_IOINT", VDINTERFACETYPE_IOINT,4042 &pDisk->VDIIOIntCallbacks, pImage, &pImage->pVDIfsImage);4035 rc = VDInterfaceAdd(&pImage->VDIo.VDIIOInt, "VD_IOINT", VDINTERFACETYPE_IOINT, 4036 &pDisk->VDIIOIntCallbacks, &pImage->VDIo, &pImage->pVDIfsImage); 4043 4037 AssertRC(rc); 4044 4038 … … 4079 4073 fLockWrite = true; 4080 4074 4075 pImage->VDIo.pBackendData = pImage->pBackendData; 4076 4081 4077 /* Check image type. As the image itself has only partial knowledge 4082 4078 * whether it's a base image or not, this info is derived here. The … … 4264 4260 } 4265 4261 4266 pCache-> pDisk= pDisk;4262 pCache->VDIo.pDisk = pDisk; 4267 4263 pCache->pVDIfsCache = pVDIfsCache; 4268 4264 … … 4278 4274 4279 4275 /* Set up the I/O interface. */ 4280 pCache-> pInterfaceIO = VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IO);4281 if (pCache-> pInterfaceIO)4282 pCache-> pInterfaceIOCallbacks = VDGetInterfaceIO(pCache->pInterfaceIO);4276 pCache->VDIo.pInterfaceIO = VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IO); 4277 if (pCache->VDIo.pInterfaceIO) 4278 pCache->VDIo.pInterfaceIOCallbacks = VDGetInterfaceIO(pCache->VDIo.pInterfaceIO); 4283 4279 else 4284 4280 { 4285 rc = VDInterfaceAdd(&pCache->VDI IO, "VD_IO", VDINTERFACETYPE_IO,4281 rc = VDInterfaceAdd(&pCache->VDIo.VDIIO, "VD_IO", VDINTERFACETYPE_IO, 4286 4282 &pDisk->VDIIOCallbacks, pDisk, &pVDIfsCache); 4287 pCache-> pInterfaceIO = &pCache->VDIIO;4288 pCache-> pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks;4283 pCache->VDIo.pInterfaceIO = &pCache->VDIo.VDIIO; 4284 pCache->VDIo.pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks; 4289 4285 } 4290 4286 … … 4292 4288 AssertBreakStmt(!VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IOINT), 4293 4289 rc = VERR_INVALID_PARAMETER); 4294 rc = VDInterfaceAdd(&pCache->VDI IOInt, "VD_IOINT", VDINTERFACETYPE_IOINT,4295 &pDisk->VDIIOIntCallbacks, pCache, &pCache->pVDIfsCache);4290 rc = VDInterfaceAdd(&pCache->VDIo.VDIIOInt, "VD_IOINT", VDINTERFACETYPE_IOINT, 4291 &pDisk->VDIIOIntCallbacks, &pCache->VDIo, &pCache->pVDIfsCache); 4296 4292 AssertRC(rc); 4297 4293 … … 4509 4505 break; 4510 4506 } 4511 pImage-> pDisk= pDisk;4507 pImage->VDIo.pDisk = pDisk; 4512 4508 pImage->pVDIfsImage = pVDIfsImage; 4513 4509 4514 4510 /* Set up the I/O interface. */ 4515 pImage-> pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO);4516 if (pImage-> pInterfaceIO)4517 pImage-> pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);4511 pImage->VDIo.pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO); 4512 if (pImage->VDIo.pInterfaceIO) 4513 pImage->VDIo.pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->VDIo.pInterfaceIO); 4518 4514 else 4519 4515 { 4520 rc = VDInterfaceAdd(&pImage->VDI IO, "VD_IO", VDINTERFACETYPE_IO,4516 rc = VDInterfaceAdd(&pImage->VDIo.VDIIO, "VD_IO", VDINTERFACETYPE_IO, 4521 4517 &pDisk->VDIIOCallbacks, pDisk, &pVDIfsImage); 4522 pImage-> pInterfaceIO = &pImage->VDIIO;4523 pImage-> pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks;4518 pImage->VDIo.pInterfaceIO = &pImage->VDIo.VDIIO; 4519 pImage->VDIo.pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks; 4524 4520 } 4525 4521 … … 4527 4523 AssertBreakStmt(!VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT), 4528 4524 rc = VERR_INVALID_PARAMETER); 4529 rc = VDInterfaceAdd(&pImage->VDI IOInt, "VD_IOINT", VDINTERFACETYPE_IOINT,4530 &pDisk->VDIIOIntCallbacks, pImage, &pImage->pVDIfsImage);4525 rc = VDInterfaceAdd(&pImage->VDIo.VDIIOInt, "VD_IOINT", VDINTERFACETYPE_IOINT, 4526 &pDisk->VDIIOIntCallbacks, &pImage->VDIo, &pImage->pVDIfsImage); 4531 4527 AssertRC(rc); 4532 4528 … … 4576 4572 if (RT_SUCCESS(rc)) 4577 4573 { 4574 pImage->VDIo.pBackendData = pImage->pBackendData; 4578 4575 pImage->uImageFlags = uImageFlags; 4579 4576 … … 4791 4788 } 4792 4789 4793 pImage-> pDisk= pDisk;4790 pImage->VDIo.pDisk = pDisk; 4794 4791 pImage->pVDIfsImage = pVDIfsImage; 4795 4792 4796 4793 /* Set up the I/O interface. */ 4797 pImage-> pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO);4798 if (pImage-> pInterfaceIO)4799 pImage-> pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->pInterfaceIO);4794 pImage->VDIo.pInterfaceIO = VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IO); 4795 if (pImage->VDIo.pInterfaceIO) 4796 pImage->VDIo.pInterfaceIOCallbacks = VDGetInterfaceIO(pImage->VDIo.pInterfaceIO); 4800 4797 else 4801 4798 { 4802 rc = VDInterfaceAdd(&pImage->VDI IO, "VD_IO", VDINTERFACETYPE_IO,4799 rc = VDInterfaceAdd(&pImage->VDIo.VDIIO, "VD_IO", VDINTERFACETYPE_IO, 4803 4800 &pDisk->VDIIOCallbacks, pDisk, &pVDIfsImage); 4804 pImage-> pInterfaceIO = &pImage->VDIIO;4805 pImage-> pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks;4801 pImage->VDIo.pInterfaceIO = &pImage->VDIo.VDIIO; 4802 pImage->VDIo.pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks; 4806 4803 } 4807 4804 … … 4809 4806 AssertBreakStmt(!VDInterfaceGet(pVDIfsImage, VDINTERFACETYPE_IOINT), 4810 4807 rc = VERR_INVALID_PARAMETER); 4811 rc = VDInterfaceAdd(&pImage->VDI IOInt, "VD_IOINT", VDINTERFACETYPE_IOINT,4812 &pDisk->VDIIOIntCallbacks, pImage, &pImage->pVDIfsImage);4808 rc = VDInterfaceAdd(&pImage->VDIo.VDIIOInt, "VD_IOINT", VDINTERFACETYPE_IOINT, 4809 &pDisk->VDIIOIntCallbacks, &pImage->VDIo, &pImage->pVDIfsImage); 4813 4810 AssertRC(rc); 4814 4811 … … 4842 4839 if (RT_SUCCESS(rc)) 4843 4840 { 4841 pImage->VDIo.pBackendData = pImage->pBackendData; 4844 4842 pImage->uImageFlags = uImageFlags; 4845 4843 … … 5013 5011 AssertRC(rc2); 5014 5012 fLockRead = true; 5015 AssertMsgBreakStmt(pDisk->cImages != 0,5016 ("Create diff image cannot be done without other images open\n"),5017 rc = VERR_VD_INVALID_STATE);5018 5013 AssertMsgBreakStmt(!pDisk->pCache, 5019 5014 ("Create cache image cannot be done with a cache already attached\n"), … … 5047 5042 } 5048 5043 5049 pCache-> pDisk= pDisk;5050 pCache->pVDIfsCache = pVDIfsCache;5044 pCache->VDIo.pDisk = pDisk; 5045 pCache->pVDIfsCache = pVDIfsCache; 5051 5046 5052 5047 /* Set up the I/O interface. */ 5053 pCache-> pInterfaceIO = VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IO);5054 if (pCache-> pInterfaceIO)5055 pCache-> pInterfaceIOCallbacks = VDGetInterfaceIO(pCache->pInterfaceIO);5048 pCache->VDIo.pInterfaceIO = VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IO); 5049 if (pCache->VDIo.pInterfaceIO) 5050 pCache->VDIo.pInterfaceIOCallbacks = VDGetInterfaceIO(pCache->VDIo.pInterfaceIO); 5056 5051 else 5057 5052 { 5058 rc = VDInterfaceAdd(&pCache->VDI IO, "VD_IO", VDINTERFACETYPE_IO,5053 rc = VDInterfaceAdd(&pCache->VDIo.VDIIO, "VD_IO", VDINTERFACETYPE_IO, 5059 5054 &pDisk->VDIIOCallbacks, pDisk, &pVDIfsCache); 5060 pCache-> pInterfaceIO = &pCache->VDIIO;5061 pCache-> pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks;5055 pCache->VDIo.pInterfaceIO = &pCache->VDIo.VDIIO; 5056 pCache->VDIo.pInterfaceIOCallbacks = &pDisk->VDIIOCallbacks; 5062 5057 } 5063 5058 … … 5065 5060 AssertBreakStmt(!VDInterfaceGet(pVDIfsCache, VDINTERFACETYPE_IOINT), 5066 5061 rc = VERR_INVALID_PARAMETER); 5067 rc = VDInterfaceAdd(&pCache->VDI IOInt, "VD_IOINT", VDINTERFACETYPE_IOINT,5068 &pDisk->VDIIOIntCallbacks, pCache, &pCache->pVDIfsCache);5062 rc = VDInterfaceAdd(&pCache->VDIo.VDIIOInt, "VD_IOINT", VDINTERFACETYPE_IOINT, 5063 &pDisk->VDIIOIntCallbacks, &pCache->VDIo, &pCache->pVDIfsCache); 5069 5064 AssertRC(rc); 5070 5065 … … 5101 5096 fLockWrite = true; 5102 5097 5098 pCache->VDIo.pBackendData = pCache->pBackendData; 5099 5103 5100 /* Re-check state, as the lock wasn't held and another image 5104 5101 * creation call could have been done by another thread. */ … … 5108 5105 } 5109 5106 5110 if (RT_SUCCESS(rc)) 5107 if ( RT_SUCCESS(rc) 5108 && pDisk->pLast) 5111 5109 { 5112 5110 RTUUID UuidModification; -
trunk/src/VBox/Storage/testcase/vbox-img.cpp
r33595 r33745 52 52 " info --filename <filename>\n" 53 53 "\n" 54 " compact --filename <filename>\n", 54 " compact --filename <filename>\n" 55 " createcache --filename <filename>\n" 56 " --size <cache size>\n", 55 57 g_pszProgName); 56 58 } … … 969 971 970 972 973 int handleCreateCache(HandlerArg *a) 974 { 975 int rc = VINF_SUCCESS; 976 PVBOXHDD pDisk = NULL; 977 const char *pszFilename = NULL; 978 uint64_t cbSize = 0; 979 980 /* Parse the command line. */ 981 static const RTGETOPTDEF s_aOptions[] = 982 { 983 { "--filename", 'f', RTGETOPT_REQ_STRING }, 984 { "--size", 's', RTGETOPT_REQ_UINT64 } 985 }; 986 int ch; 987 RTGETOPTUNION ValueUnion; 988 RTGETOPTSTATE GetState; 989 RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags */); 990 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 991 { 992 switch (ch) 993 { 994 case 'f': // --filename 995 pszFilename = ValueUnion.psz; 996 break; 997 998 case 's': // --size 999 cbSize = ValueUnion.u64; 1000 break; 1001 1002 default: 1003 ch = RTGetOptPrintError(ch, &ValueUnion); 1004 printUsage(g_pStdErr); 1005 return ch; 1006 } 1007 } 1008 1009 /* Check for mandatory parameters. */ 1010 if (!pszFilename) 1011 return errorSyntax("Mandatory --filename option missing\n"); 1012 1013 if (!cbSize) 1014 return errorSyntax("Mandatory --size option missing\n"); 1015 1016 /* just try it */ 1017 rc = VDCreate(pVDIfs, VDTYPE_HDD, &pDisk); 1018 if (RT_FAILURE(rc)) 1019 return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc); 1020 1021 rc = VDCreateCache(pDisk, "VCI", pszFilename, cbSize, VD_IMAGE_FLAGS_DEFAULT, 1022 NULL, NULL, VD_OPEN_FLAGS_NORMAL, NULL, NULL); 1023 if (RT_FAILURE(rc)) 1024 return errorRuntime("Error while creating the virtual disk cache: %Rrc\n", rc); 1025 1026 VDCloseAll(pDisk); 1027 1028 return rc; 1029 } 1030 1031 971 1032 int main(int argc, char *argv[]) 972 1033 { … … 1052 1113 } s_commandHandlers[] = 1053 1114 { 1054 { "setuuid", handleSetUUID }, 1055 { "convert", handleConvert }, 1056 { "info", handleInfo }, 1057 { "compact", handleCompact }, 1058 { NULL, NULL } 1115 { "setuuid", handleSetUUID }, 1116 { "convert", handleConvert }, 1117 { "info", handleInfo }, 1118 { "compact", handleCompact }, 1119 { "createcache", handleCreateCache }, 1120 { NULL, NULL } 1059 1121 }; 1060 1122
Note:
See TracChangeset
for help on using the changeset viewer.