- Timestamp:
- Nov 24, 2019 5:44:12 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r82056 r82145 1127 1127 */ 1128 1128 1129 if (RT_LIKELY(!fBadLUNFormat 1130 && (uTarget < pThis->cTargets 1131 && pThisCC->paTargetInstances[uTarget].fPresent 1132 && pThisCC->paTargetInstances[uTarget].pDrvMediaEx))) 1129 if (RT_LIKELY(!fBadLUNFormat)) 1133 1130 { /* likely */ } 1134 1131 else 1135 1132 { 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)); 1137 1151 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 }; 1139 1154 REQ_RESP_HDR_T respHdr = { 0 }; 1140 1155 respHdr.cbSenseLen = sizeof(abSense); 1141 1156 respHdr.uStatus = SCSI_STATUS_CHECK_CONDITION; 1142 1157 respHdr.uResponse = VIRTIOSCSI_S_BAD_TARGET; 1143 respHdr.uResidual = cbData In + cbDataOut;1144 virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr 1158 respHdr.uResidual = cbDataOut + cbDataIn; 1159 virtioScsiR3ReqErr(pDevIns, pThis, pThisCC, qIdx, pDescChain, &respHdr, abSense); 1145 1160 RTMemFree(pVirtqReq); 1146 1161 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 } 1164 1164 if (RT_LIKELY(uScsiLun == 0)) 1165 1165 { /* likely */ } … … 1176 1176 respHdr.uResidual = cbDataOut + cbDataIn; 1177 1177 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); 1178 1192 RTMemFree(pVirtqReq); 1179 1193 return VINF_SUCCESS; … … 1962 1976 PVIRTIOSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC); 1963 1977 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 1978 1964 1979 LogFunc(("LOAD EXEC!!\n")); 1965 1980 … … 1971 1986 for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++) 1972 1987 pHlp->pfnSSMGetBool(pSSM, &pThis->afQueueAttached[qIdx]); 1973 1974 1988 1975 1989 pHlp->pfnSSMGetU32(pSSM, &pThis->virtioScsiConfig.uNumQueues); … … 1996 2010 pHlp->pfnSSMGetU32(pSSM, &pThis->cTargets); 1997 2011 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 } 2021 2034 } 2022 2035 … … 2049 2062 PVIRTIOSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC); 2050 2063 PCPDMDEVHLPR3 pHlp = pDevIns->pHlpR3; 2064 2051 2065 LogFunc(("SAVE EXEC!!\n")); 2052 2066 … … 2073 2087 pHlp->pfnSSMPutU32(pSSM, pThis->fResetting); 2074 2088 2075 /* Save suspended I/O requests */2076 2077 2078 2089 /** @todo Ask aeichner about BIOS-related changes */ 2079 2090 … … 2084 2095 for (uint16_t uTarget = 0; uTarget < pThis->cTargets; uTarget++) 2085 2096 { 2086 2087 2097 PVIRTIOSCSITARGET pTarget = &pThisCC->paTargetInstances[uTarget]; 2088 2098 … … 2091 2101 { 2092 2102 uint32_t cReqsRedo = pTarget->pDrvMediaEx->pfnIoReqGetSuspendedCount(pTarget->pDrvMediaEx); 2093 LogFunc(("Saving redo reqs target=%d, cReqsRedo=%d\n", uTarget, cReqsRedo));2094 2103 2095 2104 pHlp->pfnSSMPutU16(pSSM, cReqsRedo); … … 2106 2115 while(--cReqsRedo) 2107 2116 { 2108 LogFunc((" redo req: qIdx=%d, headIdx=%d\n", pReq->qIdx, pReq->pDescChain->uHeadIdx));2109 2110 2117 pHlp->pfnSSMPutU16(pSSM, pReq->qIdx); 2111 2118 pHlp->pfnSSMPutU16(pSSM, pReq->pDescChain->uHeadIdx); … … 2236 2243 virtioCoreGetStateChangeText(pThisCC->enmQuiescingFor))); 2237 2244 2238 virtioCoreR3VmStateChanged( pDevIns,&pThis->Virtio, pThisCC->enmQuiescingFor);2245 virtioCoreR3VmStateChanged(&pThis->Virtio, pThisCC->enmQuiescingFor); 2239 2246 2240 2247 pThis->fResetting = false; … … 2283 2290 PVIRTIOSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PVIRTIOSCSI); 2284 2291 PVIRTIOSCSICC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PVIRTIOSCSICC); 2285 2286 virtioScsiR3QuiesceDevice(pDevIns, enmType);2287 2292 2288 2293 /* VM is halted, thus no new I/O being dumped into queues by the guest. … … 2298 2303 pTarget->pDrvMediaEx->pfnNotifySuspend(pTarget->pDrvMediaEx); 2299 2304 } 2305 2306 virtioScsiR3QuiesceDevice(pDevIns, enmType); 2300 2307 } 2301 2308 … … 2343 2350 } 2344 2351 /* Ensure guest is working the queues too. */ 2345 virtioCoreR3VmStateChanged( pDevIns,&pThis->Virtio, kvirtIoVmStateChangedResume);2352 virtioCoreR3VmStateChanged(&pThis->Virtio, kvirtIoVmStateChangedResume); 2346 2353 } 2347 2354 -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.cpp
r82055 r82145 1598 1598 pHlp->pfnSSMGetU64(pSSM, &pVirtio->uDriverFeatures); 1599 1599 1600 for (uint32_t i dxQueue = 0; idxQueue < VIRTQ_MAX_CNT; idxQueue++)1601 { 1602 pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueDesc[i dxQueue]);1603 pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueAvail[i dxQueue]);1604 pHlp->pfnSSMGetGCPhys64(pSSM, &pVirtio->aGCPhysQueueUsed[i dxQueue]);1605 pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueNotifyOff[i dxQueue]);1606 pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueMsixVector[i dxQueue]);1607 pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueEnable[i dxQueue]);1608 pHlp->pfnSSMGetU16(pSSM, &pVirtio->uQueueSize[i dxQueue]);1609 pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[i dxQueue].uAvailIdx);1610 pHlp->pfnSSMGetU16(pSSM, &pVirtio->virtqState[i dxQueue].uUsedIdx);1611 rc = pHlp->pfnSSMGetMem(pSSM, pVirtio->virtqState[i dxQueue].szVirtqName,1612 sizeof(pVirtio->virtqState[i dxQueue].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)); 1613 1613 AssertRCReturn(rc, rc); 1614 1614 } … … 1623 1623 1624 1624 /** 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) 1626 1628 * 1627 1629 * @param pDevIns The device instance. 1628 1630 * @param pVirtio Pointer to the shared virtio state. 1629 1631 */ 1630 void virtioCoreR3VmStateChanged(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState) 1631 { 1632 1632 void virtioCoreR3VmStateChanged(PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState) 1633 { 1633 1634 LogFunc(("State changing to %s\n", 1634 1635 virtioCoreGetStateChangeText(enmState))); … … 1650 1651 return; 1651 1652 } 1652 RT_NOREF(pDevIns, pVirtio);1653 1653 } 1654 1654 -
trunk/src/VBox/Devices/VirtIO/Virtio_1_0.h
r82004 r82145 474 474 int virtioCoreR3SaveExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM); 475 475 int virtioCoreR3LoadExec(PVIRTIOCORE pVirtio, PCPDMDEVHLPR3 pHlp, PSSMHANDLE pSSM); 476 void virtioCoreR3VmStateChanged(P PDMDEVINS pDevIns, PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState);476 void virtioCoreR3VmStateChanged(PVIRTIOCORE pVirtio, VIRTIOVMSTATECHANGED enmState); 477 477 void virtioCoreR3Term(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC); 478 478 int virtioCoreR3Init(PPDMDEVINS pDevIns, PVIRTIOCORE pVirtio, PVIRTIOCORECC pVirtioCC, PVIRTIOPCIPARAMS pPciParams,
Note:
See TracChangeset
for help on using the changeset viewer.