Changeset 9560 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Jun 9, 2008 6:52:18 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r9528 r9560 60 60 /** Data managed by the backend which keeps the actual info. */ 61 61 void *pvBackendData; 62 /** Cached sanitized image type. */ 63 VDIMAGETYPE enmImageType; 62 64 /** Image open flags (only those handled generically in this code and which 63 65 * the backends will never ever see). */ … … 1101 1103 rc = pImage->Backend->pfnGetImageType(pImage->pvBackendData, 1102 1104 &enmImageType); 1103 /* Check image type. As the image itself has no idea whether it's a 1104 * base image or not, this info is derived here. Image 0 can be fixed 1105 * or normal, all others must be normal images. */ 1105 /* Check image type. As the image itself has only partial knowledge 1106 * whether it's a base image or not, this info is derived here. The 1107 * base image can be fixed or normal, all others must be normal or 1108 * diff images. Some image formats don't distinguish between normal 1109 * and diff images, so this must be corrected here. */ 1106 1110 if ( VBOX_SUCCESS(rc) 1107 && !(uOpenFlags & VD_OPEN_FLAGS_INFO) 1108 && pDisk->cImages != 0 1109 && enmImageType != VD_IMAGE_TYPE_NORMAL) 1111 && !(uOpenFlags & VD_OPEN_FLAGS_INFO)) 1110 1112 { 1111 1113 rc = VERR_VDI_INVALID_TYPE; 1112 1114 break; 1113 1115 } 1116 if ( pDisk->cImages == 0 1117 && ( enmImageType != VD_IMAGE_TYPE_FIXED 1118 || enmImageType != VD_IMAGE_TYPE_NORMAL)) 1119 { 1120 rc = VERR_VDI_INVALID_TYPE; 1121 break; 1122 } 1123 else if (pDisk->cImages != 0) 1124 { 1125 if ( enmImageType != VD_IMAGE_TYPE_NORMAL 1126 || enmImageType != VD_IMAGE_TYPE_DIFF) 1127 { 1128 rc = VERR_VDI_INVALID_TYPE; 1129 break; 1130 } 1131 else 1132 enmImageType = VD_IMAGE_TYPE_DIFF; 1133 } 1134 pImage->enmImageType = enmImageType; 1114 1135 1115 1136 /* Force sane optimization settings. It's not worth avoiding writes … … 1324 1345 if (VBOX_SUCCESS(rc)) 1325 1346 { 1347 pImage->enmImageType = enmType; 1348 1326 1349 /* Force sane optimization settings. It's not worth avoiding writes 1327 1350 * to fixed size images. The overhead would have almost no payback. */ … … 1495 1518 if (VBOX_SUCCESS(rc) && pDisk->cImages != 0) 1496 1519 { 1520 pImage->enmImageType = VD_IMAGE_TYPE_DIFF; 1521 1497 1522 /* Switch previous image to read-only mode. */ 1498 1523 unsigned uOpenFlagsPrevImg; … … 1877 1902 rc2 = VDOpen(pDiskFrom, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags); 1878 1903 if (VBOX_FAILURE(rc2)) 1879 /* @todo Uncertain what to do on error. If this happens pImageFrom and pImageTo are both closed. */1904 /** @todo Uncertain what to do on error. If this happens pImageFrom and pImageTo are both closed. */ 1880 1905 rc = rc2; 1881 1906 break; … … 1888 1913 1889 1914 /* Collect properties of source image. */ 1890 VDIMAGETYPE enmTypeFrom; 1891 rc = VDGetImageType(pDiskFrom, nImage, &enmTypeFrom); 1892 if (VBOX_FAILURE(rc)) 1893 break; 1894 1895 uint64_t cbSizeFrom = VDGetSize(pDiskFrom, nImage); 1915 VDIMAGETYPE enmTypeFrom = pImageFrom->enmImageType; 1916 1917 uint64_t cbSizeFrom; 1918 cbSizeFrom = pImageFrom->Backend->pfnGetSize(pImageFrom->pvBackendData); 1896 1919 if (cbSizeFrom == 0) 1897 1920 { … … 1904 1927 1905 1928 unsigned uImageFlagsFrom; 1906 rc = VDGetImageFlags(pDiskFrom, nImage, &uImageFlagsFrom); 1907 if (VBOX_FAILURE(rc)) 1908 break; 1909 1910 /* @todo Get this from the source image. */ 1929 uImageFlagsFrom = pImageFrom->Backend->pfnGetImageFlags(pImageFrom->pvBackendData); 1930 1931 /** @todo Get this from the source image. */ 1911 1932 PDMMEDIAGEOMETRY PCHSGeometryFrom = {0, 0, 0}; 1912 1933 PDMMEDIAGEOMETRY LCHSGeometryFrom = {0, 0, 0}; 1913 1934 1914 1935 unsigned uOpenFlagsFrom; 1915 rc = VDGetOpenFlags(pDiskFrom, nImage, &uOpenFlagsFrom); 1916 if (VBOX_FAILURE(rc)) 1917 break; 1936 uOpenFlagsFrom = pImageFrom->Backend->pfnGetOpenFlags(pImageFrom->pvBackendData); 1918 1937 1919 1938 /* Create destination image with the properties of the source image. */ 1920 /* @todo Copy the comment. */ 1939 /** @todo Copy the comment. */ 1940 /** @todo replace the VDCreateDiff/VDCreateBase calls by direct 1941 * calls to the backend. Unifies the code and reduces the API 1942 * dependencies. */ 1921 1943 if (enmTypeFrom == VD_IMAGE_TYPE_DIFF) 1922 1944 { … … 2737 2759 PVDIMAGETYPE penmType) 2738 2760 { 2739 int rc ;2761 int rc = VINF_SUCCESS; 2740 2762 2741 2763 LogFlowFunc(("pDisk=%#p nImage=%u penmType=%#p\n", … … 2755 2777 AssertPtrBreakStmt(pImage, rc = VERR_VDI_IMAGE_NOT_FOUND); 2756 2778 2757 rc = pImage->Backend->pfnGetImageType(pImage->pvBackendData, 2758 penmType); 2779 *penmType = pImage->enmImageType; 2759 2780 } while (0); 2760 2781
Note:
See TracChangeset
for help on using the changeset viewer.