VirtualBox

Changeset 19267 in vbox


Ignore:
Timestamp:
Apr 29, 2009 2:53:28 PM (16 years ago)
Author:
vboxsync
Message:

Cleaned up the VMREQDEST_BROADCAST code.

Location:
trunk/src/VBox/VMM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VM.cpp

    r19265 r19267  
    16291629         * Request EMT to do the larger part of the destruction. (in reverse order as VCPU 0 does the real cleanup)
    16301630         */
    1631         for (int idCpu = pVM->cCPUs - 1;idCpu>=0;idCpu--)
    1632         {
    1633             PVMREQ pReq = NULL;
    1634             int rc = VMR3ReqCallU(pUVM, (VMREQDEST)idCpu, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)vmR3Destroy, 1, pVM);
    1635             if (RT_SUCCESS(rc))
    1636                 rc = pReq->iStatus;
    1637             AssertRC(rc);
    1638             VMR3ReqFree(pReq);
    1639         }
     1631        PVMREQ pReq = NULL;
     1632        int rc = VMR3ReqCallU(pUVM, VMREQDEST_BROADCAST_REVERSE, &pReq, RT_INDEFINITE_WAIT, 0, (PFNRT)vmR3Destroy, 1, pVM);
     1633        if (RT_SUCCESS(rc))
     1634            rc = pReq->iStatus;
     1635        AssertRC(rc);
     1636        VMR3ReqFree(pReq);
    16401637
    16411638        /*
  • trunk/src/VBox/VMM/VMReq.cpp

    r19265 r19267  
    401401                    VERR_VM_REQUEST_INVALID_TYPE);
    402402    AssertPtrReturn(ppReq, VERR_INVALID_POINTER);
    403     AssertMsgReturn(enmDest == VMREQDEST_ANY || enmDest == VMREQDEST_BROADCAST || (unsigned)enmDest < pUVM->cCpus, ("Invalid destination %d (max=%d)\n", enmDest, pUVM->cCpus), VERR_INVALID_PARAMETER);
     403    AssertMsgReturn(enmDest == VMREQDEST_ANY || enmDest == VMREQDEST_BROADCAST || enmDest == VMREQDEST_BROADCAST_REVERSE || (unsigned)enmDest < pUVM->cCpus, ("Invalid destination %d (max=%d)\n", enmDest, pUVM->cCpus), VERR_INVALID_PARAMETER);
    404404
    405405    /*
     
    624624    if (pReq->enmDest == VMREQDEST_BROADCAST)
    625625    {
    626         unsigned fFlags = ((VMREQ volatile *)pReq)->fFlags;     /* volatile paranoia */
    627 
    628         for (unsigned i=0;i<pUVM->cCpus;i++)
    629         {
    630             PVMCPU pVCpu = &pUVM->pVM->aCpus[i];
    631 
    632             if (   !pUVCpu
    633                 ||  pUVCpu->idCpu != i)
    634             {
    635                 /*
    636                  * Insert it.
    637                  */
    638                 pReq->enmState = VMREQSTATE_QUEUED;
    639                 PVMREQ pNext;
    640                 do
    641                 {
    642                     pNext = pUVM->aCpus[i].vm.s.pReqs;
    643                     pReq->pNext = pNext;
    644                 } while (!ASMAtomicCmpXchgPtr((void * volatile *)&pUVM->aCpus[i].vm.s.pReqs, (void *)pReq, (void *)pNext));
    645 
    646                 /*
    647                  * Notify EMT.
    648                  */
    649                 if (pUVM->pVM)
    650                     VMCPU_FF_SET(pVCpu, VMCPU_FF_REQUEST);
    651                 VMR3NotifyCpuFFU(&pUVM->aCpus[i], false);
    652 
    653                 /*
    654                  * Wait and return.
    655                  */
    656                 if (!(fFlags & VMREQFLAGS_NO_WAIT))
    657                     rc = VMR3ReqWait(pReq, cMillies);
    658                 LogFlow(("VMR3ReqQueue: returns %Rrc\n", rc));
    659             }
    660             else
    661             {
    662                 /*
    663                  * The requester was EMT, just execute it.
    664                  */
    665                 pReq->enmState = VMREQSTATE_QUEUED;
    666                 rc = vmR3ReqProcessOneU(pUVM, pReq);
    667                 LogFlow(("VMR3ReqQueue: returns %Rrc (processed)\n", rc));
    668             }
    669         } /* for each VMCPU */
     626        for (unsigned i = 0; i < pUVM->cCpus; i++)
     627        {
     628            /* Reinit some members. */
     629            pReq->enmState = VMREQSTATE_ALLOCATED;
     630            pReq->enmDest = (VMREQDEST)i;
     631            rc = VMR3ReqQueue(pReq, cMillies);
     632            if (RT_FAILURE(rc))
     633                break;
     634        }
     635    }
     636    else if (pReq->enmDest == VMREQDEST_BROADCAST_REVERSE)
     637    {
     638        for (int i = pUVM->cCpus-1; i >= 0; i--)
     639        {
     640            /* Reinit some members. */
     641            pReq->enmState = VMREQSTATE_ALLOCATED;
     642            pReq->enmDest  = (VMREQDEST)i;
     643            rc = VMR3ReqQueue(pReq, cMillies);
     644            if (RT_FAILURE(rc))
     645                break;
     646        }
    670647    }
    671648    else if (   pReq->enmDest != VMREQDEST_ANY  /* for a specific VMCPU? */
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