Provide a mechanism to merge a leaf image to its backing file without pausing the guest's execution.
Backup applications need an interface to snapshot a virtual machine's disk image so that data can be backed up in a consistent fashion. Once the backup has completed, the snapshot needs to be merged into the base image in order to eliminate any performance penalties. It should be possible to also provide information to the backup application about which blocks have changed since the last backup.
It should be possible for this to work with any type of format/protocol with the appropriate feature set.
(qemu) snapshot ide0-disk0 foo.qcow2 (qemu) # perform backup (qemu) merge -d ide0-disk0 (qemu) # original image is now restored
The -d flag causes foo.qcow2 to be deleted once the merge is complete.
(qemu) snapshot ide0-disk0 foo.qcow2 (qemu) # perform backup (qemu) merge ide0-disk0 (qemu) # still using foo.qcow2 (qemu) merge ide0-disk0 (qemu) # perform incremental backup
In this use case, the cases of full-backup and incremental backup are differentiated. There is a cost associated with doing this because a two-level image is now used.
BlockDriverAIOCB *bdrv_aio_merge(BlockDriverState *bs, uint64_t offset, BlockDriverCompletionFunc *cb, void *opaque);
bdrv_aio_merge begins searching for a mergable block at offset. Once it is able to merge at least one block, it will the number of bytes scanned and merged which can then be added to offset and used in the next call. If the completion function returns 0, that indicates the the image is fully merged. If offset + ret == bdrv_getlength(), the caller should reset offset to 0 and continue calling bdrv_aio_merge.
Still gathering requirements.