VirtualBox

Changeset 1627 in vbox


Ignore:
Timestamp:
Mar 22, 2007 4:24:20 PM (18 years ago)
Author:
vboxsync
Message:

prevent RX/TX during suspend

File:
1 edited

Legend:

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

    r1622 r1627  
    214214    /** If set the link is temporarily down because of a saved state load. */
    215215    bool                                fLinkTempDown;
     216    /** This flag is set on SavePrep to prevent altering of memory after pgmR3Save() was called */
     217    bool                                fSaving;
    216218
    217219    /** Number of times we've reported the link down. */
     
    19901992    pcnetXmitFlushFrames(pData);
    19911993#else
    1992 
    1993 #if 1
     1994# if 1
    19941995    PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(CTXSUFF(pData->pXmitQueue));
    19951996    if (RT_UNLIKELY(pItem))
    19961997        PDMQueueInsert(CTXSUFF(pData->pXmitQueue), pItem);
    1997 #else
     1998# else
    19981999    if (ASMAtomicIncU32(&pData->cPendingSends) < 16)
    19992000    {
     
    20042005    else
    20052006        PDMQueueFlush(CTXSUFF(pData->pXmitQueue));
    2006 #endif
     2007# endif
    20072008#endif
    20082009}
     
    22702271        AssertReleaseRC(rc);
    22712272
    2272         rc = pcnetAsyncTransmit(pData);
     2273        if (!pData->fSaving)
     2274            rc = pcnetAsyncTransmit(pData);
     2275
    22732276        PDMCritSectLeave(&pData->CritSect);
    22742277    }
     
    36583661
    36593662/**
     3663 * Prepares for state saving.
     3664 * We must stop the RX process to prevent altering of the main memory after saving.
     3665 *
     3666 * @returns VBox status code.
     3667 * @param   pDevIns     The device instance.
     3668 * @param   pSSMHandle  The handle to save the state to.
     3669 */
     3670static DECLCALLBACK(int) pcnetSavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     3671{
     3672    PCNetState *pData = PDMINS2DATA(pDevIns, PCNetState *);
     3673
     3674    PDMCritSectEnter(&pData->CritSect, VERR_PERMISSION_DENIED);
     3675
     3676    pData->fSaving = true;
     3677    /* From now on drop all received packets to prevent altering of main memory after
     3678     * pgmR3Save() was called but before the RX thread is terminated */
     3679
     3680    PDMCritSectLeave(&pData->CritSect);
     3681    return VINF_SUCCESS;
     3682}
     3683
     3684
     3685/**
    36603686 * Saves a state of the PC-Net II device.
    36613687 *
     
    38273853    AssertReleaseRC(rc);
    38283854
    3829     if (cb > 70) /* unqualified guess */
    3830         pData->Led.Asserted.s.fReading = pData->Led.Actual.s.fReading = 1;
    3831     pcnetReceiveNoSync(pData, (const uint8_t*)pvBuf, cb);
    3832     pData->Led.Actual.s.fReading = 0;
     3855    if (!pData->fSaving)
     3856    {
     3857        if (cb > 70) /* unqualified guess */
     3858            pData->Led.Asserted.s.fReading = pData->Led.Actual.s.fReading = 1;
     3859        pcnetReceiveNoSync(pData, (const uint8_t*)pvBuf, cb);
     3860        pData->Led.Actual.s.fReading = 0;
     3861    }
     3862    /* otherwise junk the data to Nirwana. */
    38333863
    38343864    PDMCritSectLeave(&pData->CritSect);
     
    41784208    rc = PDMDevHlpSSMRegister(pDevIns, pDevIns->pDevReg->szDeviceName, iInstance,
    41794209                              PCNET_SAVEDSTATE_VERSION, sizeof(*pData),
    4180                               NULL, pcnetSaveExec, NULL,
     4210                              pcnetSavePrep, pcnetSaveExec, NULL,
    41814211                              NULL, pcnetLoadExec, NULL);
    41824212    if (VBOX_FAILURE(rc))
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