Changeset 24301 in vbox for trunk/src/VBox/Main/ConsoleImpl.cpp
- Timestamp:
- Nov 3, 2009 10:07:55 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r24255 r24301 1504 1504 AutoWriteLock alock(this); 1505 1505 1506 if (!Global::IsActive(mMachineState)) 1507 { 1506 /** @todo Live Migration: Support powering down while teleporting. Maybe also 1507 * while taking a live snapshot. (In case they never finish and you 1508 * or some other operator wish to shut down the VM.) */ 1509 switch (mMachineState) 1510 { 1511 case MachineState_Running: 1512 case MachineState_Paused: 1513 case MachineState_Stuck: 1514 break; 1515 1508 1516 /* extra nice error message for a common case */ 1509 if (mMachineState == MachineState_Saved) 1517 case MachineState_Saved: 1518 return setError(VBOX_E_INVALID_VM_STATE, tr("Cannot power down a saved virtual machine")); 1519 case MachineState_Stopping: 1520 return setError(VBOX_E_INVALID_VM_STATE, tr("Virtual machine is being powered down.")); 1521 default: 1510 1522 return setError(VBOX_E_INVALID_VM_STATE, 1511 tr("Cannot power down a saved virtual machine")); 1512 else if (mMachineState == MachineState_Stopping) 1513 return setError(VBOX_E_INVALID_VM_STATE, 1514 tr("Virtual machine is being powered down.")); 1515 else 1516 return setError(VBOX_E_INVALID_VM_STATE, 1517 tr("Invalid machine state: %s (must be Running, Paused or Stuck)"), 1518 Global::stringifyMachineState(mMachineState)); 1523 tr("Invalid machine state: %s (must be Running, Paused or Stuck)"), 1524 Global::stringifyMachineState(mMachineState)); 1519 1525 } 1520 1526 … … 1564 1570 AutoWriteLock alock(this); 1565 1571 1566 if (mMachineState != MachineState_Running) 1572 if ( mMachineState != MachineState_Running 1573 && mMachineState != MachineState_Teleporting 1574 && mMachineState != MachineState_LiveSnapshotting 1575 /** @todo r=bird: This should be allowed on paused VMs as well. Later. */ 1576 ) 1567 1577 return setError(VBOX_E_INVALID_VM_STATE, 1568 1578 tr("Invalid machine state: %s"), … … 1597 1607 AutoWriteLock alock(this); 1598 1608 1599 if (mMachineState != MachineState_Running) 1609 if ( mMachineState != MachineState_Running 1610 && mMachineState != MachineState_Teleporting 1611 && mMachineState != MachineState_LiveSnapshotting 1612 ) 1600 1613 return setError(VBOX_E_INVALID_VM_STATE, 1601 1614 tr("Invalid machine state: %s"), … … 1671 1684 AutoWriteLock alock(this); 1672 1685 1673 if (mMachineState != MachineState_Running) 1686 if ( mMachineState != MachineState_Running 1687 && mMachineState != MachineState_Teleporting 1688 && mMachineState != MachineState_LiveSnapshotting 1689 ) 1674 1690 return setError(VBOX_E_INVALID_VM_STATE, 1675 1691 tr("Invalid machine state: %s"), … … 1712 1728 AutoWriteLock alock(this); 1713 1729 1714 if (mMachineState != MachineState_Running) 1730 if ( mMachineState != MachineState_Running 1731 && mMachineState != MachineState_Teleporting 1732 && mMachineState != MachineState_LiveSnapshotting 1733 ) 1715 1734 return setError(VBOX_E_INVALID_VM_STATE, 1716 1735 tr("Invalid machine state: %s"), … … 1756 1775 AutoWriteLock alock(this); 1757 1776 1758 if (mMachineState != MachineState_Running) 1777 if ( mMachineState != MachineState_Running 1778 && mMachineState != MachineState_Teleporting 1779 && mMachineState != MachineState_LiveSnapshotting 1780 ) 1759 1781 return setError(VBOX_E_INVALID_VM_STATE, 1760 1782 tr("Invalid machine state %s when checking if the guest entered the ACPI mode)"), … … 1791 1813 AutoWriteLock alock(this); 1792 1814 1793 if (mMachineState != MachineState_Running) 1815 if (mMachineState != MachineState_Running) /** @todo Live Migration: ??? */ 1794 1816 return setError(VBOX_E_INVALID_VM_STATE, 1795 1817 tr("Invalid machine state: %s)"), … … 1832 1854 AutoWriteLock alock(this); 1833 1855 1834 if ( mMachineState != MachineState_Running &&1835 mMachineState != MachineState_Paused)1856 if ( mMachineState != MachineState_Running 1857 && mMachineState != MachineState_Paused) 1836 1858 { 1837 1859 return setError(VBOX_E_INVALID_VM_STATE, … … 1970 1992 AutoWriteLock alock(this); 1971 1993 1972 if (mMachineState != MachineState_PoweredOff && 1973 mMachineState != MachineState_Aborted) 1994 if ( mMachineState != MachineState_PoweredOff 1995 && mMachineState != MachineState_Teleported 1996 && mMachineState != MachineState_Aborted 1997 ) 1974 1998 return setError(VBOX_E_INVALID_VM_STATE, 1975 tr("Cannot adopt the saved machine state as the machine is not in Powered Off or Aborted state (machine state: %s)"),1999 tr("Cannot adopt the saved machine state as the machine is not in Powered Off, Teleported or Aborted state (machine state: %s)"), 1976 2000 Global::stringifyMachineState(mMachineState)); 1977 2001 … … 2109 2133 AutoWriteLock alock(this); 2110 2134 2111 if ( mMachineState != MachineState_Running &&2112 mMachineState != MachineState_Paused)2135 if ( mMachineState != MachineState_Running 2136 && mMachineState != MachineState_Paused) 2113 2137 return setError(VBOX_E_INVALID_VM_STATE, 2114 2138 tr("Cannot attach a USB device to the machine which is not running or paused (machine state: %s)"), … … 2288 2312 return setError(VBOX_E_INVALID_VM_STATE, 2289 2313 tr("Cannot create a transient shared folder on the machine in the saved state")); 2290 if (mMachineState > MachineState_Paused) 2314 if ( mMachineState != MachineState_PoweredOff 2315 && mMachineState != MachineState_Teleported 2316 && mMachineState != MachineState_Aborted 2317 && mMachineState != MachineState_Running 2318 && mMachineState != MachineState_Paused 2319 ) 2291 2320 return setError(VBOX_E_INVALID_VM_STATE, 2292 2321 tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %s)"), … … 2350 2379 return setError(VBOX_E_INVALID_VM_STATE, 2351 2380 tr("Cannot remove a transient shared folder from the machine in the saved state")); 2352 if (mMachineState > MachineState_Paused) 2381 if ( mMachineState != MachineState_PoweredOff 2382 && mMachineState != MachineState_Teleported 2383 && mMachineState != MachineState_Aborted 2384 && mMachineState != MachineState_Running 2385 && mMachineState != MachineState_Paused 2386 ) 2353 2387 return setError(VBOX_E_INVALID_VM_STATE, 2354 2388 tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %s)"), … … 3514 3548 HRESULT rc = S_OK; 3515 3549 3516 if (mVRDPServer && mMachineState == MachineState_Running) 3550 if ( mVRDPServer 3551 && ( mMachineState == MachineState_Running 3552 || mMachineState == MachineState_Teleporting 3553 || mMachineState == MachineState_LiveSnapshotting 3554 ) 3555 ) 3517 3556 { 3518 3557 BOOL vrdpEnabled = FALSE; … … 4008 4047 AutoWriteLock alock(this); 4009 4048 4010 AssertReturn( mMachineState == MachineState_Saving 4011 || mMachineState == MachineState_RestoringSnapshot 4012 || mMachineState == MachineState_DeletingSnapshot, 4013 E_FAIL); 4049 AssertReturn( mMachineState == MachineState_Saving 4050 || mMachineState == MachineState_LiveSnapshotting 4051 || mMachineState == MachineState_RestoringSnapshot 4052 || mMachineState == MachineState_DeletingSnapshot 4053 , E_FAIL); 4014 4054 4015 4055 return setMachineStateLocally(aMachineState); … … 4712 4752 setMachineState(MachineState_Restoring); 4713 4753 else if (fTeleporterEnabled) 4714 setMachineState(MachineState_Teleporting From);4754 setMachineState(MachineState_TeleportingIn); 4715 4755 else 4716 4756 setMachineState(MachineState_Starting); … … 4772 4812 Assert(mpVM != NULL); 4773 4813 4774 AssertMsg(mMachineState == MachineState_Running || 4775 mMachineState == MachineState_Paused || 4776 mMachineState == MachineState_Stuck || 4777 mMachineState == MachineState_Saving || 4778 mMachineState == MachineState_Starting || 4779 mMachineState == MachineState_Restoring || 4780 mMachineState == MachineState_TeleportingFrom || /** @todo Teleportation ???*/ 4781 mMachineState == MachineState_Stopping, 4782 ("Invalid machine state: %s\n", Global::stringifyMachineState(mMachineState))); 4814 AssertMsg( mMachineState == MachineState_Running 4815 || mMachineState == MachineState_Paused 4816 || mMachineState == MachineState_Teleporting /** @todo Live Migration: ???*/ 4817 || mMachineState == MachineState_LiveSnapshotting /** @todo Live Migration: ???*/ 4818 || mMachineState == MachineState_Stuck 4819 || mMachineState == MachineState_Starting 4820 || mMachineState == MachineState_Stopping 4821 || mMachineState == MachineState_Saving 4822 || mMachineState == MachineState_Restoring 4823 || mMachineState == MachineState_TeleportingPausedVM /** @todo Teleportation ???*/ 4824 || mMachineState == MachineState_TeleportingIn /** @todo Teleportation ???*/ 4825 , ("Invalid machine state: %s\n", Global::stringifyMachineState(mMachineState))); 4783 4826 4784 4827 LogRel(("Console::powerDown(): A request to power off the VM has been issued (mMachineState=%d, InUninit=%d)\n", … … 4793 4836 && ( mMachineState == MachineState_Starting 4794 4837 || mMachineState == MachineState_Restoring 4795 || mMachineState == MachineState_Teleporting From)4838 || mMachineState == MachineState_TeleportingIn) 4796 4839 ) 4797 4840 mVMPoweredOff = true; … … 4801 4844 * set the state to Saved on VMSTATE_TERMINATED. In terms of protecting from 4802 4845 * inappropriate operations while leaving the lock below, Saving or 4803 * Restoring should be fine too */4846 * Restoring should be fine too. Ditto for Teleporting* -> Teleported. */ 4804 4847 if ( mMachineState != MachineState_Saving 4805 4848 && mMachineState != MachineState_Restoring 4806 && mMachineState != MachineState_TeleportingFrom4807 4849 && mMachineState != MachineState_Stopping 4850 && mMachineState != MachineState_TeleportingIn 4851 && mMachineState != MachineState_Teleporting /** @todo Live Migration: what should really happen here? */ 4852 && mMachineState != MachineState_TeleportingPausedVM 4853 && mMachineState != MachineState_LiveSnapshotting /** @todo Live Migration: what should really happen here? */ 4808 4854 ) 4809 4855 setMachineState(MachineState_Stopping); … … 4862 4908 uint32_t fFlags; 4863 4909 guestProp::validateFlags(Utf8Str(flagsOut[i]).raw(), &fFlags); 4864 if ( !( fFlags & guestProp::TRANSIENT) 4865 || (mMachineState == MachineState_Saving) 4910 if ( !(fFlags & guestProp::TRANSIENT) 4911 || mMachineState == MachineState_Saving 4912 || mMachineState == MachineState_LiveSnapshotting 4866 4913 ) 4867 4914 { … … 5490 5537 && that->mMachineState != MachineState_Saving 5491 5538 && that->mMachineState != MachineState_Restoring 5492 && that->mMachineState != MachineState_TeleportingFrom 5539 && that->mMachineState != MachineState_TeleportingIn 5540 && that->mMachineState != MachineState_LiveSnapshotting 5541 && that->mMachineState != MachineState_Teleporting 5542 && that->mMachineState != MachineState_TeleportingPausedVM 5493 5543 ) 5494 5544 { … … 5585 5635 that->setMachineState(MachineState_Saved); 5586 5636 break; 5587 case MachineState_Teleporting From:5637 case MachineState_TeleportingIn: 5588 5638 /* Teleportation failed or was cancelled. Back to powered off. */ 5589 5639 that->setMachineState(MachineState_PoweredOff); 5590 5640 break; 5641 case MachineState_Teleporting: 5642 case MachineState_TeleportingPausedVM: 5643 /* Successfully teleported the VM. */ 5644 that->setMachineState(MachineState_Teleported); 5645 break; 5591 5646 } 5592 5647 break; … … 5595 5650 case VMSTATE_SUSPENDED: 5596 5651 { 5597 /** @todo state/live VMSTATE_SUSPENDING_LS. */5652 /** @todo Live Migration: state/live VMSTATE_SUSPENDING_LS. */ 5598 5653 if (aOldState == VMSTATE_SUSPENDING) 5599 5654 { … … 5626 5681 && aOldState == VMSTATE_POWERING_ON) 5627 5682 || ( ( that->mMachineState == MachineState_Restoring 5628 || that->mMachineState == MachineState_Teleporting From5683 || that->mMachineState == MachineState_TeleportingIn 5629 5684 || that->mMachineState == MachineState_Paused) 5630 5685 && aOldState == VMSTATE_RESUMING)); … … 6821 6876 if ( console->mMachineState == MachineState_Starting 6822 6877 || console->mMachineState == MachineState_Restoring 6823 || console->mMachineState == MachineState_Teleporting From6878 || console->mMachineState == MachineState_TeleportingIn 6824 6879 ) 6825 6880 {
Note:
See TracChangeset
for help on using the changeset viewer.