[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen staging-4.13] block/backup: fix backup_cow_with_offload for last cluster

commit 783e7eb52c0a8e2b8cb906566d0dc2538ffefccf
Author:     Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
AuthorDate: Fri Sep 20 17:20:43 2019 +0300
Commit:     Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
CommitDate: Wed Oct 30 11:34:26 2019 -0500

    block/backup: fix backup_cow_with_offload for last cluster
    We shouldn't try to copy bytes beyond EOF. Fix it.
    Fixes: 9ded4a0114968e
    Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@xxxxxxxxxxxxx>
    Reviewed-by: Max Reitz <mreitz@xxxxxxxxxx>
    Reviewed-by: John Snow <jsnow@xxxxxxxxxx>
    Message-id: 20190920142056.12778-3-vsementsov@xxxxxxxxxxxxx
    Signed-off-by: Max Reitz <mreitz@xxxxxxxxxx>
    (cherry picked from commit 1048ddf0a32dcdaa952e581bd503d49adad527cc)
    Signed-off-by: Michael Roth <mdroth@xxxxxxxxxxxxxxxxxx>
 block/backup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/backup.c b/block/backup.c
index 7067d1d1ad..8761f1f9a7 100644
--- a/block/backup.c
+++ b/block/backup.c
@@ -167,7 +167,7 @@ static int coroutine_fn 
backup_cow_with_offload(BackupBlockJob *job,
     assert(QEMU_IS_ALIGNED(job->copy_range_size, job->cluster_size));
     assert(QEMU_IS_ALIGNED(start, job->cluster_size));
-    nbytes = MIN(job->copy_range_size, end - start);
+    nbytes = MIN(job->copy_range_size, MIN(end, job->len) - start);
     nr_clusters = DIV_ROUND_UP(nbytes, job->cluster_size);
     hbitmap_reset(job->copy_bitmap, start, job->cluster_size * nr_clusters);
     ret = blk_co_copy_range(blk, start, job->target, start, nbytes,
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.13



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.