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_shutdownparameter in the guest virtual machine's configuration file. Any change to the
on_shutdownparameter will only take effect after the domain has been shutdown and restarted.
virsh shutdowncommand command can take the following optional argument:
--modechooses the shutdown mode. This can be either
Example 20.13. How to shutdown a guest virtual machine
virsh shutdown guest1Domain guest1 is being shutdown
20.8.2. Suspending a Guest Virtual Machine
virsh suspend domaincommand suspends a guest virtual machine.
virsh resumecommand. 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 domainresets 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.
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 domaincommand 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
--running | --paused | --verbose
virsh startcommand it is automatically started from this save point. If it is used with the
--bypass-cacheargument the save will avoid the filesystem cache. Note that this option may slow down the save process speed and using the
--verboseoption 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
--runningoption to indicate that it must be left in a running state or by using
--pausedoption which indicates it is to be left in a paused state. To remove the managed save state, use the
virsh managedsave-removecommand 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
domjobinfocommand and can also be canceled using the
Example 20.16. How to stop a running guest and save its configuration
virsh managedsave guest1