VirtualBox

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


Ignore:
Timestamp:
Nov 21, 2009 9:57:48 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
55077
Message:

SSM: Added SSMR3HandleRevision, SSMR3HandleVersion and SSMR3HandleHostOSAndArch for assiting in deal with saved state blunders. (#4480)

File:
1 edited

Legend:

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

    r24804 r24843  
    549549            /** 32-bit MSC saved this? */
    550550            bool            fIsHostMsc32;
     551            /** "Host OS" dot "architecture", picked up from recent SSM data units. */
     552            char            szHostOSAndArch[32];
    551553
    552554            /** @name Header info (set by ssmR3ValidateFile)
     
    10171019            /*
    10181020             * Detect 32-bit MSC for handling SSMFIELD_ENTRY_PAD_MSC32_AUTO.
     1021             * Save the Host OS for SSMR3HandleHostOSAndArch
    10191022             */
    10201023            if (!strcmp(szVar, "Host OS"))
     
    10261029                    pSSM->u.Read.fIsHostMsc32 = fIsHostMsc32;
    10271030                }
     1031
     1032                size_t cchValue = strlen(szValue);
     1033                size_t cchCopy = RT_MIN(cchValue, sizeof(pSSM->u.Read.szHostOSAndArch) - 1);
     1034                Assert(cchValue == cchCopy);
     1035                memcpy(pSSM->u.Read.szHostOSAndArch, szValue, cchCopy);
     1036                pSSM->u.Read.szHostOSAndArch[cchCopy] = '\0';
    10281037            }
    10291038        }
     
    73527361    pSSM->u.Read.fFixedGCPtrSize= false;
    73537362    pSSM->u.Read.fIsHostMsc32   = SSM_HOST_IS_MSC_32;
     7363    RT_ZERO(pSSM->u.Read.szHostOSAndArch);
    73547364    pSSM->u.Read.u16VerMajor    = UINT16_MAX;
    73557365    pSSM->u.Read.u16VerMinor    = UINT16_MAX;
     
    86398649 * @returns 32 or 64. If pSSM is invalid, 0 is returned.
    86408650 * @param   pSSM            The saved state handle.
     8651 *
     8652 * @remarks This method should ONLY be used for hacks when loading OLDER saved
     8653 *          state that have data layout or semantical changes without the
     8654 *          compulsory version number change.
    86418655 */
    86428656VMMR3DECL(uint32_t) SSMR3HandleHostBits(PSSMHANDLE pSSM)
     
    86448658    SSM_ASSERT_VALID_HANDLE(pSSM);
    86458659    return ssmR3GetHostBits(pSSM);
     8660}
     8661
     8662
     8663/**
     8664 * Get the VirtualBox SVN revision that created the saved state.
     8665 *
     8666 * @returns The revision number on success.
     8667 *          form.  If we don't know, it's an empty string.
     8668 * @param   pSSM            The saved state handle.
     8669 *
     8670 * @remarks This method should ONLY be used for hacks when loading OLDER saved
     8671 *          state that have data layout or semantical changes without the
     8672 *          compulsory version number change.  Be VERY careful with this
     8673 *          function since it will return different values for OSE builds!
     8674 */
     8675VMMR3DECL(uint32_t)     SSMR3HandleRevision(PSSMHANDLE pSSM)
     8676{
     8677    if (pSSM->enmOp >= SSMSTATE_LOAD_PREP)
     8678        return pSSM->u.Read.u32SvnRev;
     8679    return VMMGetSvnRev();
     8680}
     8681
     8682
     8683/**
     8684 * Gets the VirtualBox version that created the saved state.
     8685 *
     8686 * @returns VBOX_FULL_VERSION style version number.
     8687 *          Returns UINT32_MAX if unknown or somehow out of range.
     8688 *
     8689 * @param   pSSM            The saved state handle.
     8690 *
     8691 * @remarks This method should ONLY be used for hacks when loading OLDER saved
     8692 *          state that have data layout or semantical changes without the
     8693 *          compulsory version number change.
     8694 */
     8695VMMR3DECL(uint32_t)     SSMR3HandleVersion(PSSMHANDLE pSSM)
     8696{
     8697    if (pSSM->enmOp >= SSMSTATE_LOAD_PREP)
     8698    {
     8699        if (    !pSSM->u.Read.u16VerMajor
     8700            &&  !pSSM->u.Read.u16VerMinor
     8701            &&  !pSSM->u.Read.u32VerBuild)
     8702            return UINT32_MAX;
     8703        AssertReturn(pSSM->u.Read.u16VerMajor <=   0xff, UINT32_MAX);
     8704        AssertReturn(pSSM->u.Read.u16VerMinor <=   0xff, UINT32_MAX);
     8705        AssertReturn(pSSM->u.Read.u32VerBuild <= 0xffff, UINT32_MAX);
     8706        return VBOX_FULL_VERSION_MAKE(pSSM->u.Read.u16VerMajor, pSSM->u.Read.u16VerMinor, pSSM->u.Read.u32VerBuild);
     8707    }
     8708    return VBOX_FULL_VERSION;
     8709}
     8710
     8711
     8712/**
     8713 * Get the host OS and architecture where the saved state was created.
     8714 *
     8715 * @returns Pointer to a read only string.  When known, this is on the os.arch
     8716 *          form.  If we don't know, it's an empty string.
     8717 * @param   pSSM            The saved state handle.
     8718 *
     8719 * @remarks This method should ONLY be used for hacks when loading OLDER saved
     8720 *          state that have data layout or semantical changes without the
     8721 *          compulsory version number change.
     8722 */
     8723VMMR3DECL(const char *) SSMR3HandleHostOSAndArch(PSSMHANDLE pSSM)
     8724{
     8725    if (pSSM->enmOp >= SSMSTATE_LOAD_PREP)
     8726        return pSSM->u.Read.szHostOSAndArch;
     8727    return KBUILD_TARGET "." KBUILD_TARGET_ARCH;
    86468728}
    86478729
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