From: "Denis V. Lunev" <den@virtuozzo.com>
To: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, shmuel.eiderman@oracle.com
Subject: Re: [PATCH v2 1/2] qemu-img: rebase: stop when reaching EOF of old backing file
Date: Fri, 26 May 2023 14:12:22 +0200 [thread overview]
Message-ID: <e3c6074b-6cff-33fc-15d3-56cd3b204cd9@virtuozzo.com> (raw)
In-Reply-To: <20230525180213.902012-2-andrey.drobyshev@virtuozzo.com>
On 5/25/23 20:02, Andrey Drobyshev wrote:
> 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>
> ---
> qemu-img.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 27f48051b0..78433f3746 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -3801,6 +3801,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
> @@ -3813,9 +3815,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;
> + }
> }
>
> /*
Revieved-by: Denis V. Lunev <den@openvz.org>
next prev parent reply other threads:[~2023-05-26 12:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-25 18:02 [PATCH v2 0/2] qemu-img: fix getting stuck in infinite loop on in-chain rebase Andrey Drobyshev via
2023-05-25 18:02 ` [PATCH v2 1/2] qemu-img: rebase: stop when reaching EOF of old backing file Andrey Drobyshev via
2023-05-26 12:12 ` Denis V. Lunev [this message]
2023-05-25 18:02 ` [PATCH v2 2/2] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size Andrey Drobyshev via
2023-05-26 12:13 ` Denis V. Lunev
2023-06-01 20:54 ` [PATCH v2 0/2] qemu-img: fix getting stuck in infinite loop on in-chain rebase Andrey Drobyshev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3c6074b-6cff-33fc-15d3-56cd3b204cd9@virtuozzo.com \
--to=den@virtuozzo.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=shmuel.eiderman@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).