[pve-devel] [PATCH qemu 2/3] avoid calling dump_cb with NULL data pointer for small/last cluster

Dietmar Maurer dietmar at proxmox.com
Thu Oct 24 08:06:51 CEST 2019


The last block of a backup may be smaller than cluster_size.

Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 block/backup.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/block/backup.c b/block/backup.c
index 2ccec79db6..cc20d77b9f 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -133,7 +133,12 @@ static int coroutine_fn backup_cow_with_bounce_buffer(BackupBlockJob *job,
 
     if (qemu_iovec_is_zero(&qiov)) {
         if (job->dump_cb) {
-            ret = job->dump_cb(job->common.job.opaque, job->target, start, qiov.size, NULL);
+            if (qiov.size == job->cluster_size) {
+                // Note: pass NULL to indicate that we want to write [0u8; cluster_size]
+                ret = job->dump_cb(job->common.job.opaque, job->target, start, qiov.size, NULL);
+            } else {
+                ret = job->dump_cb(job->common.job.opaque, job->target, start, qiov.size, *bounce_buffer);
+            }
         } else {
             ret = blk_co_pwrite_zeroes(job->target, start,
                                        qiov.size, write_flags | BDRV_REQ_MAY_UNMAP);
-- 
2.20.1




More information about the pve-devel mailing list