Changeset 24922 in vbox
- Timestamp:
- Nov 24, 2009 7:33:31 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
include/VBox/vmapi.h (modified) (1 diff)
-
src/VBox/Main/ConsoleImpl.cpp (modified) (17 diffs)
-
src/VBox/VMM/VM.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmapi.h
r24874 r24922 336 336 typedef FNVMPROGRESS *PFNVMPROGRESS; 337 337 338 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser );338 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended); 339 339 VMMR3DECL(int) VMR3Teleport(PVM pVM, uint32_t cMsDowntime, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, PFNVMPROGRESS pfnProgress, void *pvProgressUser, bool *pfSuspended); 340 340 VMMR3DECL(int) VMR3LoadFromFile(PVM pVM, const char *pszFilename, PFNVMPROGRESS pfnProgress, void *pvUser); -
trunk/src/VBox/Main/ConsoleImpl.cpp
r24899 r24922 2579 2579 ULONG ulMemSize; 2580 2580 rc = mMachine->COMGETTER(MemorySize)(&ulMemSize); 2581 if (FAILED(rc)) return rc; 2581 if (FAILED(rc)) 2582 return rc; 2582 2583 2583 2584 for (size_t i = 0; … … 2587 2588 DeviceType_T type; 2588 2589 rc = aMediumAttachments[i]->COMGETTER(Type)(&type); 2589 if (FAILED(rc)) return rc; 2590 if (FAILED(rc)) 2591 return rc; 2590 2592 2591 2593 if (type == DeviceType_HardDisk) … … 2605 2607 2606 2608 if ( fTakingSnapshotOnline 2607 || (mMachineState == MachineState_Saved)2609 || mMachineState == MachineState_Saved 2608 2610 ) 2609 2611 { … … 2624 2626 1); // ulFirstOperationWeight 2625 2627 2626 if (FAILED(rc)) return rc; 2628 if (FAILED(rc)) 2629 return rc; 2627 2630 2628 2631 VMTakeSnapshotTask *pTask; 2629 2632 if (!(pTask = new VMTakeSnapshotTask(this, pProgress, aName, aDescription))) 2630 return VERR_NO_MEMORY;2633 return E_OUTOFMEMORY; 2631 2634 2632 2635 Assert(pTask->mProgress); … … 5271 5274 if (mMachineState != aMachineState) 5272 5275 { 5273 LogFlowThisFunc(("machineState=%d\n", aMachineState)); 5276 LogThisFunc(("machineState=%s -> %s aUpdateServer=%RTbool\n", 5277 Global::stringifyMachineState(mMachineState), Global::stringifyMachineState(aMachineState), aUpdateServer)); 5274 5278 mMachineState = aMachineState; 5275 5279 … … 5627 5631 void *aUser) 5628 5632 { 5629 LogFlowFunc(("Changing state from % d to %d(aVM=%p)\n",5630 aOldState, aState, aVM));5633 LogFlowFunc(("Changing state from %s to %s (aVM=%p)\n", 5634 VMR3GetStateName(aOldState), VMR3GetStateName(aState), aVM)); 5631 5635 5632 5636 Console *that = static_cast<Console *>(aUser); … … 7345 7349 7346 7350 bool fBeganTakingSnapshot = false; 7351 bool fSuspenededBySave = false; 7347 7352 7348 7353 AutoCaller autoCaller(pTask->mConsole); … … 7368 7373 pTask->fTakingSnapshotOnline, 7369 7374 pTask->bstrSavedStateFile.asOutParam()); 7370 if (FAILED(rc)) throw rc; 7375 if (FAILED(rc)) 7376 throw rc; 7371 7377 7372 7378 fBeganTakingSnapshot = true; … … 7381 7387 7382 7388 /* sync the state with the server */ 7383 that->setMachineStateLocally(MachineState_Saving); 7389 if (pTask->lastMachineState == MachineState_Running) 7390 that->setMachineStateLocally(MachineState_LiveSnapshotting); 7391 else 7392 that->setMachineStateLocally(MachineState_Saving); 7384 7393 7385 7394 // STEP 3: save the VM state (if online) … … 7392 7401 7393 7402 alock.leave(); 7394 7403 LogFlowFunc(("VMR3Save...\n")); 7395 7404 int vrc = VMR3Save(that->mpVM, 7396 7405 strSavedStateFile.c_str(), 7397 7406 true /*fContinueAfterwards*/, 7398 7407 Console::stateProgressCallback, 7399 (void*)pTask); 7408 (void*)pTask, 7409 &fSuspenededBySave); 7410 alock.enter(); 7400 7411 if (RT_FAILURE(vrc)) 7401 7412 throw setError(E_FAIL, 7402 tr("Failed to save the machine state to '%s' (%Rrc)"), 7403 strSavedStateFile.c_str(), vrc); 7404 7405 alock.enter(); 7413 tr("Failed to save the machine state to '%s' (%Rrc)"), 7414 strSavedStateFile.c_str(), vrc); 7415 7406 7416 7407 7417 // STEP 4: reattach hard disks … … 7413 7423 com::SafeIfaceArray<IMediumAttachment> atts; 7414 7424 rc = that->mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(atts)); 7415 if (FAILED(rc)) throw rc; 7425 if (FAILED(rc)) 7426 throw rc; 7416 7427 7417 7428 for (size_t i = 0; … … 7431 7442 */ 7432 7443 rc = atts[i]->COMGETTER(Controller)(&controllerName); 7433 if (FAILED(rc)) throw rc; 7444 if (FAILED(rc)) 7445 throw rc; 7434 7446 7435 7447 rc = that->mMachine->GetStorageControllerByName(controllerName, controller.asOutParam()); 7436 if (FAILED(rc)) throw rc; 7448 if (FAILED(rc)) 7449 throw rc; 7437 7450 7438 7451 rc = controller->COMGETTER(ControllerType)(&enmController); 7439 if (FAILED(rc)) throw rc; 7452 if (FAILED(rc)) 7453 throw rc; 7440 7454 rc = controller->COMGETTER(Instance)(&lInstance); 7441 if (FAILED(rc)) throw rc; 7455 if (FAILED(rc)) 7456 throw rc; 7442 7457 rc = controller->COMGETTER(Bus)(&enmBus); 7443 if (FAILED(rc)) throw rc; 7458 if (FAILED(rc)) 7459 throw rc; 7444 7460 7445 7461 /* … … 7459 7475 if (RT_FAILURE(vrc)) 7460 7476 throw setError(E_FAIL, Console::tr("%Rrc"), vrc); 7461 if (FAILED(rc)) throw rc; 7477 if (FAILED(rc)) 7478 throw rc; 7462 7479 } 7463 7480 } … … 7468 7485 * before calling mControl->BeginTakingSnapshot(). 7469 7486 */ 7470 rc = that->mControl->EndTakingSnapshot(TRUE ); // success7487 rc = that->mControl->EndTakingSnapshot(TRUE /*aSuccess*/); 7471 7488 // do not throw rc here because we can't call EndTakingSnapshot() twice 7472 } 7473 catch (HRESULT rc) 7489 LogFlowFunc(("EndTakingSnapshot -> %Rhrc [mMachineState=%s]\n", rc, Global::stringifyMachineState(that->mMachineState))); 7490 } 7491 catch (HRESULT rcThrown) 7474 7492 { 7475 7493 /* preserve existing error info */ … … 7477 7495 7478 7496 if (fBeganTakingSnapshot) 7479 that->mControl->EndTakingSnapshot(FALSE); // failure 7480 } 7481 7482 pTask->mProgress->notifyComplete(rc); 7497 that->mControl->EndTakingSnapshot(FALSE /*aSuccess*/); 7498 7499 rc = rcThrown; 7500 LogFunc(("Caught %Rhrc [mMachineState=%s]\n", rc, Global::stringifyMachineState(that->mMachineState))); 7501 } 7502 Assert(alock.isWriteLockOnCurrentThread()); 7503 7504 if (FAILED(rc)) /* Must come before calling setMachineState. */ 7505 pTask->mProgress->notifyComplete(rc); 7506 7507 /* 7508 * Fix up the machine state. 7509 * 7510 * For live snapshots we do all the work, for the two other variantions we 7511 * just update the local copy. 7512 */ 7513 MachineState_T enmMachineState; 7514 that->mMachine->COMGETTER(State)(&enmMachineState); 7515 if ( that->mMachineState == MachineState_LiveSnapshotting 7516 || that->mMachineState == MachineState_Saving) 7517 { 7518 7519 if (!pTask->fTakingSnapshotOnline) 7520 that->setMachineStateLocally(pTask->lastMachineState); 7521 else if (SUCCEEDED(rc)) 7522 { 7523 Assert( pTask->lastMachineState == MachineState_Running 7524 || pTask->lastMachineState == MachineState_Paused); 7525 Assert(that->mMachineState == MachineState_Saving); 7526 if (pTask->lastMachineState == MachineState_Running) 7527 { 7528 LogFlowFunc(("VMR3Resume...\n")); 7529 alock.leave(); 7530 int vrc = VMR3Resume(that->mpVM); 7531 alock.enter(); 7532 if (RT_FAILURE(vrc)) 7533 { 7534 rc = setError(VBOX_E_VM_ERROR, tr("Could not resume the machine execution (%Rrc)"), vrc); 7535 pTask->mProgress->notifyComplete(rc); 7536 if (that->mMachineState == MachineState_Saving) 7537 that->setMachineStateLocally(MachineState_Paused); 7538 } 7539 } 7540 else 7541 that->setMachineStateLocally(MachineState_Paused); 7542 } 7543 else 7544 { 7545 /** @todo this could probably be made more generic and reused elsewhere. */ 7546 /* paranoid cleanup on for a failed online snapshot. */ 7547 VMSTATE enmVMState = VMR3GetState(that->mpVM); 7548 switch (enmVMState) 7549 { 7550 case VMSTATE_RUNNING: 7551 case VMSTATE_RUNNING_LS: 7552 case VMSTATE_DEBUGGING: 7553 case VMSTATE_DEBUGGING_LS: 7554 case VMSTATE_POWERING_OFF: 7555 case VMSTATE_POWERING_OFF_LS: 7556 case VMSTATE_RESETTING: 7557 case VMSTATE_RESETTING_LS: 7558 Assert(!fSuspenededBySave); 7559 that->setMachineState(MachineState_Running); 7560 break; 7561 7562 case VMSTATE_GURU_MEDITATION: 7563 case VMSTATE_GURU_MEDITATION_LS: 7564 that->setMachineState(MachineState_Stuck); 7565 break; 7566 7567 case VMSTATE_FATAL_ERROR: 7568 case VMSTATE_FATAL_ERROR_LS: 7569 if (pTask->lastMachineState == MachineState_Paused) 7570 that->setMachineStateLocally(pTask->lastMachineState); 7571 else 7572 that->setMachineState(MachineState_Paused); 7573 break; 7574 7575 default: 7576 AssertMsgFailed(("%s\n", VMR3GetStateName(enmVMState))); 7577 case VMSTATE_SUSPENDED: 7578 case VMSTATE_SUSPENDED_LS: 7579 case VMSTATE_SUSPENDING: 7580 case VMSTATE_SUSPENDING_LS: 7581 case VMSTATE_SUSPENDING_EXT_LS: 7582 if (fSuspenededBySave) 7583 { 7584 Assert(pTask->lastMachineState == MachineState_Running); 7585 LogFlowFunc(("VMR3Resume (on failure)...\n")); 7586 alock.leave(); 7587 int vrc = VMR3Resume(that->mpVM); 7588 alock.enter(); 7589 AssertLogRelRC(vrc); 7590 if (RT_FAILURE(vrc)) 7591 that->setMachineState(MachineState_Paused); 7592 } 7593 else if (pTask->lastMachineState == MachineState_Paused) 7594 that->setMachineStateLocally(pTask->lastMachineState); 7595 else 7596 that->setMachineState(MachineState_Paused); 7597 break; 7598 } 7599 7600 } 7601 } 7602 /*else: somebody else has change the state... Leave it. */ 7603 7604 /* check the remote state to see that we got it right. */ 7605 that->mMachine->COMGETTER(State)(&enmMachineState); 7606 AssertLogRelMsg(that->mMachineState == enmMachineState, 7607 ("mMachineState=%s enmMachineState=%s\n", Global::stringifyMachineState(that->mMachineState), 7608 Global::stringifyMachineState(enmMachineState) )); 7609 7610 7611 if (SUCCEEDED(rc)) /* The failure cases are handled above. */ 7612 pTask->mProgress->notifyComplete(rc); 7483 7613 7484 7614 delete pTask; 7485 7486 if (pTask->lastMachineState == MachineState_Running)7487 {7488 /* restore the paused state if appropriate */7489 that->setMachineStateLocally(MachineState_Paused);7490 /* restore the running state if appropriate */7491 that->Resume();7492 }7493 else7494 that->setMachineStateLocally(pTask->lastMachineState);7495 7615 7496 7616 LogFlowFuncLeave(); … … 7524 7644 LogFlowFunc(("Saving the state to '%s'...\n", task->mSavedStateFile.raw())); 7525 7645 7646 bool fSuspenededBySave; 7526 7647 int vrc = VMR3Save(that->mpVM, 7527 7648 task->mSavedStateFile.c_str(), 7528 7649 false, /*fContinueAfterwards*/ 7529 7650 Console::stateProgressCallback, 7530 static_cast<VMProgressTask*>(task.get())); 7651 static_cast<VMProgressTask*>(task.get()), 7652 &fSuspenededBySave); 7531 7653 if (RT_FAILURE(vrc)) 7532 7654 { … … 7535 7657 rc = E_FAIL; 7536 7658 } 7659 Assert(!fSuspenededBySave); 7537 7660 7538 7661 /* lock the console once we're going to access it */ -
trunk/src/VBox/VMM/VM.cpp
r24918 r24922 1741 1741 * @param pfnProgress Progress callback. Optional. 1742 1742 * @param pvUser User argument for the progress callback. 1743 * @param pfSuspended Set if we suspended the VM. 1743 1744 * 1744 1745 * @thread Non-EMT. … … 1747 1748 * RunningLS+SuspeningLS+SuspendedLS+Saving+Suspended. 1748 1749 */ 1749 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, PFNVMPROGRESS pfnProgress, void *pvUser) 1750 { 1751 LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p\n", 1752 pVM, pszFilename, pszFilename, fContinueAfterwards, pfnProgress, pvUser)); 1750 VMMR3DECL(int) VMR3Save(PVM pVM, const char *pszFilename, bool fContinueAfterwards, 1751 PFNVMPROGRESS pfnProgress, void *pvUser, bool *pfSuspended) 1752 { 1753 LogFlow(("VMR3Save: pVM=%p pszFilename=%p:{%s} fContinueAfterwards=%RTbool pfnProgress=%p pvUser=%p pfSuspended=%p\n", 1754 pVM, pszFilename, pszFilename, fContinueAfterwards, pfnProgress, pvUser, pfSuspended)); 1753 1755 1754 1756 /* 1755 1757 * Validate input. 1756 1758 */ 1759 AssertPtr(pfSuspended); 1760 *pfSuspended = false; 1757 1761 VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE); 1758 1762 VM_ASSERT_OTHER_THREAD(pVM); … … 1764 1768 * Join paths with VMR3Teleport. 1765 1769 */ 1766 bool fSuspended = false; /** @todo need this for live snapshots. */1767 1770 SSMAFTER enmAfter = fContinueAfterwards ? SSMAFTER_CONTINUE : SSMAFTER_DESTROY; 1768 1771 int rc = vmR3SaveTeleport(pVM, 250 /*cMsMaxDowntime*/, 1769 1772 pszFilename, NULL /*pStreamOps*/, NULL /*pvStreamOpsUser*/, 1770 enmAfter, pfnProgress, pvUser, &fSuspended);1771 LogFlow(("VMR3Save: returns %Rrc \n", rc));1773 enmAfter, pfnProgress, pvUser, pfSuspended); 1774 LogFlow(("VMR3Save: returns %Rrc (*pfSuspended=%RTbool)\n", rc, *pfSuspended)); 1772 1775 return rc; 1773 1776 }
Note:
See TracChangeset
for help on using the changeset viewer.

