Jump to: navigation, search

Cinder/QuiescedSnapshotWithQemuGuestAgent

Quiescing filesystems with QEMU guest agent during snapshotting

Related blueprints

Goals

  1. Create consistent snapshots of volumes and images with quiesced I/O using QEMU guest agent
  2. 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

  1. User calls Nova's image-create API
  2. If the instance is active and has QEMU guest agent installed, send 'guest-fsfreeze-freeze' command to the agent to quiesce filesystems in it.
  3. Take a snapshot
  4. If we quiesced successfully at step 2, unquiesce it by sending 'guest-fsfreeze-thaw' command to the agent.

Creating of Volume Snapshot

  1. User calls Cinder's snapshot-create API with new "quiesce=True" parameter.
  2. If the volume is attached and the instance is active, call Nova's "quiesce" API (admin_action) via novaclient.
  3. Nova (compute/libvirt) quiesces the instance by sending 'guest-fsfreeze-freeze' to the agent, if installed.
  4. If the "quiesce" API succeeded, create the volume snapshot. Otherwise report an error and quit.
  5. Call Nova's "unquiesce" API (admin_action) via novaclient.
  6. 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.

Related links