VirtualBox

Changeset 67841 in vbox


Ignore:
Timestamp:
Jul 6, 2017 4:57:59 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116778
Message:

Devices/Storage: Don't prevent VM startup with an empty host DVD drive when attached to the VM

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

Legend:

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

    r66193 r67841  
    343343static DECLCALLBACK(uint32_t) drvHostBaseGetRegionCount(PPDMIMEDIA pInterface)
    344344{
    345     RT_NOREF1(pInterface);
     345    PDRVHOSTBASE pThis = RT_FROM_MEMBER(pInterface, DRVHOSTBASE, IMedia);
    346346
    347347    LogFlowFunc(("\n"));
    348     uint32_t cRegions = 1;
     348    uint32_t cRegions = pThis->fMediaPresent ? 1 : 0;
    349349
    350350    /* For now just return one region for all devices. */
     
    364364    PDRVHOSTBASE pThis = RT_FROM_MEMBER(pInterface, DRVHOSTBASE, IMedia);
    365365
    366     if (uRegion < 1)
     366    if (uRegion < 1 && pThis->fMediaPresent)
    367367    {
    368368        uint64_t cbMedia;
     
    414414        && u64LbaStart < cbMedia / cbBlock)
    415415    {
    416         rc = VERR_NOT_FOUND;
    417 
    418416        if (puRegion)
    419417            *puRegion = 0;
  • trunk/src/VBox/Devices/Storage/VSCSI/VSCSILunMmc.cpp

    r66955 r67841  
    165165        int rc = vscsiLunMediumQueryRegionProperties(pVScsiLun, iTrack - 1, &uLbaStart,
    166166                                                     NULL, NULL, &enmDataForm);
    167         AssertRC(rc);
     167        if (rc == VERR_NOT_FOUND || rc == VERR_MEDIA_NOT_PRESENT)
     168             return vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_NOT_READY,
     169                                             SCSI_ASC_MEDIUM_NOT_PRESENT, 0x00);
     170        else
     171            AssertRC(rc);
    168172
    169173        *q++ = 0;                  /* reserved */
     
    201205    int rc = vscsiLunMediumQueryRegionProperties(pVScsiLun, cTracks - 1, &uLbaStart,
    202206                                                 &cBlocks, NULL, NULL);
    203     AssertRC(rc);
     207    if (rc == VERR_NOT_FOUND || rc == VERR_MEDIA_NOT_PRESENT)
     208         return vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_NOT_READY,
     209                                         SCSI_ASC_MEDIUM_NOT_PRESENT, 0x00);
     210    else
     211        AssertRC(rc);
    204212
    205213    uLbaStart += cBlocks;
     
    241249    int rc = vscsiLunMediumQueryRegionProperties(pVScsiLun, 0, NULL,
    242250                                                 NULL, NULL, &enmDataForm);
    243     AssertRC(rc);
     251    if (rc == VERR_NOT_FOUND || rc == VERR_MEDIA_NOT_PRESENT)
     252         return vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_NOT_READY,
     253                                         SCSI_ASC_MEDIUM_NOT_PRESENT, 0x00);
     254    else
     255        AssertRC(rc);
    244256
    245257    if (enmDataForm == VDREGIONDATAFORM_CDDA)
     
    9951007
    9961008    uint32_t cTracks = vscsiLunMediumGetRegionCount(pVScsiLun);
    997     for (uint32_t i = 0; i < cTracks; i++)
    998     {
    999         uint64_t cBlocks = 0;
    1000         rc = vscsiLunMediumQueryRegionProperties(pVScsiLun, i, NULL, &cBlocks,
    1001                                                  NULL, NULL);
    1002         AssertRC(rc);
    1003 
    1004         pVScsiLunMmc->cSectors += cBlocks;
     1009    if (cTracks)
     1010    {
     1011        for (uint32_t i = 0; i < cTracks; i++)
     1012        {
     1013            uint64_t cBlocks = 0;
     1014            rc = vscsiLunMediumQueryRegionProperties(pVScsiLun, i, NULL, &cBlocks,
     1015                                                     NULL, NULL);
     1016            AssertRC(rc);
     1017
     1018            pVScsiLunMmc->cSectors += cBlocks;
     1019        }
     1020
     1021        pVScsiLunMmc->Core.fMediaPresent = true;
     1022        pVScsiLunMmc->Core.fReady = false;
     1023    }
     1024    else
     1025    {
     1026        pVScsiLunMmc->Core.fMediaPresent = false;
     1027        pVScsiLunMmc->Core.fReady = false;
    10051028    }
    10061029
     
    16041627            rc = vscsiLunMediumQueryRegionPropertiesForLba(pVScsiLun, uLbaStart,
    16051628                                                           NULL, NULL, NULL, &enmDataForm);
    1606             AssertRC(rc);
    1607             if (   enmDataForm != VDREGIONDATAFORM_MODE1_2048
    1608                 && enmDataForm != VDREGIONDATAFORM_MODE1_2352
    1609                 && enmDataForm != VDREGIONDATAFORM_MODE2_2336
    1610                 && enmDataForm != VDREGIONDATAFORM_MODE2_2352
    1611                 && enmDataForm != VDREGIONDATAFORM_RAW
    1612                 && cbSector == _2K)
     1629            if (RT_FAILURE(rc))
     1630            {
     1631                rcReq = vscsiLunReqSenseErrorSet(pVScsiLun, pVScsiReq, SCSI_SENSE_ILLEGAL_REQUEST, SCSI_ASC_LOGICAL_BLOCK_OOR, 0x00);
     1632                vscsiDeviceReqComplete(pVScsiLun->pVScsiDevice, pVScsiReq, rcReq, false, VINF_SUCCESS);
     1633            }
     1634            else if (   enmDataForm != VDREGIONDATAFORM_MODE1_2048
     1635                     && enmDataForm != VDREGIONDATAFORM_MODE1_2352
     1636                     && enmDataForm != VDREGIONDATAFORM_MODE2_2336
     1637                     && enmDataForm != VDREGIONDATAFORM_MODE2_2352
     1638                     && enmDataForm != VDREGIONDATAFORM_RAW
     1639                     && cbSector == _2K)
    16131640            {
    16141641                rcReq = vscsiLunReqSenseErrorInfoSet(pVScsiLun, pVScsiReq,
     
    16911718    ASMAtomicWriteU32((volatile uint32_t *)&pVScsiLunMmc->MediaEventStatus, MMCEVENTSTATUSTYPE_MEDIA_REMOVED);
    16921719    ASMAtomicXchgU32(&pVScsiLunMmc->u32MediaTrackType, MMC_MEDIA_TYPE_NO_DISC);
     1720    pVScsiLunMmc->cSectors = 0;
    16931721    return VINF_SUCCESS;
    16941722}
Note: See TracChangeset for help on using the changeset viewer.

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