20.8. Shutting off, Shutting down, Rebooting, and Forcing a Shutdown of a Guest Virtual Machine
20.8.1. Shutting down a Guest Virtual Machine
virsh shutdown domain [--mode modename]
command shuts down a guest virtual machine. You can control the behavior of how the guest virtual machine reboots by modifying the on_shutdown
parameter in the guest virtual machine's configuration file. Any change to the on_shutdown
parameter will only take effect after the domain has been shutdown and restarted.
virsh shutdown
command command can take the following optional argument:
--mode
chooses the shutdown mode. This can be eitheracpi
,agent
,initctl
,signal
, orparavirt
.
Example 20.13. How to shutdown a guest virtual machine
acpi
mode:
# virsh shutdown guest1 --mode acpi
Domain guest1 is being shutdown
20.8.2. Suspending a Guest Virtual Machine
virsh suspend domain
command suspends a guest virtual machine.
virsh resume
command. Running this command on a transient virtual machine will delete it.
Example 20.14. How to suspend a guest virtual machine
# virsh suspend guest1
20.8.3. Resetting a Virtual Machine
virsh reset domain
resets the guest virtual machine immediately without any guest shutdown. A reset emulates the reset button on a machine, where all guest hardware sees the RST line and re-initializes the internal state. Note that without any guest virtual machine OS shutdown, there are risks for data loss.
Note
Example 20.15. How to reset a guest virtual machine
# virsh reset guest1
20.8.4. Stopping a Running Guest Virtual Machine in Order to Restart It Later
virsh managedsave domain --bypass-cache
--running | --paused | --verbose
command saves and destroys (stops) a running guest virtual machine so that it can be restarted from the same state at a later time. When used with a virsh start
command it is automatically started from this save point. If it is used with the --bypass-cache
argument the save will avoid the filesystem cache. Note that this option may slow down the save process speed and using the --verbose
option displays the progress of the dump process. Under normal conditions, the managed save will decide between using the running or paused state as determined by the state the guest virtual machine is in when the save is done. However, this can be overridden by using the --running
option to indicate that it must be left in a running state or by using --paused
option which indicates it is to be left in a paused state. To remove the managed save state, use the virsh managedsave-remove
command which will force the guest virtual machine to do a full boot the next time it is started. Note that the entire managed save process can be monitored using the domjobinfo
command and can also be canceled using the domjobabort
command.
Example 20.16. How to stop a running guest and save its configuration
# virsh managedsave guest1 --running