Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

14.8.7. Save a Guest Virtual Machine

Save the current state of a guest virtual machine to a file using the virsh command:
# virsh save {domain-name|domain-id|domain-uuid} state-file --bypass-cache --xml --running --paused --verbose
This stops the guest virtual machine you specify and saves the data to a file, which may take some time given the amount of memory in use by your guest virtual machine. You can restore the state of the guest virtual machine with the restore (Section 14.8.11, “Restore a Guest Virtual Machine”) option. Save is similar to pause, instead of just pausing a guest virtual machine the present state of the guest virtual machine is saved.
The virsh save command can take the following options:
  • --bypass-cache - causes the restore to avoid the file system cache but note that using this option may slow down the restore operation.
  • --xml - this option must be used with an XML file name. Although this option is usually omitted, it can be used to supply an alternative XML file for use on a restored guest virtual machine with changes only in the host-specific portions of the domain XML. For example, it can be used to account for the file naming differences in underlying storage due to disk snapshots taken after the guest was saved.
  • --running - overrides the state recorded in the save image to start the domain as running.
  • --paused- overrides the state recorded in the save image to start the domain as paused.
  • --verbose - displays the progress of the save.
If you want to restore the guest virtual machine directly from the XML file, the virsh restore command will do just that. You can monitor the process with the domjobinfo and cancel it with the domjobabort.