[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/27] qemu-img: rebase: stop when reaching EOF of old backing fil
From: |
Kevin Wolf |
Subject: |
[PULL 01/27] qemu-img: rebase: stop when reaching EOF of old backing file |
Date: |
Tue, 31 Oct 2023 19:58:52 +0100 |
From: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
In case when we're rebasing within one backing chain, and when target image
is larger than old backing file, bdrv_is_allocated_above() ends up setting
*pnum = 0. As a result, target offset isn't getting incremented, and we
get stuck in an infinite for loop. Let's detect this case and proceed
further down the loop body, as the offsets beyond the old backing size need
to be explicitly zeroed.
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Message-ID: <20230919165804.439110-2-andrey.drobyshev@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index 585b65640f..2b2a3a86ca 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3814,6 +3814,8 @@ static int img_rebase(int argc, char **argv)
}
if (prefix_chain_bs) {
+ uint64_t bytes = n;
+
/*
* If cluster wasn't changed since prefix_chain, we don't need
* to take action
@@ -3826,9 +3828,18 @@ static int img_rebase(int argc, char **argv)
strerror(-ret));
goto out;
}
- if (!ret) {
+ if (!ret && n) {
continue;
}
+ if (!n) {
+ /*
+ * If we've reached EOF of the old backing, it means that
+ * offsets beyond the old backing size were read as zeroes.
+ * Now we will need to explicitly zero the cluster in
+ * order to preserve that state after the rebase.
+ */
+ n = bytes;
+ }
}
/*
--
2.41.0
- [PULL 00/27] Block layer patches, Kevin Wolf, 2023/10/31
- [PULL 01/27] qemu-img: rebase: stop when reaching EOF of old backing file,
Kevin Wolf <=
- [PULL 02/27] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size, Kevin Wolf, 2023/10/31
- [PULL 03/27] qemu-img: rebase: use backing files' BlockBackend for buffer alignment, Kevin Wolf, 2023/10/31
- [PULL 04/27] qemu-img: add chunk size parameter to compare_buffers(), Kevin Wolf, 2023/10/31
- [PULL 07/27] qemu-img: add compression option to rebase subcommand, Kevin Wolf, 2023/10/31
- [PULL 05/27] qemu-img: rebase: avoid unnecessary COW operations, Kevin Wolf, 2023/10/31
- [PULL 06/27] iotests/{024, 271}: add testcases for qemu-img rebase, Kevin Wolf, 2023/10/31
- [PULL 16/27] virtio: use defer_call() in virtio_irqfd_notify(), Kevin Wolf, 2023/10/31
- [PULL 15/27] util/defer-call: move defer_call() to util/, Kevin Wolf, 2023/10/31
- [PULL 21/27] block/mirror: determine copy_to_target only once, Kevin Wolf, 2023/10/31
- [PULL 19/27] block/mirror: set actively_synced even after the job is ready, Kevin Wolf, 2023/10/31