VirtualBox

Changeset 64725 in vbox


Ignore:
Timestamp:
Nov 20, 2016 10:33:04 PM (8 years ago)
Author:
vboxsync
Message:

Storage/DrvRamDisk: Fixes

File:
1 edited

Legend:

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

    r64274 r64725  
    177177    /** Flag whether the RAM disk was pre allocated. */
    178178    bool                    fPreallocRamDisk;
     179    /** Flag whether to report a non totating medium. */
     180    bool                    fNonRotational;
    179181    /** AVL tree containing the disk blocks to check. */
    180182    PAVLRFOFFTREE           pTreeSegments;
     
    638640}
    639641
     642/** @interface_method_impl{PDMIMEDIA,pfnIsNonRotational} */
     643static DECLCALLBACK(bool) drvramdiskIsNonRotational(PPDMIMEDIA pInterface)
     644{
     645    PDRVRAMDISK pThis = RT_FROM_MEMBER(pInterface, DRVRAMDISK, IMedia);
     646    return pThis->fNonRotational;
     647}
     648
    640649
    641650/*********************************************************************************************************************************
     
    11321141
    11331142/**
     1143 * @interface_method_impl{PDMIMEDIAEX,pfnQueryFeatures}
     1144 */
     1145static DECLCALLBACK(int) drvramdiskQueryFeatures(PPDMIMEDIAEX pInterface, uint32_t *pfFeatures)
     1146{
     1147    RT_NOREF1(pInterface)
     1148    *pfFeatures = PDMIMEDIAEX_FEATURE_F_ASYNC | PDMIMEDIAEX_FEATURE_F_DISCARD;
     1149    return VINF_SUCCESS;
     1150}
     1151
     1152
     1153/**
    11341154 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqAllocSizeSet}
    11351155 */
     
    12091229    RTMemCacheFree(pThis->hIoReqCache, pIoReq);
    12101230    return VINF_SUCCESS;
     1231}
     1232
     1233/**
     1234 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqQueryResidual}
     1235 */
     1236static DECLCALLBACK(int) drvramdiskIoReqQueryResidual(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, size_t *pcbResidual)
     1237{
     1238    RT_NOREF2(pInterface, hIoReq);
     1239
     1240    *pcbResidual = 0;
     1241    return VINF_SUCCESS;
     1242}
     1243
     1244/**
     1245 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqQueryXferSize}
     1246 */
     1247static DECLCALLBACK(int) drvramdiskIoReqQueryXferSize(PPDMIMEDIAEX pInterface, PDMMEDIAEXIOREQ hIoReq, size_t *pcbXfer)
     1248{
     1249    RT_NOREF1(pInterface);
     1250    PPDMMEDIAEXIOREQINT pIoReq = hIoReq;
     1251
     1252    if (   pIoReq->enmType == PDMMEDIAEXIOREQTYPE_READ
     1253        || pIoReq->enmType == PDMMEDIAEXIOREQTYPE_WRITE)
     1254        *pcbXfer = pIoReq->ReadWrite.cbReq;
     1255    else
     1256        *pcbXfer = 0;
     1257
     1258    return VINF_SUCCESS;
     1259}
     1260
     1261/**
     1262 * @interface_method_impl{PDMIMEDIAEX,pfnIoReqCancelAll}
     1263 */
     1264static DECLCALLBACK(int) drvramdiskIoReqCancelAll(PPDMIMEDIAEX pInterface)
     1265{
     1266    RT_NOREF1(pInterface);
     1267    return VINF_SUCCESS; /** @todo */
    12111268}
    12121269
     
    16001657                                    "PreAlloc\0"
    16011658                                    "IoBufMax\0"
    1602                                     "SectorSize\0"))
     1659                                    "SectorSize\0"
     1660                                    "NonRotational\0"))
    16031661        return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
    16041662
     
    16081666                                N_("RamDisk: Error querying the media size"));
    16091667    rc = CFGMR3QueryBoolDef(pCfg, "PreAlloc", &pThis->fPreallocRamDisk, false);
    1610     AssertRC(rc);
     1668    if (RT_FAILURE(rc))
     1669        return PDMDRV_SET_ERROR(pDrvIns, rc,
     1670                                N_("RamDisk: Error querying \"PreAlloc\""));
     1671    rc = CFGMR3QueryBoolDef(pCfg, "NonRotational", &pThis->fNonRotational, true);
     1672    if (RT_FAILURE(rc))
     1673        return PDMDRV_SET_ERROR(pDrvIns, rc,
     1674                                N_("RamDisk: Error querying \"NonRotational\""));
    16111675    rc = CFGMR3QueryU32Def(pCfg, "IoBufMax", &cbIoBufMax, 5 * _1M);
    16121676    if (RT_FAILURE(rc))
     
    16401704    pThis->IMedia.pfnReadPcBios          = drvramdiskReadPcBios;
    16411705    pThis->IMedia.pfnDiscard             = drvramdiskDiscard;
     1706    pThis->IMedia.pfnIsNonRotational     = drvramdiskIsNonRotational;
    16421707
    16431708    /* IMediaEx */
     1709    pThis->IMediaEx.pfnQueryFeatures            = drvramdiskQueryFeatures;
    16441710    pThis->IMediaEx.pfnIoReqAllocSizeSet        = drvramdiskIoReqAllocSizeSet;
    16451711    pThis->IMediaEx.pfnIoReqAlloc               = drvramdiskIoReqAlloc;
    16461712    pThis->IMediaEx.pfnIoReqFree                = drvramdiskIoReqFree;
     1713    pThis->IMediaEx.pfnIoReqQueryResidual       = drvramdiskIoReqQueryResidual;
     1714    pThis->IMediaEx.pfnIoReqQueryXferSize       = drvramdiskIoReqQueryXferSize;
     1715    pThis->IMediaEx.pfnIoReqCancelAll           = drvramdiskIoReqCancelAll;
    16471716    pThis->IMediaEx.pfnIoReqCancel              = drvramdiskIoReqCancel;
    16481717    pThis->IMediaEx.pfnIoReqRead                = drvramdiskIoReqRead;
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