VirtualBox

Changeset 23540 in vbox


Ignore:
Timestamp:
Oct 4, 2009 9:00:21 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53183
Message:

SSM: Added a live save flag to the file header and handle, exposing it via SSMR3HandleIsLiveSave. Also shut up an annoying progress bar assertion.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/ssm.h

    r23002 r23540  
    658658VMMR3DECL(int)          SSMR3HandleSetStatus(PSSMHANDLE pSSM, int iStatus);
    659659VMMR3DECL(SSMAFTER)     SSMR3HandleGetAfter(PSSMHANDLE pSSM);
    660 VMMR3DECL(uint64_t)     SSMR3HandleGetUnitOffset(PSSMHANDLE pSSM);
     660VMMR3DECL(bool)         SSMR3HandleIsLiveSave(PSSMHANDLE pSSM);
    661661VMMR3_INT_DECL(int)     SSMR3SetGCPtrSize(PSSMHANDLE pSSM, unsigned cbGCPtr);
    662662VMMR3DECL(int)          SSMR3Cancel(PVM pVM);
  • trunk/src/VBox/VMM/SSM.cpp

    r23448 r23540  
    191191/** The stream is checkesummed up to the footer using CRC-32. */
    192192#define SSMFILEHDR_FLAGS_STREAM_CRC32           RT_BIT_32(0)
     193/** Indicates that the file was produced by a live save. */
     194#define SSMFILEHDR_FLAGS_STREAM_LIVE_SAVE       RT_BIT_32(1)
    193195/** @} */
    194196
     
    318320    } while (0)
    319321
     322#define SSM_ASSERT_VALID_HANDLE(pSSM) \
     323    do \
     324    { \
     325        AssertPtr(pSSM); \
     326        Assert(pSSM->enmOp > SSMSTATE_INVALID && pSSM->enmOp < SSMSTATE_OPEN_END); \
     327    } while (0)
     328
    320329
    321330/*******************************************************************************
     
    337346    SSMSTATE_LOAD_EXEC,
    338347    SSMSTATE_LOAD_DONE,
    339     SSMSTATE_OPEN_READ
     348    SSMSTATE_OPEN_READ,
     349    SSMSTATE_OPEN_END
    340350} SSMSTATE;
    341351
     
    440450    /** The current uncompressed offset into the data unit. */
    441451    uint64_t                offUnit;
     452    /** Indicates that this is a live save or restore operation. */
     453    bool                    fLiveSave;
    442454
    443455    /** Pointer to the progress callback function. */
     
    38053817
    38063818    /* (progress should be pending 99% now) */
    3807     AssertMsg(pSSM->uPercent == (101 - pSSM->uPercentDone), ("%d\n", pSSM->uPercent));
     3819    AssertMsg(   pSSM->uPercent == (101 - pSSM->uPercentDone)
     3820              || pSSM->fLiveSave, ("%d\n", pSSM->uPercent));
    38083821    return VINF_SUCCESS;
    38093822}
     
    39623975    FileHdr.cUnits       = pVM->ssm.s.cUnits;
    39633976    FileHdr.fFlags       = SSMFILEHDR_FLAGS_STREAM_CRC32;
     3977    if (pSSM->fLiveSave)
     3978        FileHdr.fFlags  |= SSMFILEHDR_FLAGS_STREAM_LIVE_SAVE;
    39643979    FileHdr.cbMaxDecompr = RT_SIZEOFMEMB(SSMHANDLE, u.Read.abDataBuffer);
    39653980    FileHdr.u32CRC       = 0;
     
    40094024    pSSM->cbUnitLeftV1          = 0;
    40104025    pSSM->offUnit               = UINT64_MAX;
     4026    pSSM->fLiveSave             = false;
    40114027    pSSM->pfnProgress           = pfnProgress;
    40124028    pSSM->pvUser                = pvUser;
     
    43774393            }
    43784394        }
    4379 #if 0
     4395#if 0 /** @todo check this out... */
    43804396        /*
    43814397         * Check the VM state to see if it has changed.
     
    45154531    pSSM->uPercentPrepare = 20; /** @todo fix these. */
    45164532    pSSM->uPercentDone    = 2;
     4533    pSSM->fLiveSave       = true;
    45174534
    45184535    /*
     
    45254542    {
    45264543/** @todo If it turns out we don't need to do ssmR3DoLivePrepRun on EMT0,
    4527  *        simply move the code to SSMR3LiveDoStep1. */
     4544 *        simply move the code to SSMR3LiveDoStep1.
     4545 *  Update: This is certinaly the case, move it. */
    45284546        rc = ssmR3DoLivePrepRun(pVM, pSSM);
    45294547        if (RT_SUCCESS(rc))
     
    60276045 *
    60286046 * @returns VBox status.
    6029  * @param   File                File to validate.
    6030  *                              The file position is undefined on return.
     6047 * @param   pSSM                The saved state handle.  A number of field will
     6048 *                              be updated, mostly header related information.
     6049 *                              fLiveSave is also set if appropriate.
    60316050 * @param   fChecksumIt         Whether to checksum the file or not.  This will
    60326051 *                              be ignored if it the stream isn't a file.
     
    61126131                return VERR_SSM_INTEGRITY;
    61136132            }
    6114             if ((uHdr.v2_0.fFlags & ~SSMFILEHDR_FLAGS_STREAM_CRC32))
     6133            if (uHdr.v2_0.fFlags & ~(SSMFILEHDR_FLAGS_STREAM_CRC32 | SSMFILEHDR_FLAGS_STREAM_LIVE_SAVE))
    61156134            {
    61166135                LogRel(("SSM: Unknown header flags: %08x\n", uHdr.v2_0.fFlags));
     
    61336152            pSSM->u.Read.cbGCPhys       = uHdr.v2_0.cbGCPhys;
    61346153            pSSM->u.Read.cbGCPtr        = uHdr.v2_0.cbGCPtr;
    6135             pSSM->u.Read.fFixedGCPtrSize = true;
     6154            pSSM->u.Read.fFixedGCPtrSize= true;
    61366155            fChecksummed = !!(uHdr.v2_0.fFlags & SSMFILEHDR_FLAGS_STREAM_CRC32);
     6156            pSSM->fLiveSave             = !!(uHdr.v2_0.fFlags & SSMFILEHDR_FLAGS_STREAM_LIVE_SAVE);
    61376157        }
    61386158        else
     
    63386358    pSSM->cbUnitLeftV1      = 0;
    63396359    pSSM->offUnit           = UINT64_MAX;
     6360    pSSM->fLiveSave         = false;
    63406361    pSSM->pfnProgress       = NULL;
    63416362    pSSM->pvUser            = NULL;
     
    73217342VMMR3DECL(int) SSMR3HandleGetStatus(PSSMHANDLE pSSM)
    73227343{
     7344    SSM_ASSERT_VALID_HANDLE(pSSM);
    73237345    return pSSM->rc;
    73247346}
     
    73387360VMMR3DECL(int) SSMR3HandleSetStatus(PSSMHANDLE pSSM, int iStatus)
    73397361{
     7362    SSM_ASSERT_VALID_HANDLE(pSSM);
    73407363    Assert(pSSM->enmOp != SSMSTATE_LIVE_VOTE);
    73417364    if (RT_FAILURE(iStatus))
     
    73597382VMMR3DECL(SSMAFTER) SSMR3HandleGetAfter(PSSMHANDLE pSSM)
    73607383{
     7384    SSM_ASSERT_VALID_HANDLE(pSSM);
    73617385    return pSSM->enmAfter;
    73627386}
     
    73647388
    73657389/**
    7366  * Get the current unit byte offset (uncompressed).
    7367  *
    7368  * @returns The offset. UINT64_MAX if called at a wrong time.
     7390 * Checks if it is a live save operation or not.
     7391 *
     7392 * @returns True if it is, false if it isn't.
    73697393 * @param   pSSM            SSM operation handle.
    73707394 */
    7371 VMMR3DECL(uint64_t) SSMR3HandleGetUnitOffset(PSSMHANDLE pSSM)
    7372 {
    7373     AssertMsgFailed(("/** @todo this isn't correct any longer. */"));
    7374     return pSSM->offUnit;
     7395VMMR3DECL(bool) SSMR3HandleIsLiveSave(PSSMHANDLE pSSM)
     7396{
     7397    SSM_ASSERT_VALID_HANDLE(pSSM);
     7398    return pSSM->fLiveSave;
    73757399}
    73767400
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