Changeset 15529 in vbox
- Timestamp:
- Dec 15, 2008 6:23:42 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxHDD-new.h
r15366 r15529 1257 1257 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). 1258 1258 * @param cbSize New image size (0 means leave unchanged). 1259 * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created. 1260 * This parameter is used if and only if a true copy is created. 1261 * In all rename/move cases the UUIDs are copied over. 1259 1262 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1260 1263 * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the … … 1265 1268 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 1266 1269 const char *pszBackend, const char *pszFilename, 1267 bool fMoveByRename, uint64_t cbSize, 1270 bool fMoveByRename, uint64_t cbSize, PRTUUID pDstUuid, 1268 1271 PVDINTERFACE pVDIfsOperation, 1269 1272 PVDINTERFACE pDstVDIfsImage, -
trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp
r15366 r15529 1865 1865 * @param fMoveByRename If true, attempt to perform a move by renaming (if successful the new size is ignored). 1866 1866 * @param cbSize New image size (0 means leave unchanged). 1867 * @param pDstUuid New UUID of the destination image. If NULL, a new UUID is created. 1868 * This parameter is used if and only if a true copy is created. 1869 * In all rename/move cases the UUIDs are copied over. 1867 1870 * @param pVDIfsOperation Pointer to the per-operation VD interface list. 1868 1871 * @param pDstVDIfsImage Pointer to the per-image VD interface list, for the … … 1873 1876 VBOXDDU_DECL(int) VDCopy(PVBOXHDD pDiskFrom, unsigned nImage, PVBOXHDD pDiskTo, 1874 1877 const char *pszBackend, const char *pszFilename, 1875 bool fMoveByRename, uint64_t cbSize, 1878 bool fMoveByRename, uint64_t cbSize, PRTUUID pDstUuid, 1876 1879 PVDINTERFACE pVDIfsOperation, 1877 1880 PVDINTERFACE pDstVDIfsImage, … … 1911 1914 ("u32Signature=%08x\n", pDiskTo->u32Signature)); 1912 1915 1913 /* If the containers are equal and the backend is the same, rename the image. */ 1914 if ( (pDiskFrom == pDiskTo) 1915 && (!RTStrICmp(pszBackend, pImageFrom->Backend->pszBackendName))) 1916 { 1917 /* Rename the image. */ 1918 rc = pImageFrom->Backend->pfnRename(pImageFrom->pvBackendData, pszFilename ? pszFilename : pImageFrom->pszFilename); 1919 break; 1920 } 1921 1922 /* If the fMoveByRename flag is set and the backend is the same, rename the image. */ 1923 if ( (fMoveByRename == true) 1924 && (!RTStrICmp(pszBackend, pImageFrom->Backend->pszBackendName))) 1925 { 1926 /* Close the source image. */ 1927 rc = pImageFrom->Backend->pfnClose(pImageFrom->pvBackendData, false); 1928 if (RT_FAILURE(rc)) 1916 /* Move the image. */ 1917 if (pDiskFrom == pDiskTo) 1918 { 1919 /* Rename only works when backends are the same. */ 1920 if ( fMoveByRename 1921 && !RTStrICmp(pszBackend, pImageFrom->Backend->pszBackendName)) 1922 { 1923 rc = pImageFrom->Backend->pfnRename(pImageFrom->pvBackendData, pszFilename ? pszFilename : pImageFrom->pszFilename); 1929 1924 break; 1930 1931 /* Open the source image in the destination container. */ 1932 /** @todo fix open flags - the flags in pImageFrom are not the right info, the info from the image format backend is relevant */ 1933 rc = VDOpen(pDiskTo, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags, pDstVDIfsImage); 1934 if (RT_FAILURE(rc)) 1935 goto movefail; 1936 1937 pImageTo = pDiskTo->pLast; 1938 1939 /* Rename the image. */ 1940 rc = pImageTo->Backend->pfnRename(pImageTo->pvBackendData, pszFilename ? pszFilename : pImageTo->pszFilename); 1941 if (RT_FAILURE(rc)) 1942 goto movefail; 1943 1944 /* Cleanup the leftovers. */ 1945 vdRemoveImageFromList(pDiskFrom, pImageFrom); 1946 pImageFrom->pvBackendData = NULL; 1947 1948 if (pImageFrom->pszFilename) 1949 RTStrFree(pImageFrom->pszFilename); 1950 1951 RTMemFree(pImageFrom); 1952 1953 break; 1954 movefail: 1955 /* In case of failure, re-open the source image in the source container. */ 1956 rc2 = VDOpen(pDiskFrom, pImageFrom->Backend->pszBackendName, pImageFrom->pszFilename, pImageFrom->uOpenFlags, pImageFrom->pVDIfsImage); 1957 if (RT_FAILURE(rc2)) 1958 /** @todo Uncertain what to do on error. If this happens pImageFrom and pImageTo are both closed. */ 1959 rc = rc2; 1960 break; 1961 } 1962 1963 /* If fMoveByRename is set pszFilename is allowed to be NULL, so do the parameter check here. */ 1925 } 1926 1927 /** @todo Moving (including shrinking/growing) of the image is 1928 * requested, but the rename attempt failed or it wasn't possible. 1929 * Must now copy image to temp location. */ 1930 AssertReleaseMsgFailed(("VDCopy: moving by copy/delete not implemented\n")); 1931 } 1932 1933 /* When moving an image pszFilename is allowed to be NULL, so do the parameter check here. */ 1964 1934 AssertMsgBreakStmt(VALID_PTR(pszFilename) && *pszFilename, 1965 1935 ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename), … … 1983 1953 uImageFlagsFrom = pImageFrom->Backend->pfnGetImageFlags(pImageFrom->pvBackendData); 1984 1954 1985 /** @todo Get this from the source image. */1986 1955 PDMMEDIAGEOMETRY PCHSGeometryFrom = {0, 0, 0}; 1987 1956 PDMMEDIAGEOMETRY LCHSGeometryFrom = {0, 0, 0}; 1957 pImageFrom->Backend->pfnGetPCHSGeometry(pImageFrom->pvBackendData, &PCHSGeometryFrom); 1958 pImageFrom->Backend->pfnGetLCHSGeometry(pImageFrom->pvBackendData, &LCHSGeometryFrom); 1959 1960 RTUUID ImageUuid, ImageModificationUuid; 1961 RTUUID ParentUuid, ParentModificationUuid; 1962 if (pDiskFrom != pDiskTo) 1963 { 1964 if (pDstUuid) 1965 ImageUuid = *pDstUuid; 1966 else 1967 RTUuidCreate(&ImageUuid); 1968 } 1969 else 1970 { 1971 rc = pImageFrom->Backend->pfnGetUuid(pImageFrom->pvBackendData, &ImageUuid); 1972 if (RT_FAILURE(rc)) 1973 RTUuidClear(&ImageUuid); 1974 } 1975 rc = pImageFrom->Backend->pfnGetModificationUuid(pImageFrom->pvBackendData, &ImageModificationUuid); 1976 if (RT_FAILURE(rc)) 1977 RTUuidClear(&ImageModificationUuid); 1978 rc = pImageFrom->Backend->pfnGetParentUuid(pImageFrom->pvBackendData, &ParentUuid); 1979 if (RT_FAILURE(rc)) 1980 RTUuidClear(&ParentUuid); 1981 rc = pImageFrom->Backend->pfnGetParentModificationUuid(pImageFrom->pvBackendData, &ParentModificationUuid); 1982 if (RT_FAILURE(rc)) 1983 RTUuidClear(&ParentModificationUuid); 1984 1985 char szComment[1024]; 1986 rc = pImageFrom->Backend->pfnGetComment(pImageFrom->pvBackendData, szComment, sizeof(szComment)); 1987 if (RT_FAILURE(rc)) 1988 szComment[0] = '\0'; 1989 else 1990 szComment[sizeof(szComment) - 1] = '\0'; 1988 1991 1989 1992 unsigned uOpenFlagsFrom; … … 1991 1994 1992 1995 /* Create destination image with the properties of the source image. */ 1993 /** @todo Copy the comment. */1994 1996 /** @todo replace the VDCreateDiff/VDCreateBase calls by direct 1995 1997 * calls to the backend. Unifies the code and reduces the API … … 1998 2000 { 1999 2001 rc = VDCreateDiff(pDiskTo, pszBackend, pszFilename, uImageFlagsFrom, 2000 "", NULL, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL);2002 szComment, &ImageUuid, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL); 2001 2003 } else { 2002 2004 rc = VDCreateBase(pDiskTo, pszBackend, pszFilename, enmTypeFrom, 2003 cbSize, uImageFlagsFrom, "",2005 cbSize, uImageFlagsFrom, szComment, 2004 2006 &PCHSGeometryFrom, &LCHSGeometryFrom, 2005 2007 NULL, uOpenFlagsFrom & ~VD_OPEN_FLAGS_READONLY, NULL, NULL); 2008 if (!RTUuidIsNull(&ImageUuid)) 2009 pImageFrom->Backend->pfnSetUuid(pImageFrom->pvBackendData, &ImageUuid); 2006 2010 } 2007 2011 if (RT_FAILURE(rc)) … … 2058 2062 } while (uOffset < cbSize); 2059 2063 2060 /* If fMoveByRename is set but the backend is different, close and delete pImageFrom. */ 2061 if ( (fMoveByRename == true) 2062 && (RTStrICmp(pszBackend, pImageFrom->Backend->pszBackendName))) 2063 { 2064 vdRemoveImageFromList(pDiskFrom, pImageFrom); 2065 2066 /* Close and delete image. */ 2067 rc2 = pImageFrom->Backend->pfnClose(pImageFrom->pvBackendData, true); 2068 AssertRC(rc2); 2069 pImageFrom->pvBackendData = NULL; 2070 2071 /* Free remaining resources. */ 2072 if (pImageFrom->pszFilename) 2073 RTStrFree(pImageFrom->pszFilename); 2074 2075 RTMemFree(pImageFrom); 2064 if (RT_SUCCESS(rc)) 2065 { 2066 pImageFrom->Backend->pfnSetModificationUuid(pImageFrom->pvBackendData, &ImageModificationUuid); 2067 pImageFrom->Backend->pfnGetParentUuid(pImageFrom->pvBackendData, &ParentUuid); 2068 pImageFrom->Backend->pfnGetParentModificationUuid(pImageFrom->pvBackendData, &ParentModificationUuid); 2076 2069 } 2077 2070 } while (0); -
trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp
r14855 r15529 735 735 rc = VDOpen(pVD, "VMDK", src, VD_OPEN_FLAGS_NORMAL, NULL); 736 736 CHECK("VDOpen()"); 737 rc = VDCopy(pVD, 0, pVD, "VMDK", dst, true, 0, NULL, NULL, NULL );737 rc = VDCopy(pVD, 0, pVD, "VMDK", dst, true, 0, NULL, NULL, NULL, NULL); 738 738 CHECK("VDCopy()"); 739 739 -
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r15366 r15529 1315 1315 else 1316 1316 { 1317 vrc = VDCopy(pDisk, 0, pDisk, "VMDK", Utf8Str(dst).raw(), true, 0, NULL, NULL, NULL );1317 vrc = VDCopy(pDisk, 0, pDisk, "VMDK", Utf8Str(dst).raw(), true, 0, NULL, NULL, NULL, NULL); 1318 1318 if (RT_FAILURE(vrc)) 1319 1319 { -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r15516 r15529 469 469 /* Create the output image */ 470 470 vrc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, Utf8Str(dstformat).raw(), 471 Utf8Str(dst).raw(), false, 0, NULL, NULL, NULL );471 Utf8Str(dst).raw(), false, 0, NULL, NULL, NULL, NULL); 472 472 if (RT_FAILURE(vrc)) 473 473 {
Note:
See TracChangeset
for help on using the changeset viewer.