Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   *  Copyright (C) 2010-2011 Oracle Corporation
   *  This file is part of the VirtualBox SDK, as available from
   *  This library is free software; you can
   *  redistribute it and/or modify it under the terms of the GNU Lesser General
   *  Public License as published by the Free Software Foundation, in version 2.1
   *  as it comes in the "COPYING.LIB" file of the VirtualBox SDK distribution.
  *  This library is distributed in the hope that it will be useful, but WITHOUT
  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
  *  License for more details.
  * DO NOT EDIT! This is a generated file.
  * Generated from: src/VBox/Main/idl/VirtualBox.xidl (VirtualBox's interface definitions in XML)
  * Generator: src/VBox/Main/glue/glue-java.xsl
 package org.virtualbox_4_2;
Virtual machine execution state. This enumeration represents possible values of the IMachine.getState() attribute. Below is the basic virtual machine state diagram. It shows how the state changes during virtual machine execution. The text in square braces shows a method of the IConsole interface that performs the given state transition.
+---------[powerDown()] <- Stuck <--[failure]-+
V                                             |
+-> PoweredOff --+-->[powerUp()]--> Starting --+      | +-----[resume()]-----+
|                |                             |      | V                    |
|   Aborted -----+                             +--> Running --[pause()]--> Paused
|                                              |      ^ |                   ^ |
|   Saved -----------[powerUp()]--> Restoring -+      | |                   | |
|     ^                                               | |                   | |
|     |     +-----------------------------------------+-|-------------------+ +
|     |     |                                           |                     |
|     |     +-- Saving <--------[takeSnapshot()]<-------+---------------------+
|     |                                                 |                     |
|     +-------- Saving <--------[saveState()]<----------+---------------------+
|                                                       |                     |
+-------------- Stopping -------[powerDown()]<----------+---------------------+
Note that states to the right from PoweredOff, Aborted and Saved in the above diagram are called online VM states. These states represent the virtual machine which is being executed in a dedicated process (usually with a GUI window attached to it where you can see the activity of the virtual machine and interact with it). There are two special pseudo-states, FirstOnline and LastOnline, that can be used in relational expressions to detect if the given machine state is online or not:
if (machine.GetState() >= MachineState_FirstOnline &&
machine.GetState() <= MachineState_LastOnline)
...the machine is being executed...
When the virtual machine is in one of the online VM states (that is, being executed), only a few machine settings can be modified. Methods working with such settings contain an explicit note about that. An attempt to change any other setting or perform a modifying operation during this time will result in the VBOX_E_INVALID_VM_STATE error. All online states except Running, Paused and Stuck are transitional: they represent temporary conditions of the virtual machine that will last as long as the operation that initiated such a condition. The Stuck state is a special case. It means that execution of the machine has reached the "Guru Meditation" condition. This condition indicates an internal VMM (virtual machine manager) failure which may happen as a result of either an unhandled low-level virtual hardware exception or one of the recompiler exceptions (such as the too-many-traps condition). Note also that any online VM state may transit to the Aborted state. This happens if the process that is executing the virtual machine terminates unexpectedly (for example, crashes). Other than that, the Aborted state is equivalent to PoweredOff. There are also a few additional state diagrams that do not deal with virtual machine execution and therefore are shown separately. The states shown on these diagrams are called offline VM states (this includes PoweredOff, Aborted and Saved too). The first diagram shows what happens when a lengthy setup operation is being executed (such as IMachine.attachDevice(java.lang.String,java.lang.Integer,java.lang.Integer,org.virtualbox_4_2.DeviceType,org.virtualbox_4_2.IMedium)).
+----------------------------------(same state as before the call)------+
|                                                                       |
+-> PoweredOff --+                                                      |
|                |                                                      |
|-> Aborted -----+-->[lengthy VM configuration call] --> SettingUp -----+
|                |
+-> Saved -------+
The next two diagrams demonstrate the process of taking a snapshot of a powered off virtual machine, restoring the state to that as of a snapshot or deleting a snapshot, respectively.
+----------------------------------(same state as before the call)------+
|                                                                       |
+-> PoweredOff --+                                                      |
|                +-->[takeSnapshot()] -------------------> Saving ------+
+-> Aborted -----+

+-> PoweredOff --+
|                |
|   Aborted -----+-->[restoreSnapshot()    ]-------> RestoringSnapshot -+
|                |   [deleteSnapshot()     ]-------> DeletingSnapshot --+
+-> Saved -------+                                                      |
|                                                                       |
+---(Saved if restored from an online snapshot, PoweredOff otherwise)---+
Note that the Saving state is present in both the offline state group and online state group. Currently, the only way to determine what group is assumed in a particular case is to remember the previous machine state: if it was Running or Paused, then Saving is an online state, otherwise it is an offline state. This inconsistency may be removed in one of the future versions of VirtualBox by adding a new state. Interface ID: {EC6C6A9E-113D-4FF4-B44F-0B69F21C97FE}
public enum MachineState {

Null value (never used by the API).
The machine is not running and has no saved execution state; it has either never been started or been shut down successfully.
The machine is not currently running, but the execution state of the machine has been saved to an external file when it was running, from where it can be resumed.
The machine was teleported to a different host (or process) and then powered off. Take care when powering it on again may corrupt resources it shares with the teleportation target (e.g. disk and network).
The process running the machine has terminated abnormally. This may indicate a crash of the VM process in host execution context, or the VM process has been terminated externally.
The machine is currently being executed.
Execution of the machine has been paused.
Execution of the machine has reached the "Guru Meditation" condition. This indicates a severe error in the hypervisor itself.
The machine is about to be teleported to a different host or process. It is possible to pause a machine in this state, but it will go to the TeleportingPausedVM state and it will not be possible to resume it again unless the teleportation fails.
A live snapshot is being taken. The machine is running normally, but some of the runtime configuration options are inaccessible. Also, if paused while in this state it will transition to Saving and it will not be resume the execution until the snapshot operation has completed.
Machine is being started after powering it on from a zero execution state.
Machine is being normally stopped powering it off, or after the guest OS has initiated a shutdown sequence.
Machine is saving its execution state to a file, or an online snapshot of the machine is being taken.
Execution state of the machine is being restored from a file after powering it on from the saved execution state.
The machine is being teleported to another host or process, but it is not running. This is the paused variant of the state.
Teleporting the machine state in from another host or process.
The machine is being synced with a fault tolerant VM running elsewhere.
Like DeletingSnapshot, but the merging of media is ongoing in the background while the machine is running.
Like DeletingSnapshotOnline, but the machine was paused when the merging of differencing media was started.
A machine snapshot is being restored; this typically does not take long.
A machine snapshot is being deleted; this can take a long time since this may require merging differencing media. This value indicates that the machine is not running while the snapshot is being deleted.
Lengthy setup operation is in progress.
Pseudo-state: first online state (for use in relational expressions).
Pseudo-state: last online state (for use in relational expressions).
Pseudo-state: first transient state (for use in relational expressions).
Pseudo-state: last transient state (for use in relational expressions).
    private final int value;
    MachineState(int v) {
         = v;
    public int value() {
        return ;
    public static MachineState fromValue(long v) {
        for (MachineState c: MachineState.values()) {
            if (c.value == (int)v) {
                return c;
        throw new IllegalArgumentException(Long.toString(v));
    public static MachineState fromValue(String v) {
        return valueOf(MachineState.classv);
New to GrepCode? Check out our FAQ X