Cinder/QuiescedSnapshotWithQemuGuestAgent
< Cinder
Contents
Quiescing filesystems with QEMU guest agent during snapshotting
Related blueprints
- https://blueprints.launchpad.net/nova/+spec/quiesced-snapshots-with-qemu-guest-agent
- https://blueprints.launchpad.net/cinder/+spec/quiesced-snapshots-with-qemu-guest-agent
Goals
- Create consistent snapshots of volumes and images with quiesced I/O using QEMU guest agent
- Take online backup of nova images and cinder volumes with application-level consistency
Prerequisites
- Use QEMU/KVM as a hypervisor (via libvirt compute driver)
- The image metadata has 'hw_qemu_guest_agent=yes' property
- QEMU guest agent is installed
Overview
Currently, we need to quiesce filesystems manually by 'fsfreeze' command before creating snapshots and taking backups, however freezing root filesystems has a slight risk of deadlock. As for cinder volumes, we can take a snapshot even if it is attached to the instance by specifying --force option, but then consistency of the snapshot is not guaranteed without fsfreeze.
This proposal is to enable automatic freezing of filesystems safely while snapshots are taken, using QEMU guest agent on KVM instances. The agent also has a hook for applications, so that applications such as mysql can be quiesced when it is configured appropriately.
Creation of Image Snapshot
- User calls Nova's image-create API
- If the instance is active and has QEMU guest agent installed, send 'guest-fsfreeze-freeze' command to the agent to quiesce filesystems in it.
- Take a snapshot
- If we quiesced successfully at step 2, unquiesce it by sending 'guest-fsfreeze-thaw' command to the agent.
Creating of Volume Snapshot
- User calls Cinder's snapshot-create API with new "quiesce=True" parameter.
- If the volume is attached and the instance is active, call Nova's "quiesce" API (admin_action) via novaclient.
- Nova (compute/libvirt) quiesces the instance by sending 'guest-fsfreeze-freeze' to the agent, if installed.
- If the "quiesce" API succeeded, create the volume snapshot. Otherwise report an error and quit.
- Call Nova's "unquiesce" API (admin_action) via novaclient.
- Nova (compute/libvirt) unquiesces the instance by sending 'guest-fsfreeze-thaw' to the agent.
New API
Nova
- New quiesce() admin action
- In libvirt/kvm driver, send 'guest-fsfreeze-freeze' command to the guest agent, if installed.
- Otherwise, return an error.
- Needs to be added to novaclient so that cinder can call it.
- New unquiesce() admin action
- In libvirt/kvm driver, send 'guest-fsfreeze-thaw' command to the guest agent, if installed.
- Otherwise, return an error.
- Needs to be added to novaclient so that cinder can call it.
Cinder
- Changes in volume_snapshot_create() API
- If force=True is specified:
- if the volume is attached to active guest, try calling Nova's quiesce()/unquisce() API before/after snapshotting.
- If force=True is specified:
Related links
- Blueprint: Add qemu-guest-agent support for kvm instance
- QEMU Wiki - Live Snapshots / Guest Agent