VirtualBox

Changeset 82145 in vbox for trunk/src


Ignore:
Timestamp:
Nov 24, 2019 5:44:12 AM (5 years ago)
Author:
vboxsync
Message:

Storage/DevVirtioSCSI.cpp: Fixed problem with scsi offline errors on Linux guest. Fixed bug in save/load exec.

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

Legend:

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

    r82056 r82145  
    11271127     */
    11281128
    1129     if (RT_LIKELY(!fBadLUNFormat
    1130                   && (uTarget < pThis->cTargets
    1131                   &&  pThisCC->paTargetInstances[uTarget].fPresent
    1132                   &&  pThisCC->paTargetInstances[uTarget].pDrvMediaEx)))
     1129    if (RT_LIKELY(!fBadLUNFormat))
    11331130    { /*  likely */ }
    11341131    else
    11351132    {
    1136         Log2Func(("Error submitting request, target not present!!\n"));
     1133        Log2Func(("Error submitting request, bad LUN format\n"));
     1134        REQ_RESP_HDR_T respHdr = { 0 };
     1135        respHdr.cbSenseLen = 0;
     1136        respHdr.uStatus    = 0;
     1137        respHdr.uResponse  = VIRTIOSCSI_S_FAILURE;
     1138        respHdr.uResidual  = cbDataIn + cbDataOut;
     1139        virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr , NULL);
     1140        RTMemFree(pVirtqReq);
     1141        return VINF_SUCCESS;
     1142    }
     1143
     1144    if (RT_LIKELY(uTarget < pThis->cTargets
     1145                  &&  pThisCC->paTargetInstances[uTarget].fPresent
     1146                  &&  pThisCC->paTargetInstances[uTarget].pDrvMediaEx))
     1147    { /*  likely */ }
     1148    else
     1149    {
     1150        Log2Func(("Error submitting request to bad target (%d) or bad LUN (%d)\n", uTarget, uScsiLun));
    11371151        uint8_t abSense[] = { RT_BIT(7) | SCSI_SENSE_RESPONSE_CODE_CURR_FIXED,
    1138                               0, SCSI_SENSE_NOT_READY, 0, 0, 0, 0, 10, 0, 0, 0 };
     1152                              0, SCSI_SENSE_ILLEGAL_REQUEST,
     1153                              0, 0, 0, 0, 10, SCSI_ASC_LOGICAL_UNIT_NOT_SUPPORTED, 0, 0 };
    11391154        REQ_RESP_HDR_T respHdr = { 0 };
    11401155        respHdr.cbSenseLen = sizeof(abSense);
    11411156        respHdr.uStatus    = SCSI_STATUS_CHECK_CONDITION;
    11421157        respHdr.uResponse  = VIRTIOSCSI_S_BAD_TARGET;
    1143         respHdr.uResidual  = cbDataIn + cbDataOut;
    1144         virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr , abSense);
     1158        respHdr.uResidual  = cbDataOut + cbDataIn;
     1159        virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr, abSense);
    11451160        RTMemFree(pVirtqReq);
    11461161        return VINF_SUCCESS;
    1147     }
    1148 
    1149     if (RT_LIKELY(!pThis->fResetting))
    1150     { /*  likely */ }
    1151     else
    1152     {
    1153         Log2Func(("Aborting req submission because reset is in progress\n"));
    1154         REQ_RESP_HDR_T respHdr = { 0 };
    1155         respHdr.cbSenseLen = 0;
    1156         respHdr.uStatus    = SCSI_STATUS_OK;
    1157         respHdr.uResponse  = VIRTIOSCSI_S_RESET;
    1158         respHdr.uResidual  = cbDataIn + cbDataOut;
    1159         virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr, NULL);
    1160         RTMemFree(pVirtqReq);
    1161         return VINF_SUCCESS;
    1162     }
    1163 
     1162
     1163    }
    11641164    if (RT_LIKELY(uScsiLun == 0))
    11651165    { /*  likely */ }
     
    11761176        respHdr.uResidual  = cbDataOut + cbDataIn;
    11771177        virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr, abSense);
     1178        RTMemFree(pVirtqReq);
     1179        return VINF_SUCCESS;
     1180    }
     1181    if (RT_LIKELY(!pThis->fResetting))
     1182    { /*  likely */ }
     1183    else
     1184    {
     1185        Log2Func(("Aborting req submission because reset is in progress\n"));
     1186        REQ_RESP_HDR_T respHdr = { 0 };
     1187        respHdr.cbSenseLen = 0;
     1188        respHdr.uStatus    = SCSI_STATUS_OK;
     1189        respHdr.uResponse  = VIRTIOSCSI_S_RESET;
     1190        respHdr.uResidual  = cbDataIn + cbDataOut;
     1191        virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr, NULL);
    11781192        RTMemFree(pVirtqReq);
    11791193        return VINF_SUCCESS;
     
    19621976    PVIRTIOSCSICC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC);
    19631977    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     1978
    19641979    LogFunc(("LOAD EXEC!!\n"));
    19651980
     
    19711986    for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    19721987        pHlp->pfnSSMGetBool(pSSM, &pThis->afQueueAttached[qIdx]);
    1973 
    19741988
    19751989    pHlp->pfnSSMGetU32(pSSM,  &pThis->virtioScsiConfig.uNumQueues);
     
    19962010    pHlp->pfnSSMGetU32(pSSM, &pThis->cTargets);
    19972011
    1998 
    1999     uint16_t cReqsRedo;
    2000     pHlp->pfnSSMGetU16(pSSM, &cReqsRedo);
    2001 
    2002     for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    2003     {
    2004         PVIRTIOSCSIWORKERR3 pWorkerR3 = &pThisCC->aWorkers[qIdx];
    2005         pWorkerR3->cRedoDescs = 0;
    2006     }
    2007 
    2008 LogFunc(("Have %d redo reqs to load\n", cReqsRedo));
    2009 
    2010     for (int i = 0; i < cReqsRedo; i++)
    2011     {
    2012         uint16_t qIdx, uHeadIdx;
    2013 
    2014         pHlp->pfnSSMGetU16(pSSM, &qIdx);
    2015         pHlp->pfnSSMGetU16(pSSM, &uHeadIdx);
    2016 LogFunc(("    loaded redo req: qIdx=%d, headIdx=%d\n", qIdx, uHeadIdx));
    2017 
    2018         PVIRTIOSCSIWORKERR3 pWorkerR3 = &pThisCC->aWorkers[qIdx];
    2019         pWorkerR3->auRedoDescs[pWorkerR3->cRedoDescs++] = uHeadIdx;
    2020         pWorkerR3->cRedoDescs %= VIRTQ_MAX_SIZE;
     2012    for (uint16_t uTarget = 0; uTarget < pThis->cTargets; uTarget++)
     2013    {
     2014        uint16_t cReqsRedo;
     2015        pHlp->pfnSSMGetU16(pSSM, &cReqsRedo);
     2016
     2017        for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
     2018        {
     2019            PVIRTIOSCSIWORKERR3 pWorkerR3 = &pThisCC->aWorkers[qIdx];
     2020            pWorkerR3->cRedoDescs = 0;
     2021        }
     2022
     2023        for (int i = 0; i < cReqsRedo; i++)
     2024        {
     2025            uint16_t qIdx, uHeadIdx;
     2026
     2027            pHlp->pfnSSMGetU16(pSSM, &qIdx);
     2028            pHlp->pfnSSMGetU16(pSSM, &uHeadIdx);
     2029
     2030            PVIRTIOSCSIWORKERR3 pWorkerR3 = &pThisCC->aWorkers[qIdx];
     2031            pWorkerR3->auRedoDescs[pWorkerR3->cRedoDescs++] = uHeadIdx;
     2032            pWorkerR3->cRedoDescs %= VIRTQ_MAX_SIZE;
     2033        }
    20212034    }
    20222035
     
    20492062    PVIRTIOSCSICC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC);
    20502063    PCPDMDEVHLPR3   pHlp    = pDevIns->pHlpR3;
     2064
    20512065    LogFunc(("SAVE EXEC!!\n"));
    20522066
     
    20732087    pHlp->pfnSSMPutU32(pSSM,  pThis->fResetting);
    20742088
    2075     /* Save suspended I/O requests */
    2076 
    2077 
    20782089    /** @todo Ask aeichner about BIOS-related changes */
    20792090
     
    20842095     for (uint16_t uTarget = 0; uTarget < pThis->cTargets; uTarget++)
    20852096     {
    2086 
    20872097        PVIRTIOSCSITARGET pTarget = &pThisCC->paTargetInstances[uTarget];
    20882098
     
    20912101         {
    20922102             uint32_t cReqsRedo = pTarget->pDrvMediaEx->pfnIoReqGetSuspendedCount(pTarget->pDrvMediaEx);
    2093 LogFunc(("Saving redo reqs target=%d, cReqsRedo=%d\n", uTarget, cReqsRedo));
    20942103
    20952104             pHlp->pfnSSMPutU16(pSSM, cReqsRedo);
     
    21062115                 while(--cReqsRedo)
    21072116                 {
    2108 LogFunc(("     redo req: qIdx=%d, headIdx=%d\n", pReq->qIdx, pReq->pDescChain->uHeadIdx));
    2109 
    21102117                    pHlp->pfnSSMPutU16(pSSM, pReq->qIdx);
    21112118                    pHlp->pfnSSMPutU16(pSSM, pReq->pDescChain->uHeadIdx);
     
    22362243        virtioCoreGetStateChangeText(pThisCC->enmQuiescingFor)));
    22372244
    2238     virtioCoreR3VmStateChanged(pDevIns, &pThis->Virtio, pThisCC->enmQuiescingFor);
     2245    virtioCoreR3VmStateChanged(&pThis->Virtio, pThisCC->enmQuiescingFor);
    22392246
    22402247    pThis->fResetting = false;
     
    22832290    PVIRTIOSCSI     pThis   = PDMDEVINS_2_DATA(pDevIns, PVIRTIOSCSI);
    22842291    PVIRTIOSCSICC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC);
    2285 
    2286     virtioScsiR3QuiesceDevice(pDevIns, enmType);
    22872292
    22882293    /* VM is halted, thus no new I/O being dumped into queues by the guest.
     
    22982303            pTarget->pDrvMediaEx->pfnNotifySuspend(pTarget->pDrvMediaEx);
    22992304    }
     2305
     2306    virtioScsiR3QuiesceDevice(pDevIns, enmType);
    23002307}
    23012308
     
    23432350    }
    23442351    /* Ensure guest is working the queues too. */
    2345     virtioCoreR3VmStateChanged(pDevIns, &pThis->Virtio, kvirtIoVmStateChangedResume);
     2352    virtioCoreR3VmStateChanged(&pThis->Virtio, kvirtIoVmStateChangedResume);
    23462353}
    23472354
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp

    r82055 r82145  
    15981598    pHlp->pfnSSMGetU64(pSSM,  &pVirtio->uDriverFeatures);
    15991599
    1600     for (uint32_t idxQueue = 0; idxQueue < VIRTQ_MAX_CNT; idxQueue++)
    1601     {
    1602         pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueDesc[idxQueue]);
    1603         pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueAvail[idxQueue]);
    1604         pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueUsed[idxQueue]);
    1605         pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueNotifyOff[idxQueue]);
    1606         pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueMsixVector[idxQueue]);
    1607         pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueEnable[idxQueue]);
    1608         pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueSize[idxQueue]);
    1609         pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[idxQueue].uAvailIdx);
    1610         pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[idxQueue].uUsedIdx);
    1611         rc = pHlp->pfnSSMGetMem(pSSM, pVirtio->virtqState[idxQueue].szVirtqName,
    1612                                 sizeof(pVirtio->virtqState[idxQueue].szVirtqName));
     1600    for (uint32_t i = 0; i < VIRTQ_MAX_CNT; i++)
     1601    {
     1602        pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueDesc[i]);
     1603        pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueAvail[i]);
     1604        pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueUsed[i]);
     1605        pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueNotifyOff[i]);
     1606        pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueMsixVector[i]);
     1607        pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueEnable[i]);
     1608        pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueSize[i]);
     1609        pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[i].uAvailIdx);
     1610        pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[i].uUsedIdx);
     1611        rc = pHlp->pfnSSMGetMem(pSSM, pVirtio->virtqState[i].szVirtqName,
     1612                                sizeof(pVirtio->virtqState[i].szVirtqName));
    16131613        AssertRCReturn(rc, rc);
    16141614    }
     
    16231623
    16241624/**
    1625  * This should be called from PDMDEVREGR3::pfnReset.
     1625 * This must be called by the client to handle VM state changes
     1626 * after the client takes care of its device-specific tasks for the state change.
     1627 * (i.e. Reset, suspend, power-off, resume)
    16261628 *
    16271629 * @param   pDevIns     The device instance.
    16281630 * @param   pVirtio     Pointer to the shared virtio state.
    16291631 */
    1630 void virtioCoreR3VmStateChanged(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState)
    1631 {
    1632 
     1632void virtioCoreR3VmStateChanged(PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState)
     1633{
    16331634    LogFunc(("State changing to %s\n",
    16341635        virtioCoreGetStateChangeText(enmState)));
     
    16501651            return;
    16511652    }
    1652     RT_NOREF(pDevIns, pVirtio);
    16531653}
    16541654
  • trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h

    r82004 r82145  
    474474int      virtioCoreR3SaveExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
    475475int      virtioCoreR3LoadExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM);
    476 void     virtioCoreR3VmStateChanged(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState);
     476void     virtioCoreR3VmStateChanged(PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState);
    477477void     virtioCoreR3Term(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC);
    478478int      virtioCoreR3Init(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
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