Index: new/block/backup.c
===================================================================
---- new.orig/block/backup.c 2013-12-02 12:30:23.000000000 +0100
-+++ new/block/backup.c 2013-12-02 12:56:03.000000000 +0100
+--- new.orig/block/backup.c 2013-12-05 08:18:53.000000000 +0100
++++ new/block/backup.c 2013-12-05 13:16:21.000000000 +0100
@@ -39,6 +39,7 @@
BlockDriverState *target;
MirrorSyncMode sync_mode;
BlockdevOnError on_source_error;
BlockdevOnError on_target_error;
CoRwlock flush_rwlock;
-@@ -137,12 +138,20 @@
+@@ -136,13 +137,21 @@
+ goto out;
}
++ int64_t start_sec = start * BACKUP_SECTORS_PER_CLUSTER;
if (buffer_is_zero(iov.iov_base, iov.iov_len)) {
- ret = bdrv_co_write_zeroes(job->target,
- start * BACKUP_SECTORS_PER_CLUSTER, n);
+ if (job->dump_cb) {
-+ ret = job->dump_cb(job->common.opaque, bs, start, NULL);
-+ } else {
-+ ret = bdrv_co_write_zeroes(job->target,
-+ start * BACKUP_SECTORS_PER_CLUSTER, n);
++ ret = job->dump_cb(job->common.opaque, job->target, start_sec, n, NULL);
++ }
++ if (job->target) {
++ ret = bdrv_co_write_zeroes(job->target, start_sec, n);
+ }
} else {
- ret = bdrv_co_writev(job->target,
- start * BACKUP_SECTORS_PER_CLUSTER, n,
- &bounce_qiov);
+ if (job->dump_cb) {
-+ ret = job->dump_cb(job->common.opaque, bs, start, bounce_buffer);
-+ } else {
-+ ret = bdrv_co_writev(job->target,
-+ start * BACKUP_SECTORS_PER_CLUSTER, n,
-+ &bounce_qiov);
++ ret = job->dump_cb(job->common.opaque, job->target, start_sec, n, bounce_buffer);
++ }
++ if (job->target) {
++ ret = bdrv_co_writev(job->target, start_sec, n, &bounce_qiov);
+ }
}
if (ret < 0) {
qemu_coroutine_enter(job->common.co, job);
Index: new/blockdev.c
===================================================================
---- new.orig/blockdev.c 2013-12-02 12:30:23.000000000 +0100
-+++ new/blockdev.c 2013-12-02 12:54:24.000000000 +0100
+--- new.orig/blockdev.c 2013-12-05 08:18:53.000000000 +0100
++++ new/blockdev.c 2013-12-05 13:07:43.000000000 +0100
@@ -1932,7 +1932,7 @@
}
error_propagate(errp, local_err);
Index: new/include/block/block_int.h
===================================================================
---- new.orig/include/block/block_int.h 2013-12-02 12:30:23.000000000 +0100
-+++ new/include/block/block_int.h 2013-12-02 12:52:21.000000000 +0100
+--- new.orig/include/block/block_int.h 2013-12-05 08:18:53.000000000 +0100
++++ new/include/block/block_int.h 2013-12-05 13:16:53.000000000 +0100
@@ -54,6 +54,9 @@
#define BLOCK_OPT_LAZY_REFCOUNTS "lazy_refcounts"
#define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
+typedef int BackupDumpFunc(void *opaque, BlockDriverState *bs,
-+ int64_t cluster_num, unsigned char *buf);
++ int64_t sector_num, int n_sectors, unsigned char *buf);
+
typedef struct BdrvTrackedRequest {
BlockDriverState *bs;