VirtualBox

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


Ignore:
Timestamp:
Jun 15, 2015 5:14:02 PM (10 years ago)
Author:
vboxsync
Message:

PDM/VSCSI: Added PDMISCSICONNECTOR interface to report LUN type.

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

Legend:

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

    r56292 r56439  
    648648}
    649649
     650/** @copydoc PDMISCSICONNECTOR::pfnQueryLUNType. */
     651static DECLCALLBACK(int) drvscsiQueryLUNType(PPDMISCSICONNECTOR pInterface, uint32_t iLun, PPDMSCSILUNTYPE pLunType)
     652{
     653    int rc;
     654    PDRVSCSI pThis = PDMISCSICONNECTOR_2_DRVSCSI(pInterface);
     655    VSCSILUNTYPE enmLunType;
     656
     657    rc = VSCSIDeviceLunQueryType(pThis->hVScsiDevice, iLun, &enmLunType);
     658    if (RT_FAILURE(rc))
     659        return rc;
     660
     661    switch (enmLunType)
     662    {
     663    case VSCSILUNTYPE_SBC:  *pLunType = PDMSCSILUNTYPE_SBC; break;
     664    case VSCSILUNTYPE_MMC:  *pLunType = PDMSCSILUNTYPE_MMC; break;
     665    case VSCSILUNTYPE_SSC:  *pLunType = PDMSCSILUNTYPE_SSC; break;
     666    default:                *pLunType = PDMSCSILUNTYPE_INVALID;
     667    }
     668
     669    return rc;
     670}
     671
    650672/* -=-=-=-=- IBase -=-=-=-=- */
    651673
     
    892914    pThis->pDrvIns                              = pDrvIns;
    893915    pThis->ISCSIConnector.pfnSCSIRequestSend    = drvscsiRequestSend;
     916    pThis->ISCSIConnector.pfnQueryLUNType       = drvscsiQueryLUNType;
    894917
    895918    pDrvIns->IBase.pfnQueryInterface            = drvscsiQueryInterface;
  • trunk/src/VBox/Devices/Storage/UsbMsd.cpp

    r56393 r56439  
    21712171        pThis->Lun0.pIScsiConnector = NULL;
    21722172    }
     2173
     2174    /*
     2175     * Find out what kind of device we are.
     2176     */
     2177    PDMSCSILUNTYPE enmLunType;
     2178    pThis->fIsCdrom = false;
     2179    rc = pThis->Lun0.pIScsiConnector->pfnQueryLUNType(pThis->Lun0.pIScsiConnector, 0 /*iLun*/, &enmLunType);
     2180    if (RT_SUCCESS(rc))
     2181    {
     2182        /* Anything else will be reported as a hard disk. */
     2183        if (enmLunType == PDMSCSILUNTYPE_MMC)
     2184            pThis->fIsCdrom = true;
     2185    }
     2186
    21732187    return rc;
    21742188}
     
    23182332     * Find out what kind of device we are.
    23192333     */
    2320     pThis->fIsCdrom = false;    //@todo: Find out somehow
     2334    PDMSCSILUNTYPE enmLunType;
     2335    pThis->fIsCdrom = false;
     2336    rc = pThis->Lun0.pIScsiConnector->pfnQueryLUNType(pThis->Lun0.pIScsiConnector, 0 /*iLun*/, &enmLunType);
     2337    if (RT_SUCCESS(rc))
     2338    {
     2339        /* Anything else will be reported as a hard disk. */
     2340        if (enmLunType == PDMSCSILUNTYPE_MMC)
     2341            pThis->fIsCdrom = true;
     2342    }
    23212343
    23222344    /*
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSIDevice.cpp

    r56292 r56439  
    257257
    258258
    259 VBOXDDU_DECL(int) VSCSIDeviceLunGet(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
    260                                     PVSCSILUN phVScsiLun)
    261 {
    262     PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
    263 
    264     /* Parameter checks */
    265     AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
    266     AssertPtrReturn(phVScsiLun, VERR_INVALID_POINTER);
     259VBOXDDU_DECL(int) VSCSIDeviceLunQueryType(VSCSIDEVICE hVScsiDevice, uint32_t iLun,
     260                                          PVSCSILUNTYPE pEnmLunType)
     261{
     262    PVSCSIDEVICEINT pVScsiDevice = (PVSCSIDEVICEINT)hVScsiDevice;
     263
     264    /* Parameter checks */
     265    AssertPtrReturn(pVScsiDevice, VERR_INVALID_HANDLE);
     266    AssertPtrReturn(pEnmLunType, VERR_INVALID_POINTER);
    267267    AssertReturn(iLun < VSCSI_DEVICE_LUN_MAX, VERR_VSCSI_LUN_INVALID);
    268268    AssertReturn(iLun < pVScsiDevice->cLunsMax, VERR_VSCSI_LUN_NOT_ATTACHED);
    269269    AssertPtrReturn(pVScsiDevice->papVScsiLun[iLun], VERR_VSCSI_LUN_NOT_ATTACHED);
    270270
    271     *phVScsiLun = pVScsiDevice->papVScsiLun[iLun];
     271    PVSCSILUNINT hVScsiLun = pVScsiDevice->papVScsiLun[iLun];
     272    *pEnmLunType = hVScsiLun->pVScsiLunDesc->enmLunType;
    272273
    273274    return VINF_SUCCESS;
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