Changeset 83573 in vbox for trunk/src/VBox/Devices/Storage
- Timestamp:
- Apr 5, 2020 10:16:38 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevVirtioSCSI.cpp
r83572 r83573 665 665 static int virtioScsiR3SendEvent(PPDMDEVINS pDevIns, PVIRTIOSCSI pThis, uint16_t uTarget, uint32_t uEventType, uint32_t uReason) 666 666 { 667 VIRTIOSCSI_EVENT_T event;668 event.uEvent = uEventType;669 event.uReason = uReason;670 event.abVirtioLun[0] = 1;671 event.abVirtioLun[1] = uTarget;672 event.abVirtioLun[2] = (LUN0 >> 8) & 0x40;673 event.abVirtioLun[3] = LUN0 & 0xff;674 event.abVirtioLun[4] = event.abVirtioLun[5] = event.abVirtioLun[6] = event.abVirtioLun[7] = 0;675 676 667 switch (uEventType) 677 668 { … … 714 705 } 715 706 707 /** @todo r=bird: virtioCoreQueueIsEmpty() only differs in one step from what 708 * virtioCoreR3QueueGet() also does, and that is checking 709 * VIRTIO_STATUS_DRIVER_OK. So, why not combine the two and check the 710 * virtioCoreR3QueueGet status code?! (Actually, I've added a status 711 * check there myself, as we'll dump core if it fails and we don't.) */ 716 712 if (virtioCoreQueueIsEmpty(pDevIns, &pThis->Virtio, EVENTQ_IDX)) 717 713 { … … 722 718 723 719 PVIRTIO_DESC_CHAIN_T pDescChain; 724 virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, EVENTQ_IDX, &pDescChain, true); 725 726 PRTSGBUF pReqSegBuf = (PRTSGBUF)RTMemAllocZ(sizeof(RTSGBUF)); 727 AssertReturn(pReqSegBuf, VERR_NO_MEMORY); 728 729 PRTSGSEG paReqSegs = (PRTSGSEG)RTMemAllocZ(sizeof(RTSGSEG) * 2); 730 AssertReturn(paReqSegs, VERR_NO_MEMORY); 731 732 /* Copy segment data to malloc'd memory to avoid stack out-of-scope errors sanitizer doesn't detect */ 733 paReqSegs[0].pvSeg = RTMemAlloc(sizeof(event)); 734 AssertReturn(paReqSegs[0].pvSeg, VERR_NO_MEMORY); 735 memcpy(paReqSegs[0].pvSeg, &event, sizeof(event)); 736 737 RTSgBufInit(pReqSegBuf, paReqSegs, 1); 738 739 virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, EVENTQ_IDX, pReqSegBuf, pDescChain, true /*fFence*/); 720 int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, EVENTQ_IDX, &pDescChain, true); 721 AssertRCReturn(rc, rc); 722 723 VIRTIOSCSI_EVENT_T Event; 724 Event.uEvent = uEventType; 725 Event.uReason = uReason; 726 Event.abVirtioLun[0] = 1; 727 Event.abVirtioLun[1] = uTarget; 728 Event.abVirtioLun[2] = (LUN0 >> 8) & 0x40; 729 Event.abVirtioLun[3] = LUN0 & 0xff; 730 Event.abVirtioLun[4] = 0; 731 Event.abVirtioLun[5] = 0; 732 Event.abVirtioLun[6] = 0; 733 Event.abVirtioLun[7] = 0; 734 735 RTSGSEG aReqSegs[1]; 736 aReqSegs[0].pvSeg = &Event; 737 aReqSegs[0].cbSeg = sizeof(Event); 738 739 RTSGBUF ReqSgBuf; 740 RTSgBufInit(&ReqSgBuf, aReqSegs, RT_ELEMENTS(aReqSegs)); 741 742 virtioCoreR3QueuePut(pDevIns, &pThis->Virtio, EVENTQ_IDX, &ReqSgBuf, pDescChain, true /*fFence*/); 740 743 virtioCoreQueueSync(pDevIns, &pThis->Virtio, EVENTQ_IDX); 741 742 RTMemFree(paReqSegs[0].pvSeg);743 RTMemFree(paReqSegs);744 RTMemFree(pReqSegBuf);745 744 746 745 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.