VirtualBox

Changeset 24198 in vbox


Ignore:
Timestamp:
Oct 30, 2009 2:43:23 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54145
Message:

SSM: Do the SaveDone round on live failure.

File:
1 edited

Legend:

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

    r23905 r24198  
    39633963
    39643964/**
    3965  * Worker for SSMR3LiveDone and SSMR3Save that closes the handle and deletes the
    3966  * saved state file on failure.
    3967  *
    3968  * @returns VBox status code (pSSM->rc).
    3969  * @param   pVM                 The VM handle.
    3970  * @param   pSSM                The saved state handle.
    3971  */
    3972 static int ssmR3SaveDoClose(PVM pVM, PSSMHANDLE pSSM)
    3973 {
    3974     VM_ASSERT_EMT0(pVM);
    3975 
    3976     /*
    3977      * Make it non-cancellable, close the stream and delete the file on failure.
    3978      */
    3979     ssmR3SetCancellable(pVM, pSSM, false);
    3980     int rc = ssmR3StrmClose(&pSSM->Strm);
    3981     if (RT_SUCCESS(rc))
    3982         rc = pSSM->rc;
    3983     if (RT_SUCCESS(rc))
    3984     {
    3985         if (pSSM->pfnProgress)
    3986             pSSM->pfnProgress(pVM, 100, pSSM->pvUser);
    3987         LogRel(("SSM: Successfully saved the VM state to '%s'\n",
    3988                 pSSM->pszFilename ? pSSM->pszFilename : "<remote-machine>"));
    3989     }
    3990     else
    3991     {
    3992         if (pSSM->pszFilename)
    3993         {
    3994             int rc2 = RTFileDelete(pSSM->pszFilename);
    3995             AssertRC(rc2);
    3996             if (RT_SUCCESS(rc2))
    3997                 LogRel(("SSM: Failed to save the VM state to '%s' (file deleted): %Rrc\n",
    3998                         pSSM->pszFilename, rc));
    3999             else
    4000                 LogRel(("SSM: Failed to save the VM state to '%s' (file deletion failed, rc2=%Rrc): %Rrc\n",
    4001                         pSSM->pszFilename, rc2, rc));
    4002         }
    4003         else
    4004             LogRel(("SSM: Failed to save the VM state.\n"));
    4005     }
    4006 
    4007     /*
    4008      * Trash the handle before freeing it.
    4009      */
    4010     ASMAtomicWriteU32(&pSSM->fCancelled, 0);
    4011     pSSM->pVM = NULL;
    4012     pSSM->enmAfter = SSMAFTER_INVALID;
    4013     pSSM->enmOp = SSMSTATE_INVALID;
    4014     RTMemFree(pSSM);
    4015 
    4016     return rc;
    4017 }
    4018 
    4019 
    4020 /**
    4021  * Closes the SSM handle.
    4022  *
    4023  * This must always be called on a handled returned by SSMR3LiveSave.
    4024  *
    4025  * @returns VBox status.
    4026  *
    4027  * @param   pSSM            The SSM handle returned by SSMR3LiveSave.
    4028  *
    4029  * @thread  EMT(0).
    4030  */
    4031 VMMR3_INT_DECL(int) SSMR3LiveDone(PSSMHANDLE pSSM)
    4032 {
    4033     LogFlow(("SSMR3LiveDone: pSSM=%p\n", pSSM));
    4034 
    4035     /*
    4036      * Validate input.
    4037      */
    4038     AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
    4039     PVM pVM = pSSM->pVM;
    4040     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
    4041     VM_ASSERT_EMT0(pVM);
    4042     AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
    4043                     || pSSM->enmAfter == SSMAFTER_CONTINUE
    4044                     || pSSM->enmAfter == SSMAFTER_TELEPORT,
    4045                     ("%d\n", pSSM->enmAfter),
    4046                     VERR_INVALID_PARAMETER);
    4047     AssertMsgReturn(    pSSM->enmOp >= SSMSTATE_LIVE_PREP
    4048                     &&  pSSM->enmOp <= SSMSTATE_SAVE_DONE,
    4049                     ("%d\n", pSSM->enmOp), VERR_INVALID_STATE);
    4050 
    4051     /*
    4052      * Join paths with SSMR3Save again.
    4053      */
    4054     return ssmR3SaveDoClose(pVM, pSSM);
    4055 }
    4056 
    4057 
    4058 /**
    40593965 * Do the pfnSaveDone run.
    40603966 *
     
    41084014    }
    41094015    return pSSM->rc;
     4016}
     4017
     4018
     4019/**
     4020 * Worker for SSMR3LiveDone and SSMR3Save that closes the handle and deletes the
     4021 * saved state file on failure.
     4022 *
     4023 * @returns VBox status code (pSSM->rc).
     4024 * @param   pVM                 The VM handle.
     4025 * @param   pSSM                The saved state handle.
     4026 */
     4027static int ssmR3SaveDoClose(PVM pVM, PSSMHANDLE pSSM)
     4028{
     4029    VM_ASSERT_EMT0(pVM);
     4030
     4031
     4032    /*
     4033     * Make it non-cancellable, close the stream and delete the file on failure.
     4034     */
     4035    ssmR3SetCancellable(pVM, pSSM, false);
     4036    int rc = ssmR3StrmClose(&pSSM->Strm);
     4037    if (RT_SUCCESS(rc))
     4038        rc = pSSM->rc;
     4039    if (RT_SUCCESS(rc))
     4040    {
     4041        Assert(pSSM->enmOp == SSMSTATE_SAVE_DONE);
     4042        if (pSSM->pfnProgress)
     4043            pSSM->pfnProgress(pVM, 100, pSSM->pvUser);
     4044        LogRel(("SSM: Successfully saved the VM state to '%s'\n",
     4045                pSSM->pszFilename ? pSSM->pszFilename : "<remote-machine>"));
     4046    }
     4047    else
     4048    {
     4049        if (pSSM->pszFilename)
     4050        {
     4051            int rc2 = RTFileDelete(pSSM->pszFilename);
     4052            AssertRC(rc2);
     4053            if (RT_SUCCESS(rc2))
     4054                LogRel(("SSM: Failed to save the VM state to '%s' (file deleted): %Rrc\n",
     4055                        pSSM->pszFilename, rc));
     4056            else
     4057                LogRel(("SSM: Failed to save the VM state to '%s' (file deletion failed, rc2=%Rrc): %Rrc\n",
     4058                        pSSM->pszFilename, rc2, rc));
     4059        }
     4060        else
     4061            LogRel(("SSM: Failed to save the VM state.\n"));
     4062
     4063        Assert(pSSM->enmOp <= SSMSTATE_SAVE_DONE);
     4064        if (pSSM->enmOp != SSMSTATE_SAVE_DONE)
     4065            ssmR3SaveDoDoneRun(pVM, pSSM);
     4066    }
     4067
     4068    /*
     4069     * Trash the handle before freeing it.
     4070     */
     4071    ASMAtomicWriteU32(&pSSM->fCancelled, 0);
     4072    pSSM->pVM = NULL;
     4073    pSSM->enmAfter = SSMAFTER_INVALID;
     4074    pSSM->enmOp = SSMSTATE_INVALID;
     4075    RTMemFree(pSSM);
     4076
     4077    return rc;
     4078}
     4079
     4080
     4081/**
     4082 * Closes the SSM handle.
     4083 *
     4084 * This must always be called on a handled returned by SSMR3LiveSave.
     4085 *
     4086 * @returns VBox status.
     4087 *
     4088 * @param   pSSM            The SSM handle returned by SSMR3LiveSave.
     4089 *
     4090 * @thread  EMT(0).
     4091 */
     4092VMMR3_INT_DECL(int) SSMR3LiveDone(PSSMHANDLE pSSM)
     4093{
     4094    LogFlow(("SSMR3LiveDone: pSSM=%p\n", pSSM));
     4095
     4096    /*
     4097     * Validate input.
     4098     */
     4099    AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
     4100    PVM pVM = pSSM->pVM;
     4101    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     4102    VM_ASSERT_EMT0(pVM);
     4103    AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
     4104                    || pSSM->enmAfter == SSMAFTER_CONTINUE
     4105                    || pSSM->enmAfter == SSMAFTER_TELEPORT,
     4106                    ("%d\n", pSSM->enmAfter),
     4107                    VERR_INVALID_PARAMETER);
     4108    AssertMsgReturn(    pSSM->enmOp >= SSMSTATE_LIVE_PREP
     4109                    &&  pSSM->enmOp <= SSMSTATE_SAVE_DONE,
     4110                    ("%d\n", pSSM->enmOp), VERR_INVALID_STATE);
     4111
     4112    /*
     4113     * Join paths with SSMR3Save again.
     4114     */
     4115    return ssmR3SaveDoClose(pVM, pSSM);
    41104116}
    41114117
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