Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
10.2.5. Creating a Guest Virtual Machine Disk Backup
libvirt can communicate with qemu-ga to assure that snapshots of guest virtual machine file systems are consistent internally and ready for use on an as needed basis. Improvements in Red Hat Enterprise Linux 6 have been made to make sure that both file and application level synchronization (flushing) is done. Guest system administrators can write and install application-specific freeze/thaw hook scripts. Before freezing the filesystems, the qemu-ga invokes the main hook script (included in the qemu-ga package). The freezing process temporarily deactivates all guest virtual machine applications.
Just before filesystems are frozen, the following actions occur:
- File system applications / databases flush working buffers to the virtual disk and stop accepting client connections
- Applications bring their data files into a consistent state
- Main hook script returns
- qemu-ga freezes the filesystems and management stack takes a snapshot
- Snapshot is confirmed
- Filesystem function resumes
Thawing happens in reverse order.
snapshot-create-ascommand to create a snapshot of the guest disk. See Section 18.104.22.168, “Creating a snapshot for the current domain” for more details on this command.
An application-specific hook script might need various SELinux permissions in order to run correctly, as is done when the script needs to connect to a socket in order to talk to a database. In general, local SELinux policies should be developed and installed for such purposes. Accessing file system nodes should work out of the box, after issuing the
restorecon -FvvRcommand listed in Table 10.1, “QEMU guest agent package contents” in the table row labeled
The qemu-guest-agent binary RPM includes the following files:
Table 10.1. QEMU guest agent package contents
|Service control script (start/stop) for the QEMU guest agent.|
|Configuration file for the QEMU guest agent, as it is read by the |
|QEMU guest agent binary file.|
|Root directory for hook scripts.|
|Main hook script. No modifications are needed here.|
|Directory for individual, application-specific hook scripts. The guest system administrator should copy hook scripts manually into this directory, ensure proper file mode bits for them, and then run |
|Directory with sample scripts (for example purposes only). The scripts contained here are not executed.|
The main hook script,
/usr/libexec/qemu-ga/fsfreeze-hooklogs its own messages, as well as the application-specific script's standard output and error messages, in the following log file:
/var/log/qemu-ga/fsfreeze-hook.log. For more information, refer to the qemu-guest-agent wiki page at wiki.qemu.org or libvirt.org.