Red Hat Training

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

14.5.16. Using blockpull to Shorten a Backing Chain

blockpull can be used in in the following applications:
  • Flattens an image by populating it with data from its backing image chain. This makes the image file self-contained so that it no longer depends on backing images and looks like this:
    • Before: base.img ← Active
    • After: base.img is no longer used by the guest and Active contains all of the data.
  • Flattens part of the backing image chain. This can be used to flatten snapshots into the top-level image and looks like this:
    • Before: base ← sn1 ←sn2 ← active
    • After: base.img ← active. Note that active now contains all data from sn1 and sn2 and neither sn1 nor sn2 are used by the guest.
  • Moves the disk image to a new file system on the host. This is allows image files to be moved while the guest is running and looks like this:
    • Before (The original image file): /fs1/base.vm.img
    • After: /fs2/active.vm.qcow2 is now the new file system and /fs1/base.vm.img is no longer used.
  • Useful in live migration with post-copy storage migration. The disk image is copied from the source host to the destination host after live migration completes.
    In short this is what happens: Before:/source-host/base.vm.img After:/destination-host/active.vm.qcow2./source-host/base.vm.img is no longer used.

Procedure 14.3. Using blockpull to Shorten a Backing Chain

  1. It may be helpful to run this command prior to running blockpull:
    # virsh snapshot-create-as $dom $name - disk-only
  2. If the chain looks like this: base ← snap1 ← snap2 ← active run the following:
    # virsh blockpull $dom $disk snap1
    This command makes 'snap1' the backing file of active, by pulling data from snap2 into active resulting in: base ← snap1 ← active.
  3. Once the blockpull is complete, the libvirt tracking of the snapshot that created the extra image in the chain is no longer useful. Delete the tracking on the outdated snapshot with this command:
    # virsh snapshot-delete $dom $name - metadata
Additional applications of blockpull can be done as follows:
  • To flatten a single image and populate it with data from its backing image chain:# virsh blockpull example-domain vda - wait
  • To flatten part of the backing image chain:# virsh blockpull example-domain vda - base /path/to/base.img - wait
  • To move the disk image to a new file system on the host:# virsh snapshot-create example-domaine - xmlfile /path/to/new.xml - disk-only followed by # virsh blockpull example-domain vda - wait
  • To use live migration with post-copy storage migration:
    • On the destination run:
       # qemu-img create -f qcow2 -o backing_file=/source-host/vm.img /destination-host/vm.qcow2
    • On the source run:
      # virsh migrate example-domain
    • On the destination run:
      # virsh blockpull example-domain vda - wait