Performing Virtual Machine Power Operations
Just like physical machines, virtual machines have power states.
- Powered on – The virtual machine is running. If no OS has been installed, you can perform OS installation as you would for a physical machine.
- Powered off – The virtual machine is not running. You can still update the software on the virtual machine’s physical disk, which is impossible for physical machines.
- Suspended – The virtual machine is paused and
can be resumed; like a physical machine in standby or hibernate state.
Important: Before you power on a virtual machine, you must make sure that the host has sufficient resources. You must have enough memory for the virtual machine, and some memory overhead. See Querying Virtual Machine Memory Overhead.
VirtualMachine power operations allow you to change the power state. Each operation is sensitive to the current power state, for example, powering on a powered off virtual machine has the desired result while powering on a powered on virtual machine results in an error. You must check the current state before you run one of these tasks.
- PowerOnVM_Task – Powers on a virtual machine. If the virtual machine is suspended, this method resumes execution from the suspend point.
- PowerOffVM_Task – Powers off a virtual machine.
- ResetVM_Task – Resets power
on this virtual machine. If the current state is poweredOn, ResetVM_Task
first performs a hard powerOff
operation. After the power state is poweredOff, ResetVM_Task performs a powerOn operation.
Although this method functions as a powerOff followed by a powerOn, the two operations are atomic with respect to other clients, meaning that other power operations cannot be performed until the reset method completes.
- SuspendVM_Task – Suspends the virtual machine. You can later power on the suspended virtual machine to the same state.
Virtual machines are often configured to start up the guest operating system when they are started, and try to shut down the guest operating system when being shut down. However, starting and stopping a virtual machine differs from starting and stopping the guest operating system (see Customizing the Guest Operating System).
You can use the Datacenter.PowerOnMultiVM_Task to power on multiple virtual machines in a datacenter. Pass an array of VirtualMachine managed object references and an array of option values to the method. If any of the virtual machines in the list is manually managed by VMware DRS, the system generates a DRS recommendation that the user needs to apply manually. Standalone or DRS disabled virtual machines are powered on for the current host. Virtual machines managed by DRS, to be placed by DRS, are powered on for the recommended host.