Changeset 38469 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Aug 16, 2011 10:34:32 AM (13 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp
r36523 r38469 1676 1676 HRESULT rc = S_OK; 1677 1677 1678 PVDINTERFACEIO pSha1 Callbacks= 0;1679 PVDINTERFACEIO pTar Callbacks= 0;1678 PVDINTERFACEIO pSha1Io = 0; 1679 PVDINTERFACEIO pTarIo = 0; 1680 1680 do 1681 1681 { 1682 pSha1 Callbacks= Sha1CreateInterface();1683 if (!pSha1 Callbacks)1682 pSha1Io = Sha1CreateInterface(); 1683 if (!pSha1Io) 1684 1684 { 1685 1685 rc = E_OUTOFMEMORY; 1686 1686 break; 1687 1687 } 1688 pTar Callbacks= TarCreateInterface();1689 if (!pTar Callbacks)1688 pTarIo = TarCreateInterface(); 1689 if (!pTarIo) 1690 1690 { 1691 1691 rc = E_OUTOFMEMORY; 1692 1692 break; 1693 1693 } 1694 VDINTERFACE VDInterfaceIO;1695 1694 SHA1STORAGE storage; 1696 1695 RT_ZERO(storage); 1697 1696 storage.fCreateDigest = m->fManifest; 1698 vrc = VDInterfaceAdd(& VDInterfaceIO, "Appliance::IOTar",1699 VDINTERFACETYPE_IO, pTarCallbacks,1700 tar,&storage.pVDImageIfaces);1697 vrc = VDInterfaceAdd(&pTarIo->Core, "Appliance::IOTar", 1698 VDINTERFACETYPE_IO, tar, sizeof(VDINTERFACEIO), 1699 &storage.pVDImageIfaces); 1701 1700 if (RT_FAILURE(vrc)) 1702 1701 { … … 1704 1703 break; 1705 1704 } 1706 rc = writeFSImpl(pTask, writeLock, pSha1 Callbacks, &storage);1705 rc = writeFSImpl(pTask, writeLock, pSha1Io, &storage); 1707 1706 }while(0); 1708 1707 … … 1710 1709 1711 1710 /* Cleanup */ 1712 if (pSha1 Callbacks)1713 RTMemFree(pSha1 Callbacks);1714 if (pTar Callbacks)1715 RTMemFree(pTar Callbacks);1711 if (pSha1Io) 1712 RTMemFree(pSha1Io); 1713 if (pTarIo) 1714 RTMemFree(pTarIo); 1716 1715 1717 1716 /* Delete ova file on error */ … … 1723 1722 } 1724 1723 1725 HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO p Callbacks, PSHA1STORAGE pStorage)1724 HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHA1STORAGE pStorage) 1726 1725 { 1727 1726 LogFlowFuncEnter(); … … 1755 1754 strOvfFile.c_str()); 1756 1755 /* Write the ovf file to disk. */ 1757 vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, p Callbacks, pStorage);1756 vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage); 1758 1757 if (RT_FAILURE(vrc)) 1759 1758 throw setError(VBOX_E_FILE_ERROR, … … 1825 1824 1826 1825 // create a flat copy of the source disk image 1827 rc = pSourceDisk->exportFile(strTargetFilePath.c_str(), format, MediumVariant_VmdkStreamOptimized, p Callbacks, pStorage, pProgress2);1826 rc = pSourceDisk->exportFile(strTargetFilePath.c_str(), format, MediumVariant_VmdkStreamOptimized, pIfIo, pStorage, pProgress2); 1828 1827 if (FAILED(rc)) throw rc; 1829 1828 … … 1872 1871 pStorage->fCreateDigest = false; 1873 1872 /* Write the manifest file to disk. */ 1874 vrc = Sha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, p Callbacks, pStorage);1873 vrc = Sha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, pIfIo, pStorage); 1875 1874 RTMemFree(pvBuf); 1876 1875 if (RT_FAILURE(vrc)) … … 1897 1896 it1 != fileList.end(); 1898 1897 ++it1) 1899 p Callbacks->pfnDelete(pStorage, (*it1).first.c_str());1898 pIfIo->pfnDelete(pStorage, (*it1).first.c_str()); 1900 1899 } 1901 1900 -
trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
r36043 r38469 468 468 PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvUser; 469 469 470 PVDINTERFACE pIO = VDInterfaceGet(pInt->pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 471 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 472 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 473 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 470 PVDINTERFACEIO pIfIo = VDIfIoGet(pInt->pSha1Storage->pVDImageIfaces); 471 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 474 472 475 473 int rc = VINF_SUCCESS; … … 518 516 size_t cbToWrite = cbMemRead - cbAllWritten; 519 517 size_t cbWritten = 0; 520 rc = pCallbacks->pfnWriteSync(pIO->pvUser, pInt->pvStorage, pInt->cbCurFile, &pcBuf[cbAllWritten], cbToWrite, &cbWritten);518 rc = vdIfIoFileWriteSync(pIfIo, pInt->pvStorage, pInt->cbCurFile, &pcBuf[cbAllWritten], cbToWrite, &cbWritten); 521 519 // RTPrintf ("%lu %lu %lu %Rrc\n", pInt->cbCurFile, cbToRead, cbRead, rc); 522 520 if (RT_FAILURE(rc)) … … 570 568 size_t cbToRead = cbMemWrite - cbAllRead; 571 569 size_t cbRead = 0; 572 rc = pCallbacks->pfnReadSync(pIO->pvUser, pInt->pvStorage, pInt->cbCurFile, &pcBuf[cbAllRead], cbToRead, &cbRead);570 rc = vdIfIoFileReadSync(pIfIo, pInt->pvStorage, pInt->cbCurFile, &pcBuf[cbAllRead], cbToRead, &cbRead); 573 571 // RTPrintf ("%lu %lu %lu %Rrc\n", pInt->cbCurFile, cbToRead, cbRead, rc); 574 572 if (RT_FAILURE(rc)) … … 670 668 671 669 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 672 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 673 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 674 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 675 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 670 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 671 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 676 672 677 673 DEBUG_PRINT_FLOW(); … … 729 725 730 726 /* Open the file. */ 731 rc = pCallbacks->pfnOpen(pIO->pvUser, pszLocation, 732 fOpen, pInt->pfnCompleted, 733 &pInt->pvStorage); 727 rc = vdIfIoFileOpen(pIfIo, pszLocation, fOpen, pInt->pfnCompleted, 728 &pInt->pvStorage); 734 729 if (RT_FAILURE(rc)) 735 730 break; … … 773 768 774 769 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 775 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 776 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 777 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 778 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 770 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 771 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 779 772 780 773 PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage; … … 813 806 814 807 /* Close the file */ 815 rc = pCallbacks->pfnClose(pIO->pvUser, pInt->pvStorage);808 rc = vdIfIoFileClose(pIfIo, pInt->pvStorage); 816 809 817 810 // RTPrintf("%lu %lu\n", pInt->calls, pInt->waits); … … 837 830 838 831 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 839 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 840 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 841 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 842 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 843 844 DEBUG_PRINT_FLOW(); 845 846 return pCallbacks->pfnDelete(pIO->pvUser, pcszFilename); 832 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 833 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 834 835 DEBUG_PRINT_FLOW(); 836 837 return vdIfIoFileDelete(pIfIo, pcszFilename); 847 838 } 848 839 … … 853 844 854 845 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 855 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 856 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 857 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 858 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 859 860 DEBUG_PRINT_FLOW(); 861 862 return pCallbacks->pfnMove(pIO->pvUser, pcszSrc, pcszDst, fMove); 846 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 847 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 848 849 850 DEBUG_PRINT_FLOW(); 851 852 return vdIfIoFileMove(pIfIo, pcszSrc, pcszDst, fMove); 863 853 } 864 854 … … 869 859 870 860 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 871 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 872 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 873 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 874 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 875 876 DEBUG_PRINT_FLOW(); 877 878 return pCallbacks->pfnGetFreeSpace(pIO->pvUser, pcszFilename, pcbFreeSpace); 861 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 862 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 863 864 DEBUG_PRINT_FLOW(); 865 866 return vdIfIoFileGetFreeSpace(pIfIo, pcszFilename, pcbFreeSpace); 879 867 } 880 868 … … 885 873 886 874 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 887 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 888 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 889 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 890 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 891 892 DEBUG_PRINT_FLOW(); 893 894 return pCallbacks->pfnGetModificationTime(pIO->pvUser, pcszFilename, pModificationTime); 875 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 876 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 877 878 DEBUG_PRINT_FLOW(); 879 880 return vdIfIoFileGetModificationTime(pIfIo, pcszFilename, pModificationTime); 895 881 } 896 882 … … 903 889 904 890 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 905 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 906 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 907 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 908 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 891 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 892 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 909 893 910 894 PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage; … … 913 897 914 898 uint64_t cbSize; 915 int rc = pCallbacks->pfnGetSize(pIO->pvUser, pInt->pvStorage, &cbSize);899 int rc = vdIfIoFileGetSize(pIfIo, pInt->pvStorage, &cbSize); 916 900 if (RT_FAILURE(rc)) 917 901 return rc; … … 929 913 930 914 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 931 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 932 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 933 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 934 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 915 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 916 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 935 917 936 918 PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage; … … 938 920 DEBUG_PRINT_FLOW(); 939 921 940 return pCallbacks->pfnSetSize(pIO->pvUser, pInt->pvStorage, cbSize);922 return vdIfIoFileSetSize(pIfIo, pInt->pvStorage, cbSize); 941 923 } 942 924 … … 949 931 950 932 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 951 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 952 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 953 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 954 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 933 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 934 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 955 935 956 936 PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage; … … 977 957 size_t cbWritten = 0; 978 958 rc = sha1WriteSyncCallback(pvUser, pvStorage, pInt->cbCurAll, 979 959 pInt->pvZeroBuf, cbToWrite, &cbWritten); 980 960 if (RT_FAILURE(rc)) 981 961 break; … … 1046 1026 1047 1027 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 1048 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 1049 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 1050 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 1051 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 1028 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 1029 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 1052 1030 1053 1031 // DEBUG_PRINT_FLOW(); … … 1135 1113 1136 1114 PSHA1STORAGE pSha1Storage = (PSHA1STORAGE)pvUser; 1137 PVDINTERFACE pIO = VDInterfaceGet(pSha1Storage->pVDImageIfaces, VDINTERFACETYPE_IO); 1138 AssertPtrReturn(pIO, VERR_INVALID_PARAMETER); 1139 PVDINTERFACEIO pCallbacks = VDGetInterfaceIO(pIO); 1140 AssertPtrReturn(pCallbacks, VERR_INVALID_PARAMETER); 1115 PVDINTERFACEIO pIfIo = VDIfIoGet(pSha1Storage->pVDImageIfaces); 1116 AssertPtrReturn(pIfIo, VERR_INVALID_PARAMETER); 1141 1117 1142 1118 DEBUG_PRINT_FLOW(); … … 1149 1125 return rc; 1150 1126 1151 return pCallbacks->pfnFlushSync(pIO->pvUser, pInt->pvStorage);1127 return vdIfIoFileFlushSync(pIfIo, pInt->pvStorage); 1152 1128 } 1153 1129 … … 1162 1138 return NULL; 1163 1139 1164 pCallbacks->cbSize = sizeof(VDINTERFACEIO);1165 pCallbacks->enmInterface = VDINTERFACETYPE_IO;1166 1140 pCallbacks->pfnOpen = sha1OpenCallback; 1167 1141 pCallbacks->pfnClose = sha1CloseCallback; … … 1185 1159 return NULL; 1186 1160 1187 pCallbacks->cbSize = sizeof(VDINTERFACEIO);1188 pCallbacks->enmInterface = VDINTERFACETYPE_IO;1189 1161 pCallbacks->pfnOpen = fileOpenCallback; 1190 1162 pCallbacks->pfnClose = fileCloseCallback; … … 1208 1180 return NULL; 1209 1181 1210 pCallbacks->cbSize = sizeof(VDINTERFACEIO);1211 pCallbacks->enmInterface = VDINTERFACETYPE_IO;1212 1182 pCallbacks->pfnOpen = tarOpenCallback; 1213 1183 pCallbacks->pfnClose = tarCloseCallback; … … 1225 1195 } 1226 1196 1227 int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO p Callbacks, void *pvUser)1197 int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pIfIo, void *pvUser) 1228 1198 { 1229 1199 /* Validate input. */ 1230 1200 AssertPtrReturn(ppvBuf, VERR_INVALID_POINTER); 1231 1201 AssertPtrReturn(pcbSize, VERR_INVALID_POINTER); 1232 AssertPtrReturn(p Callbacks, VERR_INVALID_POINTER);1202 AssertPtrReturn(pIfIo, VERR_INVALID_POINTER); 1233 1203 1234 1204 void *pvStorage; 1235 int rc = p Callbacks->pfnOpen(pvUser, pcszFilename,1236 1237 1205 int rc = pIfIo->pfnOpen(pvUser, pcszFilename, 1206 RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE, 0, 1207 &pvStorage); 1238 1208 if (RT_FAILURE(rc)) 1239 1209 return rc; … … 1255 1225 { 1256 1226 size_t cbRead = 0; 1257 rc = p Callbacks->pfnReadSync(pvUser, pvStorage, cbAllRead, pvTmpBuf, cbTmpSize, &cbRead);1227 rc = pIfIo->pfnReadSync(pvUser, pvStorage, cbAllRead, pvTmpBuf, cbTmpSize, &cbRead); 1258 1228 if ( RT_FAILURE(rc) 1259 1229 || cbRead == 0) … … 1270 1240 }while(0); 1271 1241 1272 p Callbacks->pfnClose(pvUser, pvStorage);1242 pIfIo->pfnClose(pvUser, pvStorage); 1273 1243 1274 1244 if (rc == VERR_EOF) … … 1291 1261 } 1292 1262 1293 int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO p Callbacks, void *pvUser)1263 int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser) 1294 1264 { 1295 1265 /* Validate input. */ 1296 1266 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 1297 1267 AssertReturn(cbSize, VERR_INVALID_PARAMETER); 1298 AssertPtrReturn(p Callbacks, VERR_INVALID_POINTER);1268 AssertPtrReturn(pIfIo, VERR_INVALID_POINTER); 1299 1269 1300 1270 void *pvStorage; 1301 int rc = p Callbacks->pfnOpen(pvUser, pcszFilename,1302 1303 1271 int rc = pIfIo->pfnOpen(pvUser, pcszFilename, 1272 RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL, 0, 1273 &pvStorage); 1304 1274 if (RT_FAILURE(rc)) 1305 1275 return rc; … … 1312 1282 size_t cbToWrite = cbSize - cbAllWritten; 1313 1283 size_t cbWritten = 0; 1314 rc = p Callbacks->pfnWriteSync(pvUser, pvStorage, cbAllWritten, &((char*)pvBuf)[cbAllWritten], cbToWrite, &cbWritten);1284 rc = pIfIo->pfnWriteSync(pvUser, pvStorage, cbAllWritten, &((char*)pvBuf)[cbAllWritten], cbToWrite, &cbWritten); 1315 1285 if (RT_FAILURE(rc)) 1316 1286 break; … … 1318 1288 } 1319 1289 1320 p Callbacks->pfnClose(pvUser, pvStorage);1290 pIfIo->pfnClose(pvUser, pvStorage); 1321 1291 1322 1292 return rc; -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r38455 r38469 870 870 HRESULT rc = S_OK; 871 871 872 PVDINTERFACEIO pSha1 Callbacks= 0;873 PVDINTERFACEIO pTar Callbacks= 0;872 PVDINTERFACEIO pSha1Io = 0; 873 PVDINTERFACEIO pTarIo = 0; 874 874 char *pszFilename = 0; 875 875 do … … 881 881 break; 882 882 } 883 pSha1 Callbacks= Sha1CreateInterface();884 if (!pSha1 Callbacks)883 pSha1Io = Sha1CreateInterface(); 884 if (!pSha1Io) 885 885 { 886 886 rc = E_OUTOFMEMORY; 887 887 break; 888 888 } 889 pTar Callbacks= TarCreateInterface();890 if (!pTar Callbacks)889 pTarIo = TarCreateInterface(); 890 if (!pTarIo) 891 891 { 892 892 rc = E_OUTOFMEMORY; 893 893 break; 894 894 } 895 VDINTERFACE VDInterfaceIO;896 895 SHA1STORAGE storage; 897 896 RT_ZERO(storage); 898 vrc = VDInterfaceAdd(& VDInterfaceIO, "Appliance::IOTar",899 VDINTERFACETYPE_IO, pTarCallbacks,900 tar,&storage.pVDImageIfaces);897 vrc = VDInterfaceAdd(&pTarIo->Core, "Appliance::IOTar", 898 VDINTERFACETYPE_IO, tar, sizeof(VDINTERFACEIO), 899 &storage.pVDImageIfaces); 901 900 if (RT_FAILURE(vrc)) 902 901 { … … 904 903 break; 905 904 } 906 rc = readFSImpl(pTask, pszFilename, pSha1 Callbacks, &storage);905 rc = readFSImpl(pTask, pszFilename, pSha1Io, &storage); 907 906 }while(0); 908 907 … … 912 911 if (pszFilename) 913 912 RTMemFree(pszFilename); 914 if (pSha1 Callbacks)915 RTMemFree(pSha1 Callbacks);916 if (pTar Callbacks)917 RTMemFree(pTar Callbacks);913 if (pSha1Io) 914 RTMemFree(pSha1Io); 915 if (pTarIo) 916 RTMemFree(pTarIo); 918 917 919 918 LogFlowFunc(("rc=%Rhrc\n", rc)); … … 923 922 } 924 923 925 HRESULT Appliance::readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO p Callbacks, PSHA1STORAGE pStorage)924 HRESULT Appliance::readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pIfIo, PSHA1STORAGE pStorage) 926 925 { 927 926 LogFlowFuncEnter(); … … 936 935 /* Read the OVF into a memory buffer */ 937 936 size_t cbSize = 0; 938 int vrc = Sha1ReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, p Callbacks, pStorage);937 int vrc = Sha1ReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, pIfIo, pStorage); 939 938 if ( RT_FAILURE(vrc) 940 939 || !pvTmpBuf) … … 1307 1306 HRESULT rc = S_OK; 1308 1307 1309 PVDINTERFACEIO pSha1 Callbacks= 0;1310 PVDINTERFACEIO pTar Callbacks= 0;1308 PVDINTERFACEIO pSha1Io = 0; 1309 PVDINTERFACEIO pTarIo = 0; 1311 1310 char *pszFilename = 0; 1312 1311 void *pvMfBuf = 0; … … 1315 1314 { 1316 1315 /* Create the necessary file access interfaces. */ 1317 pSha1 Callbacks= Sha1CreateInterface();1318 if (!pSha1 Callbacks)1316 pSha1Io = Sha1CreateInterface(); 1317 if (!pSha1Io) 1319 1318 throw E_OUTOFMEMORY; 1320 pTar Callbacks= TarCreateInterface();1321 if (!pTar Callbacks)1319 pTarIo = TarCreateInterface(); 1320 if (!pTarIo) 1322 1321 throw E_OUTOFMEMORY; 1323 1322 1324 VDINTERFACE VDInterfaceIO;1325 1323 SHA1STORAGE storage; 1326 1324 RT_ZERO(storage); 1327 vrc = VDInterfaceAdd(& VDInterfaceIO, "Appliance::IOTar",1328 VDINTERFACETYPE_IO, pTarCallbacks,1329 tar,&storage.pVDImageIfaces);1325 vrc = VDInterfaceAdd(&pTarIo->Core, "Appliance::IOTar", 1326 VDINTERFACETYPE_IO, tar, sizeof(VDINTERFACEIO), 1327 &storage.pVDImageIfaces); 1330 1328 if (RT_FAILURE(vrc)) 1331 1329 throw setError(E_FAIL, … … 1345 1343 tr("Internal error (%Rrc)"), vrc); 1346 1344 1347 PVDINTERFACEIO pCallbacks = pSha1 Callbacks;1345 PVDINTERFACEIO pCallbacks = pSha1Io; 1348 1346 PSHA1STORAGE pStorage = &storage; 1349 1347 … … 1400 1398 if (pvMfBuf) 1401 1399 RTMemFree(pvMfBuf); 1402 if (pSha1 Callbacks)1403 RTMemFree(pSha1 Callbacks);1404 if (pTar Callbacks)1405 RTMemFree(pTar Callbacks);1400 if (pSha1Io) 1401 RTMemFree(pSha1Io); 1402 if (pTarIo) 1403 RTMemFree(pTarIo); 1406 1404 1407 1405 LogFlowFunc(("rc=%Rhrc\n", rc)); -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r38452 r38469 153 153 Utf8Str vdError; /*< Error remembered by the VD error callback. */ 154 154 155 VDINTERFACE vdIfError; 156 VDINTERFACEERROR vdIfCallsError; 157 158 VDINTERFACE vdIfConfig; 159 VDINTERFACECONFIG vdIfCallsConfig; 160 161 VDINTERFACE vdIfTcpNet; 162 VDINTERFACETCPNET vdIfCallsTcpNet; 155 VDINTERFACEERROR vdIfError; 156 157 VDINTERFACECONFIG vdIfConfig; 158 159 VDINTERFACETCPNET vdIfTcpNet; 163 160 164 161 PVDINTERFACE vdDiskIfaces; … … 214 211 /* Set up a per-operation progress interface, can be used freely (for 215 212 * binary operations you can use it either on the source or target). */ 216 mVDIfCallsProgress.cbSize = sizeof(VDINTERFACEPROGRESS); 217 mVDIfCallsProgress.enmInterface = VDINTERFACETYPE_PROGRESS; 218 mVDIfCallsProgress.pfnProgress = vdProgressCall; 219 int vrc = VDInterfaceAdd(&mVDIfProgress, 213 mVDIfProgress.pfnProgress = vdProgressCall; 214 int vrc = VDInterfaceAdd(&mVDIfProgress.Core, 220 215 "Medium::Task::vdInterfaceProgress", 221 216 VDINTERFACETYPE_PROGRESS, 222 &mVDIfCallsProgress,223 217 mProgress, 218 sizeof(VDINTERFACEPROGRESS), 224 219 &mVDOperationIfaces); 225 220 AssertRC(vrc); … … 262 257 static DECLCALLBACK(int) vdProgressCall(void *pvUser, unsigned uPercent); 263 258 264 VDINTERFACE mVDIfProgress; 265 VDINTERFACEPROGRESS mVDIfCallsProgress; 259 VDINTERFACEPROGRESS mVDIfProgress; 266 260 267 261 /* Must have a strong VirtualBox reference during a task otherwise the … … 591 585 MediumFormat *aFormat, 592 586 MediumVariant_T aVariant, 593 void *aVDImageIOCallbacks,587 VDINTERFACEIO *aVDImageIOIf, 594 588 void *aVDImageIOUser, 595 589 MediumLockList *aSourceMediumLockList, … … 605 599 606 600 mVDImageIfaces = aMedium->m->vdImageIfaces; 607 if (aVDImageIO Callbacks)608 { 609 int vrc = VDInterfaceAdd(& mVDInterfaceIO, "Medium::vdInterfaceIO",610 VDINTERFACETYPE_IO, aVDImageIO Callbacks,611 aVDImageIOUser, &mVDImageIfaces);601 if (aVDImageIOIf) 602 { 603 int vrc = VDInterfaceAdd(&aVDImageIOIf->Core, "Medium::vdInterfaceIO", 604 VDINTERFACETYPE_IO, aVDImageIOUser, 605 sizeof(VDINTERFACEIO), &mVDImageIfaces); 612 606 AssertRCReturnVoidStmt(vrc, mRC = E_FAIL); 613 607 } … … 630 624 631 625 bool mfKeepSourceMediumLockList; 632 VDINTERFACE mVDInterfaceIO;633 626 }; 634 627 … … 641 634 MediumFormat *aFormat, 642 635 MediumVariant_T aVariant, 643 void *aVDImageIOCallbacks,636 VDINTERFACEIO *aVDImageIOIf, 644 637 void *aVDImageIOUser, 645 638 Medium *aParent, … … 662 655 663 656 mVDImageIfaces = aMedium->m->vdImageIfaces; 664 if (aVDImageIO Callbacks)665 { 666 int vrc = VDInterfaceAdd(& mVDInterfaceIO, "Medium::vdInterfaceIO",667 VDINTERFACETYPE_IO, aVDImageIO Callbacks,668 aVDImageIOUser, &mVDImageIfaces);657 if (aVDImageIOIf) 658 { 659 int vrc = VDInterfaceAdd(&aVDImageIOIf->Core, "Medium::vdInterfaceIO", 660 VDINTERFACETYPE_IO, aVDImageIOUser, 661 sizeof(VDINTERFACEIO), &mVDImageIfaces); 669 662 AssertRCReturnVoidStmt(vrc, mRC = E_FAIL); 670 663 } … … 689 682 AutoCaller mParentCaller; 690 683 bool mfKeepTargetMediumLockList; 691 VDINTERFACE mVDInterfaceIO;692 684 }; 693 685 … … 846 838 847 839 /* Initialize the callbacks of the VD error interface */ 848 m->vdIfCallsError.cbSize = sizeof(VDINTERFACEERROR); 849 m->vdIfCallsError.enmInterface = VDINTERFACETYPE_ERROR; 850 m->vdIfCallsError.pfnError = vdErrorCall; 851 m->vdIfCallsError.pfnMessage = NULL; 840 m->vdIfError.pfnError = vdErrorCall; 841 m->vdIfError.pfnMessage = NULL; 852 842 853 843 /* Initialize the callbacks of the VD config interface */ 854 m->vdIfCallsConfig.cbSize = sizeof(VDINTERFACECONFIG); 855 m->vdIfCallsConfig.enmInterface = VDINTERFACETYPE_CONFIG; 856 m->vdIfCallsConfig.pfnAreKeysValid = vdConfigAreKeysValid; 857 m->vdIfCallsConfig.pfnQuerySize = vdConfigQuerySize; 858 m->vdIfCallsConfig.pfnQuery = vdConfigQuery; 844 m->vdIfConfig.pfnAreKeysValid = vdConfigAreKeysValid; 845 m->vdIfConfig.pfnQuerySize = vdConfigQuerySize; 846 m->vdIfConfig.pfnQuery = vdConfigQuery; 859 847 860 848 /* Initialize the callbacks of the VD TCP interface (we always use the host 861 849 * IP stack for now) */ 862 m->vdIfCallsTcpNet.cbSize = sizeof(VDINTERFACETCPNET); 863 m->vdIfCallsTcpNet.enmInterface = VDINTERFACETYPE_TCPNET; 864 m->vdIfCallsTcpNet.pfnSocketCreate = vdTcpSocketCreate; 865 m->vdIfCallsTcpNet.pfnSocketDestroy = vdTcpSocketDestroy; 866 m->vdIfCallsTcpNet.pfnClientConnect = vdTcpClientConnect; 867 m->vdIfCallsTcpNet.pfnClientClose = vdTcpClientClose; 868 m->vdIfCallsTcpNet.pfnIsClientConnected = vdTcpIsClientConnected; 869 m->vdIfCallsTcpNet.pfnSelectOne = vdTcpSelectOne; 870 m->vdIfCallsTcpNet.pfnRead = vdTcpRead; 871 m->vdIfCallsTcpNet.pfnWrite = vdTcpWrite; 872 m->vdIfCallsTcpNet.pfnSgWrite = vdTcpSgWrite; 873 m->vdIfCallsTcpNet.pfnFlush = vdTcpFlush; 874 m->vdIfCallsTcpNet.pfnSetSendCoalescing = vdTcpSetSendCoalescing; 875 m->vdIfCallsTcpNet.pfnGetLocalAddress = vdTcpGetLocalAddress; 876 m->vdIfCallsTcpNet.pfnGetPeerAddress = vdTcpGetPeerAddress; 877 m->vdIfCallsTcpNet.pfnSelectOneEx = NULL; 878 m->vdIfCallsTcpNet.pfnPoke = NULL; 850 m->vdIfTcpNet.pfnSocketCreate = vdTcpSocketCreate; 851 m->vdIfTcpNet.pfnSocketDestroy = vdTcpSocketDestroy; 852 m->vdIfTcpNet.pfnClientConnect = vdTcpClientConnect; 853 m->vdIfTcpNet.pfnClientClose = vdTcpClientClose; 854 m->vdIfTcpNet.pfnIsClientConnected = vdTcpIsClientConnected; 855 m->vdIfTcpNet.pfnSelectOne = vdTcpSelectOne; 856 m->vdIfTcpNet.pfnRead = vdTcpRead; 857 m->vdIfTcpNet.pfnWrite = vdTcpWrite; 858 m->vdIfTcpNet.pfnSgWrite = vdTcpSgWrite; 859 m->vdIfTcpNet.pfnFlush = vdTcpFlush; 860 m->vdIfTcpNet.pfnSetSendCoalescing = vdTcpSetSendCoalescing; 861 m->vdIfTcpNet.pfnGetLocalAddress = vdTcpGetLocalAddress; 862 m->vdIfTcpNet.pfnGetPeerAddress = vdTcpGetPeerAddress; 863 m->vdIfTcpNet.pfnSelectOneEx = NULL; 864 m->vdIfTcpNet.pfnPoke = NULL; 879 865 880 866 /* Initialize the per-disk interface chain (could be done more globally, 881 867 * but it's not wasting much time or space so it's not worth it). */ 882 868 int vrc; 883 vrc = VDInterfaceAdd(&m->vdIfError ,869 vrc = VDInterfaceAdd(&m->vdIfError.Core, 884 870 "Medium::vdInterfaceError", 885 VDINTERFACETYPE_ERROR, 886 &m->vdIfCallsError, this, &m->vdDiskIfaces);871 VDINTERFACETYPE_ERROR, this, 872 sizeof(VDINTERFACEERROR), &m->vdDiskIfaces); 887 873 AssertRCReturn(vrc, E_FAIL); 888 874 889 875 /* Initialize the per-image interface chain */ 890 vrc = VDInterfaceAdd(&m->vdIfConfig ,876 vrc = VDInterfaceAdd(&m->vdIfConfig.Core, 891 877 "Medium::vdInterfaceConfig", 892 VDINTERFACETYPE_CONFIG, 893 &m->vdIfCallsConfig, this, &m->vdImageIfaces);878 VDINTERFACETYPE_CONFIG, this, 879 sizeof(VDINTERFACECONFIG), &m->vdImageIfaces); 894 880 AssertRCReturn(vrc, E_FAIL); 895 881 896 vrc = VDInterfaceAdd(&m->vdIfTcpNet ,882 vrc = VDInterfaceAdd(&m->vdIfTcpNet.Core, 897 883 "Medium::vdInterfaceTcpNet", 898 VDINTERFACETYPE_TCPNET, 899 &m->vdIfCallsTcpNet, this, &m->vdImageIfaces);884 VDINTERFACETYPE_TCPNET, this, 885 sizeof(VDINTERFACETCPNET), &m->vdImageIfaces); 900 886 AssertRCReturn(vrc, E_FAIL); 901 887 … … 4952 4938 const ComObjPtr<MediumFormat> &aFormat, 4953 4939 MediumVariant_T aVariant, 4954 void *aVDImageIOCallbacks, void *aVDImageIOUser,4940 PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser, 4955 4941 const ComObjPtr<Progress> &aProgress) 4956 4942 { … … 4995 4981 /* setup task object to carry out the operation asynchronously */ 4996 4982 pTask = new Medium::ExportTask(this, aProgress, aFilename, aFormat, 4997 aVariant, aVDImageIO Callbacks,4983 aVariant, aVDImageIOIf, 4998 4984 aVDImageIOUser, pSourceMediumLockList); 4999 4985 rc = pTask->rc(); … … 5030 5016 const ComObjPtr<MediumFormat> &aFormat, 5031 5017 MediumVariant_T aVariant, 5032 void *aVDImageIOCallbacks, void *aVDImageIOUser,5018 PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser, 5033 5019 const ComObjPtr<Medium> &aParent, 5034 5020 const ComObjPtr<Progress> &aProgress) … … 5078 5064 /* setup task object to carry out the operation asynchronously */ 5079 5065 pTask = new Medium::ImportTask(this, aProgress, aFilename, aFormat, 5080 aVariant, aVDImageIO Callbacks,5066 aVariant, aVDImageIOIf, 5081 5067 aVDImageIOUser, aParent, 5082 5068 pTargetMediumLockList);
Note:
See TracChangeset
for help on using the changeset viewer.