qemu/block
Ian Main fc5d3f8432 Implement sync modes for drive-backup.
This patch adds sync-modes to the drive-backup interface and
implements the FULL, NONE and TOP modes of synchronization.

FULL performs as before copying the entire contents of the drive
while preserving the point-in-time using CoW.
NONE only copies new writes to the target drive.
TOP copies changes to the topmost drive image and preserves the
point-in-time using CoW.

For sync mode TOP are creating a new target image using the same backing
file as the original disk image.  Then any new data that has been laid
on top of it since creation is copied in the main backup_run() loop.
There is an extra check in the 'TOP' case so that we don't bother to copy
all the data of the backing file as it already exists in the target.
This is where the bdrv_co_is_allocated() is used to determine if the
data exists in the topmost layer or below.

Also any new data being written is intercepted via the write_notifier
hook which ends up calling backup_do_cow() to copy old data out before
it gets overwritten.

For mode 'NONE' we create the new target image and only copy in the
original data from the disk image starting from the time the call was
made.  This preserves the point in time data by only copying the parts
that are *going to change* to the target image.  This way we can
reconstruct the final image by checking to see if the given block exists
in the new target image first, and if it does not, you can get it from
the original image.  This is basically an optimization allowing you to
do point-in-time snapshots with low overhead vs the 'FULL' version.

Since there is no old data to copy out the loop in backup_run() for the
NONE case just calls qemu_coroutine_yield() which only wakes up after
an event (usually cancel in this case).  The rest is handled by the
before_write notifier which again calls backup_do_cow() to write out
the old data so it can be preserved.

Signed-off-by: Ian Main <imain@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2013-07-26 22:01:31 +02:00
..
backup.c Implement sync modes for drive-backup. 2013-07-26 22:01:31 +02:00
blkdebug.c blkdebug: Add BLKDBG_FLUSH_TO_OS/DISK events 2013-06-06 11:27:22 +02:00
blkverify.c
bochs.c
cloop.c
commit.c block: Make BlockJobTypes const 2013-06-28 09:20:27 +02:00
cow.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
curl.c curl: refuse to open URL from HTTP server without range support 2013-07-05 09:40:18 +02:00
dmg.c
gluster.c gluster: Add discard support for GlusterFS block driver. 2013-07-19 12:29:21 +08:00
iscsi.c iscsi: factor out sector conversions 2013-07-17 17:01:41 +02:00
linux-aio.c
Makefile.objs block: add basic backup support to block driver 2013-06-28 09:20:26 +02:00
mirror.c block: Make BlockJobTypes const 2013-06-28 09:20:27 +02:00
nbd.c nbd: strip braces from literal IPv6 address in URI 2013-06-18 11:43:00 +02:00
parallels.c
qapi.c qmp: add ImageInfo in BlockDeviceInfo used by query-block 2013-06-07 13:37:45 +02:00
qcow2-cache.c
qcow2-cluster.c qcow2: Batch discards 2013-06-24 10:25:17 +02:00
qcow2-refcount.c qcow2: Batch discards 2013-06-24 10:25:17 +02:00
qcow2-snapshot.c qcow2: Add refcount update reason to all callers 2013-06-24 10:25:17 +02:00
qcow2.c qcow2: Use dashes instead of underscores in options 2013-07-26 21:59:56 +02:00
qcow2.h qcow2: Use dashes instead of underscores in options 2013-07-26 21:59:56 +02:00
qcow.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
qed-check.c
qed-cluster.c
qed-gencb.c
qed-l2-cache.c
qed-table.c
qed.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
qed.h
raw-aio.h
raw-posix.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
raw-win32.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
raw.c block/raw: add .bdrv_get_info 2013-07-19 15:27:37 +08:00
rbd.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
sheepdog.c block: Don't parse protocol from file.filename 2013-07-15 09:49:00 +02:00
snapshot.c block: move snapshot code in block.c to block/snapshot.c 2013-06-04 13:56:30 +02:00
ssh.c block/ssh: Set bdrv_has_zero_init according to the file type. 2013-06-28 09:20:27 +02:00
stream.c block: Make BlockJobTypes const 2013-06-28 09:20:27 +02:00
vdi.c block: change default of .has_zero_init to 0 2013-06-28 13:52:35 +02:00
vhdx.c
vhdx.h
vmdk.c vmdk: Implement .bdrv_has_zero_init 2013-07-05 09:40:18 +02:00
vpc.c vpc: Implement .bdrv_has_zero_init 2013-06-28 10:21:00 +02:00
vvfat.c block: fix vvfat error path for enable_write_target 2013-07-19 12:29:21 +08:00
win32-aio.c Remove twice include of qemu-common.h 2013-05-18 16:35:11 +04:00