VirtualBox

Changeset 53760 in vbox for trunk/src/VBox/Main/src-client


Ignore:
Timestamp:
Jan 8, 2015 9:05:35 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97548
Message:

Main/ConsoleImpl: when doing VMR3ReqCall requests, do always drop the object lock while waiting on the result. EMT will not only call us back but, more important, it might wait for the lock at another place! It might be simpler to do alock.release() first and then do VMR3ReqCallWait() but for now don't do invasive changes. And do only wait if the VMR3Req request did not yet succeed (in rare cases), otherwise we will wait forever. See also ticket #13722 and xtracker 7648.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r53560 r53760  
    22672267        return ptrVM.rc();
    22682268
    2269     /* release the lock before a VMR3* call (EMT will call us back)! */
     2269    /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    22702270    alock.release();
    22712271
     
    23732373                           (PFNRT)i_unplugCpu, 3,
    23742374                           this, pUVM, (VMCPUID)aCpu);
    2375         if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    2376         {
     2375   
     2376        /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
     2377        alock.release();
     2378
     2379        if (vrc == VERR_TIMEOUT)
    23772380            vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    2378             AssertRC(vrc);
    2379             if (RT_SUCCESS(vrc))
    2380                 vrc = pReq->iStatus;
    2381         }
     2381        AssertRC(vrc);
     2382        if (RT_SUCCESS(vrc))
     2383            vrc = pReq->iStatus;
    23822384        VMR3ReqFree(pReq);
    23832385
     
    24802482                           this, pUVM, aCpu);
    24812483
    2482     /* release the lock before a VMR3* call (EMT will call us back)! */
     2484    /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    24832485    alock.release();
    24842486
    2485     if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    2486     {
     2487    if (vrc == VERR_TIMEOUT)
    24872488        vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    2488         AssertRC(vrc);
    2489         if (RT_SUCCESS(vrc))
    2490             vrc = pReq->iStatus;
    2491     }
     2489    AssertRC(vrc);
     2490    if (RT_SUCCESS(vrc))
     2491        vrc = pReq->iStatus;
    24922492    VMR3ReqFree(pReq);
    2493 
    2494     rc = RT_SUCCESS(vrc) ? S_OK :
    2495         setError(VBOX_E_VM_ERROR,
    2496                  tr("Could not add CPU to the machine (%Rrc)"),
    2497                  vrc);
    24982493
    24992494    if (RT_SUCCESS(vrc))
     
    25062501        /** @todo warning if the guest doesn't support it */
    25072502    }
     2503    else
     2504        rc = setError(VBOX_E_VM_ERROR,
     2505                      tr("Could not add CPU to the machine (%Rrc)"),
     2506                      vrc);
    25082507
    25092508    LogFlowThisFunc(("mMachineState=%d, rc=%Rhrc\n", mMachineState, rc));
     
    36033602                           this, pUVM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fForce);
    36043603
    3605     /* release the lock before waiting for a result (EMT will call us back!) */
     3604    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
    36063605    alock.release();
    36073606
    3608     if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    3609     {
     3607    if (vrc == VERR_TIMEOUT)
    36103608        vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    3611         AssertRC(vrc);
    3612         if (RT_SUCCESS(vrc))
    3613             vrc = pReq->iStatus;
    3614     }
     3609    AssertRC(vrc);
     3610    if (RT_SUCCESS(vrc))
     3611        vrc = pReq->iStatus;
    36153612    VMR3ReqFree(pReq);
    36163613
     
    37993796                           this, pUVM, pszDevice, uInstance, enmBus, fUseHostIOCache, aMediumAttachment, fSilent);
    38003797
    3801     /* release the lock before waiting for a result (EMT will call us back!) */
     3798    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
    38023799    alock.release();
    38033800
    3804     if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    3805     {
     3801    if (vrc == VERR_TIMEOUT)
    38063802        vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    3807         AssertRC(vrc);
    3808         if (RT_SUCCESS(vrc))
    3809             vrc = pReq->iStatus;
    3810     }
     3803    AssertRC(vrc);
     3804    if (RT_SUCCESS(vrc))
     3805        vrc = pReq->iStatus;
    38113806    VMR3ReqFree(pReq);
    38123807
     
    39913986                           this, pUVM, pszDevice, uInstance, enmBus, aMediumAttachment, fSilent);
    39923987
    3993     /* release the lock before waiting for a result (EMT will call us back!) */
     3988    /* release the lock before waiting for a result (EMT might wait for it, @bugref{7648})! */
    39943989    alock.release();
    39953990
    3996     if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    3997     {
     3991    if (vrc == VERR_TIMEOUT)
    39983992        vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    3999         AssertRC(vrc);
    4000         if (RT_SUCCESS(vrc))
    4001             vrc = pReq->iStatus;
    4002     }
     3993    AssertRC(vrc);
     3994    if (RT_SUCCESS(vrc))
     3995        vrc = pReq->iStatus;
    40033996    VMR3ReqFree(pReq);
    40043997
     
    47714764     */
    47724765    PVMREQ pReq;
    4773     int vrc = VMR3ReqCallU(pUVM, 0 /*idDstCpu*/, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    4774                            (PFNRT)i_changeNetworkAttachment, 6,
    4775                            this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
    4776 
    4777     if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
    4778     {
    4779         vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
    4780         AssertRC(vrc);
    4781         if (RT_SUCCESS(vrc))
    4782             vrc = pReq->iStatus;
    4783     }
    4784     VMR3ReqFree(pReq);
     4766    int vrc = VMR3ReqCallWaitU(pUVM, 0 /*idDstCpu*/,
     4767                               (PFNRT)i_changeNetworkAttachment, 6,
     4768                               this, pUVM, pszDevice, uInstance, uLun, aNetworkAdapter);
    47854769
    47864770    if (fResume)
     
    61096093        return ptrVM.rc();
    61106094
    6111     /* release the lock before a VMR3* call (EMT will call us back)! */
     6095    /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    61126096    alock.release();
    61136097
     
    61686152        return ptrVM.rc();
    61696153
    6170     /* release the lock before a VMR3* call (EMT will call us back)! */
     6154    /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    61716155    alock.release();
    61726156
     
    62476231            return ptrVM.rc();
    62486232
    6249         /* release the lock before a VMR3* call (EMT will call us back)! */
     6233        /* release the lock before a VMR3* call (EMT might wait for it, @bugref{7648})! */
    62506234        alock.release();
    62516235        VMSUSPENDREASON enmReason = VMSUSPENDREASON_USER;
     
    74237407        LogFlowThisFunc(("Shutdown HGCM...\n"));
    74247408
    7425         /* Leave the lock since EMT will call us back as addVMCaller() */
     7409        /* Leave the lock since EMT might wait for it and will call us back as addVMCaller() */
    74267410        alock.release();
    74277411
     
    87698753            tr("General failure attaching to host interface"));
    87708754    }
    8771     LogFlowThisFunc(("rc=%d\n", rc));
     8755    LogFlowThisFunc(("rc=%Rhrc\n", rc));
    87728756    return rc;
    87738757}
     
    99389922                 * isn't going to need the Console lock.
    99399923                 */
     9924
     9925                /* TODO: do alock.release here as EMT might wait on it! See other places
     9926                 * where we do VMR3ReqCall requests. See @bugref{7648}. */
    99409927                vrc = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY,
    99419928                                       (PFNRT)i_reconfigureMediumAttachment, 13,
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