VirtualBox

Changeset 23584 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Oct 6, 2009 3:54:44 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53250
Message:

pdmR3Load: Relaxed device/instance ordering assumptions.

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

Legend:

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

    r23329 r23584  
    660660        SSMR3PutU32(pSSM, pDevIns->iInstance);
    661661    }
    662     return SSMR3PutU32(pSSM, ~0); /* terminator */
     662    return SSMR3PutU32(pSSM, UINT32_MAX); /* terminator */
    663663}
    664664
     
    819819    /*
    820820     * Load the list of devices and verify that they are all there.
    821      *
    822      * We boldly ASSUME that the order is fixed and that it's a good, this
    823      * makes it way easier to validate...
    824      */
    825     uint32_t i = 0;
    826     PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances;
    827     for (;; pDevIns = pDevIns->Internal.s.pNextR3, i++)
    828     {
    829         /* Get the separator / terminator. */
     821     */
     822    for (PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextR3)
     823        pDevIns->Internal.s.fIntFlags &= PDMDEVINSINT_FLAGS_FOUND;
     824
     825    for (uint32_t i = 0; ; i++)
     826    {
     827        /* Get the sequence number / terminator. */
    830828        uint32_t    u32Sep;
    831829        int rc = SSMR3GetU32(pSSM, &u32Sep);
    832830        if (RT_FAILURE(rc))
    833831            return rc;
    834         if (u32Sep == (uint32_t)~0)
     832        if (u32Sep == UINT32_MAX)
    835833            break;
    836834        if (u32Sep != i)
    837835            AssertMsgFailedReturn(("Out of seqence. u32Sep=%#x i=%#x\n", u32Sep, i), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
    838836
    839         /* get the name and instance number. */
    840         char szDeviceName[sizeof(pDevIns->pDevReg->szDeviceName)];
     837        /* Get the name and instance number. */
     838        char szDeviceName[RT_SIZEOFMEMB(PDMDEVREG, szDeviceName)];
    841839        rc = SSMR3GetStrZ(pSSM, szDeviceName, sizeof(szDeviceName));
    842840        if (RT_FAILURE(rc))
     
    847845            return rc;
    848846
    849         /* compare */
     847        /* Try locate it. */
     848        PPDMDEVINS pDevIns;
     849        for (pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextR3)
     850            if (   !strcmp(szDeviceName, pDevIns->pDevReg->szDeviceName)
     851                && pDevIns->iInstance == iInstance)
     852            {
     853                AssertLogRelReturn(!(pDevIns->Internal.s.fIntFlags & PDMDEVINSINT_FLAGS_FOUND), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     854                pDevIns->Internal.s.fIntFlags |= PDMDEVINSINT_FLAGS_FOUND;
     855                break;
     856            }
    850857        if (!pDevIns)
    851858        {
     
    853860            if (SSMR3HandleGetAfter(pSSM) != SSMAFTER_DEBUG_IT)
    854861                AssertFailedReturn(VERR_SSM_LOAD_CONFIG_MISMATCH);
    855             break;
    856         }
    857         if (    strcmp(szDeviceName, pDevIns->pDevReg->szDeviceName)
    858             ||  pDevIns->iInstance != iInstance)
    859         {
    860             LogRel(("u32Sep=%d loaded '%s'/%d  configured '%s'/%d\n",
    861                     u32Sep, szDeviceName, iInstance, pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
     862        }
     863    }
     864
     865    /*
     866     * Check that no additional devices were configured.
     867     */
     868    for (PPDMDEVINS pDevIns = pVM->pdm.s.pDevInstances; pDevIns; pDevIns = pDevIns->Internal.s.pNextR3)
     869        if (!(pDevIns->Internal.s.fIntFlags & PDMDEVINSINT_FLAGS_FOUND))
     870        {
     871            LogRel(("Device '%s'/%d not found in the saved state\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    862872            if (SSMR3HandleGetAfter(pSSM) != SSMAFTER_DEBUG_IT)
    863873                AssertFailedReturn(VERR_SSM_LOAD_CONFIG_MISMATCH);
    864874        }
    865     }
    866 
    867     /*
    868      * Too many devices?
    869      */
    870     if (pDevIns)
    871     {
    872         LogRel(("Device '%s'/%d not found in saved state\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    873         if (SSMR3HandleGetAfter(pSSM) != SSMAFTER_DEBUG_IT)
    874             AssertFailedReturn(VERR_SSM_LOAD_CONFIG_MISMATCH);
    875     }
    876875
    877876    return VINF_SUCCESS;
  • trunk/src/VBox/VMM/PDMInternal.h

    r22924 r23584  
    126126    /** RC pointer to associated PCI bus structure. */
    127127    RCPTRTYPE(PPDMPCIBUS)           pPciBusRC;
    128     /** Alignment padding. */
    129     RTRCPTR                         Alignment1;
     128
     129    /** Flags, see PDMDEVINSINT_FLAGS_XXX. */
     130    uint32_t                        fIntFlags;
    130131} PDMDEVINSINT;
     132
     133/** @name PDMDEVINSINT::fIntFlags
     134 * @{ */
     135/** Used by pdmR3Load to mark device instances it found in the saved state. */
     136#define PDMDEVINSINT_FLAGS_FOUND         RT_BIT_32(0)
     137/** @} */
    131138
    132139
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