Live storage migration using libvirt blockcopy and blockcommit =============================================================== [Notes, from a discussion with Eric Blake.] [FIXME] Address, feedback from Eric Blake on 17MAR2015: ----------------------------------------------------------------------- - If your end goal is to commit back into the migrated image, then --quiesce doesn't add any value. --quiesce is only useful if you plan to revert to a known point in time and want the filesystem stable at that point in time. That, and snapshot-create-as doesn't yet support --quiesce, although we already have an open BZ to add it. - Next, when you do the blockcopy, you probably want to pre-create the destination /path/to/sn2 with the backing information correctly pointing to /path/to/base - And use the blockcopy --reuse-external flag, because if you don't, then libvirt/QEMU will create /path/to/sn2 with /path1/to/base as its backing file, which is not what you want. If you want, you can use 'blockcopy ... --pivot', instead of 'blockcopy ... --finish' + 'blockjob --pivot' (one command instead of two). - Might also be worth mentioning that there might be more efficient copies than `rsync`. For example, if you have BTRFS or ISCSI or other storage with a super-fast copy-on-write cloning operation, 10:42:42> so the step that copies /path1/to/base to /path2/to/base can take advantage of these faster storage-specific tricks. But otherwise, it looks like your page is mostly there, in describing a live storage migration ----------------------------------------------------------------------- Scenario -------- Start with: [/path1/to/base] (qemu active) then snapshot: [/path1/to/base] <- [sn1] (qemu active) then background copy (using `rsync` or `cp`): [/path1/to/base] <- [sn1] (qemu active) | [/path2/to/base] then shallow blockcopy: [/path1/to/base] <- [sn1] (qemu active) | | [/path2/to/base] <- [sn2] then pivot: [/path2/to/base] <- [sn2] (qemu active) then live commit: [/path2/to/base] Procedure --------- [Need to test this thoroughly.] $ virsh domblklist vm1 # Create snapshot ( use --quiesce $ virsh snapshot-create-as --domain vm1 sn1 \ --diskspec vda,file=/export/images/sn1.qcow2 \ --disk-only --atomic --no-metadata NOTE: Above, if you have QEMU guest agent installed in your virtual machine, try '--quiesce' option with 'snapshot-create-as' to ensure you have a consistent disk state. # Take a backup of disk $ rsync -avh --progress /export/images/base.img \ /export/images/copy.img # Shallow blockcopy (to path 2) $ virsh blockcopy \ --domain vm1 vda /export/images/copy.qcow2 \ --wait --verbose --shallow --finish # Then, pivot to the copy (FIXME: test) $ virsh blockjob vda --pivot # Then, live blockcommit (to path 2): $ virsh blockcommit vm1 vda --active --verbose --pivot