VirtualBox

Changeset 11435 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Aug 14, 2008 6:23:31 PM (16 years ago)
Author:
vboxsync
Message:

Storage: big cleanup of the VD interfaces, especially hide the linked list better.

Location:
trunk/src/VBox/Devices/Storage
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DrvVD.cpp

    r11287 r11435  
    8989    /** Flag whether suspend has changed image open mode to read only. */
    9090    bool               fTempReadOnly;
     91    /** Pointer to list of VD interfaces. */
     92    PVDINTERFACE       pVDIfs;
    9193    /** Common structure for the supported error interface. */
    9294    VDINTERFACE        VDIError;
     
    535537
    536538    /* Initialize supported VD interfaces. */
     539    pThis->pVDIfs = NULL;
     540
    537541    pThis->VDIErrorCallbacks.cbSize       = sizeof(VDINTERFACEERROR);
    538542    pThis->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
    539543    pThis->VDIErrorCallbacks.pfnError     = drvvdErrorCallback;
    540544
    541     rc = VDInterfaceCreate(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
    542                            &pThis->VDIErrorCallbacks, pDrvIns, NULL);
     545    rc = VDInterfaceAdd(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
     546                        &pThis->VDIErrorCallbacks, pDrvIns, &pThis->pVDIfs);
    543547    AssertRC(rc);
    544548
     
    554558    pThis->VDIAsyncIOCallbacks.pfnTasksSubmit          = drvvdAsyncIOTasksSubmit;
    555559
    556     rc = VDInterfaceCreate(&pThis->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO,
    557                            &pThis->VDIAsyncIOCallbacks, pThis, &pThis->VDIError);
     560    rc = VDInterfaceAdd(&pThis->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO,
     561                        &pThis->VDIAsyncIOCallbacks, pThis, &pThis->pVDIfs);
    558562    AssertRC(rc);
    559563
     
    573577     * At the moment this is harmless, as iSCSI can only be used as a base
    574578     * image, and no other backend uses the private data for these callbacks. */
    575     rc = VDInterfaceCreate(&pThis->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
    576                            &pThis->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pThis->VDIAsyncIO);
     579    rc = VDInterfaceAdd(&pThis->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
     580                        &pThis->VDIConfigCallbacks, NULL /**< @todo TEMP */, &pThis->pVDIfs);
    577581    AssertRC(rc);
    578582
  • trunk/src/VBox/Devices/Storage/RawHDDCore.cpp

    r11421 r11435  
    4747    RTFILE          File;
    4848
     49    /** Pointer to list of VD interfaces. */
     50    PVDINTERFACE      pVDIfs;
    4951    /** Error callback. */
    5052    PVDINTERFACE      pInterfaceError;
     
    116118    pImage->uOpenFlags = uOpenFlags;
    117119
     120    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     121    if (pImage->pInterfaceError)
     122        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     123
    118124    /*
    119125     * Open the image.
     
    176182    pImage->LCHSGeometry = *pLCHSGeometry;
    177183
     184    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     185    if (pImage->pInterfaceError)
     186        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     187
    178188    /* Create image file. */
    179189    rc = RTFileOpen(&File, pImage->pszFilename,
     
    320330/** @copydoc VBOXHDDBACKEND::pfnOpen */
    321331static int rawOpen(const char *pszFilename, unsigned uOpenFlags,
    322                    PVDINTERFACE pInterfaces, void **ppBackendData)
     332                   PVDINTERFACE pVDIfs, void **ppBackendData)
    323333{
    324334    LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x ppBackendData=%#p\n", pszFilename, uOpenFlags, ppBackendData));
     
    352362    pImage->pInterfaceError = NULL;
    353363    pImage->pInterfaceErrorCallbacks = NULL;
    354 
    355     pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
    356     if (pImage->pInterfaceError)
    357         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     364    pImage->pVDIfs = pVDIfs;
    358365
    359366    rc = rawOpenImage(pImage, uOpenFlags);
     
    374381                     unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,
    375382                     void *pvUser, unsigned uPercentStart,
    376                      unsigned uPercentSpan, PVDINTERFACE pInterfaces,
     383                     unsigned uPercentSpan, PVDINTERFACE pVDIfs,
    377384                     void **ppBackendData)
    378385{
    379     LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pInterfaces=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pInterfaces, ppBackendData));
     386    LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pVDIfs=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pVDIfs, ppBackendData));
    380387    int rc;
    381388    PRAWIMAGE pImage;
     
    407414    pImage->pszFilename = pszFilename;
    408415    pImage->File = NIL_RTFILE;
    409 
    410     pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
    411     if (pImage->pInterfaceError)
    412         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
    413 
     416    pImage->pVDIfs = pVDIfs;
    414417
    415418    rc = rawCreateImage(pImage, enmType, cbSize, uImageFlags, pszComment,
  • trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp

    r11421 r11435  
    819819            pDisk->pInterfaceErrorCallbacks = NULL;
    820820
    821             pDisk->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
     821            pDisk->pInterfaceError = VDInterfaceGet(pInterfaces, VDINTERFACETYPE_ERROR);
    822822            if (pDisk->pInterfaceError)
    823823                pDisk->pInterfaceErrorCallbacks = VDGetInterfaceError(pDisk->pInterfaceError);
  • trunk/src/VBox/Devices/Storage/VDICore.h

    r10781 r11435  
    579579    /** Physical geometry of this image (never actually stored). */
    580580    PDMMEDIAGEOMETRY        PCHSGeometry;
     581    /** Pointer to list of VD interfaces. */
     582    PVDINTERFACE            pVDIfs;
    581583    /** Error interface. */
    582584    PVDINTERFACE            pInterfaceError;
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r11421 r11435  
    347347    Assert(VALID_PTR(pLCHSGeometry));
    348348
     349    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     350    if (pImage->pInterfaceError)
     351        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     352
    349353    vdiInitPreHeader(&pImage->PreHeader);
    350354    vdiInitHeader(&pImage->Header, enmType, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0);
     
    528532
    529533    pImage->uOpenFlags = uOpenFlags;
     534
     535    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     536    if (pImage->pInterfaceError)
     537        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
    530538
    531539    /*
     
    751759    pImage->pInterfaceError = NULL;
    752760    pImage->pInterfaceErrorCallbacks = NULL;
     761    pImage->pVDIfs = NULL;
    753762
    754763    rc = vdiOpenImage(pImage, VD_OPEN_FLAGS_INFO | VD_OPEN_FLAGS_READONLY);
     
    762771/** @copydoc VBOXHDDBACKEND::pfnOpen */
    763772static int vdiOpen(const char *pszFilename, unsigned uOpenFlags,
    764                    PVDINTERFACE pInterfaces,
    765                    void **ppBackendData)
     773                   PVDINTERFACE pVDIfs, void **ppBackendData)
    766774{
    767775    LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x ppBackendData=%#p\n", pszFilename, uOpenFlags, ppBackendData));
     
    795803    pImage->pInterfaceError = NULL;
    796804    pImage->pInterfaceErrorCallbacks = NULL;
    797 
    798     pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
    799     if (pImage->pInterfaceError)
    800         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     805    pImage->pVDIfs = pVDIfs;
    801806
    802807    rc = vdiOpenImage(pImage, uOpenFlags);
     
    817822                     unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,
    818823                     void *pvUser, unsigned uPercentStart,
    819                      unsigned uPercentSpan, PVDINTERFACE pInterfaces,
     824                     unsigned uPercentSpan, PVDINTERFACE pVDIfs,
    820825                     void **ppBackendData)
    821826{
    822     LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pInterfaces=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pInterfaces, ppBackendData));
     827    LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pVDIfs=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pVDIfs, ppBackendData));
    823828    int rc;
    824829    PVDIIMAGEDESC pImage;
     
    855860    pImage->pInterfaceError = NULL;
    856861    pImage->pInterfaceErrorCallbacks = NULL;
     862    pImage->pVDIfs = pVDIfs;
    857863
    858864    rc = vdiCreateImage(pImage, enmType, cbSize, uImageFlags, pszComment,
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r11421 r11435  
    359359    PVMDKFILE        pFile;
    360360
     361    /** Pointer to list of VD interfaces. */
     362    PVDINTERFACE     pVDIfs;
     363
    361364    /** Error interface. */
    362365    PVDINTERFACE      pInterfaceError;
     
    23262329    pImage->uOpenFlags = uOpenFlags;
    23272330
     2331    /* Try to get error interface. */
     2332    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     2333    if (pImage->pInterfaceError)
     2334        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     2335
     2336    /* Try to get async I/O interface. */
     2337    pImage->pInterfaceAsyncIO = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ASYNCIO);
     2338    if (pImage->pInterfaceAsyncIO)
     2339        pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO);
     2340
    23282341    /*
    23292342     * Open the image.
     
    31133126
    31143127    pImage->uImageFlags = uImageFlags;
     3128
     3129    /* Try to get error interface. */
     3130    pImage->pInterfaceError = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ERROR);
     3131    if (pImage->pInterfaceError)
     3132        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
     3133
     3134    /* Try to get async I/O interface. */
     3135    pImage->pInterfaceAsyncIO = VDInterfaceGet(pImage->pVDIfs, VDINTERFACETYPE_ASYNCIO);
     3136    if (pImage->pInterfaceAsyncIO)
     3137        pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO);
     3138
    31153139    rc = vmdkCreateDescriptor(pImage, pImage->pDescData, pImage->cbDescAlloc,
    31163140                              &pImage->Descriptor);
     
    36783702    pImage->pInterfaceError = NULL;
    36793703    pImage->pInterfaceErrorCallbacks = NULL;
     3704    pImage->pInterfaceAsyncIO = NULL;
     3705    pImage->pInterfaceAsyncIOCallbacks = NULL;
     3706    pImage->pVDIfs = NULL;
    36803707    /** @todo speed up this test open (VD_OPEN_FLAGS_INFO) by skipping as
    36813708     * much as possible in vmdkOpenImage. */
     
    36903717/** @copydoc VBOXHDDBACKEND::pfnOpen */
    36913718static int vmdkOpen(const char *pszFilename, unsigned uOpenFlags,
    3692                     PVDINTERFACE pInterfaces,
    3693                     void **ppBackendData)
     3719                    PVDINTERFACE pVDIfs, void **ppBackendData)
    36943720{
    36953721    LogFlowFunc(("pszFilename=\"%s\" uOpenFlags=%#x ppBackendData=%#p\n", pszFilename, uOpenFlags, ppBackendData));
     
    37283754    pImage->pInterfaceError = NULL;
    37293755    pImage->pInterfaceErrorCallbacks = NULL;
    3730 
    3731     /* Try to get error interface. */
    3732     pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
    3733     if (pImage->pInterfaceError)
    3734         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
    3735 
    3736     /* Try to get async I/O interface. */
    3737     pImage->pInterfaceAsyncIO = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ASYNCIO);
    3738     if (pImage->pInterfaceAsyncIO)
    3739         pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO);
    3740 
     3756    pImage->pInterfaceAsyncIO = NULL;
     3757    pImage->pInterfaceAsyncIOCallbacks = NULL;
     3758    pImage->pVDIfs = NULL;
    37413759
    37423760    rc = vmdkOpenImage(pImage, uOpenFlags);
     
    37573775                      unsigned uOpenFlags, PFNVMPROGRESS pfnProgress,
    37583776                      void *pvUser, unsigned uPercentStart,
    3759                       unsigned uPercentSpan, PVDINTERFACE pInterfaces,
     3777                      unsigned uPercentSpan, PVDINTERFACE pVDIfs,
    37603778                      void **ppBackendData)
    37613779{
    3762     LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pInterfaces=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pInterfaces, ppBackendData));
     3780    LogFlowFunc(("pszFilename=\"%s\" enmType=%d cbSize=%llu uImageFlags=%#x pszComment=\"%s\" pPCHSGeometry=%#p pLCHSGeometry=%#p Uuid=%RTuuid uOpenFlags=%#x pfnProgress=%#p pvUser=%#p uPercentStart=%u uPercentSpan=%u pVDIfs=%#p ppBackendData=%#p", pszFilename, enmType, cbSize, uImageFlags, pszComment, pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags, pfnProgress, pvUser, uPercentStart, uPercentSpan, pVDIfs, ppBackendData));
    37633781    int rc;
    37643782    PVMDKIMAGE pImage;
     
    38013819    pImage->pInterfaceError = NULL;
    38023820    pImage->pInterfaceErrorCallbacks = NULL;
     3821    pImage->pInterfaceAsyncIO = NULL;
     3822    pImage->pInterfaceAsyncIOCallbacks = NULL;
     3823    pImage->pVDIfs = NULL;
    38033824    pImage->cbDescAlloc = VMDK_SECTOR2BYTE(20);
    38043825    pImage->pDescData = (char *)RTMemAllocZ(pImage->cbDescAlloc);
     
    38083829        goto out;
    38093830    }
    3810 
    3811     /* Get error interface. */
    3812     pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR);
    3813     if (pImage->pInterfaceError)
    3814         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError);
    38153831
    38163832    rc = vmdkCreateImage(pImage, enmType, cbSize, uImageFlags, pszComment,
  • trunk/src/VBox/Devices/Storage/testcase/tstVD.cpp

    r11353 r11435  
    5656    PDMMEDIAGEOMETRY PCHS = { 0, 0, 0 };
    5757    PDMMEDIAGEOMETRY LCHS = { 0, 0, 0 };
     58    PVDINTERFACE     pVDIfs = NULL;
    5859    VDINTERFACE      VDIError;
    5960    VDINTERFACEERROR VDIErrorCallbacks;
     
    7576    VDIErrorCallbacks.pfnError = tstVDError;
    7677
    77     rc = VDInterfaceCreate(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
    78                            NULL, NULL);
     78    rc = VDInterfaceAdd(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
     79                        NULL, &pVDIfs);
    7980    AssertRC(rc);
    8081
     
    431432    uint64_t u64DiskSize  = 1000 * _1M;
    432433    uint32_t u32SectorSize = 512;
     434    PVDINTERFACE     pVDIfs = NULL;
    433435    VDINTERFACE      VDIError;
    434436    VDINTERFACEERROR VDIErrorCallbacks;
     
    450452    VDIErrorCallbacks.pfnError = tstVDError;
    451453
    452     rc = VDInterfaceCreate(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
    453                            NULL, NULL);
     454    rc = VDInterfaceAdd(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
     455                        NULL, &pVDIfs);
    454456    AssertRC(rc);
    455457
     
    549551    uint64_t u64DiskSize  = 1000 * _1M;
    550552    uint32_t u32SectorSize = 512;
     553    PVDINTERFACE     pVDIfs;
    551554    VDINTERFACE      VDIError;
    552555    VDINTERFACEERROR VDIErrorCallbacks;
     
    568571    VDIErrorCallbacks.pfnError = tstVDError;
    569572
    570     rc = VDInterfaceCreate(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
    571                            NULL, NULL);
     573    rc = VDInterfaceAdd(&VDIError, "tstVD_Error", VDINTERFACETYPE_ERROR, &VDIErrorCallbacks,
     574                        NULL, &pVDIfs);
    572575    AssertRC(rc);
    573576
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