Changeset 11444
- Timestamp:
- 08/15/08 16:33:02 (3 months ago)
- Files:
-
- trunk/include/VBox/VBoxHDD-new.h (modified) (14 diffs)
- trunk/src/VBox/Devices/Storage/DrvVD.cpp (modified) (14 diffs)
- trunk/src/VBox/Devices/Storage/RawHDDCore.cpp (modified) (7 diffs)
- trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp (modified) (28 diffs)
- trunk/src/VBox/Devices/Storage/VBoxHDD-newInternal.h (modified) (4 diffs)
- trunk/src/VBox/Devices/Storage/VDICore.h (modified) (1 diff)
- trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp (modified) (7 diffs)
- trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp (modified) (8 diffs)
- trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp (modified) (3 diffs)
- trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp (modified) (3 diffs)
- trunk/src/VBox/Main/HardDiskImpl.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/VBox/VBoxHDD-new.h
r11435 r11444 237 237 /** First valid interface. */ 238 238 VDINTERFACETYPE_FIRST = 0, 239 /** Interface to pass error message to upper layers. */239 /** Interface to pass error message to upper layers. Per-disk. */ 240 240 VDINTERFACETYPE_ERROR = VDINTERFACETYPE_FIRST, 241 /** Interface for asynchronous I/O operations. */241 /** Interface for asynchronous I/O operations. Per-disk. */ 242 242 VDINTERFACETYPE_ASYNCIO, 243 /** Interface for progress notification. */243 /** Interface for progress notification. Per-operation. */ 244 244 VDINTERFACETYPE_PROGRESS, 245 /** Interface for configuration information. */245 /** Interface for configuration information. Per-image. */ 246 246 VDINTERFACETYPE_CONFIG, 247 247 /** invalid interface. */ … … 274 274 /** 275 275 * Helper functions to handle interface lists. 276 * 277 * @note These interface lists are used consistently to pass per-disk, 278 * per-image and/or per-operation callbacks. Those three purposes are strictly 279 * separate. See the individual interface declarations for what context they 280 * apply to. The caller is responsible for ensuring that the lifetime of the 281 * interface descriptors is appropriate for the category of interface. 276 282 */ 277 283 … … 349 355 /** 350 356 * Interface to deliver error messages to upper layers. 357 * 358 * Per disk interface. Optional, but think twice if you want to miss the 359 * opportunity of reporting better human-readable error messages. 351 360 */ 352 361 typedef struct VDINTERFACEERROR … … 401 410 * Completion callback which is called by the interface owner 402 411 * to inform the backend that a task finished. 403 * 412 * 404 413 * @return VBox status code. 405 414 * @param pvUser Opaque user data which is passed on request submission. … … 412 421 /** 413 422 * Support interface for asynchronous I/O 423 * 424 * Per-disk. Optional. 414 425 */ 415 426 typedef struct VDINTERFACEASYNCIO … … 551 562 /** 552 563 * Progress notification interface 564 * 565 * Per-operation. Optional. 553 566 */ 554 567 typedef struct VDINTERFACEPROGRESS … … 614 627 /** 615 628 * Configuration information interface 629 * 630 * Per-image. Optional for most backends, but mandatory for images which do 631 * not operate on files (including standard block or character devices). 616 632 */ 617 633 typedef struct VDINTERFACECONFIG … … 902 918 * 903 919 * @return VBox status code. 904 * @param pVDIfs Pointer to theVD interface list.920 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 905 921 * @param ppDisk Where to store the reference to HDD container. 906 922 */ 907 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfs , PVBOXHDD *ppDisk);923 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk); 908 924 909 925 /** … … 943 959 * @param pszFilename Name of the image file to open. 944 960 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 961 * @param pVDIfsImage Pointer to the per-image VD interface list. 945 962 */ 946 963 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend, 947 const char *pszFilename, unsigned uOpenFlags); 964 const char *pszFilename, unsigned uOpenFlags, 965 PVDINTERFACE pVDIfsImage); 948 966 949 967 /** … … 962 980 * @param pUuid New UUID of the image. If NULL, a new UUID is created. 963 981 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 964 * @param p fnProgress Progress callback. Optional. NULL if not to be used.965 * @param p vUser User argument for the progress callback.982 * @param pVDIfsImage Pointer to the per-image VD interface list. 983 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 966 984 */ 967 985 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend, … … 972 990 PCPDMMEDIAGEOMETRY pLCHSGeometry, 973 991 PCRTUUID pUuid, unsigned uOpenFlags, 974 PFNVMPROGRESS pfnProgress, void *pvUser); 992 PVDINTERFACE pVDIfsImage, 993 PVDINTERFACE pVDIfsOperation); 975 994 976 995 /** … … 986 1005 * @param pUuid New UUID of the image. If NULL, a new UUID is created. 987 1006 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 988 * @param p fnProgress Progress callback. Optional. NULL if not to be used.989 * @param p vUser User argument for the progress callback.1007 * @param pVDIfsImage Pointer to the per-image VD interface list. 1008 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 990 1009 */ 991 1010 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend, 992 1011 const char *pszFilename, unsigned uImageFlags, 993 1012 const char *pszComment, PCRTUUID pUuid, 994 unsigned uOpenFlags, P FNVMPROGRESS pfnProgress,995 void *pvUser);1013 unsigned uOpenFlags, PVDINTERFACE pVDIfsImage, 1014 PVDINTERFACE pVDIfsOperation); 996 1015 997 1016 /** … … 1006 1025 * @param nImageFrom Name of the image file to merge from. 1007 1026 * @param nImageTo Name of the image file to merge to. 1008 * @param pfnProgress Progress callback. Optional. NULL if not to be used. 1009 * @param pvUser User argument for the progress callback. 1027 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1010 1028 */ 1011 1029 VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, 1012 unsigned nImageTo, PFNVMPROGRESS pfnProgress, 1013 void *pvUser); 1030 unsigned nImageTo, PVDINTERFACE pVDIfsOperation); 1014 1031 1015 1032 /** … … 1032 1049 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). 1033 1050 * @param cbSize New image size (0 means leave unchanged). 1034 * @param pfnProgress Progress callback. Optional. NULL if not to be used. 1035 * @param pvUser User argument for the progress callback. 1051 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1052 * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the 1053 * destination image. 1054 * @param pDstVDIfsOperation Pointer to the per-operation VD interface list, 1055 * for the destination operation. 1036 1056 */ 1037 1057 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 1038 1058 const char *pszBackend, const char *pszFilename, 1039 1059 bool fMoveByRename, uint64_t cbSize, 1040 PFNVMPROGRESS pfnProgress, void *pvUser); 1060 PVDINTERFACE pVDIfsOperation, 1061 PVDINTERFACE pDstVDIfsImage, 1062 PVDINTERFACE pDstVDIfsOperation); 1041 1063 1042 1064 /** trunk/src/VBox/Devices/Storage/DrvVD.cpp
r11435 r11444 77 77 78 78 /** 79 * VBox disk container, image information, private part. 80 */ 81 82 typedef struct VBOXIMAGE 83 { 84 /** Pointer to next image. */ 85 struct VBOXIMAGE *pNext; 86 /** Pointer to list of VD interfaces. Per-image. */ 87 PVDINTERFACE pVDIfsImage; 88 /** Common structure for the configuration information interface. */ 89 VDINTERFACE VDIConfig; 90 } VBOXIMAGE, *PVBOXIMAGE; 91 92 /** 79 93 * VBox disk container media main structure, private part. 80 94 */ … … 89 103 /** Flag whether suspend has changed image open mode to read only. */ 90 104 bool fTempReadOnly; 91 /** Pointer to list of VD interfaces. */92 PVDINTERFACE pVDIfs ;105 /** Pointer to list of VD interfaces. Per-disk. */ 106 PVDINTERFACE pVDIfsDisk; 93 107 /** Common structure for the supported error interface. */ 94 108 VDINTERFACE VDIError; … … 99 113 /** Callback table for async I/O interface. */ 100 114 VDINTERFACEASYNCIO VDIAsyncIOCallbacks; 101 /** Common structure for the configuration information interface. */102 VDINTERFACE VDIConfig;103 115 /** Callback table for the configuration information interface. */ 104 116 VDINTERFACECONFIG VDIConfigCallbacks; … … 115 127 /** Our cache to reduce allocation overhead. */ 116 128 PRTOBJCACHE pCache; 129 /** Pointer to the list of data we need to keep per image. */ 130 PVBOXIMAGE pImages; 117 131 } VBOXDISK, *PVBOXDISK; 118 132 … … 126 140 PPDMDRVINS pDrvIns = (PPDMDRVINS)pvUser; 127 141 pDrvIns->pDrvHlp->pfnVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va); 142 } 143 144 145 /** 146 * Internal: allocate new image descriptor and put it in the list 147 */ 148 static PVBOXIMAGE drvvdNewImage(PVBOXDISK pThis) 149 { 150 AssertPtr(pThis); 151 PVBOXIMAGE pImage = (PVBOXIMAGE)RTMemAllocZ(sizeof(VBOXIMAGE)); 152 if (pImage) 153 { 154 pImage->pVDIfsImage = NULL; 155 PVBOXIMAGE *pp = &pThis->pImages; 156 while (*pp != NULL) 157 pp = &(*pp)->pNext; 158 *pp = pImage; 159 pImage->pNext = NULL; 160 } 161 162 return pImage; 163 } 164 165 /** 166 * Internal: free the list of images descriptors. 167 */ 168 static void drvvdFreeImages(PVBOXDISK pThis) 169 { 170 while (pThis->pImages != NULL) 171 { 172 PVBOXIMAGE p = pThis->pImages; 173 pThis->pImages = pThis->pImages->pNext; 174 RTMemFree(p); 175 } 128 176 } 129 177 … … 537 585 538 586 /* Initialize supported VD interfaces. */ 539 pThis->pVDIfs = NULL;587 pThis->pVDIfsDisk = NULL; 540 588 541 589 pThis->VDIErrorCallbacks.cbSize = sizeof(VDINTERFACEERROR); … … 544 592 545 593 rc = VDInterfaceAdd(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR, 546 &pThis->VDIErrorCallbacks, pDrvIns, &pThis->pVDIfs );594 &pThis->VDIErrorCallbacks, pDrvIns, &pThis->pVDIfsDisk); 547 595 AssertRC(rc); 548 596 … … 559 607 560 608 rc = VDInterfaceAdd(&pThis->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO, 561 &pThis->VDIAsyncIOCallbacks, pThis, &pThis->pVDIfs );609 &pThis->VDIAsyncIOCallbacks, pThis, &pThis->pVDIfsDisk); 562 610 AssertRC(rc); 563 611 612 /* This is just prepared here, the actual interface is per-image, so it's 613 * added later. No need to have separate callback tables. */ 564 614 pThis->VDIConfigCallbacks.cbSize = sizeof(VDINTERFACECONFIG); 565 615 pThis->VDIConfigCallbacks.enmInterface = VDINTERFACETYPE_CONFIG; … … 573 623 pThis->VDIConfigCallbacks.pfnQueryBytes = drvvdCfgQueryBytes; 574 624 575 /** @todo TEMP! this isn't really correct - this needs to be made per image, 576 * as CFGM needs access to the right configuration node for each image. 577 * At the moment this is harmless, as iSCSI can only be used as a base 578 * image, and no other backend uses the private data for these callbacks. */ 579 rc = VDInterfaceAdd(&pThis->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 580 &pThis->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pThis->pVDIfs); 581 AssertRC(rc); 625 /* List of images is empty now. */ 626 pThis->pImages = NULL; 582 627 583 628 /* Try to attach async media port interface above.*/ … … 662 707 if (RT_SUCCESS(rc)) 663 708 { 664 /** @todo TEMP! later the iSCSI config callbacks won't be included here */ 665 rc = VDCreate(&pThis->VDIConfig, &pThis->pDisk); 709 rc = VDCreate(pThis->pVDIfsDisk, &pThis->pDisk); 666 710 /* Error message is already set correctly. */ 667 711 } 668 712 669 unsigned cImages = iLevel;670 713 while (pCurNode && RT_SUCCESS(rc)) 671 714 { 715 /* Allocate per-image data. */ 716 PVBOXIMAGE pImage = drvvdNewImage(pThis); 717 if (!pImage) 718 { 719 rc = VERR_NO_MEMORY; 720 break; 721 } 722 672 723 /* 673 724 * Read the image configuration. … … 717 768 } 718 769 719 /** @todo TEMP! Later this needs to be done for each image. */ 720 if (iLevel == cImages) 721 { 722 PCFGMNODE pCfg = CFGMR3GetChild(pCurNode, "VDConfig"); 723 pThis->VDIConfig.pvUser = pCfg; /**< @todo TEMP! */ 724 } 770 PCFGMNODE pCfg = CFGMR3GetChild(pCurNode, "VDConfig"); 771 rc = VDInterfaceAdd(&pImage->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 772 &pThis->VDIConfigCallbacks, pCfg, &pImage->pVDIfsImage); 773 AssertRC(rc); 725 774 726 775 /* … … 738 787 739 788 /** Try to open backend in asyc I/O mode first. */ 740 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags );789 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 741 790 if (rc == VERR_NOT_SUPPORTED) 742 791 { 743 792 /* Seems async I/O is not supported by the backend, open in normal mode. */ 744 793 uOpenFlags &= ~VD_OPEN_FLAGS_ASYNC_IO; 745 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags );794 rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage); 746 795 } 747 796 … … 774 823 pThis->pDisk = NULL; 775 824 } 825 drvvdFreeImages(pThis); 776 826 if (VALID_PTR(pszName)) 777 827 MMR3HeapFree(pszName); … … 841 891 LogFlow(("%s:\n", __FUNCTION__)); 842 892 893 drvvdFreeImages(pThis); 843 894 if (pThis->pCache) 844 895 { trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
r11435 r11444 47 47 RTFILE File; 48 48 49 /** Pointer to list of VD interfaces. */ 50 PVDINTERFACE pVDIfs; 49 /** Pointer to the per-disk VD interface list. */ 50 PVDINTERFACE pVDIfsDisk; 51 51 52 /** Error callback. */ 52 53 PVDINTERFACE pInterfaceError; … … 118 119 pImage->uOpenFlags = uOpenFlags; 119 120 120 pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs , VDINTERFACETYPE_ERROR);121 pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ERROR); 121 122 if (pImage->pInterfaceError) 122 123 pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); … … 182 183 pImage->LCHSGeometry = *pLCHSGeometry; 183 184 184 pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs , VDINTERFACETYPE_ERROR);185 pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfsDisk, VDINTERFACETYPE_ERROR); 185 186 if (pImage->pInterfaceError) 186 187 pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); … … 330 331 /** @copydoc VBOXHDDBACKEND::pfnOpen */ 331 332 static int rawOpen(const char *pszFilename, unsigned uOpenFlags, 332 PVDINTERFACE pVDIfs, void **ppBackendData) 333 { 334 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x ppBackendData=%#p\n", pszFilename, uOpenFlags, ppBackendData)); 333 PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, 334 void **ppBackendData) 335 { 336 LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x pVDIfsDisk=%#p pVDIfsImage=%#p ppBackendData=%#p\n", pszFilename, uOpenFlags, pVDIfsDisk, pVDIfsImage, ppBackendData)); 335 337 int rc; 336 338 PRAWIMAGE pImage; … … 360 362 pImage->pszFilename = pszFilename; 361 363 pImage->File = NIL_RTFILE; 362 pImage->pInterfaceError = NULL; 363 pImage->pInterfaceErrorCallbacks = NULL; 364 pImage->pVDIfs = pVDIfs; 364 pImage->pVDIfsDisk = pVDIfsDisk; 365 365 366 366 rc = rawOpenImage(pImage, uOpenFlags); … … 379 379 PCPDMMEDIAGEOMETRY pPCHSGeometry, 380 380 PCPDMMEDIAGEOMETRY pLCHSGeometry, PCRTUUID pUuid, 381 unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,382 void *pvUser, unsigned uPercentStart,383 unsigned uPercentSpan, PVDINTERFACE pVDIfs,381 unsigned uOpenFlags, unsigned uPercentStart, 382 unsigned uPercentSpan, PVDINTERFACE pVDIfsDisk, 383 PVDINTERFACE pVDIfsImage, PVDINTERFACE pVDIfsOperation, 384 384 void **ppBackendData) 385 385 { 386 LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pVDIfs=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pVDIfs, ppBackendData));386 LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x uPercentStart=%u uPercentSpan=%u pVDIfsDisk=%#p pVDIfsImage=%#p pVDIfsOperation=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, uPercentStart, uPercentSpan, pVDIfsDisk, pVDIfsImage, pVDIfsOperation, ppBackendData)); 387 387 int rc; 388 388 PRAWIMAGE pImage; 389 390 PFNVMPROGRESS pfnProgress = NULL; 391 void *pvUser = NULL; 392 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, 393 VDINTERFACETYPE_PROGRESS); 394 PVDINTERFACEPROGRESS pCbProgress = NULL; 395 if (pIfProgress) 396 { 397 pCbProgress = VDGetInterfaceProgress(pIfProgress); 398 pfnProgress = pCbProgress->pfnProgress; 399 pvUser = pIfProgress->pvUser; 400 } 389 401 390 402 /* Check open flags. All valid flags are supported. */ … … 414 426 pImage->pszFilename = pszFilename; 415 427 pImage->File = NIL_RTFILE; 416 pImage->pVDIfs = pVDIfs;428 pImage->pVDIfsDisk = pVDIfsDisk; 417 429 418 430 rc = rawCreateImage(pImage, enmType, cbSize, uImageFlags, pszComment, trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r11435 r11444 70 70 /** Function pointers for the various backend methods. */ 71 71 PCVBOXHDDBACKEND Backend; 72 73 /** Pointer to list of VD interfaces, per-image. */ 74 PVDINTERFACE pVDIfsImage; 72 75 } VDIMAGE, *PVDIMAGE; 73 76 … … 108 111 PDMMEDIAGEOMETRY LCHSGeometry; 109 112 110 /** List of interfaces the caller supports. */111 PVDINTERFACE p Interfaces;113 /** Pointer to list of VD interfaces, per-disk. */ 114 PVDINTERFACE pVDIfsDisk; 112 115 /** Pointer to the common interface structure for error reporting. */ 113 116 PVDINTERFACE pInterfaceError; … … 785 788 * 786 789 * @returns VBox status code. 787 * @param p Interfaces Pointer to the first supported interface.790 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 788 791 * @param ppDisk Where to store the reference to HDD container. 789 792 */ 790 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE p Interfaces, PVBOXHDD *ppDisk)793 VBOXDDU_DECL(int) VDCreate(PVDINTERFACE pVDIfsDisk, PVBOXHDD *ppDisk) 791 794 { 792 795 int rc = VINF_SUCCESS; 793 796 PVBOXHDD pDisk = NULL; 794 797 795 LogFlowFunc(("p Interfaces=%#p\n", pInterfaces));798 LogFlowFunc(("pVDIfsDisk=%#p\n", pVDIfsDisk)); 796 799 do 797 800 { … … 815 818 pDisk->LCHSGeometry.cHeads = 0; 816 819 pDisk->LCHSGeometry.cSectors = 0; 817 pDisk->p Interfaces = pInterfaces;820 pDisk->pVDIfsDisk = pVDIfsDisk; 818 821 pDisk->pInterfaceError = NULL; 819 822 pDisk->pInterfaceErrorCallbacks = NULL; 820 823 821 pDisk->pInterfaceError = VDInterfaceGet(p Interfaces, VDINTERFACETYPE_ERROR);824 pDisk->pInterfaceError = VDInterfaceGet(pVDIfsDisk, VDINTERFACETYPE_ERROR); 822 825 if (pDisk->pInterfaceError) 823 826 pDisk->pInterfaceErrorCallbacks = VDGetInterfaceError(pDisk->pInterfaceError); … … 1043 1046 * @param pszFilename Name of the image file to open. 1044 1047 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 1048 * @param pVDIfsImage Pointer to the per-image VD interface list. 1045 1049 */ 1046 1050 VBOXDDU_DECL(int) VDOpen(PVBOXHDD pDisk, const char *pszBackend, 1047 const char *pszFilename, unsigned uOpenFlags) 1051 const char *pszFilename, unsigned uOpenFlags, 1052 PVDINTERFACE pVDIfsImage) 1048 1053 { 1049 1054 int rc = VINF_SUCCESS; 1050 1055 PVDIMAGE pImage = NULL; 1051 1056 1052 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uOpenFlags=%#x\n ",1053 pDisk, pszBackend, pszFilename, uOpenFlags ));1057 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uOpenFlags=%#x\n, pVDIfsImage=%#p", 1058 pDisk, pszBackend, pszFilename, uOpenFlags, pVDIfsImage)); 1054 1059 do 1055 1060 { … … 1082 1087 break; 1083 1088 } 1089 pImage->pVDIfsImage = pVDIfsImage; 1084 1090 1085 1091 rc = vdFindBackend(pszBackend, &pImage->Backend, &pImage->hPlugin); … … 1096 1102 rc = pImage->Backend->pfnOpen(pImage->pszFilename, 1097 1103 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME, 1098 pDisk->pInterfaces, 1104 pDisk->pVDIfsDisk, 1105 pImage->pVDIfsImage, 1099 1106 &pImage->pvBackendData); 1100 1107 /* If the open in read-write mode failed, retry in read-only mode. */ … … 1110 1117 (uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME) 1111 1118 | VD_OPEN_FLAGS_READONLY, 1112 pDisk->pInterfaces, 1119 pDisk->pVDIfsDisk, 1120 pImage->pVDIfsImage, 1113 1121 &pImage->pvBackendData); 1114 1122 if (RT_FAILURE(rc)) … … 1261 1269 * @param pUuid New UUID of the image. If NULL, a new UUID is created. 1262 1270 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 1263 * @param p fnProgress Progress callback. Optional. NULL if not to be used.1264 * @param p vUser User argument for the progress callback.1271 * @param pVDIfsImage Pointer to the per-image VD interface list. 1272 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1265 1273 */ 1266 1274 VBOXDDU_DECL(int) VDCreateBase(PVBOXHDD pDisk, const char *pszBackend, … … 1271 1279 PCPDMMEDIAGEOMETRY pLCHSGeometry, 1272 1280 PCRTUUID pUuid, unsigned uOpenFlags, 1273 PFNVMPROGRESS pfnProgress, void *pvUser) 1281 PVDINTERFACE pVDIfsImage, 1282 PVDINTERFACE pVDIfsOperation) 1274 1283 { 1275 1284 int rc = VINF_SUCCESS; … … 1277 1286 RTUUID uuid; 1278 1287 1279 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" enmType=%#x cbSize=%llu uImageFlags=%#x pszComment=\"%s\" PCHS=%u/%u/%u LCHS=%u/%u/%u Uuid=%RTuuid uOpenFlags=%#x p fnProgress=%#p pvUser=%#p\n",1288 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" enmType=%#x cbSize=%llu uImageFlags=%#x pszComment=\"%s\" PCHS=%u/%u/%u LCHS=%u/%u/%u Uuid=%RTuuid uOpenFlags=%#x pVDIfsImage=%#p pVDIfsOperation=%#p\n", 1280 1289 pDisk, pszBackend, pszFilename, enmType, cbSize, uImageFlags, pszComment, 1281 1290 pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, 1282 1291 pPCHSGeometry->cSectors, pLCHSGeometry->cCylinders, 1283 1292 pLCHSGeometry->cHeads, pLCHSGeometry->cSectors, pUuid, 1284 uOpenFlags, pfnProgress, pvUser)); 1293 uOpenFlags, pVDIfsImage, pVDIfsOperation)); 1294 1295 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, 1296 VDINTERFACETYPE_PROGRESS); 1297 PVDINTERFACEPROGRESS pCbProgress = NULL; 1298 if (pIfProgress) 1299 pCbProgress = VDGetInterfaceProgress(pIfProgress); 1300 1285 1301 do 1286 1302 { … … 1349 1365 break; 1350 1366 } 1367 pImage->pVDIfsImage = pVDIfsImage; 1351 1368 1352 1369 rc = vdFindBackend(pszBackend, &pImage->Backend, &pImage->hPlugin); … … 1379 1396 pLCHSGeometry, pUuid, 1380 1397 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME, 1381 pfnProgress, pvUser, 0, 99, 1382 pDisk->pInterfaces, 1398 0, 99, 1399 pDisk->pVDIfsDisk, 1400 pImage->pVDIfsImage, 1401 pVDIfsOperation, 1383 1402 &pImage->pvBackendData); 1384 1403 … … 1464 1483 } 1465 1484 1466 if (RT_SUCCESS(rc) && pfnProgress) 1467 pfnProgress(NULL /* WARNING! pVM=NULL */, 100, pvUser); 1485 if (RT_SUCCESS(rc) && pCbProgress->pfnProgress) 1486 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 1487 pIfProgress->pvUser); 1468 1488 1469 1489 LogFlowFunc(("returns %Rrc\n", rc)); … … 1483 1503 * @param pUuid New UUID of the image. If NULL, a new UUID is created. 1484 1504 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 1485 * @param p fnProgress Progress callback. Optional. NULL if not to be used.1486 * @param p vUser User argument for the progress callback.1505 * @param pVDIfsImage Pointer to the per-image VD interface list. 1506 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1487 1507 */ 1488 1508 VBOXDDU_DECL(int) VDCreateDiff(PVBOXHDD pDisk, const char *pszBackend, 1489 1509 const char *pszFilename, unsigned uImageFlags, 1490 1510 const char *pszComment, PCRTUUID pUuid, 1491 unsigned uOpenFlags, P FNVMPROGRESS pfnProgress,1492 void *pvUser)1511 unsigned uOpenFlags, PVDINTERFACE pVDIfsImage, 1512 PVDINTERFACE pVDIfsOperation) 1493 1513 { 1494 1514 int rc = VINF_SUCCESS; … … 1496 1516 RTUUID uuid; 1497 1517 1498 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uImageFlags=%#x pszComment=\"%s\" Uuid=%RTuuid uOpenFlags=%#x p fnProgress=%#p pvUser=%#p\n",1518 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uImageFlags=%#x pszComment=\"%s\" Uuid=%RTuuid uOpenFlags=%#x pVDIfsImage=%#p pVDIfsOperation=%#p\n", 1499 1519 pDisk, pszBackend, pszFilename, uImageFlags, pszComment, pUuid, uOpenFlags, 1500 pfnProgress, pvUser)); 1520 pVDIfsImage, pVDIfsOperation)); 1521 1522 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, 1523 VDINTERFACETYPE_PROGRESS); 1524 PVDINTERFACEPROGRESS pCbProgress = NULL; 1525 if (pIfProgress) 1526 pCbProgress = VDGetInterfaceProgress(pIfProgress); 1527 1501 1528 do 1502 1529 { … … 1573 1600 &pDisk->LCHSGeometry, pUuid, 1574 1601 uOpenFlags & ~VD_OPEN_FLAGS_HONOR_SAME, 1575 pfnProgress, pvUser, 0, 99, 1576 pDisk->pInterfaces, 1602 0, 99, 1603 pDisk->pVDIfsDisk, 1604 pImage->pVDIfsImage, 1605 pVDIfsOperation, 1577 1606 &pImage->pvBackendData); 1578 1607 … … 1649 1678 } 1650 1679 1651 if (RT_SUCCESS(rc) && pfnProgress) 1652 pfnProgress(NULL /* WARNING! pVM=NULL */, 100, pvUser); 1680 if (RT_SUCCESS(rc) && pCbProgress->pfnProgress) 1681 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 1682 pIfProgress->pvUser); 1653 1683 1654 1684 LogFlowFunc(("returns %Rrc\n", rc)); … … 1667 1697 * @param nImageFrom Name of the image file to merge from. 1668 1698 * @param nImageTo Name of the image file to merge to. 1669 * @param pfnProgress Progress callback. Optional. NULL if not to be used. 1670 * @param pvUser User argument for the progress callback. 1699 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1671 1700 */ 1672 1701 VBOXDDU_DECL(int) VDMerge(PVBOXHDD pDisk, unsigned nImageFrom, 1673 unsigned nImageTo, PFNVMPROGRESS pfnProgress, 1674 void *pvUser) 1702 unsigned nImageTo, PVDINTERFACE pVDIfsOperation) 1675 1703 { 1676 1704 int rc = VINF_SUCCESS; 1677 1705 void *pvBuf = NULL; 1678 1706 1679 LogFlowFunc(("pDisk=%#p nImageFrom=%u nImageTo=%u pfnProgress=%#p pvUser=%#p\n", 1680 pDisk, nImageFrom, nImageTo, pfnProgress, pvUser)); 1707 LogFlowFunc(("pDisk=%#p nImageFrom=%u nImageTo=%u pVDIfsOperation=%#p\n", 1708 pDisk, nImageFrom, nImageTo, pVDIfsOperation)); 1709 1710 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, 1711 VDINTERFACETYPE_PROGRESS); 1712 PVDINTERFACEPROGRESS pCbProgress = NULL; 1713 if (pIfProgress) 1714 pCbProgress = VDGetInterfaceProgress(pIfProgress); 1715 1681 1716 do 1682 1717 { … … 1768 1803 uOffset += cbThisRead; 1769 1804 cbRemaining -= cbThisRead; 1805 1806 if (pCbProgress->pfnProgress) 1807 { 1808 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 1809 uOffset * 99 / cbSize, 1810 pIfProgress->pvUser); 1811 if (RT_FAILURE(rc)) 1812 break; 1813 } 1770 1814 } while (uOffset < cbSize); 1771 1815 } … … 1808 1852 uOffset += cbThisRead; 1809 1853 cbRemaining -= cbThisRead; 1854 1855 if (pCbProgress->pfnProgress) 1856 { 1857 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 1858 uOffset * 99 / cbSize, 1859 pIfProgress->pvUser); 1860 if (RT_FAILURE(rc)) 1861 break; 1862 } 1810 1863 } while (uOffset < cbSize); 1811 1864 } … … 1868 1921 RTMemTmpFree(pvBuf); 1869 1922 1870 if (RT_SUCCESS(rc) && pfnProgress) 1871 pfnProgress(NULL /* WARNING! pVM=NULL */, 100, pvUser); 1923 if (RT_SUCCESS(rc) && pCbProgress->pfnProgress) 1924 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 1925 pIfProgress->pvUser); 1872 1926 1873 1927 LogFlowFunc(("returns %Rrc\n", rc)); … … 1894 1948 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). 1895 1949 * @param cbSize New image size (0 means leave unchanged). 1896 * @param pfnProgress Progress callback. Optional. NULL if not to be used. 1897 * @param pvUser User argument for the progress callback. 1950 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1951 * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the 1952 * destination image. 1953 * @param pDstVDIfsOperation Pointer to the per-image VD interface list, 1954 * for the destination image. 1898 1955 */ 1899 1956 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 1900 1957 const char *pszBackend, const char *pszFilename, 1901 1958 bool fMoveByRename, uint64_t cbSize, 1902 PFNVMPROGRESS pfnProgress, void *pvUser) 1959 PVDINTERFACE pVDIfsOperation, 1960 PVDINTERFACE pDstVDIfsImage, 1961 PVDINTERFACE pDstVDIfsOperation) 1903 1962 { 1904 1963 int rc, rc2 = VINF_SUCCESS; … … 1906 1965 PVDIMAGE pImageTo = NULL; 1907 1966 1908 LogFlowFunc(("pDiskFrom=%#p nImage=%u pDiskTo=%#p pszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu pfnProgress=%#p pvUser=%#p\n", 1909 pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, pfnProgress, pvUser)); 1967 LogFlowFunc(("pDiskFrom=%#p nImage=%u pDiskTo=%#p pszBackend=\"%s\" pszFilename=\"%s\" fMoveByRename=%d cbSize=%llu pVDIfsOperation=%#p pDstVDIfsImage=%#p pDstVDIfsOperation=%#p\n", 1968 pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation)); 1969 1970 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, 1971 VDINTERFACETYPE_PROGRESS); 1972 PVDINTERFACEPROGRESS pCbProgress = NULL; 1973 if (pIfProgress) 1974 pCbProgress = VDGetInterfaceProgress(pIfProgress); 1975 1976 PVDINTERFACE pDstIfProgress = VDInterfaceGet(pDstVDIfsOperation, 1977 VDINTERFACETYPE_PROGRESS); 1978 PVDINTERFACEPROGRESS pDstCbProgress = NULL; 1979 if (pDstIfProgress) 1980 pDstCbProgress = VDGetInterfaceProgress(pDstIfProgress); 1910 1981 1911 1982 do { … … 1942 2013 1943 2014 /* Open the source image in the destination container. */ 1944 rc = VDOpen(pDiskTo, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags );2015 rc = VDOpen(pDiskTo, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags, pDstVDIfsImage); 1945 2016 if (RT_FAILURE(rc)) 1946 2017 goto movefail; … … 1968 2039 movefail: 1969 2040 /* In case of failure, re-open the source image in the source container. */ 1970 rc2 = VDOpen(pDiskFrom, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags );2041 rc2 = VDOpen(pDiskFrom, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags, pImageFrom->pVDIfsImage); 1971 2042 if (RT_FAILURE(rc2)) 1972 2043 /** @todo Uncertain what to do on error. If this happens pImageFrom and pImageTo are both closed. */ … … 2053 2124 uOffset += cbThisRead; 2054 2125 cbRemaining -= cbThisRead; 2055 if (pfnProgress) 2126 2127 if (pCbProgress->pfnProgress) 2056 2128 { 2057 rc = pfnProgress(NULL /* WARNING! pVM=NULL */, 2058 ((cbSize - cbRemaining) * 100) / cbSize, 2059 pvUser); 2129 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2130 uOffset * 99 / cbSize, 2131 pIfProgress->pvUser); 2132 if (RT_FAILURE(rc)) 2133 break; 2134 } 2135 if (pDstCbProgress->pfnProgress) 2136 { 2137 rc = pDstCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2138 uOffset * 99 / cbSize, 2139 pDstIfProgress->pvUser); 2060 2140 if (RT_FAILURE(rc)) 2061 2141 break; … … 2108 2188 RTMemTmpFree(pvBuf); 2109 2189 2110 if (RT_SUCCESS(rc) && pfnProgress) 2111 pfnProgress(NULL /* WARNING! pVM=NULL */, 100, pvUser); 2190 if (RT_SUCCESS(rc)) 2191 { 2192 if (pCbProgress->pfnProgress) 2193 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2194 pIfProgress->pvUser); 2195 if (pDstCbProgress->pfnProgress) 2196 pDstCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2197 pDstIfProgress->pvUser); 2198 } 2112 2199 2113 2200 LogFlowFunc(("returns %Rrc\n", rc)); trunk/src/VBox/Devices/Storage/VBoxHDD-newInternal.h
r11421 r11444 78 78 * unchanged during the lifetime of this image. 79 79 * @param uOpenFlags Image file open mode, see VD_OPEN_FLAGS_* constants. 80 * @param pInterfaces Pointer to the first element of supported interfaces of the caller. 80 * @param pVDIfsDisk Pointer to the per-disk VD interface list. 81 * @param pVDIfsImage Pointer to the per-image VD interface list. 81 82 * @param ppvBackendData Opaque state data for this image. 82 83 */

