VirtualBox

Changeset 107871 in vbox for trunk


Ignore:
Timestamp:
Jan 21, 2025 9:33:52 AM (3 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167079
Message:

UsbNet: bugref:10779 Added suspend/resume handlers to prevent NATRX thread hanging during suspend

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/UsbNet.cpp

    r107791 r107871  
    407407    volatile bool                       fHaveToHostQueueWaiter;
    408408
     409    /** VM is currently suspended and we should ignore all external requests. */
     410    volatile bool                       fSuspended;
     411
    409412    /** Whether to signal the reset semaphore when the current request completes. */
    410413    bool                                fSignalResetSem;
     
    12481251
    12491252    RTCritSectEnter(&pThis->CritSect);
    1250     if (!usbNetQueueIsEmpty(&pThis->ToHostQueue))
     1253    if (!usbNetQueueIsEmpty(&pThis->ToHostQueue) || pThis->fSuspended)
    12511254    {
    12521255        RTCritSectLeave(&pThis->CritSect);
     
    12761279    RTCritSectEnter(&pThis->CritSect);
    12771280
    1278     if (usbNetQueueIsEmpty(&pThis->ToHostQueue))
     1281    if (usbNetQueueIsEmpty(&pThis->ToHostQueue) || pThis->fSuspended)
    12791282    {
    12801283        RTCritSectLeave(&pThis->CritSect);
     
    21152118
    21162119
     2120 /**
     2121 * @interface_method_impl{PDMUSBREG,pfnVMSuspend}
     2122 */
     2123static DECLCALLBACK(void) usbNetVMSuspend(PPDMUSBINS pUsbIns)
     2124{
     2125    PUSBNET pThis = PDMINS_2_DATA(pUsbIns, PUSBNET);
     2126#ifdef LOG_ENABLED
     2127    PCPDMUSBHLP pHlp  = pUsbIns->pHlpR3;
     2128    VMSUSPENDREASON enmReason = pHlp->pfnVMGetSuspendReason(pUsbIns);
     2129    LogFlowFunc(("/#%u/ enmReason=%u\n", pUsbIns->iInstance, enmReason));
     2130#endif
     2131    RTCritSectEnter(&pThis->CritSect);
     2132    pThis->fSuspended = true;
     2133    /* Unblock receive thread */
     2134    RTSemEventSignal(pThis->hEvtToHostQueue);
     2135    RTCritSectLeave(&pThis->CritSect);
     2136}
     2137
     2138
     2139/**
     2140 * @interface_method_impl{PDMUSBREG,pfnVMResume}
     2141 */
     2142static DECLCALLBACK(void) usbNetVMResume(PPDMUSBINS pUsbIns)
     2143{
     2144    PUSBNET pThis = PDMINS_2_DATA(pUsbIns, PUSBNET);
     2145#ifdef LOG_ENABLED
     2146    PCPDMUSBHLP pHlp  = pUsbIns->pHlpR3;
     2147    VMRESUMEREASON enmReason = pHlp->pfnVMGetResumeReason(pUsbIns);
     2148    LogFlowFunc(("/#%u/ enmReason=%u\n", pUsbIns->iInstance, enmReason));
     2149#endif
     2150    RTCritSectEnter(&pThis->CritSect);
     2151    pThis->fSuspended = false;
     2152    RTCritSectLeave(&pThis->CritSect);
     2153}
     2154
     2155
    21172156/**
    21182157 * @interface_method_impl{PDMUSBREG,pfnDestruct}
     
    23362375    usbNetVMReset,
    23372376    /* pfnVMSuspend */
    2338     NULL,
     2377    usbNetVMSuspend,
    23392378    /* pfnVMResume */
    2340     NULL,
     2379    usbNetVMResume,
    23412380    /* pfnVMPowerOff */
    23422381    NULL,
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette