VirtualBox

Changeset 82042 in vbox


Ignore:
Timestamp:
Nov 20, 2019 7:04:20 PM (5 years ago)
Author:
vboxsync
Message:

Factored out virtq naming code so it can be re-used in load exec code and fixed parameter list in Log*() statement that caused burn

File:
1 edited

Legend:

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

    r82023 r82042  
    109109#define VIRTQ_REQ_BASE                              2           /**< Spec-defined base index of request queues       */
    110110
    111 #define QUEUENAME(qIdx) (pThis->aszQueueNames[qIdx])            /**< Macro to get queue name from its index          */
    112 #define CBQUEUENAME(qIdx) RTStrNLen(QUEUENAME(qIdx), sizeof(QUEUENAME(qIdx)))
     111#define VIRTQNAME(qIdx) (pThis->aszVIRTQNAMEs[qIdx])            /**< Macro to get queue name from its index          */
     112#define CBVIRTQNAME(qIdx) RTStrNLen(VIRTQNAME(qIdx), sizeof(VIRTQNAME(qIdx)))
    113113
    114114#define IS_REQ_QUEUE(qIdx) (qIdx >= VIRTQ_REQ_BASE && qIdx < VIRTIOSCSI_QUEUE_CNT)
     
    426426    char                            szInstance[16];
    427427
    428     /** Device-specific spec-based VirtIO queuenames */
    429     char                            aszQueueNames[VIRTIOSCSI_QUEUE_CNT][VIRTIO_MAX_QUEUE_NAME_SIZE];
     428    /** Device-specific spec-based VirtIO VIRTQNAMEs */
     429    char                            aszVIRTQNAMEs[VIRTIOSCSI_QUEUE_CNT][VIRTIO_MAX_QUEUE_NAME_SIZE];
    430430
    431431    /** Track which VirtIO queues we've attached to */
     
    577577#ifdef IN_RING3 /* spans most of the file, at the moment. */
    578578
     579
     580DECLINLINE(void) virtioScsiSetVirtqNames(PVIRTIOSCSI pThis)
     581{
     582    RTStrCopy(pThis->aszVIRTQNAMEs[CONTROLQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "controlq");
     583    RTStrCopy(pThis->aszVIRTQNAMEs[EVENTQ_IDX],   VIRTIO_MAX_QUEUE_NAME_SIZE, "eventq");
     584    for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTQ_REQ_BASE + VIRTIOSCSI_REQ_QUEUE_CNT; qIdx++)
     585        RTStrPrintf(pThis->aszVIRTQNAMEs[qIdx], VIRTIO_MAX_QUEUE_NAME_SIZE,
     586                    "requestq<%d>", qIdx - VIRTQ_REQ_BASE);
     587}
     588
    579589#ifdef LOG_ENABLED
     590
    580591
    581592DECLINLINE(const char *) virtioGetTxDirText(uint32_t enmTxDir)
     
    13251336                               | pScsiCtrlUnion->scsiCtrlTmf.abScsiLun[3]) & 0x3fff;
    13261337            Log2Func(("[%s] (Target: %d LUN: %d)  Task Mgt Function: %s\n",
    1327                       QUEUENAME(qIdx), uTarget, uScsiLun, virtioGetTMFTypeText(pScsiCtrlUnion->scsiCtrlTmf.uSubtype)));
     1338                      VIRTQNAME(qIdx), uTarget, uScsiLun, virtioGetTMFTypeText(pScsiCtrlUnion->scsiCtrlTmf.uSubtype)));
    13281339
    13291340            if (uTarget >= pThis->cTargets || !pThisCC->paTargetInstances[uTarget].fPresent)
     
    13931404                virtioGetControlAsyncMaskText(szTypeText, sizeof(szTypeText), pScsiCtrlAnQuery->fEventsRequested);
    13941405                Log2Func(("[%s] (Target: %d LUN: %d)  Async. Notification Query: %s\n",
    1395                           QUEUENAME(qIdx), uTarget, uScsiLun, szTypeText));
     1406                          VIRTQNAME(qIdx), uTarget, uScsiLun, szTypeText));
    13961407            }
    13971408#endif
     
    14241435                virtioGetControlAsyncMaskText(szTypeText, sizeof(szTypeText), pScsiCtrlAnSubscribe->fEventsRequested);
    14251436                Log2Func(("[%s] (Target: %d LUN: %d)  Async. Notification Subscribe: %s\n",
    1426                           QUEUENAME(qIdx), uTarget, uScsiLun, szTypeText));
     1437                          VIRTQNAME(qIdx), uTarget, uScsiLun, szTypeText));
    14271438            }
    14281439#endif
     
    14521463        default:
    14531464        {
    1454             LogFunc(("Unknown control type extracted from %s: %u\n", QUEUENAME(qIdx), pScsiCtrlUnion->scsiCtrl.uType));
     1465            LogFunc(("Unknown control type extracted from %s: %u\n", VIRTQNAME(qIdx), pScsiCtrlUnion->scsiCtrl.uType));
    14551466
    14561467            bResponse = VIRTIOSCSI_S_FAILURE;
     
    15081519            if (!fNotificationSent)
    15091520            {
    1510                 Log6Func(("%s worker sleeping...\n", QUEUENAME(qIdx)));
     1521                Log6Func(("%s worker sleeping...\n", VIRTQNAME(qIdx)));
    15111522                Assert(ASMAtomicReadBool(&pWorkerR3->fSleeping));
    15121523                int rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pWorker->hEvtProcess, RT_INDEFINITE_WAIT);
     
    15141525                if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
    15151526                    return VINF_SUCCESS;
    1516                 Log6Func(("%s worker woken\n", QUEUENAME(qIdx)));
     1527                Log6Func(("%s worker woken\n", VIRTQNAME(qIdx)));
    15171528                ASMAtomicWriteBool(&pWorkerR3->fNotified, false);
    15181529            }
     
    15221533        if (!pThis->afQueueAttached[qIdx])
    15231534        {
    1524             LogFunc(("%s queue not attached, worker aborting...\n", QUEUENAME(qIdx)));
     1535            LogFunc(("%s queue not attached, worker aborting...\n", VIRTQNAME(qIdx)));
    15251536            break;
    15261537        }
     
    15421553             pWorkerR3->cRedoDescs = 0;
    15431554
    1544              Log6Func(("fetching next descriptor chain from %s\n", QUEUENAME(qIdx)));
     1555             Log6Func(("fetching next descriptor chain from %s\n", VIRTQNAME(qIdx)));
    15451556             PVIRTIO_DESC_CHAIN_T pDescChain;
    15461557             int rc = virtioCoreR3QueueGet(pDevIns, &pThis->Virtio, qIdx, &pDescChain, true);
    15471558             if (rc == VERR_NOT_AVAILABLE)
    15481559             {
    1549                 Log6Func(("Nothing found in %s\n", QUEUENAME(qIdx)));
     1560                Log6Func(("Nothing found in %s\n", VIRTQNAME(qIdx)));
    15501561                continue;
    15511562             }
     
    16641675    if (qIdx == CONTROLQ_IDX || IS_REQ_QUEUE(qIdx))
    16651676    {
    1666         Log6Func(("%s has available data\n", QUEUENAME(qIdx)));
     1677        Log6Func(("%s has available data\n", VIRTQNAME(qIdx)));
    16671678        /* Wake queue's worker thread up if sleeping */
    16681679        if (!ASMAtomicXchgBool(&pWorkerR3->fNotified, true))
     
    16701681            if (ASMAtomicReadBool(&pWorkerR3->fSleeping))
    16711682            {
    1672                 Log6Func(("waking %s worker.\n", QUEUENAME(qIdx)));
     1683                Log6Func(("waking %s worker.\n", VIRTQNAME(qIdx)));
    16731684                int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pWorker->hEvtProcess);
    16741685                AssertRC(rc);
     
    16781689    else if (qIdx == EVENTQ_IDX)
    16791690    {
    1680         Log3Func(("Driver queued buffer(s) to %s\n", QUEUENAME(qIdx)));
     1691        Log3Func(("Driver queued buffer(s) to %s\n", VIRTQNAME(qIdx)));
    16811692        if (ASMAtomicXchgBool(&pThis->fEventsMissed, false))
    16821693            virtioScsiR3ReportEventsMissed(pDevIns, pThis, 0);
     
    19601971    AssertLogRelMsgReturn(uVersion == VIRTIOSCSI_SAVED_STATE_VERSION,
    19611972                          ("uVersion=%u\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
    1962 // re-calculate names in aszQueueNames
    1963 
     1973
     1974    virtioScsiSetVirtqNames(pThis);
    19641975    for (int qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    19651976        pHlp->pfnSSMGetBool(pSSM, &pThis->afQueueAttached[qIdx]);
     1977
    19661978
    19671979    pHlp->pfnSSMGetU32(pSSM,  &pThis->virtioScsiConfig.uNumQueues);
     
    19841996    pHlp->pfnSSMGetU32(pSSM,  &pThis->fResetting);
    19851997
    1986     /* TODO: Ask aiechner about BIOS-related changes */
     1998    /* TODO: Ask aeichner about BIOS-related changes */
    19871999    pHlp->pfnSSMGetU32(pSSM, &pThis->cTargets);
    19882000
     
    20042016
    20052017        pHlp->pfnSSMGetU16(pSSM, &qIdx);
    2006 
    20072018        pHlp->pfnSSMGetU16(pSSM, &uHeadIdx);
    20082019LogFunc(("    loaded redo req: qIdx=%d, headIdx=%d\n", qIdx, uHeadIdx));
     
    20252036        if (pThis->afQueueAttached[qIdx])
    20262037        {
    2027             LogFunc(("Waking %s worker.\n", QUEUENAME(qIdx)));
     2038            LogFunc(("Waking %s worker.\n", VIRTQNAME(qIdx)));
    20282039            rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->aWorkers[qIdx].hEvtProcess);
    20292040            AssertRCReturn(rc, rc);
     
    23282339        if (ASMAtomicReadBool(&pThisCC->aWorkers[qIdx].fSleeping))
    23292340        {
    2330             Log6Func(("waking %s worker.\n", QUEUENAME(qIdx)));
     2341            Log6Func(("waking %s worker.\n", VIRTQNAME(qIdx)));
    23312342            int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->aWorkers[qIdx].hEvtProcess);
    23322343            AssertRC(rc);
     
    24942505     */
    24952506
    2496     /* Name the queues: */
    2497     RTStrCopy(pThis->aszQueueNames[CONTROLQ_IDX], VIRTIO_MAX_QUEUE_NAME_SIZE, "controlq");
    2498     RTStrCopy(pThis->aszQueueNames[EVENTQ_IDX],   VIRTIO_MAX_QUEUE_NAME_SIZE, "eventq");
    2499     for (uint16_t qIdx = VIRTQ_REQ_BASE; qIdx < VIRTQ_REQ_BASE + VIRTIOSCSI_REQ_QUEUE_CNT; qIdx++)
    2500         RTStrPrintf(pThis->aszQueueNames[qIdx], VIRTIO_MAX_QUEUE_NAME_SIZE,
    2501                     "requestq<%d>", qIdx - VIRTQ_REQ_BASE);
     2507    virtioScsiSetVirtqNames(pThis);
    25022508
    25032509    /* Attach the queues and create worker threads for them: */
    25042510    for (uint16_t qIdx = 0; qIdx < VIRTIOSCSI_QUEUE_CNT; qIdx++)
    25052511    {
    2506         rc = virtioCoreR3QueueAttach(&pThis->Virtio, qIdx, QUEUENAME(qIdx));
     2512        rc = virtioCoreR3QueueAttach(&pThis->Virtio, qIdx, VIRTQNAME(qIdx));
    25072513        if (RT_FAILURE(rc))
    25082514            continue;
     
    25112517            rc = PDMDevHlpThreadCreate(pDevIns, &pThisCC->aWorkers[qIdx].pThread,
    25122518                                       (void *)(uintptr_t)qIdx, virtioScsiR3WorkerThread,
    2513                                        virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, QUEUENAME(qIdx));
     2519                                       virtioScsiR3WorkerWakeUp, 0, RTTHREADTYPE_IO, VIRTQNAME(qIdx));
    25142520            if (rc != VINF_SUCCESS)
    25152521            {
    2516                 LogRel(("Error creating thread for Virtual Queue %s: %Rrc\n", QUEUENAME(qIdx), rc));
     2522                LogRel(("Error creating thread for Virtual Queue %s: %Rrc\n", VIRTQNAME(qIdx), rc));
    25172523                return rc;
    25182524            }
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