Cinder/GuestAssistedSnapshotting
Contents
QEMU guest-assisted snapshotting
Related blueprints
- https://blueprints.launchpad.net/nova/+spec/qemu-assisted-snapshots
- https://blueprints.launchpad.net/cinder/+spec/qemu-assisted-snapshots
Goals
1. Add snapshot support for Cinder backing stores which lack internal snapshots (NFS, Gluster, etc.)
Prerequisites
- QEMU/libvirt live snapshot support
- QEMU guest agent installed (for quiescing)
Overview
Currently, GlusterFS + Cinder does not support snapshots. Snapshot support can be enabled by storing volume data as QCOW2 files on Cinder volumes rather than as flat raw files (as is done today), and leveraging QCOW2's snapshot functionality.
Creation of Snapshot:
- User calls new nova API call to executed an assisted snapshot
- Nova will quiesce guest (use existing pause functionality if guest assisted quiesce is not available)
- Nova will execute snapshot API call in Cinder for each Cinder Volume
- Cinder creates snapshot(s)
- Nova resumes VM on completion of the snapshot(s)
The snapshot can then be managed like any other Cinder snapshot.
Changes required for Cinder QCOW2 volumes:
- Cinder code to create them (per-driver code & options)
- Cinder code to translate/process them for operations like upload-to-image, backup_create, clone
- Possibly DB information tracking type (qcow2 or raw) - if needed
Related Notes
- Some examples on libvirt's blockcommit and blockpull -- http://kashyapc.fedorapeople.org/virt/lc-2012/snapshots-handout.html
- More notes on libvirt qcow2 based block operations -- http://kashyapc.fedorapeople.org/virt/lc-2012
API Details
New APIs
Cinder
new API "create-snapshot-metadata" (Note: this may actually need to be two APIs, or use different parameters to specify "creating" vs "done, created successfully".)
- Allow creation of a snapshot by providing metadata rather than Cinder creating snapshot. (i.e. it was created by Nova.) Cinder driver snapshot code is not called. - Metadata: volume_id created_at display_name (maybe?) display_description (optional?) size
- Leave snapshot in "creating" status - This will be implemented as a volume_action
new API "finalize-snapshot-metadata" - Finalize snapshot creation process, set status to available or failed - This will be implemented as a volume_action
new API "snapshot-delete-metadata"
- Deletes a snapshot without performing any real storage operation - Is this needed? Maybe not if the GlusterFS driver's snapshot-delete is smart enough.
Nova
New API to create snapshots of multiple volumes - Allow "all volumes" or a subset of volumes to be specified
Snapshot creation
Currently, it is assumed that file names are: volume-<UUID> for the original volume (as is done today), and volume-<UUID>.<snap-UUID> where snap-UUID is the snapshot which depends directly on this qcow2 file as a backing file. The offline Cinder case works this way, ideally Nova can match the same behavior.
Case 1: Nova-driven snaps (attached)
Nova:
Create multiple-snapshots Nova API called, specifying which volumes, or all volumes Determine which volumes are local files, which are iSCSI/FC-attached Call libvirt create-snapshot-as for each local file (on Gluster volume) For other attached Cinder volumes, call Cinder snapshot API Create a Cinder snapshot for each snapshot created (cinder create-snapshot-from-metadata API call) Done
Case 2: Cinder-driven snapshot
Only works if volume not attached create-snapshot goes through GlusterFS driver like a typical Cinder driver snapshot Snapshot created via qemu-img manipulation
Snapshot deletion
Case 1: Nova-driven (attached)
Nova (method 1 - should work today):
Create libvirt snapshot from metadata retrieved from Cinder Call libvirt blockpull operation (merge base into snapshot) Rename snapshot file to previous base name (libvirt operation: ?) Delete snapshot from Cinder (snapshot-delete-metadata, or maybe just snapshot-delete)
Nova (method 2 - more efficient, may not work today):
Create libvirt snapshot from metadata retrieved from Cinder Call libvirt blockcommit operation (merge snapshot into base) - In current (or at least recent) libvirt, live blockcommit is not supported. Should be added in the future. Delete snapshot from Cinder (snapshot-delete-metadata, or maybe just snapshot-delete)
Case 2: Cinder-driven
Only works if volume not attached Delete via qemu-img manipulation, works like a typical Cinder driver