- Timestamp:
- Mar 9, 2010 9:05:57 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r26916 r27232 5 5 6 6 /* 7 * Copyright (C) 2006-20 08Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 103 103 /** Callback routine */ 104 104 PFNVDCOMPLETED pfnCompleted; 105 106 /** Pointer to the optional thread synchronization interface of the disk. */ 107 PVDINTERFACE pInterfaceThreadSync; 108 /** Pointer to the optional thread synchronization callbacks of the disk. */ 109 PVDINTERFACETHREADSYNC pInterfaceThreadSyncCallbacks; 105 110 } DRVVDSTORAGEBACKEND, *PDRVVDSTORAGEBACKEND; 106 111 … … 263 268 pvCallerUser = pvUser; 264 269 270 /* If thread synchronization is active, then signal the end of the 271 * this disk read/write operation. */ 272 /** @todo provide a way to determine the type of task (read/write) 273 * which was completed, see also VBoxHDD.cpp. */ 274 if (RT_UNLIKELY(pStorageBackend->pInterfaceThreadSyncCallbacks)) 275 { 276 int rc2 = pStorageBackend->pInterfaceThreadSyncCallbacks->pfnFinishWrite(pStorageBackend->pInterfaceThreadSync->pvUser); 277 AssertRC(rc2); 278 } 279 265 280 if (rc == VINF_VD_ASYNC_IO_FINISHED) 266 281 { … … 273 288 } 274 289 275 static DECLCALLBACK(int) drvvdAsyncIOOpen(void *pvUser, const char *pszLocation, unsigned uOpenFlags, 276 PFNVDCOMPLETED pfnCompleted, void **ppStorage) 290 static DECLCALLBACK(int) drvvdAsyncIOOpen(void *pvUser, const char *pszLocation, 291 unsigned uOpenFlags, 292 PFNVDCOMPLETED pfnCompleted, 293 PVDINTERFACE pVDIfsDisk, 294 void **ppStorage) 277 295 { 278 296 PVBOXDISK pDrvVD = (PVBOXDISK)pvUser; … … 284 302 pStorageBackend->fSyncIoPending = false; 285 303 pStorageBackend->pfnCompleted = pfnCompleted; 304 pStorageBackend->pInterfaceThreadSync = NULL; 305 pStorageBackend->pInterfaceThreadSyncCallbacks = NULL; 306 307 pStorageBackend->pInterfaceThreadSync = VDInterfaceGet(pVDIfsDisk, VDINTERFACETYPE_THREADSYNC); 308 if (RT_UNLIKELY(pStorageBackend->pInterfaceThreadSync)) 309 pStorageBackend->pInterfaceThreadSyncCallbacks = VDGetInterfaceThreadSync(pStorageBackend->pInterfaceThreadSync); 286 310 287 311 rc = RTSemEventCreate(&pStorageBackend->EventSem); … … 1265 1289 #endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */ 1266 1290 } 1291 1292 /** @todo implement and set up the thread synchronization interface 1293 * if enabled by some CFGM key. If this is enabled then there also 1294 * needs to be a way for the console object to query the pDisk pointer 1295 * (so that it can perform the merge in parallel), or alternatively 1296 * some code needs to be added here which does the merge. The latter 1297 * might be preferred, as a running merge must block the destruction 1298 * of the disk, or things will go really wrong. */ 1267 1299 1268 1300 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Devices/Storage/ParallelsHDDCore.cpp
r26291 r27232 6 6 7 7 /* 8 * Copyright (C) 2006-20 09Sun Microsystems, Inc.8 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 162 162 pImage->pszFilename, 163 163 uOpenFlags, 164 NULL, &pImage->pvStorage); 164 NULL, 165 pImage->pVDIfsDisk, 166 &pImage->pvStorage); 165 167 #endif 166 168 -
trunk/src/VBox/Devices/Storage/RawHDDCore.cpp
r26291 r27232 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 141 141 pImage->pszFilename, 142 142 uOpenFlags, 143 NULL, &pImage->pvStorage); 143 NULL, 144 pImage->pVDIfsDisk, 145 &pImage->pvStorage); 144 146 #endif 145 147 … … 317 319 PCPDMMEDIAGEOMETRY pPCHSGeometry, 318 320 PCPDMMEDIAGEOMETRY pLCHSGeometry, 319 PFNV MPROGRESS pfnProgress, void *pvUser,321 PFNVDPROGRESS pfnProgress, void *pvUser, 320 322 unsigned uPercentStart, unsigned uPercentSpan) 321 323 { … … 403 405 if (pfnProgress) 404 406 { 405 rc = pfnProgress(NULL /* WARNING! pVM=NULL */, 406 uPercentStart + uOff * uPercentSpan * 98 / (cbSize * 100), 407 pvUser); 407 rc = pfnProgress(pvUser, 408 uPercentStart + uOff * uPercentSpan * 98 / (cbSize * 100)); 408 409 if (RT_FAILURE(rc)) 409 410 goto out; … … 413 414 414 415 if (RT_SUCCESS(rc) && pfnProgress) 415 pfnProgress(NULL /* WARNING! pVM=NULL */, 416 uPercentStart + uPercentSpan * 98 / 100, pvUser); 416 pfnProgress(pvUser, uPercentStart + uPercentSpan * 98 / 100); 417 417 418 418 pImage->cbSize = cbSize; … … 422 422 out: 423 423 if (RT_SUCCESS(rc) && pfnProgress) 424 pfnProgress(NULL /* WARNING! pVM=NULL */, 425 uPercentStart + uPercentSpan, pvUser); 424 pfnProgress(pvUser, uPercentStart + uPercentSpan); 426 425 427 426 if (RT_FAILURE(rc)) … … 548 547 PRAWIMAGE pImage; 549 548 550 PFNV MPROGRESS pfnProgress = NULL;549 PFNVDPROGRESS pfnProgress = NULL; 551 550 void *pvUser = NULL; 552 551 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, -
trunk/src/VBox/Devices/Storage/VBoxHDD.cpp
r27213 r27232 5 5 6 6 /* 7 * Copyright (C) 2006-20 08Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 127 127 /** Pointer to the common interface structure for error reporting. */ 128 128 PVDINTERFACE pInterfaceError; 129 /** Pointer to the error interface we use if available. */129 /** Pointer to the error interface callbacks we use if available. */ 130 130 PVDINTERFACEERROR pInterfaceErrorCallbacks; 131 132 /** Pointer to the optional thread synchronization interface. */ 133 PVDINTERFACE pInterfaceThreadSync; 134 /** Pointer to the optional thread synchronization callbacks. */ 135 PVDINTERFACETHREADSYNC pInterfaceThreadSyncCallbacks; 131 136 132 137 /** Fallback async interface. */ … … 206 211 pDisk->pInterfaceErrorCallbacks->pfnError(pDisk->pInterfaceError->pvUser, rc, RT_SRC_POS_ARGS, pszFormat, va); 207 212 va_end(va); 213 return rc; 214 } 215 216 /** 217 * internal: thread synchronization, start read. 218 */ 219 DECLINLINE(int) vdThreadStartRead(PVBOXHDD pDisk) 220 { 221 int rc = VINF_SUCCESS; 222 if (RT_UNLIKELY(pDisk->pInterfaceThreadSyncCallbacks)) 223 rc = pDisk->pInterfaceThreadSyncCallbacks->pfnStartRead(pDisk->pInterfaceThreadSync->pvUser); 224 return rc; 225 } 226 227 /** 228 * internal: thread synchronization, finish read. 229 */ 230 DECLINLINE(int) vdThreadFinishRead(PVBOXHDD pDisk) 231 { 232 int rc = VINF_SUCCESS; 233 if (RT_UNLIKELY(pDisk->pInterfaceThreadSyncCallbacks)) 234 rc = pDisk->pInterfaceThreadSyncCallbacks->pfnFinishRead(pDisk->pInterfaceThreadSync->pvUser); 235 return rc; 236 } 237 238 /** 239 * internal: thread synchronization, start write. 240 */ 241 DECLINLINE(int) vdThreadStartWrite(PVBOXHDD pDisk) 242 { 243 int rc = VINF_SUCCESS; 244 if (RT_UNLIKELY(pDisk->pInterfaceThreadSyncCallbacks)) 245 rc = pDisk->pInterfaceThreadSyncCallbacks->pfnStartWrite(pDisk->pInterfaceThreadSync->pvUser); 246 return rc; 247 } 248 249 /** 250 * internal: thread synchronization, finish write. 251 */ 252 DECLINLINE(int) vdThreadFinishWrite(PVBOXHDD pDisk) 253 { 254 int rc = VINF_SUCCESS; 255 if (RT_UNLIKELY(pDisk->pInterfaceThreadSyncCallbacks)) 256 rc = pDisk->pInterfaceThreadSyncCallbacks->pfnFinishWrite(pDisk->pInterfaceThreadSync->pvUser); 208 257 return rc; 209 258 } … … 744 793 */ 745 794 static int vdAsyncIOOpen(void *pvUser, const char *pszLocation, unsigned uOpenFlags, 746 PFNVDCOMPLETED pfnCompleted, void **ppStorage) 795 PFNVDCOMPLETED pfnCompleted, PVDINTERFACE pVDIfsDisk, 796 void **ppStorage) 747 797 { 748 798 PVDIASYNCIOSTORAGE pStorage = (PVDIASYNCIOSTORAGE)RTMemAllocZ(sizeof(VDIASYNCIOSTORAGE)); … … 925 975 926 976 927 928 977 /** 929 978 * Lists all HDD backends and their capabilities in a caller-provided buffer. 930 *931 * @todo this code contains memory leaks, inconsistent (and probably buggy)932 * allocation, and it lacks documentation what the caller needs to free.933 979 * 934 980 * @returns VBox status code. … … 982 1028 /** 983 1029 * Lists the capablities of a backend indentified by its name. 984 * Free all returned names with RTStrFree() when you no longer need them.985 1030 * 986 1031 * @returns VBox status code. … … 1055 1100 pDisk->pInterfaceError = NULL; 1056 1101 pDisk->pInterfaceErrorCallbacks = NULL; 1102 pDisk->pInterfaceThreadSync = NULL; 1103 pDisk->pInterfaceThreadSyncCallbacks = NULL; 1057 1104 1058 1105 pDisk->pInterfaceError = VDInterfaceGet(pVDIfsDisk, VDINTERFACETYPE_ERROR); 1059 1106 if (pDisk->pInterfaceError) 1060 1107 pDisk->pInterfaceErrorCallbacks = VDGetInterfaceError(pDisk->pInterfaceError); 1108 1109 pDisk->pInterfaceThreadSync = VDInterfaceGet(pVDIfsDisk, VDINTERFACETYPE_THREADSYNC); 1110 if (pDisk->pInterfaceThreadSync) 1111 pDisk->pInterfaceThreadSyncCallbacks = VDGetInterfaceThreadSync(pDisk->pInterfaceThreadSync); 1061 1112 1062 1113 /* Use the fallback async I/O interface if the caller doesn't provide one. */ … … 1228 1279 { 1229 1280 int rc = VINF_SUCCESS; 1281 int rc2; 1282 bool fLockWrite = false; 1230 1283 PVDIMAGE pImage = NULL; 1231 1284 1232 1285 LogFlowFunc(("pDisk=%#p pszBackend=\"%s\" pszFilename=\"%s\" uOpenFlags=%#x, pVDIfsImage=%#p\n", 1233 1286 pDisk, pszBackend, pszFilename, uOpenFlags, pVDIfsImage)); 1287 1234 1288 do 1235 1289 { … … 1303 1357 } 1304 1358 1305 unsigned uImageFlags; 1306 uImageFlags = pImage->Backend->pfnGetImageFlags(pImage->pvBackendData); 1359 /* Lock disk for writing, as we modify pDisk information below. */ 1360 rc2 = vdThreadStartWrite(pDisk); 1361 AssertRC(rc2); 1362 fLockWrite = true; 1363 1307 1364 /* Check image type. As the image itself has only partial knowledge 1308 1365 * whether it's a base image or not, this info is derived here. The … … 1310 1367 * diff images. Some image formats don't distinguish between normal 1311 1368 * and diff images, so this must be corrected here. */ 1369 unsigned uImageFlags; 1370 uImageFlags = pImage->Backend->pfnGetImageFlags(pImage->pvBackendData); 1312 1371 if (RT_FAILURE(rc)) 1313 1372 uImageFlags = VD_IMAGE_FLAGS_NONE; … … 1341 1400 /** @todo optionally check UUIDs */ 1342 1401 1343 int rc2;1344 1345 1402 /* Cache disk information. */ 1346 1403 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); … … 1406 1463 } 1407 1464 } while (0); 1465 1466 if (RT_UNLIKELY(fLockWrite)) 1467 { 1468 rc2 = vdThreadFinishWrite(pDisk); 1469 AssertRC(rc2); 1470 } 1408 1471 1409 1472 if (RT_FAILURE(rc)) … … 1448 1511 { 1449 1512 int rc = VINF_SUCCESS; 1513 int rc2; 1514 bool fLockWrite = false, fLockRead = false; 1450 1515 PVDIMAGE pImage = NULL; 1451 1516 RTUUID uuid; … … 1508 1573 rc = VERR_INVALID_PARAMETER); 1509 1574 1510 /* Check state. */ 1575 /* Check state. Needs a temporary read lock. Holding the write lock 1576 * all the time would be blocking other activities for too long. */ 1577 rc2 = vdThreadStartRead(pDisk); 1578 AssertRC(rc2); 1579 fLockRead = true; 1511 1580 AssertMsgBreakStmt(pDisk->cImages == 0, 1512 1581 ("Create base image cannot be done with other images open\n"), 1513 1582 rc = VERR_VD_INVALID_STATE); 1583 rc2 = vdThreadFinishRead(pDisk); 1584 AssertRC(rc2); 1585 fLockRead = false; 1514 1586 1515 1587 /* Set up image descriptor. */ … … 1573 1645 pImage->uOpenFlags |= VD_OPEN_FLAGS_HONOR_SAME; 1574 1646 1647 /* Lock disk for writing, as we modify pDisk information below. */ 1648 rc2 = vdThreadStartWrite(pDisk); 1649 AssertRC(rc2); 1650 fLockWrite = true; 1651 1575 1652 /** @todo optionally check UUIDs */ 1576 1653 1577 int rc2; 1578 1654 /* Re-check state, as the lock wasn't held and another image 1655 * creation call could have been done by another thread. */ 1656 AssertMsgStmt(pDisk->cImages == 0, 1657 ("Create base image cannot be done with other images open\n"), 1658 rc = VERR_VD_INVALID_STATE); 1659 } 1660 1661 if (RT_SUCCESS(rc)) 1662 { 1579 1663 /* Cache disk information. */ 1580 1664 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); … … 1612 1696 pDisk->LCHSGeometry.cSectors = RT_MIN(pDisk->LCHSGeometry.cSectors, 63); 1613 1697 } 1614 } 1615 1616 if (RT_SUCCESS(rc)) 1617 { 1698 1618 1699 /* Image successfully opened, make it the last image. */ 1619 1700 vdAddImageToList(pDisk, pImage); … … 1631 1712 } while (0); 1632 1713 1714 if (RT_UNLIKELY(fLockWrite)) 1715 { 1716 rc2 = vdThreadFinishWrite(pDisk); 1717 AssertRC(rc2); 1718 } 1719 else if (RT_UNLIKELY(fLockRead)) 1720 { 1721 rc2 = vdThreadFinishRead(pDisk); 1722 AssertRC(rc2); 1723 } 1724 1633 1725 if (RT_FAILURE(rc)) 1634 1726 { … … 1642 1734 1643 1735 if (RT_SUCCESS(rc) && pCbProgress && pCbProgress->pfnProgress) 1644 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 1645 pIfProgress->pvUser); 1736 pCbProgress->pfnProgress(pIfProgress, 100); 1646 1737 1647 1738 LogFlowFunc(("returns %Rrc\n", rc)); … … 1673 1764 { 1674 1765 int rc = VINF_SUCCESS; 1766 int rc2; 1767 bool fLockWrite = false, fLockRead = false; 1675 1768 PVDIMAGE pImage = NULL; 1676 1769 RTUUID uuid; … … 1714 1807 rc = VERR_INVALID_PARAMETER); 1715 1808 1716 /* Check state. */ 1809 /* Check state. Needs a temporary read lock. Holding the write lock 1810 * all the time would be blocking other activities for too long. */ 1811 rc2 = vdThreadStartRead(pDisk); 1812 AssertRC(rc2); 1813 fLockRead = true; 1717 1814 AssertMsgBreakStmt(pDisk->cImages != 0, 1718 1815 ("Create diff image cannot be done without other images open\n"), 1719 1816 rc = VERR_VD_INVALID_STATE); 1817 rc2 = vdThreadFinishRead(pDisk); 1818 AssertRC(rc2); 1819 fLockRead = false; 1720 1820 1721 1821 /* Set up image descriptor. */ … … 1770 1870 &pImage->pvBackendData); 1771 1871 1772 if (RT_SUCCESS(rc) && pDisk->cImages != 0)1872 if (RT_SUCCESS(rc)) 1773 1873 { 1774 1874 pImage->uImageFlags = uImageFlags; 1875 1876 /* Lock disk for writing, as we modify pDisk information below. */ 1877 rc2 = vdThreadStartWrite(pDisk); 1878 AssertRC(rc2); 1879 fLockWrite = true; 1775 1880 1776 1881 /* Switch previous image to read-only mode. */ … … 1782 1887 rc = pDisk->pLast->Backend->pfnSetOpenFlags(pDisk->pLast->pvBackendData, uOpenFlagsPrevImg); 1783 1888 } 1889 1890 /** @todo optionally check UUIDs */ 1891 1892 /* Re-check state, as the lock wasn't held and another image 1893 * creation call could have been done by another thread. */ 1894 AssertMsgStmt(pDisk->cImages != 0, 1895 ("Create diff image cannot be done without other images open\n"), 1896 rc = VERR_VD_INVALID_STATE); 1784 1897 } 1785 1898 … … 1788 1901 RTUUID Uuid; 1789 1902 RTTIMESPEC ts; 1790 int rc2;1791 1903 1792 1904 if (pParentUuid && !RTUuidIsNull(pParentUuid)) … … 1817 1929 if (RT_SUCCESS(rc)) 1818 1930 { 1819 /** @todo optionally check UUIDs */1820 }1821 1822 if (RT_SUCCESS(rc))1823 {1824 1931 /* Image successfully opened, make it the last image. */ 1825 1932 vdAddImageToList(pDisk, pImage); … … 1830 1937 { 1831 1938 /* Error detected, but image opened. Close and delete image. */ 1832 int rc2;1833 1939 rc2 = pImage->Backend->pfnClose(pImage->pvBackendData, true); 1834 1940 AssertRC(rc2); … … 1837 1943 } while (0); 1838 1944 1945 if (RT_UNLIKELY(fLockWrite)) 1946 { 1947 rc2 = vdThreadFinishWrite(pDisk); 1948 AssertRC(rc2); 1949 } 1950 else if (RT_UNLIKELY(fLockRead)) 1951 { 1952 rc2 = vdThreadFinishRead(pDisk); 1953 AssertRC(rc2); 1954 } 1955 1839 1956 if (RT_FAILURE(rc)) 1840 1957 { … … 1848 1965 1849 1966 if (RT_SUCCESS(rc) && pCbProgress && pCbProgress->pfnProgress) 1850 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 1851 pIfProgress->pvUser); 1967 pCbProgress->pfnProgress(pIfProgress, 100); 1852 1968 1853 1969 LogFlowFunc(("returns %Rrc\n", rc)); … … 1873 1989 { 1874 1990 int rc = VINF_SUCCESS; 1991 int rc2; 1992 bool fLockWrite = false, fLockRead = false; 1875 1993 void *pvBuf = NULL; 1876 1994 … … 1890 2008 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 1891 2009 2010 rc2 = vdThreadStartRead(pDisk); 2011 AssertRC(rc2); 2012 fLockRead = true; 1892 2013 PVDIMAGE pImageFrom = vdGetImageByNumber(pDisk, nImageFrom); 1893 2014 PVDIMAGE pImageTo = vdGetImageByNumber(pDisk, nImageTo); … … 1912 2033 /* Get size of destination image. */ 1913 2034 uint64_t cbSize = pImageTo->Backend->pfnGetSize(pImageTo->pvBackendData); 2035 rc2 = vdThreadFinishRead(pDisk); 2036 AssertRC(rc2); 2037 fLockRead = false; 1914 2038 1915 2039 /* Allocate tmp buffer. */ … … 1923 2047 /* Merging is done directly on the images itself. This potentially 1924 2048 * causes trouble if the disk is full in the middle of operation. */ 1925 /** @todo write alternative implementation which works with temporary1926 * images (which is safer, but requires even more space). Also has the1927 * drawback that merging into a raw disk parent simply isn't possible1928 * this way (but in that case disk full isn't really a problem). */1929 2049 if (nImageFrom < nImageTo) 1930 2050 { … … 1937 2057 { 1938 2058 size_t cbThisRead = RT_MIN(VD_MERGE_BUFFER_SIZE, cbRemaining); 2059 2060 /* Need to hold the write lock during a read-write operation. */ 2061 rc2 = vdThreadStartWrite(pDisk); 2062 AssertRC(rc2); 2063 fLockWrite = true; 2064 1939 2065 rc = pImageTo->Backend->pfnRead(pImageTo->pvBackendData, 1940 2066 uOffset, pvBuf, cbThisRead, … … 1972 2098 break; 1973 2099 2100 rc2 = vdThreadFinishWrite(pDisk); 2101 AssertRC(rc2); 2102 fLockWrite = false; 2103 1974 2104 uOffset += cbThisRead; 1975 2105 cbRemaining -= cbThisRead; … … 1977 2107 if (pCbProgress && pCbProgress->pfnProgress) 1978 2108 { 1979 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 1980 uOffset * 99 / cbSize, 1981 pIfProgress->pvUser); 2109 rc = pCbProgress->pfnProgress(pIfProgress->pvUser, 2110 uOffset * 99 / cbSize); 1982 2111 if (RT_FAILURE(rc)) 1983 2112 break; … … 2020 2149 size_t cbThisRead = RT_MIN(VD_MERGE_BUFFER_SIZE, cbRemaining); 2021 2150 rc = VERR_VD_BLOCK_FREE; 2151 2152 /* Need to hold the write lock during a read-write operation. */ 2153 rc2 = vdThreadStartWrite(pDisk); 2154 AssertRC(rc2); 2155 fLockWrite = true; 2156 2022 2157 /* Search for image with allocated block. Do not attempt to 2023 2158 * read more than the previous reads marked as valid. Otherwise … … 2045 2180 rc = VINF_SUCCESS; 2046 2181 2182 rc2 = vdThreadFinishWrite(pDisk); 2183 AssertRC(rc2); 2184 fLockWrite = true; 2185 2047 2186 uOffset += cbThisRead; 2048 2187 cbRemaining -= cbThisRead; … … 2050 2189 if (pCbProgress && pCbProgress->pfnProgress) 2051 2190 { 2052 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2053 uOffset * 99 / cbSize, 2054 pIfProgress->pvUser); 2191 rc = pCbProgress->pfnProgress(pIfProgress->pvUser, 2192 uOffset * 99 / cbSize); 2055 2193 if (RT_FAILURE(rc)) 2056 2194 break; … … 2058 2196 } while (uOffset < cbSize); 2059 2197 } 2198 2199 /* Need to hold the write lock while finishing the merge. */ 2200 rc2 = vdThreadStartWrite(pDisk); 2201 AssertRC(rc2); 2202 fLockWrite = true; 2060 2203 2061 2204 /* Update parent UUID so that image chain is consistent. */ … … 2137 2280 } while (0); 2138 2281 2282 if (RT_UNLIKELY(fLockWrite)) 2283 { 2284 rc2 = vdThreadFinishWrite(pDisk); 2285 AssertRC(rc2); 2286 } 2287 else if (RT_UNLIKELY(fLockRead)) 2288 { 2289 rc2 = vdThreadFinishRead(pDisk); 2290 AssertRC(rc2); 2291 } 2292 2139 2293 if (pvBuf) 2140 2294 RTMemTmpFree(pvBuf); 2141 2295 2142 2296 if (RT_SUCCESS(rc) && pCbProgress && pCbProgress->pfnProgress) 2143 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2144 pIfProgress->pvUser); 2297 pCbProgress->pfnProgress(pIfProgress->pvUser, 100); 2145 2298 2146 2299 LogFlowFunc(("returns %Rrc\n", rc)); … … 2185 2338 PVDINTERFACE pDstVDIfsOperation) 2186 2339 { 2187 int rc, rc2 = VINF_SUCCESS; 2340 int rc = VINF_SUCCESS; 2341 int rc2; 2342 bool fLockReadFrom = false, fLockWriteFrom = false, fLockWriteTo = false; 2188 2343 void *pvBuf = NULL; 2189 2344 PVDIMAGE pImageTo = NULL; … … 2211 2366 ("u32Signature=%08x\n", pDiskFrom->u32Signature)); 2212 2367 2368 rc2 = vdThreadStartRead(pDiskFrom); 2369 AssertRC(rc2); 2370 fLockReadFrom = true; 2213 2371 PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImage); 2214 2372 AssertPtrBreakStmt(pImageFrom, rc = VERR_VD_IMAGE_NOT_FOUND); … … 2225 2383 && !RTStrICmp(pszBackend, pImageFrom->Backend->pszBackendName)) 2226 2384 { 2385 rc2 = vdThreadFinishRead(pDiskFrom); 2386 AssertRC(rc2); 2387 fLockReadFrom = false; 2388 2389 rc2 = vdThreadStartWrite(pDiskFrom); 2390 AssertRC(rc2); 2391 fLockWriteFrom = true; 2227 2392 rc = pImageFrom->Backend->pfnRename(pImageFrom->pvBackendData, pszFilename ? pszFilename : pImageFrom->pszFilename); 2228 2393 break; … … 2288 2453 uOpenFlagsFrom = pImageFrom->Backend->pfnGetOpenFlags(pImageFrom->pvBackendData); 2289 2454 2455 rc2 = vdThreadFinishRead(pDiskFrom); 2456 AssertRC(rc2); 2457 fLockReadFrom = false; 2458 2290 2459 if (pszFilename) 2291 2460 { … … 2296 2465 /** @todo replace the VDCreateDiff/VDCreateBase calls by direct 2297 2466 * calls to the backend. Unifies the code and reduces the API 2298 * dependencies. */2467 * dependencies. Would also make the synchronization explicit. */ 2299 2468 if (uImageFlags & VD_IMAGE_FLAGS_DIFF) 2300 2469 { 2301 2470 rc = VDCreateDiff(pDiskTo, pszBackend, pszFilename, uImageFlags, 2302 2471 szComment, &ImageUuid, &ParentUuid, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL); 2472 2473 rc2 = vdThreadStartWrite(pDiskTo); 2474 AssertRC(rc2); 2475 fLockWriteTo = true; 2303 2476 } else { 2304 /** @todo Please, review this! It's an ugly hack I think... */ 2477 /** @todo hack to force creation of a fixed image for 2478 * the RAW backend, which can't handle anything else. */ 2305 2479 if (!RTStrICmp(pszBackend, "RAW")) 2306 2480 uImageFlags |= VD_IMAGE_FLAGS_FIXED; … … 2325 2499 &PCHSGeometryFrom, &LCHSGeometryFrom, 2326 2500 NULL, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL); 2501 2502 rc2 = vdThreadStartWrite(pDiskTo); 2503 AssertRC(rc2); 2504 fLockWriteTo = true; 2505 2327 2506 if (RT_SUCCESS(rc) && !RTUuidIsNull(&ImageUuid)) 2328 2507 pDiskTo->pLast->Backend->pfnSetUuid(pDiskTo->pLast->pvBackendData, &ImageUuid); … … 2355 2534 } 2356 2535 2536 rc2 = vdThreadFinishWrite(pDiskTo); 2537 AssertRC(rc2); 2538 fLockWriteTo = false; 2539 2357 2540 /* Allocate tmp buffer. */ 2358 2541 pvBuf = RTMemTmpAlloc(VD_MERGE_BUFFER_SIZE); … … 2370 2553 { 2371 2554 size_t cbThisRead = RT_MIN(VD_MERGE_BUFFER_SIZE, cbRemaining); 2555 2556 /* Note that we don't attempt to synchronize cross-disk accesses. 2557 * It wouldn't be very difficult to do, just the lock order would 2558 * need to be defined somehow to prevent deadlocks. Postpone such 2559 * magic as there is no use case for this. */ 2560 2561 rc2 = vdThreadStartRead(pDiskFrom); 2562 AssertRC(rc2); 2563 fLockReadFrom = true; 2372 2564 2373 2565 rc = vdReadHelper(pDiskFrom, pImageFrom, NULL, uOffset, pvBuf, … … 2376 2568 break; 2377 2569 2570 rc2 = vdThreadFinishRead(pDiskFrom); 2571 AssertRC(rc2); 2572 fLockReadFrom = false; 2573 2574 rc2 = vdThreadStartWrite(pDiskTo); 2575 AssertRC(rc2); 2576 fLockWriteTo = true; 2577 2378 2578 rc = vdWriteHelper(pDiskTo, pImageTo, NULL, uOffset, pvBuf, 2379 2579 cbThisRead); … … 2381 2581 break; 2382 2582 2583 rc2 = vdThreadFinishWrite(pDiskTo); 2584 AssertRC(rc2); 2585 fLockWriteTo = false; 2586 2383 2587 uOffset += cbThisRead; 2384 2588 cbRemaining -= cbThisRead; … … 2386 2590 if (pCbProgress && pCbProgress->pfnProgress) 2387 2591 { 2388 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2389 uOffset * 99 / cbSize, 2390 pIfProgress->pvUser); 2592 rc = pCbProgress->pfnProgress(pIfProgress->pvUser, 2593 uOffset * 99 / cbSize); 2391 2594 if (RT_FAILURE(rc)) 2392 2595 break; … … 2394 2597 if (pDstCbProgress && pDstCbProgress->pfnProgress) 2395 2598 { 2396 rc = pDstCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2397 uOffset * 99 / cbSize, 2398 pDstIfProgress->pvUser); 2599 rc = pDstCbProgress->pfnProgress(pDstIfProgress->pvUser, 2600 uOffset * 99 / cbSize); 2399 2601 if (RT_FAILURE(rc)) 2400 2602 break; … … 2404 2606 if (RT_SUCCESS(rc)) 2405 2607 { 2608 rc2 = vdThreadStartWrite(pDiskTo); 2609 AssertRC(rc2); 2610 fLockWriteTo = true; 2611 2406 2612 /* Only set modification UUID if it is non-null, since the source 2407 2613 * backend might not provide a valid modification UUID. */ … … 2418 2624 if (RT_FAILURE(rc) && pImageTo && pszFilename) 2419 2625 { 2626 /* Take the write lock only if it is not taken. Not worth making the 2627 * above code even more complicated. */ 2628 if (RT_UNLIKELY(!fLockWriteTo)) 2629 { 2630 rc2 = vdThreadStartWrite(pDiskTo); 2631 AssertRC(rc2); 2632 fLockWriteTo = true; 2633 } 2420 2634 /* Error detected, but new image created. Remove image from list. */ 2421 2635 vdRemoveImageFromList(pDiskTo, pImageTo); … … 2433 2647 } 2434 2648 2649 if (RT_UNLIKELY(fLockWriteTo)) 2650 { 2651 rc2 = vdThreadFinishWrite(pDiskTo); 2652 AssertRC(rc2); 2653 } 2654 if (RT_UNLIKELY(fLockWriteFrom)) 2655 { 2656 rc2 = vdThreadFinishWrite(pDiskFrom); 2657 AssertRC(rc2); 2658 } 2659 else if (RT_UNLIKELY(fLockReadFrom)) 2660 { 2661 rc2 = vdThreadFinishRead(pDiskFrom); 2662 AssertRC(rc2); 2663 } 2664 2435 2665 if (pvBuf) 2436 2666 RTMemTmpFree(pvBuf); … … 2439 2669 { 2440 2670 if (pCbProgress && pCbProgress->pfnProgress) 2441 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2442 pIfProgress->pvUser); 2671 pCbProgress->pfnProgress(pIfProgress->pvUser, 100); 2443 2672 if (pDstCbProgress && pDstCbProgress->pfnProgress) 2444 pDstCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2445 pDstIfProgress->pvUser); 2673 pDstCbProgress->pfnProgress(pDstIfProgress->pvUser, 100); 2446 2674 } 2447 2675 … … 2469 2697 PVDINTERFACE pVDIfsOperation) 2470 2698 { 2471 int rc; 2699 int rc = VINF_SUCCESS; 2700 int rc2; 2701 bool fLockRead = false, fLockWrite = false; 2472 2702 void *pvBuf = NULL; 2473 2703 void *pvTmp = NULL; … … 2488 2718 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, 2489 2719 ("u32Signature=%08x\n", pDisk->u32Signature)); 2720 2721 rc2 = vdThreadStartRead(pDisk); 2722 AssertRC(rc2); 2723 fLockRead = true; 2490 2724 2491 2725 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 2521 2755 } 2522 2756 2757 rc2 = vdThreadFinishRead(pDisk); 2758 AssertRC(rc2); 2759 fLockRead = false; 2760 2761 rc2 = vdThreadStartWrite(pDisk); 2762 AssertRC(rc2); 2763 fLockWrite = true; 2764 2523 2765 rc = pImage->Backend->pfnCompact(pImage->pvBackendData, 2524 2766 0, 99, 2767 pDisk->pVDIfsDisk, 2768 pImage->pVDIfsImage, 2525 2769 pVDIfsOperation); 2526 2770 } while (0); 2771 2772 if (RT_UNLIKELY(fLockWrite)) 2773 { 2774 rc2 = vdThreadFinishWrite(pDisk); 2775 AssertRC(rc2); 2776 } 2777 else if (RT_UNLIKELY(fLockRead)) 2778 { 2779 rc2 = vdThreadFinishRead(pDisk); 2780 AssertRC(rc2); 2781 } 2527 2782 2528 2783 if (pvBuf) … … 2534 2789 { 2535 2790 if (pCbProgress && pCbProgress->pfnProgress) 2536 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 100, 2537 pIfProgress->pvUser); 2791 pCbProgress->pfnProgress(pIfProgress->pvUser, 100); 2538 2792 } 2539 2793 … … 2544 2798 /** 2545 2799 * Closes the last opened image file in HDD container. 2546 * If previous image file was opened in read-only mode (th at is normal) and closing image2547 * was opened in read-write mode (the whole disk was in read-write mode) - the previous image2548 * will bereopened in read/write mode.2800 * If previous image file was opened in read-only mode (the normal case) and 2801 * the last opened image is in read-write mode then the previous image will be 2802 * reopened in read/write mode. 2549 2803 * 2550 2804 * @returns VBox status code. … … 2556 2810 { 2557 2811 int rc = VINF_SUCCESS; 2812 int rc2; 2813 bool fLockWrite = false; 2558 2814 2559 2815 LogFlowFunc(("pDisk=%#p fDelete=%d\n", pDisk, fDelete)); … … 2563 2819 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER); 2564 2820 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 2821 2822 /* Not worth splitting this up into a read lock phase and write 2823 * lock phase, as closing an image is a relatively fast operation 2824 * dominated by the part which needs the write lock. */ 2825 rc2 = vdThreadStartWrite(pDisk); 2826 AssertRC(rc2); 2827 fLockWrite = true; 2565 2828 2566 2829 PVDIMAGE pImage = pDisk->pLast; … … 2593 2856 } 2594 2857 2595 int rc2;2596 2597 2858 /* Cache disk information. */ 2598 2859 pDisk->cbSize = pImage->Backend->pfnGetSize(pImage->pvBackendData); … … 2632 2893 } while (0); 2633 2894 2895 if (RT_UNLIKELY(fLockWrite)) 2896 { 2897 rc2 = vdThreadFinishWrite(pDisk); 2898 AssertRC(rc2); 2899 } 2900 2634 2901 LogFlowFunc(("returns %Rrc\n", rc)); 2635 2902 return rc; … … 2645 2912 { 2646 2913 int rc = VINF_SUCCESS; 2914 int rc2; 2915 bool fLockWrite = false; 2647 2916 2648 2917 LogFlowFunc(("pDisk=%#p\n", pDisk)); … … 2652 2921 AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER); 2653 2922 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 2923 2924 /* Lock the entire operation. */ 2925 rc2 = vdThreadStartWrite(pDisk); 2926 AssertRC(rc2); 2927 fLockWrite = true; 2654 2928 2655 2929 PVDIMAGE pImage = pDisk->pLast; … … 2671 2945 } while (0); 2672 2946 2947 if (RT_UNLIKELY(fLockWrite)) 2948 { 2949 rc2 = vdThreadFinishWrite(pDisk); 2950 AssertRC(rc2); 2951 } 2952 2673 2953 LogFlowFunc(("returns %Rrc\n", rc)); 2674 2954 return rc; … … 2688 2968 size_t cbRead) 2689 2969 { 2690 int rc; 2970 int rc = VINF_SUCCESS; 2971 int rc2; 2972 bool fLockRead = false; 2691 2973 2692 2974 LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbRead=%zu\n", … … 2705 2987 ("cbRead=%zu\n", cbRead), 2706 2988 rc = VERR_INVALID_PARAMETER); 2989 2990 rc2 = vdThreadStartRead(pDisk); 2991 AssertRC(rc2); 2992 fLockRead = true; 2993 2707 2994 AssertMsgBreakStmt(uOffset + cbRead <= pDisk->cbSize, 2708 2995 ("uOffset=%llu cbRead=%zu pDisk->cbSize=%llu\n", … … 2715 3002 rc = vdReadHelper(pDisk, pImage, NULL, uOffset, pvBuf, cbRead); 2716 3003 } while (0); 3004 3005 if (RT_UNLIKELY(fLockRead)) 3006 { 3007 rc2 = vdThreadFinishRead(pDisk); 3008 AssertRC(rc2); 3009 } 2717 3010 2718 3011 LogFlowFunc(("returns %Rrc\n", rc)); … … 2735 3028 { 2736 3029 int rc = VINF_SUCCESS; 3030 int rc2; 3031 bool fLockWrite = false; 2737 3032 2738 3033 LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbWrite=%zu\n", … … 2751 3046 ("cbWrite=%zu\n", cbWrite), 2752 3047 rc = VERR_INVALID_PARAMETER); 3048 3049 rc2 = vdThreadStartWrite(pDisk); 3050 AssertRC(rc2); 3051 fLockWrite = true; 3052 2753 3053 AssertMsgBreakStmt(uOffset + cbWrite <= pDisk->cbSize, 2754 3054 ("uOffset=%llu cbWrite=%zu pDisk->cbSize=%llu\n", … … 2763 3063 } while (0); 2764 3064 3065 if (RT_UNLIKELY(fLockWrite)) 3066 { 3067 rc2 = vdThreadFinishWrite(pDisk); 3068 AssertRC(rc2); 3069 } 3070 2765 3071 LogFlowFunc(("returns %Rrc\n", rc)); 2766 3072 return rc; … … 2777 3083 { 2778 3084 int rc = VINF_SUCCESS; 3085 int rc2; 3086 bool fLockWrite = false; 2779 3087 2780 3088 LogFlowFunc(("pDisk=%#p\n", pDisk)); … … 2785 3093 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 2786 3094 3095 rc2 = vdThreadStartWrite(pDisk); 3096 AssertRC(rc2); 3097 fLockWrite = true; 3098 2787 3099 PVDIMAGE pImage = pDisk->pLast; 2788 3100 AssertPtrBreakStmt(pImage, rc = VERR_VD_NOT_OPENED); … … 2792 3104 } while (0); 2793 3105 3106 if (RT_UNLIKELY(fLockWrite)) 3107 { 3108 rc2 = vdThreadFinishWrite(pDisk); 3109 AssertRC(rc2); 3110 } 3111 2794 3112 LogFlowFunc(("returns %Rrc\n", rc)); 2795 3113 return rc; … … 2805 3123 { 2806 3124 unsigned cImages; 3125 int rc2; 3126 bool fLockRead = false; 2807 3127 2808 3128 LogFlowFunc(("pDisk=%#p\n", pDisk)); … … 2813 3133 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 2814 3134 3135 rc2 = vdThreadStartRead(pDisk); 3136 AssertRC(rc2); 3137 fLockRead = true; 3138 2815 3139 cImages = pDisk->cImages; 2816 3140 } while (0); 3141 3142 if (RT_UNLIKELY(fLockRead)) 3143 { 3144 rc2 = vdThreadFinishRead(pDisk); 3145 AssertRC(rc2); 3146 } 2817 3147 2818 3148 LogFlowFunc(("returns %u\n", cImages)); … … 2830 3160 { 2831 3161 bool fReadOnly; 3162 int rc2; 3163 bool fLockRead = false; 2832 3164 2833 3165 LogFlowFunc(("pDisk=%#p\n", pDisk)); … … 2837 3169 AssertPtrBreakStmt(pDisk, fReadOnly = false); 2838 3170 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 3171 3172 rc2 = vdThreadStartRead(pDisk); 3173 AssertRC(rc2); 3174 fLockRead = true; 2839 3175 2840 3176 PVDIMAGE pImage = pDisk->pLast; … … 2846 3182 } while (0); 2847 3183 3184 if (RT_UNLIKELY(fLockRead)) 3185 { 3186 rc2 = vdThreadFinishRead(pDisk); 3187 AssertRC(rc2); 3188 } 3189 2848 3190 LogFlowFunc(("returns %d\n", fReadOnly)); 2849 3191 return fReadOnly; … … 2861 3203 { 2862 3204 uint64_t cbSize; 3205 int rc2; 3206 bool fLockRead = false; 2863 3207 2864 3208 LogFlowFunc(("pDisk=%#p nImage=%u\n", pDisk, nImage)); … … 2868 3212 AssertPtrBreakStmt(pDisk, cbSize = 0); 2869 3213 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 3214 3215 rc2 = vdThreadStartRead(pDisk); 3216 AssertRC(rc2); 3217 fLockRead = true; 2870 3218 2871 3219 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 2874 3222 } while (0); 2875 3223 3224 if (RT_UNLIKELY(fLockRead)) 3225 { 3226 rc2 = vdThreadFinishRead(pDisk); 3227 AssertRC(rc2); 3228 } 3229 2876 3230 LogFlowFunc(("returns %llu\n", cbSize)); 2877 3231 return cbSize; … … 2889 3243 { 2890 3244 uint64_t cbSize; 3245 int rc2; 3246 bool fLockRead = false; 2891 3247 2892 3248 LogFlowFunc(("pDisk=%#p nImage=%u\n", pDisk, nImage)); … … 2896 3252 AssertPtrBreakStmt(pDisk, cbSize = 0); 2897 3253 AssertMsg(pDisk->u32Signature == VBOXHDDDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature)); 3254 3255 rc2 = vdThreadStartRead(pDisk); 3256 AssertRC(rc2); 3257 fLockRead = true; 2898 3258 2899 3259 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 2901 3261 cbSize = pImage->Backend->pfnGetFileSize(pImage->pvBackendData); 2902 3262 } while (0); 3263 3264 if (RT_UNLIKELY(fLockRead)) 3265 { 3266 rc2 = vdThreadFinishRead(pDisk); 3267 AssertRC(rc2); 3268 } 2903 3269 2904 3270 LogFlowFunc(("returns %llu\n", cbSize)); … … 2920 3286 { 2921 3287 int rc = VINF_SUCCESS; 3288 int rc2; 3289 bool fLockRead = false; 2922 3290 2923 3291 LogFlowFunc(("pDisk=%#p nImage=%u pPCHSGeometry=%#p\n", … … 2933 3301 ("pPCHSGeometry=%#p\n", pPCHSGeometry), 2934 3302 rc = VERR_INVALID_PARAMETER); 3303 3304 rc2 = vdThreadStartRead(pDisk); 3305 AssertRC(rc2); 3306 fLockRead = true; 2935 3307 2936 3308 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 2949 3321 pPCHSGeometry); 2950 3322 } while (0); 3323 3324 if (RT_UNLIKELY(fLockRead)) 3325 { 3326 rc2 = vdThreadFinishRead(pDisk); 3327 AssertRC(rc2); 3328 } 2951 3329 2952 3330 LogFlowFunc(("%s: %Rrc (PCHS=%u/%u/%u)\n", __FUNCTION__, rc, … … 2972 3350 { 2973 3351 int rc = VINF_SUCCESS; 3352 int rc2; 3353 bool fLockWrite = false; 2974 3354 2975 3355 LogFlowFunc(("pDisk=%#p nImage=%u pPCHSGeometry=%#p PCHS=%u/%u/%u\n", … … 2990 3370 pPCHSGeometry->cSectors), 2991 3371 rc = VERR_INVALID_PARAMETER); 3372 3373 rc2 = vdThreadStartWrite(pDisk); 3374 AssertRC(rc2); 3375 fLockWrite = true; 2992 3376 2993 3377 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 3046 3430 } while (0); 3047 3431 3432 if (RT_UNLIKELY(fLockWrite)) 3433 { 3434 rc2 = vdThreadFinishWrite(pDisk); 3435 AssertRC(rc2); 3436 } 3437 3048 3438 LogFlowFunc(("returns %Rrc\n", rc)); 3049 3439 return rc; … … 3064 3454 { 3065 3455 int rc = VINF_SUCCESS; 3456 int rc2; 3457 bool fLockRead = false; 3066 3458 3067 3459 LogFlowFunc(("pDisk=%#p nImage=%u pLCHSGeometry=%#p\n", … … 3077 3469 ("pLCHSGeometry=%#p\n", pLCHSGeometry), 3078 3470 rc = VERR_INVALID_PARAMETER); 3471 3472 rc2 = vdThreadStartRead(pDisk); 3473 AssertRC(rc2); 3474 fLockRead = true; 3079 3475 3080 3476 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 3093 3489 pLCHSGeometry); 3094 3490 } while (0); 3491 3492 if (RT_UNLIKELY(fLockRead)) 3493 { 3494 rc2 = vdThreadFinishRead(pDisk); 3495 AssertRC(rc2); 3496 } 3095 3497 3096 3498 LogFlowFunc((": %Rrc (LCHS=%u/%u/%u)\n", rc, … … 3116 3518 { 3117 3519 int rc = VINF_SUCCESS; 3520 int rc2; 3521 bool fLockWrite = false; 3118 3522 3119 3523 LogFlowFunc(("pDisk=%#p nImage=%u pLCHSGeometry=%#p LCHS=%u/%u/%u\n", … … 3134 3538 pLCHSGeometry->cSectors), 3135 3539 rc = VERR_INVALID_PARAMETER); 3540 3541 rc2 = vdThreadStartWrite(pDisk); 3542 AssertRC(rc2); 3543 fLockWrite = true; 3136 3544 3137 3545 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 3190 3598 } while (0); 3191 3599 3600 if (RT_UNLIKELY(fLockWrite)) 3601 { 3602 rc2 = vdThreadFinishWrite(pDisk); 3603 AssertRC(rc2); 3604 } 3605 3192 3606 LogFlowFunc(("returns %Rrc\n", rc)); 3193 3607 return rc; … … 3207 3621 { 3208 3622 int rc = VINF_SUCCESS; 3623 int rc2; 3624 bool fLockRead = false; 3209 3625 3210 3626 LogFlowFunc(("pDisk=%#p nImage=%u puVersion=%#p\n", … … 3221 3637 rc = VERR_INVALID_PARAMETER); 3222 3638 3639 rc2 = vdThreadStartRead(pDisk); 3640 AssertRC(rc2); 3641 fLockRead = true; 3642 3223 3643 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3224 3644 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3226 3646 *puVersion = pImage->Backend->pfnGetVersion(pImage->pvBackendData); 3227 3647 } while (0); 3648 3649 if (RT_UNLIKELY(fLockRead)) 3650 { 3651 rc2 = vdThreadFinishRead(pDisk); 3652 AssertRC(rc2); 3653 } 3228 3654 3229 3655 LogFlowFunc(("returns %Rrc uVersion=%#x\n", rc, *puVersion)); … … 3244 3670 { 3245 3671 int rc = VINF_SUCCESS; 3672 int rc2; 3673 bool fLockRead = false; 3246 3674 3247 3675 LogFlowFunc(("pDisk=%#p nImage=%u pBackendInfo=%#p\n", … … 3258 3686 rc = VERR_INVALID_PARAMETER); 3259 3687 3688 rc2 = vdThreadStartRead(pDisk); 3689 AssertRC(rc2); 3690 fLockRead = true; 3691 3260 3692 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3261 3693 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); 3262 3694 3263 pBackendInfo->pszBackend = RTStrDup(pImage->Backend->pszBackendName);3695 pBackendInfo->pszBackend = pImage->Backend->pszBackendName; 3264 3696 pBackendInfo->uBackendCaps = pImage->Backend->uBackendCaps; 3265 3697 pBackendInfo->papszFileExtensions = pImage->Backend->papszFileExtensions; 3266 3698 pBackendInfo->paConfigInfo = pImage->Backend->paConfigInfo; 3267 3699 } while (0); 3700 3701 if (RT_UNLIKELY(fLockRead)) 3702 { 3703 rc2 = vdThreadFinishRead(pDisk); 3704 AssertRC(rc2); 3705 } 3268 3706 3269 3707 LogFlowFunc(("returns %Rrc\n", rc)); … … 3284 3722 { 3285 3723 int rc = VINF_SUCCESS; 3724 int rc2; 3725 bool fLockRead = false; 3286 3726 3287 3727 LogFlowFunc(("pDisk=%#p nImage=%u puImageFlags=%#p\n", … … 3298 3738 rc = VERR_INVALID_PARAMETER); 3299 3739 3740 rc2 = vdThreadStartRead(pDisk); 3741 AssertRC(rc2); 3742 fLockRead = true; 3743 3300 3744 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3301 3745 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3303 3747 *puImageFlags = pImage->Backend->pfnGetImageFlags(pImage->pvBackendData); 3304 3748 } while (0); 3749 3750 if (RT_UNLIKELY(fLockRead)) 3751 { 3752 rc2 = vdThreadFinishRead(pDisk); 3753 AssertRC(rc2); 3754 } 3305 3755 3306 3756 LogFlowFunc(("returns %Rrc uImageFlags=%#x\n", rc, *puImageFlags)); … … 3321 3771 { 3322 3772 int rc = VINF_SUCCESS; 3773 int rc2; 3774 bool fLockRead = false; 3323 3775 3324 3776 LogFlowFunc(("pDisk=%#p nImage=%u puOpenFlags=%#p\n", … … 3335 3787 rc = VERR_INVALID_PARAMETER); 3336 3788 3789 rc2 = vdThreadStartRead(pDisk); 3790 AssertRC(rc2); 3791 fLockRead = true; 3792 3337 3793 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3338 3794 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3340 3796 *puOpenFlags = pImage->Backend->pfnGetOpenFlags(pImage->pvBackendData); 3341 3797 } while (0); 3798 3799 if (RT_UNLIKELY(fLockRead)) 3800 { 3801 rc2 = vdThreadFinishRead(pDisk); 3802 AssertRC(rc2); 3803 } 3342 3804 3343 3805 LogFlowFunc(("returns %Rrc uOpenFlags=%#x\n", rc, *puOpenFlags)); … … 3360 3822 { 3361 3823 int rc; 3824 int rc2; 3825 bool fLockWrite = false; 3362 3826 3363 3827 LogFlowFunc(("pDisk=%#p uOpenFlags=%#u\n", pDisk, uOpenFlags)); … … 3373 3837 rc = VERR_INVALID_PARAMETER); 3374 3838 3839 rc2 = vdThreadStartWrite(pDisk); 3840 AssertRC(rc2); 3841 fLockWrite = true; 3842 3375 3843 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3376 3844 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3379 3847 uOpenFlags); 3380 3848 } while (0); 3849 3850 if (RT_UNLIKELY(fLockWrite)) 3851 { 3852 rc2 = vdThreadFinishWrite(pDisk); 3853 AssertRC(rc2); 3854 } 3381 3855 3382 3856 LogFlowFunc(("returns %Rrc\n", rc)); … … 3401 3875 { 3402 3876 int rc; 3877 int rc2; 3878 bool fLockRead = false; 3403 3879 3404 3880 LogFlowFunc(("pDisk=%#p nImage=%u pszFilename=%#p cbFilename=%u\n", … … 3418 3894 rc = VERR_INVALID_PARAMETER); 3419 3895 3896 rc2 = vdThreadStartRead(pDisk); 3897 AssertRC(rc2); 3898 fLockRead = true; 3899 3420 3900 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3421 3901 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3434 3914 } 3435 3915 } while (0); 3916 3917 if (RT_UNLIKELY(fLockRead)) 3918 { 3919 rc2 = vdThreadFinishRead(pDisk); 3920 AssertRC(rc2); 3921 } 3436 3922 3437 3923 LogFlowFunc(("returns %Rrc, pszFilename=\"%s\"\n", rc, pszFilename)); … … 3454 3940 { 3455 3941 int rc; 3942 int rc2; 3943 bool fLockRead = false; 3456 3944 3457 3945 LogFlowFunc(("pDisk=%#p nImage=%u pszComment=%#p cbComment=%u\n", … … 3471 3959 rc = VERR_INVALID_PARAMETER); 3472 3960 3961 rc2 = vdThreadStartRead(pDisk); 3962 AssertRC(rc2); 3963 fLockRead = true; 3964 3473 3965 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3474 3966 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3477 3969 cbComment); 3478 3970 } while (0); 3971 3972 if (RT_UNLIKELY(fLockRead)) 3973 { 3974 rc2 = vdThreadFinishRead(pDisk); 3975 AssertRC(rc2); 3976 } 3479 3977 3480 3978 LogFlowFunc(("returns %Rrc, pszComment=\"%s\"\n", rc, pszComment)); … … 3495 3993 { 3496 3994 int rc; 3995 int rc2; 3996 bool fLockWrite = false; 3497 3997 3498 3998 LogFlowFunc(("pDisk=%#p nImage=%u pszComment=%#p \"%s\"\n", … … 3509 4009 rc = VERR_INVALID_PARAMETER); 3510 4010 4011 rc2 = vdThreadStartWrite(pDisk); 4012 AssertRC(rc2); 4013 fLockWrite = true; 4014 3511 4015 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3512 4016 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3514 4018 rc = pImage->Backend->pfnSetComment(pImage->pvBackendData, pszComment); 3515 4019 } while (0); 4020 4021 if (RT_UNLIKELY(fLockWrite)) 4022 { 4023 rc2 = vdThreadFinishWrite(pDisk); 4024 AssertRC(rc2); 4025 } 3516 4026 3517 4027 LogFlowFunc(("returns %Rrc\n", rc)); … … 3532 4042 { 3533 4043 int rc; 4044 int rc2; 4045 bool fLockRead = false; 3534 4046 3535 4047 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid)); … … 3545 4057 rc = VERR_INVALID_PARAMETER); 3546 4058 4059 rc2 = vdThreadStartRead(pDisk); 4060 AssertRC(rc2); 4061 fLockRead = true; 4062 3547 4063 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3548 4064 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3550 4066 rc = pImage->Backend->pfnGetUuid(pImage->pvBackendData, pUuid); 3551 4067 } while (0); 4068 4069 if (RT_UNLIKELY(fLockRead)) 4070 { 4071 rc2 = vdThreadFinishRead(pDisk); 4072 AssertRC(rc2); 4073 } 3552 4074 3553 4075 LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid)); … … 3567 4089 { 3568 4090 int rc; 4091 int rc2; 4092 bool fLockWrite = false; 3569 4093 3570 4094 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n", … … 3580 4104 rc = VERR_INVALID_PARAMETER); 3581 4105 4106 rc2 = vdThreadStartWrite(pDisk); 4107 AssertRC(rc2); 4108 fLockWrite = true; 4109 3582 4110 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3583 4111 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3591 4119 rc = pImage->Backend->pfnSetUuid(pImage->pvBackendData, pUuid); 3592 4120 } while (0); 4121 4122 if (RT_UNLIKELY(fLockWrite)) 4123 { 4124 rc2 = vdThreadFinishWrite(pDisk); 4125 AssertRC(rc2); 4126 } 3593 4127 3594 4128 LogFlowFunc(("returns %Rrc\n", rc)); … … 3608 4142 { 3609 4143 int rc = VINF_SUCCESS; 4144 int rc2; 4145 bool fLockRead = false; 3610 4146 3611 4147 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid)); … … 3621 4157 rc = VERR_INVALID_PARAMETER); 3622 4158 4159 rc2 = vdThreadStartRead(pDisk); 4160 AssertRC(rc2); 4161 fLockRead = true; 4162 3623 4163 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3624 4164 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3627 4167 pUuid); 3628 4168 } while (0); 4169 4170 if (RT_UNLIKELY(fLockRead)) 4171 { 4172 rc2 = vdThreadFinishRead(pDisk); 4173 AssertRC(rc2); 4174 } 3629 4175 3630 4176 LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid)); … … 3644 4190 { 3645 4191 int rc; 4192 int rc2; 4193 bool fLockWrite = false; 3646 4194 3647 4195 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n", … … 3658 4206 rc = VERR_INVALID_PARAMETER); 3659 4207 4208 rc2 = vdThreadStartWrite(pDisk); 4209 AssertRC(rc2); 4210 fLockWrite = true; 4211 3660 4212 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3661 4213 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3670 4222 pUuid); 3671 4223 } while (0); 4224 4225 if (RT_UNLIKELY(fLockWrite)) 4226 { 4227 rc2 = vdThreadFinishWrite(pDisk); 4228 AssertRC(rc2); 4229 } 3672 4230 3673 4231 LogFlowFunc(("returns %Rrc\n", rc)); … … 3688 4246 { 3689 4247 int rc = VINF_SUCCESS; 4248 int rc2; 4249 bool fLockRead = false; 3690 4250 3691 4251 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid)); … … 3701 4261 rc = VERR_INVALID_PARAMETER); 3702 4262 4263 rc2 = vdThreadStartRead(pDisk); 4264 AssertRC(rc2); 4265 fLockRead = true; 4266 3703 4267 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3704 4268 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3706 4270 rc = pImage->Backend->pfnGetParentUuid(pImage->pvBackendData, pUuid); 3707 4271 } while (0); 4272 4273 if (RT_UNLIKELY(fLockRead)) 4274 { 4275 rc2 = vdThreadFinishRead(pDisk); 4276 AssertRC(rc2); 4277 } 3708 4278 3709 4279 LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid)); … … 3723 4293 { 3724 4294 int rc; 4295 int rc2; 4296 bool fLockWrite = false; 3725 4297 3726 4298 LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n", … … 3737 4309 rc = VERR_INVALID_PARAMETER); 3738 4310 4311 rc2 = vdThreadStartWrite(pDisk); 4312 AssertRC(rc2); 4313 fLockWrite = true; 4314 3739 4315 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); 3740 4316 AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND); … … 3749 4325 } while (0); 3750 4326 4327 if (RT_UNLIKELY(fLockWrite)) 4328 { 4329 rc2 = vdThreadFinishWrite(pDisk); 4330 AssertRC(rc2); 4331 } 4332 3751 4333 LogFlowFunc(("returns %Rrc\n", rc)); 3752 4334 return rc; … … 3761 4343 VBOXDDU_DECL(void) VDDumpImages(PVBOXHDD pDisk) 3762 4344 { 4345 int rc2; 4346 bool fLockRead = false; 4347 3763 4348 do 3764 4349 { … … 3778 4363 } 3779 4364 4365 rc2 = vdThreadStartRead(pDisk); 4366 AssertRC(rc2); 4367 fLockRead = true; 4368 3780 4369 pfnMessage(pvUser, "--- Dumping VD Disk, Images=%u\n", pDisk->cImages); 3781 4370 for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext) … … 3786 4375 } 3787 4376 } while (0); 4377 4378 if (RT_UNLIKELY(fLockRead)) 4379 { 4380 rc2 = vdThreadFinishRead(pDisk); 4381 AssertRC(rc2); 4382 } 3788 4383 } 3789 4384 … … 3800 4395 { 3801 4396 int rc = VINF_SUCCESS; 4397 int rc2; 4398 bool fLockRead = false; 3802 4399 3803 4400 LogFlowFunc(("pDisk=%#p nImage=%u pfAIOSupported=%#p\n", pDisk, nImage, pfAIOSupported)); … … 3812 4409 ("pfAIOSupported=%#p\n", pfAIOSupported), 3813 4410 rc = VERR_INVALID_PARAMETER); 4411 4412 rc2 = vdThreadStartRead(pDisk); 4413 AssertRC(rc2); 4414 fLockRead = true; 3814 4415 3815 4416 PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage); … … 3821 4422 *pfAIOSupported = false; 3822 4423 } while (0); 4424 4425 if (RT_UNLIKELY(fLockRead)) 4426 { 4427 rc2 = vdThreadFinishRead(pDisk); 4428 AssertRC(rc2); 4429 } 3823 4430 3824 4431 LogFlowFunc(("returns %Rrc, fAIOSupported=%u\n", rc, *pfAIOSupported)); … … 3842 4449 { 3843 4450 int rc = VERR_VD_BLOCK_FREE; 4451 int rc2; 4452 bool fLockWrite = false; 3844 4453 3845 4454 LogFlowFunc(("pDisk=%#p uOffset=%llu paSeg=%p cSeg=%u cbRead=%zu\n", … … 3855 4464 ("cbRead=%zu\n", cbRead), 3856 4465 rc = VERR_INVALID_PARAMETER); 4466 AssertMsgBreakStmt(VALID_PTR(paSeg), 4467 ("paSeg=%#p\n", paSeg), 4468 rc = VERR_INVALID_PARAMETER); 4469 AssertMsgBreakStmt(cSeg, 4470 ("cSeg=%zu\n", cSeg), 4471 rc = VERR_INVALID_PARAMETER); 4472 4473 /** @todo handle this just like a write, as in the completion code in 4474 * DrvVD.cpp there is no way to figure out if it is a read or write. */ 4475 rc2 = vdThreadStartWrite(pDisk); 4476 AssertRC(rc2); 4477 fLockWrite = true; 4478 3857 4479 AssertMsgBreakStmt(uOffset + cbRead <= pDisk->cbSize, 3858 4480 ("uOffset=%llu cbRead=%zu pDisk->cbSize=%llu\n", 3859 4481 uOffset, cbRead, pDisk->cbSize), 3860 4482 rc = VERR_INVALID_PARAMETER); 3861 AssertMsgBreakStmt(VALID_PTR(paSeg),3862 ("paSeg=%#p\n", paSeg),3863 rc = VERR_INVALID_PARAMETER);3864 AssertMsgBreakStmt(cSeg,3865 ("cSeg=%zu\n", cSeg),3866 rc = VERR_INVALID_PARAMETER);3867 3868 4483 3869 4484 PVDIMAGE pImage = pDisk->pLast; … … 3890 4505 /* Request finished without the need to enqueue a async I/O request. Tell caller. */ 3891 4506 rc = VINF_VD_ASYNC_IO_FINISHED; 4507 4508 rc2 = vdThreadFinishWrite(pDisk); 4509 AssertRC(rc2); 4510 fLockWrite = false; 3892 4511 } 3893 4512 3894 4513 } while (0); 4514 4515 if (RT_UNLIKELY(fLockWrite) && RT_FAILURE(rc)) 4516 { 4517 rc2 = vdThreadFinishWrite(pDisk); 4518 AssertRC(rc2); 4519 } 3895 4520 3896 4521 LogFlowFunc(("returns %Rrc\n", rc)); … … 3915 4540 { 3916 4541 int rc; 4542 int rc2; 4543 bool fLockWrite = false; 3917 4544 3918 4545 LogFlowFunc(("pDisk=%#p uOffset=%llu paSeg=%p cSeg=%u cbWrite=%zu\n", … … 3928 4555 ("cbWrite=%zu\n", cbWrite), 3929 4556 rc = VERR_INVALID_PARAMETER); 4557 AssertMsgBreakStmt(VALID_PTR(paSeg), 4558 ("paSeg=%#p\n", paSeg), 4559 rc = VERR_INVALID_PARAMETER); 4560 AssertMsgBreakStmt(cSeg, 4561 ("cSeg=%zu\n", cSeg), 4562 rc = VERR_INVALID_PARAMETER); 4563 4564 rc2 = vdThreadStartWrite(pDisk); 4565 AssertRC(rc2); 4566 fLockWrite = true; 4567 3930 4568 AssertMsgBreakStmt(uOffset + cbWrite <= pDisk->cbSize, 3931 4569 ("uOffset=%llu cbWrite=%zu pDisk->cbSize=%llu\n", 3932 4570 uOffset, cbWrite, pDisk->cbSize), 3933 4571 rc = VERR_INVALID_PARAMETER); 3934 AssertMsgBreakStmt(VALID_PTR(paSeg),3935 ("paSeg=%#p\n", paSeg),3936 rc = VERR_INVALID_PARAMETER);3937 AssertMsgBreakStmt(cSeg,3938 ("cSeg=%zu\n", cSeg),3939 rc = VERR_INVALID_PARAMETER);3940 3941 4572 3942 4573 PVDIMAGE pImage = pDisk->pLast; … … 3949 4580 } while (0); 3950 4581 4582 if (RT_UNLIKELY(fLockWrite) && RT_FAILURE(rc)) 4583 { 4584 rc2 = vdThreadFinishWrite(pDisk); 4585 AssertRC(rc2); 4586 } 3951 4587 LogFlowFunc(("returns %Rrc\n", rc)); 3952 4588 return rc; -
trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp
r27100 r27232 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Sun Microsystems, Inc.6 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 108 108 pImage->pszFilename, 109 109 uOpenFlags, 110 NULL, &pImage->pvStorage); 110 NULL, 111 pImage->pVDIfsDisk, 112 &pImage->pvStorage); 111 113 #endif 112 114 … … 499 501 PCPDMMEDIAGEOMETRY pPCHSGeometry, 500 502 PCPDMMEDIAGEOMETRY pLCHSGeometry, PCRTUUID pUuid, 501 PFNV MPROGRESS pfnProgress, void *pvUser,503 PFNVDPROGRESS pfnProgress, void *pvUser, 502 504 unsigned uPercentStart, unsigned uPercentSpan) 503 505 { … … 676 678 if (pfnProgress) 677 679 { 678 rc = pfnProgress(NULL /* WARNING! pVM=NULL */, 679 uPercentStart + uOff * uPercentSpan / cbFill, 680 pvUser); 680 rc = pfnProgress(pvUser, 681 uPercentStart + uOff * uPercentSpan / cbFill); 681 682 if (RT_FAILURE(rc)) 682 683 goto out; … … 688 689 out: 689 690 if (RT_SUCCESS(rc) && pfnProgress) 690 pfnProgress(NULL /* WARNING! pVM=NULL */, 691 uPercentStart + uPercentSpan, pvUser); 691 pfnProgress(pvUser, uPercentStart + uPercentSpan); 692 692 693 693 if (RT_FAILURE(rc)) … … 1012 1012 PVDIIMAGEDESC pImage; 1013 1013 1014 PFNV MPROGRESS pfnProgress = NULL;1014 PFNVDPROGRESS pfnProgress = NULL; 1015 1015 void *pvUser = NULL; 1016 1016 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, … … 2006 2006 /** @copydoc VBOXHDDBACKEND::pfnCompact */ 2007 2007 static int vdiCompact(void *pBackendData, unsigned uPercentStart, 2008 unsigned uPercentSpan, PVDINTERFACE pVDIfsOperation) 2008 unsigned uPercentSpan, PVDINTERFACE pVDIfsDisk, 2009 PVDINTERFACE pVDIfsImage, PVDINTERFACE pVDIfsOperation) 2009 2010 { 2010 2011 PVDIIMAGEDESC pImage = (PVDIIMAGEDESC)pBackendData; … … 2026 2027 } 2027 2028 2028 PFNV MPROGRESS pfnProgress = NULL;2029 PFNVDPROGRESS pfnProgress = NULL; 2029 2030 void *pvUser = NULL; 2030 2031 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, … … 2156 2157 if (pCbProgress && pCbProgress->pfnProgress) 2157 2158 { 2158 rc = pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2159 (uint64_t)i * uPercentSpan / (cBlocks + cBlocksToMove) + uPercentStart, 2160 pIfProgress->pvUser); 2159 rc = pCbProgress->pfnProgress(pIfProgress->pvUser, 2160 (uint64_t)i * uPercentSpan / (cBlocks + cBlocksToMove) + uPercentStart); 2161 2161 if (RT_FAILURE(rc)) 2162 2162 break; … … 2201 2201 if (pCbProgress && pCbProgress->pfnProgress) 2202 2202 { 2203 rc = pCbProgress->pfnProgress( NULL /* WARNING! pVM=NULL */,2204 (uint64_t)(cBlocks + cBlocksMoved) * uPercentSpan / (cBlocks + cBlocksToMove) + uPercentStart ,2205 pIfProgress->pvUser);2203 rc = pCbProgress->pfnProgress(pIfProgress->pvUser, 2204 (uint64_t)(cBlocks + cBlocksMoved) * uPercentSpan / (cBlocks + cBlocksToMove) + uPercentStart); 2205 2206 2206 if (RT_FAILURE(rc)) 2207 2207 break; … … 2230 2230 if (RT_SUCCESS(rc) && pCbProgress && pCbProgress->pfnProgress) 2231 2231 { 2232 pCbProgress->pfnProgress(NULL /* WARNING! pVM=NULL */, 2233 uPercentStart + uPercentSpan, 2234 pIfProgress->pvUser); 2232 pCbProgress->pfnProgress(pIfProgress->pvUser, 2233 uPercentStart + uPercentSpan); 2235 2234 } 2236 2235 -
trunk/src/VBox/Devices/Storage/VHDHDDCore.cpp
r26995 r27232 4 4 5 5 /* 6 * Copyright (C) 2006-20 08Sun Microsystems, Inc.6 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 245 245 pImage->pszFilename, 246 246 uOpenFlags, 247 NULL, &pImage->pvStorage); 247 NULL, 248 pImage->pVDIfsDisk, 249 &pImage->pvStorage); 248 250 #endif 249 251 … … 1807 1809 PCPDMMEDIAGEOMETRY pLCHSGeometry, PCRTUUID pUuid, 1808 1810 unsigned uOpenFlags, 1809 PFNV MPROGRESS pfnProgress, void *pvUser,1811 PFNVDPROGRESS pfnProgress, void *pvUser, 1810 1812 unsigned uPercentStart, unsigned uPercentSpan) 1811 1813 { … … 1893 1895 /* We are half way thourgh with creation of image, let the caller know. */ 1894 1896 if (pfnProgress) 1895 pfnProgress( NULL /* WARNING! pVM=NULL */, (uPercentStart + uPercentSpan) / 2, pvUser);1897 pfnProgress(pvUser, (uPercentStart + uPercentSpan) / 2); 1896 1898 1897 1899 rc = vhdCreateDynamicImage(pImage, cbSize); … … 1929 1931 1930 1932 if (pfnProgress) 1931 pfnProgress( NULL /* WARNING! pVM=NULL */, uPercentStart + uPercentSpan, pvUser);1933 pfnProgress(pvUser, uPercentStart + uPercentSpan); 1932 1934 1933 1935 out: … … 1947 1949 PVHDIMAGE pImage; 1948 1950 1949 PFNV MPROGRESS pfnProgress = NULL;1951 PFNVDPROGRESS pfnProgress = NULL; 1950 1952 void *pvUser = NULL; 1951 1953 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, -
trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp
r26986 r27232 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Sun Microsystems, Inc.7 * Copyright (C) 2006-2010 Sun Microsystems, Inc. 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 587 587 : 0, 588 588 NULL, 589 pImage->pVDIfsDisk, 589 590 &pVmdkFile->pStorage); 590 591 pVmdkFile->fAsyncIO = true; … … 3487 3488 static int vmdkCreateRegularImage(PVMDKIMAGE pImage, uint64_t cbSize, 3488 3489 unsigned uImageFlags, 3489 PFNV MPROGRESS pfnProgress, void *pvUser,3490 PFNVDPROGRESS pfnProgress, void *pvUser, 3490 3491 unsigned uPercentStart, unsigned uPercentSpan) 3491 3492 { … … 3626 3627 if (pfnProgress) 3627 3628 { 3628 rc = pfnProgress(NULL /* WARNING! pVM=NULL */, 3629 uPercentStart + uOff * uPercentSpan / cbExtent, 3630 pvUser); 3629 rc = pfnProgress(pvUser, 3630 uPercentStart + uOff * uPercentSpan / cbExtent); 3631 3631 if (RT_FAILURE(rc)) 3632 3632 { … … 3695 3695 3696 3696 if (RT_SUCCESS(rc) && pfnProgress) 3697 pfnProgress(NULL /* WARNING! pVM=NULL */, 3698 uPercentStart + i * uPercentSpan / cExtents, 3699 pvUser); 3697 pfnProgress(pvUser, uPercentStart + i * uPercentSpan / cExtents); 3700 3698 3701 3699 cbRemaining -= cbExtent; … … 3746 3744 PCPDMMEDIAGEOMETRY pPCHSGeometry, 3747 3745 PCPDMMEDIAGEOMETRY pLCHSGeometry, PCRTUUID pUuid, 3748 PFNV MPROGRESS pfnProgress, void *pvUser,3746 PFNVDPROGRESS pfnProgress, void *pvUser, 3749 3747 unsigned uPercentStart, unsigned uPercentSpan) 3750 3748 { … … 3793 3791 3794 3792 if (RT_SUCCESS(rc) && pfnProgress) 3795 pfnProgress(NULL /* WARNING! pVM=NULL */, 3796 uPercentStart + uPercentSpan * 98 / 100, pvUser); 3793 pfnProgress(pvUser, uPercentStart + uPercentSpan * 98 / 100); 3797 3794 3798 3795 pImage->cbSize = cbSize; … … 3880 3877 3881 3878 if (RT_SUCCESS(rc) && pfnProgress) 3882 pfnProgress(NULL /* WARNING! pVM=NULL */, 3883 uPercentStart + uPercentSpan * 99 / 100, pvUser); 3879 pfnProgress(pvUser, uPercentStart + uPercentSpan * 99 / 100); 3884 3880 3885 3881 rc = vmdkFlushImage(pImage); … … 3887 3883 out: 3888 3884 if (RT_SUCCESS(rc) && pfnProgress) 3889 pfnProgress(NULL /* WARNING! pVM=NULL */, 3890 uPercentStart + uPercentSpan, pvUser); 3885 pfnProgress(pvUser, uPercentStart + uPercentSpan); 3891 3886 3892 3887 if (RT_FAILURE(rc)) … … 4515 4510 PVMDKIMAGE pImage; 4516 4511 4517 PFNV MPROGRESS pfnProgress = NULL;4512 PFNVDPROGRESS pfnProgress = NULL; 4518 4513 void *pvUser = NULL; 4519 4514 PVDINTERFACE pIfProgress = VDInterfaceGet(pVDIfsOperation, -
trunk/src/VBox/Main/MediumImpl.cpp
r27200 r27232 4785 4785 4786 4786 /** 4787 * PFNVMPROGRESS callback handler for Task operations. 4788 * 4787 * PFNVDPROGRESS callback handler for Task operations. 4788 * 4789 * @param pvUser Pointer to the Progress instance. 4789 4790 * @param uPercent Completetion precentage (0-100). 4790 * @param pvUser Pointer to the Progress instance.4791 4791 */ 4792 4792 /*static*/ 4793 DECLCALLBACK(int) Medium::vdProgressCall(PVM /* pVM */, unsigned uPercent, 4794 void *pvUser) 4793 DECLCALLBACK(int) Medium::vdProgressCall(void *pvUser, unsigned uPercent) 4795 4794 { 4796 4795 Progress *that = static_cast<Progress *>(pvUser); -
trunk/src/VBox/Main/include/MediumImpl.h
r26984 r27232 27 27 28 28 class Progress; 29 struct VM;30 29 31 30 namespace settings … … 295 294 const char *pszFormat, va_list va); 296 295 297 static DECLCALLBACK(int) vdProgressCall(VM* /* pVM */, unsigned uPercent, 298 void *pvUser); 296 static DECLCALLBACK(int) vdProgressCall(void *pvUser, unsigned uPercent); 299 297 300 298 static DECLCALLBACK(bool) vdConfigAreKeysValid(void *pvUser,
Note:
See TracChangeset
for help on using the changeset viewer.