VirtualBox

Changeset 38469 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Aug 16, 2011 10:34:32 AM (13 years ago)
Author:
vboxsync
Message:

VD: Interface cleanup. Merge the two involved structures (generic interface descriptor and callback table) into one, remove the duplicated interface wrappers in the backends and move the interface definitions into separate headers separating public and private interfaces.

Location:
trunk/src/VBox/Main/src-server
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImplExport.cpp

    r36523 r38469  
    16761676    HRESULT rc = S_OK;
    16771677
    1678     PVDINTERFACEIO pSha1Callbacks = 0;
    1679     PVDINTERFACEIO pTarCallbacks = 0;
     1678    PVDINTERFACEIO pSha1Io = 0;
     1679    PVDINTERFACEIO pTarIo = 0;
    16801680    do
    16811681    {
    1682         pSha1Callbacks = Sha1CreateInterface();
    1683         if (!pSha1Callbacks)
     1682        pSha1Io = Sha1CreateInterface();
     1683        if (!pSha1Io)
    16841684        {
    16851685            rc = E_OUTOFMEMORY;
    16861686            break;
    16871687        }
    1688         pTarCallbacks = TarCreateInterface();
    1689         if (!pTarCallbacks)
     1688        pTarIo = TarCreateInterface();
     1689        if (!pTarIo)
    16901690        {
    16911691            rc = E_OUTOFMEMORY;
    16921692            break;
    16931693        }
    1694         VDINTERFACE VDInterfaceIO;
    16951694        SHA1STORAGE storage;
    16961695        RT_ZERO(storage);
    16971696        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);
    17011700        if (RT_FAILURE(vrc))
    17021701        {
     
    17041703            break;
    17051704        }
    1706         rc = writeFSImpl(pTask, writeLock, pSha1Callbacks, &storage);
     1705        rc = writeFSImpl(pTask, writeLock, pSha1Io, &storage);
    17071706    }while(0);
    17081707
     
    17101709
    17111710    /* Cleanup */
    1712     if (pSha1Callbacks)
    1713         RTMemFree(pSha1Callbacks);
    1714     if (pTarCallbacks)
    1715         RTMemFree(pTarCallbacks);
     1711    if (pSha1Io)
     1712        RTMemFree(pSha1Io);
     1713    if (pTarIo)
     1714        RTMemFree(pTarIo);
    17161715
    17171716    /* Delete ova file on error */
     
    17231722}
    17241723
    1725 HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage)
     1724HRESULT Appliance::writeFSImpl(TaskOVF *pTask, AutoWriteLockBase& writeLock, PVDINTERFACEIO pIfIo, PSHA1STORAGE pStorage)
    17261725{
    17271726    LogFlowFuncEnter();
     
    17551754                               strOvfFile.c_str());
    17561755            /* Write the ovf file to disk. */
    1757             vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pCallbacks, pStorage);
     1756            vrc = Sha1WriteBuf(strOvfFile.c_str(), pvBuf, cbSize, pIfIo, pStorage);
    17581757            if (RT_FAILURE(vrc))
    17591758                throw setError(VBOX_E_FILE_ERROR,
     
    18251824
    18261825                // create a flat copy of the source disk image
    1827                 rc = pSourceDisk->exportFile(strTargetFilePath.c_str(), format, MediumVariant_VmdkStreamOptimized, pCallbacks, pStorage, pProgress2);
     1826                rc = pSourceDisk->exportFile(strTargetFilePath.c_str(), format, MediumVariant_VmdkStreamOptimized, pIfIo, pStorage, pProgress2);
    18281827                if (FAILED(rc)) throw rc;
    18291828
     
    18721871            pStorage->fCreateDigest = false;
    18731872            /* Write the manifest file to disk. */
    1874             vrc = Sha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, pCallbacks, pStorage);
     1873            vrc = Sha1WriteBuf(strMfFilePath.c_str(), pvBuf, cbSize, pIfIo, pStorage);
    18751874            RTMemFree(pvBuf);
    18761875            if (RT_FAILURE(vrc))
     
    18971896             it1 != fileList.end();
    18981897             ++it1)
    1899              pCallbacks->pfnDelete(pStorage, (*it1).first.c_str());
     1898             pIfIo->pfnDelete(pStorage, (*it1).first.c_str());
    19001899    }
    19011900
  • trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp

    r36043 r38469  
    468468    PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvUser;
    469469
    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);
    474472
    475473    int rc = VINF_SUCCESS;
     
    518516                        size_t cbToWrite = cbMemRead - cbAllWritten;
    519517                        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);
    521519//                        RTPrintf ("%lu %lu %lu %Rrc\n", pInt->cbCurFile, cbToRead, cbRead, rc);
    522520                        if (RT_FAILURE(rc))
     
    570568                        size_t cbToRead = cbMemWrite - cbAllRead;
    571569                        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);
    573571//                        RTPrintf ("%lu %lu %lu %Rrc\n", pInt->cbCurFile, cbToRead, cbRead, rc);
    574572                        if (RT_FAILURE(rc))
     
    670668
    671669    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);
    676672
    677673    DEBUG_PRINT_FLOW();
     
    729725
    730726        /* 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);
    734729        if (RT_FAILURE(rc))
    735730            break;
     
    773768
    774769    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);
    779772
    780773    PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;
     
    813806
    814807    /* Close the file */
    815     rc = pCallbacks->pfnClose(pIO->pvUser, pInt->pvStorage);
     808    rc = vdIfIoFileClose(pIfIo, pInt->pvStorage);
    816809
    817810//    RTPrintf("%lu %lu\n", pInt->calls, pInt->waits);
     
    837830
    838831    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);
    847838}
    848839
     
    853844
    854845    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);
    863853}
    864854
     
    869859
    870860    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);
    879867}
    880868
     
    885873
    886874    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);
    895881}
    896882
     
    903889
    904890    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);
    909893
    910894    PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;
     
    913897
    914898    uint64_t cbSize;
    915     int rc = pCallbacks->pfnGetSize(pIO->pvUser, pInt->pvStorage, &cbSize);
     899    int rc = vdIfIoFileGetSize(pIfIo, pInt->pvStorage, &cbSize);
    916900    if (RT_FAILURE(rc))
    917901        return rc;
     
    929913
    930914    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);
    935917
    936918    PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;
     
    938920    DEBUG_PRINT_FLOW();
    939921
    940     return pCallbacks->pfnSetSize(pIO->pvUser, pInt->pvStorage, cbSize);
     922    return vdIfIoFileSetSize(pIfIo, pInt->pvStorage, cbSize);
    941923}
    942924
     
    949931
    950932    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);
    955935
    956936    PSHA1STORAGEINTERNAL pInt = (PSHA1STORAGEINTERNAL)pvStorage;
     
    977957            size_t cbWritten = 0;
    978958            rc = sha1WriteSyncCallback(pvUser, pvStorage, pInt->cbCurAll,
    979                                          pInt->pvZeroBuf, cbToWrite, &cbWritten);
     959                                       pInt->pvZeroBuf, cbToWrite, &cbWritten);
    980960            if (RT_FAILURE(rc))
    981961                break;
     
    10461026
    10471027    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);
    10521030
    10531031//    DEBUG_PRINT_FLOW();
     
    11351113
    11361114    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);
    11411117
    11421118    DEBUG_PRINT_FLOW();
     
    11491125        return rc;
    11501126
    1151     return pCallbacks->pfnFlushSync(pIO->pvUser, pInt->pvStorage);
     1127    return vdIfIoFileFlushSync(pIfIo, pInt->pvStorage);
    11521128}
    11531129
     
    11621138        return NULL;
    11631139
    1164     pCallbacks->cbSize                 = sizeof(VDINTERFACEIO);
    1165     pCallbacks->enmInterface           = VDINTERFACETYPE_IO;
    11661140    pCallbacks->pfnOpen                = sha1OpenCallback;
    11671141    pCallbacks->pfnClose               = sha1CloseCallback;
     
    11851159        return NULL;
    11861160
    1187     pCallbacks->cbSize                 = sizeof(VDINTERFACEIO);
    1188     pCallbacks->enmInterface           = VDINTERFACETYPE_IO;
    11891161    pCallbacks->pfnOpen                = fileOpenCallback;
    11901162    pCallbacks->pfnClose               = fileCloseCallback;
     
    12081180        return NULL;
    12091181
    1210     pCallbacks->cbSize                 = sizeof(VDINTERFACEIO);
    1211     pCallbacks->enmInterface           = VDINTERFACETYPE_IO;
    12121182    pCallbacks->pfnOpen                = tarOpenCallback;
    12131183    pCallbacks->pfnClose               = tarCloseCallback;
     
    12251195}
    12261196
    1227 int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pCallbacks, void *pvUser)
     1197int Sha1ReadBuf(const char *pcszFilename, void **ppvBuf, size_t *pcbSize, PVDINTERFACEIO pIfIo, void *pvUser)
    12281198{
    12291199    /* Validate input. */
    12301200    AssertPtrReturn(ppvBuf, VERR_INVALID_POINTER);
    12311201    AssertPtrReturn(pcbSize, VERR_INVALID_POINTER);
    1232     AssertPtrReturn(pCallbacks, VERR_INVALID_POINTER);
     1202    AssertPtrReturn(pIfIo, VERR_INVALID_POINTER);
    12331203
    12341204    void *pvStorage;
    1235     int rc = pCallbacks->pfnOpen(pvUser, pcszFilename,
    1236                                  RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE, 0,
    1237                                  &pvStorage);
     1205    int rc = pIfIo->pfnOpen(pvUser, pcszFilename,
     1206                            RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE, 0,
     1207                            &pvStorage);
    12381208    if (RT_FAILURE(rc))
    12391209        return rc;
     
    12551225        {
    12561226            size_t cbRead = 0;
    1257             rc = pCallbacks->pfnReadSync(pvUser, pvStorage, cbAllRead, pvTmpBuf, cbTmpSize, &cbRead);
     1227            rc = pIfIo->pfnReadSync(pvUser, pvStorage, cbAllRead, pvTmpBuf, cbTmpSize, &cbRead);
    12581228            if (   RT_FAILURE(rc)
    12591229                || cbRead == 0)
     
    12701240    }while(0);
    12711241
    1272     pCallbacks->pfnClose(pvUser, pvStorage);
     1242    pIfIo->pfnClose(pvUser, pvStorage);
    12731243
    12741244    if (rc == VERR_EOF)
     
    12911261}
    12921262
    1293 int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pCallbacks, void *pvUser)
     1263int Sha1WriteBuf(const char *pcszFilename, void *pvBuf, size_t cbSize, PVDINTERFACEIO pIfIo, void *pvUser)
    12941264{
    12951265    /* Validate input. */
    12961266    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
    12971267    AssertReturn(cbSize, VERR_INVALID_PARAMETER);
    1298     AssertPtrReturn(pCallbacks, VERR_INVALID_POINTER);
     1268    AssertPtrReturn(pIfIo, VERR_INVALID_POINTER);
    12991269
    13001270    void *pvStorage;
    1301     int rc = pCallbacks->pfnOpen(pvUser, pcszFilename,
    1302                                  RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL, 0,
    1303                                  &pvStorage);
     1271    int rc = pIfIo->pfnOpen(pvUser, pcszFilename,
     1272                            RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL, 0,
     1273                            &pvStorage);
    13041274    if (RT_FAILURE(rc))
    13051275        return rc;
     
    13121282        size_t cbToWrite = cbSize - cbAllWritten;
    13131283        size_t cbWritten = 0;
    1314         rc = pCallbacks->pfnWriteSync(pvUser, pvStorage, cbAllWritten, &((char*)pvBuf)[cbAllWritten], cbToWrite, &cbWritten);
     1284        rc = pIfIo->pfnWriteSync(pvUser, pvStorage, cbAllWritten, &((char*)pvBuf)[cbAllWritten], cbToWrite, &cbWritten);
    13151285        if (RT_FAILURE(rc))
    13161286            break;
     
    13181288    }
    13191289
    1320     pCallbacks->pfnClose(pvUser, pvStorage);
     1290    pIfIo->pfnClose(pvUser, pvStorage);
    13211291
    13221292    return rc;
  • trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp

    r38455 r38469  
    870870    HRESULT rc = S_OK;
    871871
    872     PVDINTERFACEIO pSha1Callbacks = 0;
    873     PVDINTERFACEIO pTarCallbacks = 0;
     872    PVDINTERFACEIO pSha1Io = 0;
     873    PVDINTERFACEIO pTarIo = 0;
    874874    char *pszFilename = 0;
    875875    do
     
    881881            break;
    882882        }
    883         pSha1Callbacks = Sha1CreateInterface();
    884         if (!pSha1Callbacks)
     883        pSha1Io = Sha1CreateInterface();
     884        if (!pSha1Io)
    885885        {
    886886            rc = E_OUTOFMEMORY;
    887887            break;
    888888        }
    889         pTarCallbacks = TarCreateInterface();
    890         if (!pTarCallbacks)
     889        pTarIo = TarCreateInterface();
     890        if (!pTarIo)
    891891        {
    892892            rc = E_OUTOFMEMORY;
    893893            break;
    894894        }
    895         VDINTERFACE VDInterfaceIO;
    896895        SHA1STORAGE storage;
    897896        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);
    901900        if (RT_FAILURE(vrc))
    902901        {
     
    904903            break;
    905904        }
    906         rc = readFSImpl(pTask, pszFilename, pSha1Callbacks, &storage);
     905        rc = readFSImpl(pTask, pszFilename, pSha1Io, &storage);
    907906    }while(0);
    908907
     
    912911    if (pszFilename)
    913912        RTMemFree(pszFilename);
    914     if (pSha1Callbacks)
    915         RTMemFree(pSha1Callbacks);
    916     if (pTarCallbacks)
    917         RTMemFree(pTarCallbacks);
     913    if (pSha1Io)
     914        RTMemFree(pSha1Io);
     915    if (pTarIo)
     916        RTMemFree(pTarIo);
    918917
    919918    LogFlowFunc(("rc=%Rhrc\n", rc));
     
    923922}
    924923
    925 HRESULT Appliance::readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pCallbacks, PSHA1STORAGE pStorage)
     924HRESULT Appliance::readFSImpl(TaskOVF *pTask, const RTCString &strFilename, PVDINTERFACEIO pIfIo, PSHA1STORAGE pStorage)
    926925{
    927926    LogFlowFuncEnter();
     
    936935        /* Read the OVF into a memory buffer */
    937936        size_t cbSize = 0;
    938         int vrc = Sha1ReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, pCallbacks, pStorage);
     937        int vrc = Sha1ReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, pIfIo, pStorage);
    939938        if (   RT_FAILURE(vrc)
    940939            || !pvTmpBuf)
     
    13071306    HRESULT rc = S_OK;
    13081307
    1309     PVDINTERFACEIO pSha1Callbacks = 0;
    1310     PVDINTERFACEIO pTarCallbacks = 0;
     1308    PVDINTERFACEIO pSha1Io = 0;
     1309    PVDINTERFACEIO pTarIo = 0;
    13111310    char *pszFilename = 0;
    13121311    void *pvMfBuf = 0;
     
    13151314    {
    13161315        /* Create the necessary file access interfaces. */
    1317         pSha1Callbacks = Sha1CreateInterface();
    1318         if (!pSha1Callbacks)
     1316        pSha1Io = Sha1CreateInterface();
     1317        if (!pSha1Io)
    13191318            throw E_OUTOFMEMORY;
    1320         pTarCallbacks = TarCreateInterface();
    1321         if (!pTarCallbacks)
     1319        pTarIo = TarCreateInterface();
     1320        if (!pTarIo)
    13221321            throw E_OUTOFMEMORY;
    13231322
    1324         VDINTERFACE VDInterfaceIO;
    13251323        SHA1STORAGE storage;
    13261324        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);
    13301328        if (RT_FAILURE(vrc))
    13311329            throw setError(E_FAIL,
     
    13451343                           tr("Internal error (%Rrc)"), vrc);
    13461344
    1347         PVDINTERFACEIO pCallbacks = pSha1Callbacks;
     1345        PVDINTERFACEIO pCallbacks = pSha1Io;
    13481346        PSHA1STORAGE pStorage = &storage;
    13491347
     
    14001398    if (pvMfBuf)
    14011399        RTMemFree(pvMfBuf);
    1402     if (pSha1Callbacks)
    1403         RTMemFree(pSha1Callbacks);
    1404     if (pTarCallbacks)
    1405         RTMemFree(pTarCallbacks);
     1400    if (pSha1Io)
     1401        RTMemFree(pSha1Io);
     1402    if (pTarIo)
     1403        RTMemFree(pTarIo);
    14061404
    14071405    LogFlowFunc(("rc=%Rhrc\n", rc));
  • trunk/src/VBox/Main/src-server/MediumImpl.cpp

    r38452 r38469  
    153153    Utf8Str vdError;        /*< Error remembered by the VD error callback. */
    154154
    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;
    163160
    164161    PVDINTERFACE vdDiskIfaces;
     
    214211        /* Set up a per-operation progress interface, can be used freely (for
    215212         * 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,
    220215                                "Medium::Task::vdInterfaceProgress",
    221216                                VDINTERFACETYPE_PROGRESS,
    222                                 &mVDIfCallsProgress,
    223217                                mProgress,
     218                                sizeof(VDINTERFACEPROGRESS),
    224219                                &mVDOperationIfaces);
    225220        AssertRC(vrc);
     
    262257    static DECLCALLBACK(int) vdProgressCall(void *pvUser, unsigned uPercent);
    263258
    264     VDINTERFACE mVDIfProgress;
    265     VDINTERFACEPROGRESS mVDIfCallsProgress;
     259    VDINTERFACEPROGRESS mVDIfProgress;
    266260
    267261    /* Must have a strong VirtualBox reference during a task otherwise the
     
    591585               MediumFormat *aFormat,
    592586               MediumVariant_T aVariant,
    593                void *aVDImageIOCallbacks,
     587               VDINTERFACEIO *aVDImageIOIf,
    594588               void *aVDImageIOUser,
    595589               MediumLockList *aSourceMediumLockList,
     
    605599
    606600        mVDImageIfaces = aMedium->m->vdImageIfaces;
    607         if (aVDImageIOCallbacks)
    608         {
    609             int vrc = VDInterfaceAdd(&mVDInterfaceIO, "Medium::vdInterfaceIO",
    610                                      VDINTERFACETYPE_IO, aVDImageIOCallbacks,
    611                                      aVDImageIOUser, &mVDImageIfaces);
     601        if (aVDImageIOIf)
     602        {
     603            int vrc = VDInterfaceAdd(&aVDImageIOIf->Core, "Medium::vdInterfaceIO",
     604                                     VDINTERFACETYPE_IO, aVDImageIOUser,
     605                                     sizeof(VDINTERFACEIO), &mVDImageIfaces);
    612606            AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);
    613607        }
     
    630624
    631625    bool mfKeepSourceMediumLockList;
    632     VDINTERFACE mVDInterfaceIO;
    633626};
    634627
     
    641634               MediumFormat *aFormat,
    642635               MediumVariant_T aVariant,
    643                void *aVDImageIOCallbacks,
     636               VDINTERFACEIO *aVDImageIOIf,
    644637               void *aVDImageIOUser,
    645638               Medium *aParent,
     
    662655
    663656        mVDImageIfaces = aMedium->m->vdImageIfaces;
    664         if (aVDImageIOCallbacks)
    665         {
    666             int vrc = VDInterfaceAdd(&mVDInterfaceIO, "Medium::vdInterfaceIO",
    667                                      VDINTERFACETYPE_IO, aVDImageIOCallbacks,
    668                                      aVDImageIOUser, &mVDImageIfaces);
     657        if (aVDImageIOIf)
     658        {
     659            int vrc = VDInterfaceAdd(&aVDImageIOIf->Core, "Medium::vdInterfaceIO",
     660                                     VDINTERFACETYPE_IO, aVDImageIOUser,
     661                                     sizeof(VDINTERFACEIO), &mVDImageIfaces);
    669662            AssertRCReturnVoidStmt(vrc, mRC = E_FAIL);
    670663        }
     
    689682    AutoCaller mParentCaller;
    690683    bool mfKeepTargetMediumLockList;
    691     VDINTERFACE mVDInterfaceIO;
    692684};
    693685
     
    846838
    847839    /* 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;
    852842
    853843    /* 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;
    859847
    860848    /* Initialize the callbacks of the VD TCP interface (we always use the host
    861849     * 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;
    879865
    880866    /* Initialize the per-disk interface chain (could be done more globally,
    881867     * but it's not wasting much time or space so it's not worth it). */
    882868    int vrc;
    883     vrc = VDInterfaceAdd(&m->vdIfError,
     869    vrc = VDInterfaceAdd(&m->vdIfError.Core,
    884870                         "Medium::vdInterfaceError",
    885                          VDINTERFACETYPE_ERROR,
    886                          &m->vdIfCallsError, this, &m->vdDiskIfaces);
     871                         VDINTERFACETYPE_ERROR, this,
     872                         sizeof(VDINTERFACEERROR), &m->vdDiskIfaces);
    887873    AssertRCReturn(vrc, E_FAIL);
    888874
    889875    /* Initialize the per-image interface chain */
    890     vrc = VDInterfaceAdd(&m->vdIfConfig,
     876    vrc = VDInterfaceAdd(&m->vdIfConfig.Core,
    891877                         "Medium::vdInterfaceConfig",
    892                          VDINTERFACETYPE_CONFIG,
    893                          &m->vdIfCallsConfig, this, &m->vdImageIfaces);
     878                         VDINTERFACETYPE_CONFIG, this,
     879                         sizeof(VDINTERFACECONFIG), &m->vdImageIfaces);
    894880    AssertRCReturn(vrc, E_FAIL);
    895881
    896     vrc = VDInterfaceAdd(&m->vdIfTcpNet,
     882    vrc = VDInterfaceAdd(&m->vdIfTcpNet.Core,
    897883                         "Medium::vdInterfaceTcpNet",
    898                          VDINTERFACETYPE_TCPNET,
    899                          &m->vdIfCallsTcpNet, this, &m->vdImageIfaces);
     884                         VDINTERFACETYPE_TCPNET, this,
     885                         sizeof(VDINTERFACETCPNET), &m->vdImageIfaces);
    900886    AssertRCReturn(vrc, E_FAIL);
    901887
     
    49524938                           const ComObjPtr<MediumFormat> &aFormat,
    49534939                           MediumVariant_T aVariant,
    4954                            void *aVDImageIOCallbacks, void *aVDImageIOUser,
     4940                           PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser,
    49554941                           const ComObjPtr<Progress> &aProgress)
    49564942{
     
    49954981        /* setup task object to carry out the operation asynchronously */
    49964982        pTask = new Medium::ExportTask(this, aProgress, aFilename, aFormat,
    4997                                        aVariant, aVDImageIOCallbacks,
     4983                                       aVariant, aVDImageIOIf,
    49984984                                       aVDImageIOUser, pSourceMediumLockList);
    49994985        rc = pTask->rc();
     
    50305016                           const ComObjPtr<MediumFormat> &aFormat,
    50315017                           MediumVariant_T aVariant,
    5032                            void *aVDImageIOCallbacks, void *aVDImageIOUser,
     5018                           PVDINTERFACEIO aVDImageIOIf, void *aVDImageIOUser,
    50335019                           const ComObjPtr<Medium> &aParent,
    50345020                           const ComObjPtr<Progress> &aProgress)
     
    50785064        /* setup task object to carry out the operation asynchronously */
    50795065        pTask = new Medium::ImportTask(this, aProgress, aFilename, aFormat,
    5080                                        aVariant, aVDImageIOCallbacks,
     5066                                       aVariant, aVDImageIOIf,
    50815067                                       aVDImageIOUser, aParent,
    50825068                                       pTargetMediumLockList);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette