VirtualBox

Changeset 22784 in vbox for trunk


Ignore:
Timestamp:
Sep 4, 2009 2:25:31 PM (15 years ago)
Author:
vboxsync
Message:

VMM,Main,VBoxBFE: Changed VMR3Save and started working on making TakeSnapshot work without pausing the VM first.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Config.kmk

    r22777 r22784  
    505505endif
    506506
     507#
     508# Config items for enabling work in progress.
     509#
     510# It's good pratice to add stuff here even if it is currently disabled by
     511# default.
     512#
     513# Note! Please, do *not* add stuff to the global DEFS unless it is *really*
     514#       necessary!  The other guys will hate for it you when they have to
     515#       recompile everything when the feature is enabled or disabled.  Put
     516#       the ifdefs in target or template definitions.
     517#
     518
    507519## For experimenting with disabling preemption instead of interrupts
    508520# when working VT-x/AMD-V in VMMR0.
     
    511523 VBOX_WITH_VMMR0_DISABLE_PREEMPTION = 1
    512524endif
     525
     526## Enabled the live migration API changes.
     527#VBOX_WITH_LIVE_MIGRATION = 1
    513528
    514529#
  • trunk/include/VBox/vmapi.h

    r21217 r22784  
    370370typedef FNVMPROGRESS *PFNVMPROGRESS;
    371371
    372 VMMR3DECL(int)  VMR3Save(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
     372VMMR3DECL(int)  VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser);
    373373VMMR3DECL(int)  VMR3Load(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
    374374VMMR3DECL(int)  VMR3PowerOff(PVM pVM);
  • trunk/src/VBox/Frontends/VBoxBFE/VMControl.cpp

    r19300 r22784  
    161161    startProgressInfo("Saving");
    162162    rc = VMR3ReqCall(pVM, VMCPUID_ANY, &pReq, RT_INDEFINITE_WAIT,
    163                      (PFNRT)VMR3Save, 4, pVM, g_pszStateFile, &callProgressInfo, (uintptr_t)NULL);
     163                     (PFNRT)VMR3Save, 5, pVM, g_pszStateFile, false /*fContinueAftewards*/, &callProgressInfo, (uintptr_t)NULL);
    164164    endProgressInfo();
    165165    if (RT_SUCCESS(rc))
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r22624 r22784  
    23862386    MachineState_T lastMachineState = mMachineState;
    23872387
     2388#ifndef VBOX_WITH_LIVE_MIGRATION /** @todo update the API docs. */
    23882389    if (mMachineState == MachineState_Running)
    23892390    {
     
    23912392        CheckComRCReturnRC(rc);
    23922393    }
     2394#endif
    23932395
    23942396    HRESULT rc = S_OK;
    23952397
    2396     bool fTakingSnapshotOnline = (mMachineState == MachineState_Paused);
     2398    bool const fTakingSnapshotOnline = (   mMachineState == MachineState_Running
     2399                                        || mMachineState == MachineState_Paused);
    23972400
    23982401    /*
     
    24502453
    24512454        /*
    2452          *  state file is non-null only when the VM is paused
    2453          *  (i.e. creating a snapshot online)
     2455         *  The state file is non-null only when creating a online or live snapshot.
    24542456         */
    24552457        ComAssertBreak(    (!stateFilePath.isNull() && fTakingSnapshotOnline)
     
    73167318        int vrc = VMR3Save(that->mpVM,
    73177319                           task->mSavedStateFile.c_str(),
     7320                           task->mIsSnapshot /*fContinueAfterwards*/,
    73187321                           Console::stateProgressCallback,
    73197322                           static_cast<VMProgressTask*>(task.get()));
  • trunk/src/VBox/Main/MachineImpl.cpp

    r22779 r22784  
    79277927    AssertReturn(    (    !Global::IsOnlineOrTransient (mData->mMachineState)
    79287928                       || mData->mMachineState == MachineState_Paused
     7929#ifdef VBOX_WITH_LIVE_MIGRATION
     7930                       || mData->mMachineState == MachineState_Running
     7931#endif
    79297932                     )
    79307933                  && mSnapshotData.mLastState == MachineState_Null
     
    79337936                  && mSnapshotData.mCombinedProgress.isNull(), E_FAIL);
    79347937
    7935     bool fTakingSnapshotOnline = (mData->mMachineState == MachineState_Paused);
     7938    bool const fTakingSnapshotOnline = (   mData->mMachineState == MachineState_Running
     7939                                        || mData->mMachineState == MachineState_Paused);
    79367940
    79377941    if (    !fTakingSnapshotOnline
  • trunk/src/VBox/Main/Makefile.kmk

    r22705 r22784  
    216216        $(if $(VBOX_WITH_PDM_ASYNC_COMPLETION),VBOX_WITH_PDM_ASYNC_COMPLETION,) \
    217217        $(if $(VBOX_WITH_DBUS),VBOX_WITH_DBUS,) \
    218         $(if $(VBOX_USB_WITH_SYSFS),VBOX_USB_WITH_SYSFS,)
     218        $(if $(VBOX_USB_WITH_SYSFS),VBOX_USB_WITH_SYSFS,) \
     219        $(if $(VBOX_WITH_LIVE_MIGRATION),VBOX_WITH_LIVE_MIGRATION,)
    219220ifdef VBOX_WITH_USB
    220221 VBoxSVC_DEFS += \
     
    529530        $(if $(VBOX_WITH_SMC),VBOX_WITH_SMC,) \
    530531        $(if $(VBOX_WITH_LPC),VBOX_WITH_LPC,) \
    531         $(if $(VBOX_WITH_PDM_ASYNC_COMPLETION),VBOX_WITH_PDM_ASYNC_COMPLETION,)
     532        $(if $(VBOX_WITH_PDM_ASYNC_COMPLETION),VBOX_WITH_PDM_ASYNC_COMPLETION,) \
     533        $(if $(VBOX_WITH_LIVE_MIGRATION),VBOX_WITH_LIVE_MIGRATION,)
    532534ifdef VBOX_WITH_USB
    533535VBoxC_DEFS += \
  • trunk/src/VBox/VMM/VM.cpp

    r22636 r22784  
    135135static DECLCALLBACK(int) vmR3Suspend(PVM pVM);
    136136static DECLCALLBACK(int) vmR3Resume(PVM pVM);
    137 static DECLCALLBACK(int) vmR3Save(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
     137static DECLCALLBACK(int) vmR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
    138138static DECLCALLBACK(int) vmR3Load(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser);
    139139static DECLCALLBACK(int) vmR3PowerOff(PVM pVM);
     
    13861386 * Save current VM state.
    13871387 *
    1388  * To save and terminate the VM, the VM must be suspended before the call.
     1388 * Can be used for both saving the state and creating snapshots.
     1389 *
     1390 * When called for a VM in the RUNNING state, the saved state is created live
     1391 * and the VM is only suspended when the final part of the saving is preformed.
     1392 * The VM state will not be restored to RUNNING in this case and it's up to the
     1393 * caller to call VMR3Resume if this is desirable.  (The rational is that the
     1394 * caller probably wish to reconfigure the disks before resuming the VM.)
     1395 *
     1396 * @returns VBox status code.
     1397 *
     1398 * @param   pVM                 VM which state should be saved.
     1399 * @param   pszFilename         Name of the save state file.
     1400 * @param   fContinueAftewards  Continue execution afterwards. When in doubt,
     1401 *                              set this to true.
     1402 * @param   pfnProgress         Progress callback. Optional.
     1403 * @param   pvUser              User argument for the progress callback.
     1404 *
     1405 * @thread      Any thread. Will forward the request to EMT(0).
     1406 * @vmstate     Suspended, Running
     1407 * @vmstateto   Suspended.
     1408 */
     1409VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAftewards, PFNVMPROGRESS pfnProgress, void *pvUser)
     1410{
     1411    LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAftewards=%RTbool pfnProgress=%p pvUser=%p\n",
     1412             pVM, pszFilename, pszFilename, fContinueAftewards, pfnProgress, pvUser));
     1413
     1414    /*
     1415     * Validate input.
     1416     */
     1417    VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
     1418    AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
     1419    AssertReturn(*pszFilename, VERR_INVALID_PARAMETER);
     1420    AssertPtrNullReturn(pfnProgress, VERR_INVALID_POINTER);
     1421
     1422    /*
     1423     * Request the operation in EMT(0).
     1424     */
     1425    SSMAFTER enmAfter = fContinueAftewards ? SSMAFTER_CONTINUE : SSMAFTER_DESTROY;
     1426    PVMREQ pReq;
     1427    int rc = VMR3ReqCall(pVM, 0 /* VCPU 0 */, &pReq, RT_INDEFINITE_WAIT,
     1428                         (PFNRT)vmR3Save, 5, pVM, pszFilename, enmAfter, pfnProgress, pvUser);
     1429    if (RT_SUCCESS(rc))
     1430    {
     1431        rc = pReq->iStatus;
     1432        VMR3ReqFree(pReq);
     1433    }
     1434
     1435    LogFlow(("VMR3Save: returns %Rrc\n", rc));
     1436    return rc;
     1437}
     1438
     1439
     1440/**
     1441 * Worker for VMR3Save that validates the state and calls SSMR3Save.
    13891442 *
    13901443 * @returns 0 on success.
     
    13921445 * @param   pVM             VM which state should be saved.
    13931446 * @param   pszFilename     Name of the save state file.
    1394  * @param   pfnProgress     Progress callback. Optional.
    1395  * @param   pvUser          User argument for the progress callback.
    1396  * @thread      Any thread.
    1397  * @vmstate     Suspended
    1398  * @vmstateto   Unchanged state.
    1399  */
    1400 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser)
    1401 {
    1402     LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} pfnProgress=%p pvUser=%p\n", pVM, pszFilename, pszFilename, pfnProgress, pvUser));
    1403 
    1404     /*
    1405      * Validate input.
    1406      */
    1407     if (!pVM)
    1408     {
    1409         AssertMsgFailed(("Invalid VM pointer\n"));
    1410         return VERR_INVALID_PARAMETER;
    1411     }
    1412     if (!pszFilename)
    1413     {
    1414         AssertMsgFailed(("Must specify a filename to save the state to, wise guy!\n"));
    1415         return VERR_INVALID_PARAMETER;
    1416     }
    1417 
    1418     /*
    1419      * Request the operation in EMT.
    1420      */
    1421     PVMREQ pReq;
    1422     int rc = VMR3ReqCall(pVM, 0 /* VCPU 0 */, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3Save, 4, pVM, pszFilename, pfnProgress, pvUser);
    1423     if (RT_SUCCESS(rc))
    1424     {
    1425         rc = pReq->iStatus;
    1426         VMR3ReqFree(pReq);
    1427     }
    1428 
    1429     LogFlow(("VMR3Save: returns %Rrc\n", rc));
    1430     return rc;
    1431 }
    1432 
    1433 
    1434 /**
    1435  * Save current VM state.
    1436  *
    1437  * To save and terminate the VM, the VM must be suspended before the call.
    1438  *
    1439  * @returns 0 on success.
    1440  * @returns VBox error code on failure.
    1441  * @param   pVM             VM which state should be saved.
    1442  * @param   pszFilename     Name of the save state file.
     1447 * @param   enmAfter        What to do afterwards.
    14431448 * @param   pfnProgress     Progress callback. Optional.
    14441449 * @param   pvUser          User argument for the progress callback.
    14451450 * @thread  EMT
    14461451 */
    1447 static DECLCALLBACK(int) vmR3Save(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser)
    1448 {
    1449     LogFlow(("vmR3Save: pVM=%p pszFilename=%p:{%s} pfnProgress=%p pvUser=%p\n", pVM, pszFilename, pszFilename, pfnProgress, pvUser));
     1452static DECLCALLBACK(int) vmR3Save(PVM pVM, const char *pszFilename, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser)
     1453{
     1454    LogFlow(("vmR3Save: pVM=%p pszFilename=%p:{%s} enmAfter=%d pfnProgress=%p pvUser=%p\n", pVM, pszFilename, pszFilename, enmAfter, pfnProgress, pvUser));
    14501455
    14511456    /*
    14521457     * Validate input.
    14531458     */
    1454     if (pVM->enmVMState != VMSTATE_SUSPENDED)
    1455     {
    1456         AssertMsgFailed(("Invalid VM state %d\n", pVM->enmVMState));
    1457         return VERR_VM_INVALID_VM_STATE;
    1458     }
     1459    /** @todo SMP: Check that vmR3SetState always done by EMT(0). If not add a vmR3TrySetState(). */
     1460    AssertMsgReturn(   pVM->enmVMState == VMSTATE_SUSPENDED
     1461                    || pVM->enmVMState == VMSTATE_RUNNING,
     1462                    ("%d\n", pVM->enmVMState),
     1463                    VERR_VM_INVALID_VM_STATE);
    14591464
    14601465    /* If we are in an inconsistent state, then we don't allow state saving. */
    1461     if (pVM->vm.s.fPreventSaveState)
     1466    if (pVM->vm.s.fPreventSaveState)    /** @todo Incorporate VMINT::fPreventSaveState into the VMSTATE. There is a defect for this. */
    14621467    {
    14631468        LogRel(("VMM: vmR3Save: saving the VM state is not allowed at this moment\n"));
     
    14681473     * Change the state and perform the save.
    14691474     */
    1470     vmR3SetState(pVM, VMSTATE_SAVING);
    1471     int rc = SSMR3Save(pVM, pszFilename, SSMAFTER_CONTINUE, pfnProgress,  pvUser);
     1475    vmR3SetState(pVM, VMSTATE_SAVING); /** @todo Should probably use a different state for live snapshots and/or live migration. Will fix the state machine later. */
     1476    int rc = SSMR3Save(pVM, pszFilename, enmAfter, pfnProgress,  pvUser);
    14721477    vmR3SetState(pVM, VMSTATE_SUSPENDED);
    14731478
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