VirtualBox

Ignore:
Timestamp:
Jan 25, 2011 12:53:39 PM (14 years ago)
Author:
vboxsync
Message:

VBoxManage: allow tot save the state of a VM which is already paused

Location:
trunk/src/VBox/Frontends/VBoxManage
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h

    r35239 r35707  
    194194                   VMINFO_DETAILS details = VMINFO_NONE,
    195195                   ComPtr <IConsole> console = ComPtr<IConsole>());
     196const char *stateToName(MachineState_T machineState, bool fShort);
    196197
    197198/* VBoxManageList.cpp */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp

    r35194 r35707  
    162162        {
    163163            /* first pause so we don't trigger a live save which needs more time/resources */
    164             CHECK_ERROR_BREAK(console, Pause());
     164            rc = console->Pause();
     165            if (FAILED(rc))
     166            {
     167                if (rc == VBOX_E_INVALID_VM_STATE)
     168                {
     169                    /* check if we are already paused */
     170                    MachineState_T machineState;
     171                    CHECK_ERROR_BREAK(console, COMGETTER(State)(&machineState));
     172                    if (machineState != MachineState_Paused)
     173                    {
     174                        RTMsgError("Machine in invalid state %d -- %s\n",
     175                                   machineState, stateToName(machineState, false));
     176                        break;
     177                    }
     178                }
     179            }
    165180
    166181            ComPtr<IProgress> progress;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r35541 r35707  
    256256    if (machineState != MachineState_Running)
    257257    {
    258         RTMsgError("Machine \"%s\" is not running!\n", pszNameOrId);
     258        RTMsgError("Machine \"%s\" is not running (currently %s)!\n",
     259                   pszNameOrId, stateToName(machineState, false));
    259260        return VERR_VM_INVALID_VM_STATE;
    260261    }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r35517 r35707  
    109109                        t.i32Year, t.u8Month, t.u8MonthDay,
    110110                        t.u8Hour, t.u8Minute, t.u8Second);
     111}
     112
     113
     114const char *stateToName(MachineState_T machineState, bool fShort)
     115{
     116    switch (machineState)
     117    {
     118        case MachineState_PoweredOff:
     119            return fShort ? "poweroff"             : "powered off";
     120        case MachineState_Saved:
     121            return "saved";
     122        case MachineState_Aborted:
     123            return "aborted";
     124        case MachineState_Teleported:
     125            return "teleported";
     126        case MachineState_Running:
     127            return "running";
     128        case MachineState_Paused:
     129            return "paused";
     130        case MachineState_Stuck:
     131            return fShort ? "gurumeditation"       : "guru meditation";
     132        case MachineState_LiveSnapshotting:
     133            return fShort ? "livesnapshotting"     : "live snapshotting";
     134        case MachineState_Teleporting:
     135            return "teleporting";
     136        case MachineState_Starting:
     137            return "starting";
     138        case MachineState_Stopping:
     139            return "stopping";
     140        case MachineState_Saving:
     141            return "saving";
     142        case MachineState_Restoring:
     143            return "restoring";
     144        case MachineState_TeleportingPausedVM:
     145            return fShort ? "teleportingpausedvm"  : "teleporting paused vm";
     146        case MachineState_TeleportingIn:
     147            return fShort ? "teleportingin"        : "teleporting (incoming)";
     148        case MachineState_RestoringSnapshot:
     149            return fShort ? "restoringsnapshot"    : "restoring snapshot";
     150        case MachineState_DeletingSnapshot:
     151            return fShort ? "deletingsnapshot"     : "deleting snapshot";
     152        case MachineState_DeletingSnapshotOnline:
     153            return fShort ? "deletingsnapshotlive" : "deleting snapshot live";
     154        case MachineState_DeletingSnapshotPaused:
     155            return fShort ? "deletingsnapshotlivepaused" : "deleting snapshot live paused";
     156        case MachineState_SettingUp:
     157            return fShort ? "settingup"           : "setting up";
     158        default:
     159            return "unknown";
     160    }
    111161}
    112162
     
    518568
    519569    MachineState_T machineState;
    520     const char *pszState = NULL;
    521570    rc = machine->COMGETTER(State)(&machineState);
    522     switch (machineState)
    523     {
    524         case MachineState_PoweredOff:
    525             pszState = details == VMINFO_MACHINEREADABLE ? "poweroff"            : "powered off";
    526             break;
    527         case MachineState_Saved:
    528             pszState = "saved";
    529             break;
    530         case MachineState_Aborted:
    531             pszState = "aborted";
    532             break;
    533         case MachineState_Teleported:
    534             pszState = "teleported";
    535             break;
    536         case MachineState_Running:
    537             pszState = "running";
    538             break;
    539         case MachineState_Paused:
    540             pszState = "paused";
    541             break;
    542         case MachineState_Stuck:
    543             pszState = details == VMINFO_MACHINEREADABLE ? "gurumeditation"      : "guru meditation";
    544             break;
    545         case MachineState_LiveSnapshotting:
    546             pszState = details == VMINFO_MACHINEREADABLE ? "livesnapshotting"    : "live snapshotting";
    547             break;
    548         case MachineState_Teleporting:
    549             pszState = "teleporting";
    550             break;
    551         case MachineState_Starting:
    552             pszState = "starting";
    553             break;
    554         case MachineState_Stopping:
    555             pszState = "stopping";
    556             break;
    557         case MachineState_Saving:
    558             pszState = "saving";
    559             break;
    560         case MachineState_Restoring:
    561             pszState = "restoring";
    562             break;
    563         case MachineState_TeleportingPausedVM:
    564             pszState = details == VMINFO_MACHINEREADABLE ? "teleportingpausedvm" : "teleporting paused vm";
    565             break;
    566         case MachineState_TeleportingIn:
    567             pszState = details == VMINFO_MACHINEREADABLE ? "teleportingin"       : "teleporting (incoming)";
    568             break;
    569         case MachineState_RestoringSnapshot:
    570             pszState = details == VMINFO_MACHINEREADABLE ? "restoringsnapshot"   : "restoring snapshot";
    571             break;
    572         case MachineState_DeletingSnapshot:
    573             pszState = details == VMINFO_MACHINEREADABLE ? "deletingsnapshot"    : "deleting snapshot";
    574             break;
    575         case MachineState_DeletingSnapshotOnline:
    576             pszState = details == VMINFO_MACHINEREADABLE ? "deletingsnapshotlive" : "deleting snapshot live";
    577             break;
    578         case MachineState_DeletingSnapshotPaused:
    579             pszState = details == VMINFO_MACHINEREADABLE ? "deletingsnapshotlivepaused" : "deleting snapshot live paused";
    580             break;
    581         case MachineState_SettingUp:
    582             pszState = details == VMINFO_MACHINEREADABLE ? "settingup"           : "setting up";
    583             break;
    584         default:
    585             pszState = "unknown";
    586             break;
    587     }
     571    const char *pszState = stateToName(machineState, details == VMINFO_MACHINEREADABLE /*=fShort*/);
     572
    588573    LONG64 stateSince;
    589574    machine->COMGETTER(LastStateChange)(&stateSince);
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