VirtualBox

Changeset 24076 in vbox for trunk/src


Ignore:
Timestamp:
Oct 26, 2009 1:39:50 PM (15 years ago)
Author:
vboxsync
Message:

VMMDev: Save and verify config. Drop the SSM_VERSION* stuff since we won't ever make incompatible changes and it only makes things harder to read and introduced a but (wrong version check in vmmdevLoadExec). The change is only smoke tested.

Location:
trunk/src/VBox/Devices/VMMDev
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/VMMDev/VMMDev.cpp

    r23910 r24076  
    5656#define VMMDEVSTATE_2_DEVINS(pVMMDevState)         ( (pVMMDevState)->pDevIns )
    5757
    58 #define VBOX_GUEST_ADDITIONS_VERSION_1_03(s)            \
    59     ((RT_HIWORD ((s)->guestInfo.additionsVersion) == 1) && \
    60      (RT_LOWORD ((s)->guestInfo.additionsVersion) == 3))
     58#define VBOX_GUEST_ADDITIONS_VERSION_1_03(s) \
     59    (   RT_HIWORD((s)->guestInfo.additionsVersion) == 1 \
     60     && RT_LOWORD((s)->guestInfo.additionsVersion) == 3 )
    6161
    6262#define VBOX_GUEST_ADDITIONS_VERSION_OK(additionsVersion) \
    63       (RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
    64     && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION))
     63      (   RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
     64       && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) )
    6565
    6666#define VBOX_GUEST_ADDITIONS_VERSION_OLD(additionsVersion) \
    67       ((RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) \
    68       || ((RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
    69           && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION))
     67      (   (RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) \
     68       || (   RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
     69           && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) ) )
    7070
    7171#define VBOX_GUEST_ADDITIONS_VERSION_TOO_OLD(additionsVersion) \
    72       (RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION))
     72      ( RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) )
    7373
    7474#define VBOX_GUEST_ADDITIONS_VERSION_NEW(additionsVersion) \
    75       ((RT_HIWORD(additionsVersion) > RT_HIWORD(VMMDEV_VERSION) \
    76       || ((RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
    77           && RT_LOWORD(additionsVersion) > RT_LOWORD(VMMDEV_VERSION))
     75      (   RT_HIWORD(additionsVersion) > RT_HIWORD(VMMDEV_VERSION) \
     76       || (   RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
     77           && RT_LOWORD(additionsVersion) >  RT_LOWORD(VMMDEV_VERSION) ) )
     78
     79/** The saved state version. */
     80#define VMMDEV_SAVED_STATE_VERSION          12
     81/** The saved state version used by VirtualBox 3.0.
     82 *  This doesn't have the config part. */
     83#define VMMDEV_SAVED_STATE_VERSION_VBOX_30  11
     84
    7885
    7986#ifndef VBOX_DEVICE_STRUCT_TESTCASE
     
    21032110
    21042111
    2105 /* -=-=-=-=-=- IHGCMPort -=-=-=-=-=- */
    2106 
    2107 /** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
    2108 #define IHGCMPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, HGCMPort)) )
    2109 
    2110 
    2111 
    2112 #define VMMDEV_SSM_VERSION  11
     2112/* -=-=-=-=-=- Saved State -=-=-=-=-=- */
    21132113
    21142114/**
    2115  * Saves a state of the VMM device.
    2116  *
    2117  * @returns VBox status code.
    2118  * @param   pDevIns     The device instance.
    2119  * @param   pSSMHandle  The handle to save the state to.
     2115 * @copydoc FNSSMDEVLIVEEXEC
    21202116 */
    2121 static DECLCALLBACK(int) vmmdevSaveState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     2117static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
    21222118{
    21232119    VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
    2124     SSMR3PutU32(pSSMHandle, pThis->hypervisorSize);
    2125     SSMR3PutU32(pSSMHandle, pThis->mouseCapabilities);
    2126     SSMR3PutU32(pSSMHandle, pThis->mouseXAbs);
    2127     SSMR3PutU32(pSSMHandle, pThis->mouseYAbs);
    2128 
    2129     SSMR3PutBool(pSSMHandle, pThis->fNewGuestFilterMask);
    2130     SSMR3PutU32(pSSMHandle, pThis->u32NewGuestFilterMask);
    2131     SSMR3PutU32(pSSMHandle, pThis->u32GuestFilterMask);
    2132     SSMR3PutU32(pSSMHandle, pThis->u32HostEventFlags);
    2133     // here be dragons (probably)
    2134 //    SSMR3PutBool(pSSMHandle, pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents);
    2135     SSMR3PutMem(pSSMHandle, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
    2136 
    2137     SSMR3PutMem(pSSMHandle, &pThis->guestInfo, sizeof (pThis->guestInfo));
    2138     SSMR3PutU32(pSSMHandle, pThis->fu32AdditionsOk);
    2139     SSMR3PutU32(pSSMHandle, pThis->u32VideoAccelEnabled);
    2140     SSMR3PutBool(pSSMHandle, pThis->fGuestSentChangeEventAck);
    2141 
    2142     SSMR3PutU32(pSSMHandle, pThis->guestCaps);
     2120
     2121    SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled);
     2122    SSMR3PutBool(pSSM, pThis->fBackdoorLogDisabled);
     2123    SSMR3PutBool(pSSM, pThis->fKeepCredentials);
     2124    SSMR3PutBool(pSSM, pThis->fHeapEnabled);
     2125
     2126    return VINF_SSM_DONT_CALL_AGAIN;
     2127}
     2128
     2129
     2130/**
     2131 * @copydoc FNSSMDEVSAVEEXEC
     2132 *
     2133 */
     2134static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
     2135{
     2136    VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
     2137
     2138    vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
     2139
     2140    SSMR3PutU32(pSSM, pThis->hypervisorSize);
     2141    SSMR3PutU32(pSSM, pThis->mouseCapabilities);
     2142    SSMR3PutU32(pSSM, pThis->mouseXAbs);
     2143    SSMR3PutU32(pSSM, pThis->mouseYAbs);
     2144
     2145    SSMR3PutBool(pSSM, pThis->fNewGuestFilterMask);
     2146    SSMR3PutU32(pSSM, pThis->u32NewGuestFilterMask);
     2147    SSMR3PutU32(pSSM, pThis->u32GuestFilterMask);
     2148    SSMR3PutU32(pSSM, pThis->u32HostEventFlags);
     2149    /* The following is not strictly necessary as PGM restors MMIO2, keeping it for historical reasons. */
     2150    SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
     2151
     2152    SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
     2153    SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);
     2154    SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);
     2155    SSMR3PutBool(pSSM, pThis->fGuestSentChangeEventAck);
     2156
     2157    SSMR3PutU32(pSSM, pThis->guestCaps);
    21432158
    21442159#ifdef VBOX_WITH_HGCM
    2145     vmmdevHGCMSaveState (pThis, pSSMHandle);
     2160    vmmdevHGCMSaveState(pThis, pSSM);
    21462161#endif /* VBOX_WITH_HGCM */
    21472162
    2148     SSMR3PutU32(pSSMHandle, pThis->fHostCursorRequested);
     2163    SSMR3PutU32(pSSM, pThis->fHostCursorRequested);
    21492164
    21502165    return VINF_SUCCESS;
     
    21522167
    21532168/**
    2154  * Loads the saved VMM device state.
    2155  *
    2156  * @returns VBox status code.
    2157  * @param   pDevIns     The device instance.
    2158  * @param   pSSMHandle  The handle to the saved state.
    2159  * @param   uVersion    The data unit version number.
    2160  * @param   uPass       The data pass.
     2169 * @copydoc FNSSMDEVLOADEXEC
    21612170 */
    2162 static DECLCALLBACK(int) vmmdevLoadState(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle, uint32_t uVersion, uint32_t uPass)
     2171static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
    21632172{
    21642173    /** @todo The code load code is assuming we're always loaded into a freshly
    21652174     *        constructed VM. */
    21662175    VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
    2167     if (   SSM_VERSION_MAJOR_CHANGED(uVersion, VMMDEV_SSM_VERSION)
    2168         || (SSM_VERSION_MINOR(uVersion) < 6))
     2176    int          rc;
     2177
     2178    if (   uVersion > VMMDEV_SAVED_STATE_VERSION
     2179        || uVersion < 6)
    21692180        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    2170     Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
    2171 
    2172     SSMR3GetU32(pSSMHandle, &pThis->hypervisorSize);
    2173     SSMR3GetU32(pSSMHandle, &pThis->mouseCapabilities);
    2174     SSMR3GetU32(pSSMHandle, &pThis->mouseXAbs);
    2175     SSMR3GetU32(pSSMHandle, &pThis->mouseYAbs);
    2176 
    2177     SSMR3GetBool(pSSMHandle, &pThis->fNewGuestFilterMask);
    2178     SSMR3GetU32(pSSMHandle, &pThis->u32NewGuestFilterMask);
    2179     SSMR3GetU32(pSSMHandle, &pThis->u32GuestFilterMask);
    2180     SSMR3GetU32(pSSMHandle, &pThis->u32HostEventFlags);
    2181 //    SSMR3GetBool(pSSMHandle, &pThis->pVMMDevRAMR3->fHaveEvents);
     2181
     2182    /* config */
     2183    if (uVersion > VMMDEV_SAVED_STATE_VERSION_VBOX_30)
     2184    {
     2185        bool f;
     2186        rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     2187        if (pThis->fGetHostTimeDisabled != f)
     2188            LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
     2189
     2190        rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     2191        if (pThis->fBackdoorLogDisabled != f)
     2192            LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
     2193
     2194        rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     2195        if (pThis->fKeepCredentials != f)
     2196        {
     2197            LogRel(("VMMDev: Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool\n", pThis->fKeepCredentials, f));
     2198            return VERR_SSM_LOAD_CONFIG_MISMATCH;
     2199        }
     2200        rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
     2201        if (pThis->fHeapEnabled != f)
     2202        {
     2203            LogRel(("VMMDev: Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool\n", pThis->fHeapEnabled, f));
     2204            return VERR_SSM_LOAD_CONFIG_MISMATCH;
     2205        }
     2206    }
     2207
     2208    if (uPass != SSM_PASS_FINAL)
     2209        return VINF_SUCCESS;
     2210
     2211    /* state */
     2212    SSMR3GetU32(pSSM, &pThis->hypervisorSize);
     2213    SSMR3GetU32(pSSM, &pThis->mouseCapabilities);
     2214    SSMR3GetU32(pSSM, &pThis->mouseXAbs);
     2215    SSMR3GetU32(pSSM, &pThis->mouseYAbs);
     2216
     2217    SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMask);
     2218    SSMR3GetU32(pSSM, &pThis->u32NewGuestFilterMask);
     2219    SSMR3GetU32(pSSM, &pThis->u32GuestFilterMask);
     2220    SSMR3GetU32(pSSM, &pThis->u32HostEventFlags);
     2221
     2222//    SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
    21822223    // here be dragons (probably)
    2183     SSMR3GetMem(pSSMHandle, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
    2184 
    2185     SSMR3GetMem(pSSMHandle, &pThis->guestInfo, sizeof (pThis->guestInfo));
    2186     SSMR3GetU32(pSSMHandle, &pThis->fu32AdditionsOk);
    2187     SSMR3GetU32(pSSMHandle, &pThis->u32VideoAccelEnabled);
     2224    SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
     2225
     2226    SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
     2227    SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);
     2228    SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);
    21882229    if (uVersion > 10)
    2189         SSMR3GetBool(pSSMHandle, &pThis->fGuestSentChangeEventAck);
    2190 
    2191     SSMR3GetU32(pSSMHandle, &pThis->guestCaps);
     2230        SSMR3GetBool(pSSM, &pThis->fGuestSentChangeEventAck);
     2231
     2232    rc = SSMR3GetU32(pSSM, &pThis->guestCaps);
    21922233
    21932234    /* Attributes which were temporarily introduced in r30072 */
    2194     if (   SSM_VERSION_MAJOR(uVersion) ==  0
    2195         && SSM_VERSION_MINOR(uVersion) == 7)
     2235    if (uVersion == 7)
    21962236    {
    21972237        uint32_t temp;
    2198         SSMR3GetU32(pSSMHandle, &temp);
    2199         SSMR3GetU32(pSSMHandle, &temp);
    2200     }
     2238        SSMR3GetU32(pSSM, &temp);
     2239        rc = SSMR3GetU32(pSSM, &temp);
     2240    }
     2241    AssertRCReturn(rc, rc);
    22012242
    22022243#ifdef VBOX_WITH_HGCM
    2203     vmmdevHGCMLoadState (pThis, pSSMHandle, uVersion);
     2244    rc = vmmdevHGCMLoadState(pThis, pSSM, uVersion);
     2245    AssertRCReturn(rc, rc);
    22042246#endif /* VBOX_WITH_HGCM */
    22052247
    2206     if (   SSM_VERSION_MAJOR(uVersion) ==  0
    2207         && SSM_VERSION_MINOR(uVersion) >= 10)
    2208         SSMR3GetU32(pSSMHandle, &pThis->fHostCursorRequested);
     2248    if (uVersion >= 10)
     2249        rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);
     2250    AssertRCReturn(rc, rc);
    22092251
    22102252    /*
     
    22162258    {
    22172259        pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
    2218         if (   SSM_VERSION_MAJOR(uVersion) ==  0
    2219             && SSM_VERSION_MINOR(uVersion) >= 10)
    2220                 pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
    2221                                                    pThis->fHostCursorRequested,
    2222                                                    0,
    2223                                                    0, 0,
    2224                                                    0, 0,
    2225                                                    NULL);
     2260        if (uVersion >= 10)
     2261            pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
     2262                                               pThis->fHostCursorRequested,
     2263                                               0,
     2264                                               0, 0,
     2265                                               0, 0,
     2266                                               NULL);
    22262267    }
    22272268
     
    22522293 * @returns VBox status code.
    22532294 * @param   pDevIns    The device instance.
    2254  * @param   pSSMHandle The handle to the saved state.
     2295 * @param   pSSM The handle to the saved state.
    22552296 */
    2256 static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSMHandle)
     2297static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    22572298{
    22582299    VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
    22592300
    22602301#ifdef VBOX_WITH_HGCM
    2261     vmmdevHGCMLoadStateDone (pThis, pSSMHandle);
     2302    int rc = vmmdevHGCMLoadStateDone(pThis, pSSM);
     2303    AssertLogRelRCReturn(rc, rc);
    22622304#endif /* VBOX_WITH_HGCM */
    22632305
    2264     VMMDevNotifyGuest (pThis, VMMDEV_EVENT_RESTORED);
     2306    VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED);
    22652307
    22662308    return VINF_SUCCESS;
     
    23252367                                N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
    23262368
    2327     bool fHeapEnabled;
    2328     rc = CFGMR3QueryBoolDef(pCfgHandle, "HeapEnabled", &fHeapEnabled, true);
     2369    rc = CFGMR3QueryBoolDef(pCfgHandle, "HeapEnabled", &pThis->fHeapEnabled, true);
    23292370    if (RT_FAILURE(rc))
    23302371        return PDMDEV_SET_ERROR(pDevIns, rc,
     
    24132454    vmmdevInitRam(pThis);
    24142455
    2415     if (fHeapEnabled)
     2456    if (pThis->fHeapEnabled)
    24162457    {
    24172458        rc = PDMDevHlpMMIO2Register(pDevIns, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
     
    24352476    if (RT_FAILURE(rc))
    24362477        return rc;
    2437     if (fHeapEnabled)
     2478    if (pThis->fHeapEnabled)
    24382479    {
    24392480        rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
     
    24852526     * Register saved state and init the HGCM CmdList critsect.
    24862527     */
    2487     rc = PDMDevHlpSSMRegisterEx(pDevIns, VMMDEV_SSM_VERSION, sizeof(*pThis), NULL,
    2488                                 NULL, NULL, NULL,
    2489                                 NULL, vmmdevSaveState, NULL,
    2490                                 NULL, vmmdevLoadState, vmmdevLoadStateDone);
     2528    rc = PDMDevHlpSSMRegisterEx(pDevIns, VMMDEV_SAVED_STATE_VERSION, sizeof(*pThis), NULL,
     2529                                NULL, vmmdevLiveExec, NULL,
     2530                                NULL, vmmdevSaveExec, NULL,
     2531                                NULL, vmmdevLoadExec, vmmdevLoadStateDone);
    24912532    AssertRCReturn(rc, rc);
    24922533
  • trunk/src/VBox/Devices/VMMDev/VMMDevHGCM.cpp

    r23016 r24076  
    21632163
    21642164/* @thread EMT */
    2165 int vmmdevHGCMLoadState(VMMDevState *pVMMDevState, PSSMHANDLE pSSM, uint32_t u32Version)
     2165int vmmdevHGCMLoadState(VMMDevState *pVMMDevState, PSSMHANDLE pSSM, uint32_t uVersion)
    21662166{
    21672167    int rc = VINF_SUCCESS;
     
    21762176    LogFlowFunc(("cCmds = %d\n", cCmds));
    21772177
    2178     if (   SSM_VERSION_MAJOR(u32Version) ==  0
    2179         && SSM_VERSION_MINOR(u32Version) < 9)
     2178    if (uVersion < 9)
    21802179    {
    21812180        /* Only the guest physical address is saved. */
  • trunk/src/VBox/Devices/VMMDev/VMMDevState.h

    r23003 r24076  
    176176    bool fKeepCredentials;
    177177
     178    /** Heap enabled. */
     179    bool fHeapEnabled;
     180
    178181#ifdef VBOX_WITH_HGCM
    179182    /** List of pending HGCM requests, used for saving the HGCM state. */
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