qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Drobyshev via <qemu-devel@nongnu.org>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com,
	shmuel.eiderman@oracle.com, andrey.drobyshev@virtuozzo.com,
	den@virtuozzo.com
Subject: [PATCH 1/2] qemu-img: rebase: stop when reaching EOF of old backing file
Date: Tue, 23 May 2023 19:24:57 +0300	[thread overview]
Message-ID: <20230523162458.704266-2-andrey.drobyshev@virtuozzo.com> (raw)
In-Reply-To: <20230523162458.704266-1-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 break the
loop, as there's no more data to be read and merged from the old backing.

Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
---
 qemu-img.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qemu-img.c b/qemu-img.c
index 27f48051b0..55b6ce407c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3813,6 +3813,13 @@ static int img_rebase(int argc, char **argv)
                                  strerror(-ret));
                     goto out;
                 }
+                if (!n) {
+                    /*
+                     * We've reached EOF of the old backing, therefore there's
+                     * no more mergeable data.
+                     */
+                    break;
+                }
                 if (!ret) {
                     continue;
                 }
-- 
2.31.1



  reply	other threads:[~2023-05-23 16:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 16:24 [PATCH 0/2] qemu-img: fix getting stuck in infinite loop on Andrey Drobyshev via
2023-05-23 16:24 ` Andrey Drobyshev via [this message]
2023-05-24  8:30   ` [PATCH 1/2] qemu-img: rebase: stop when reaching EOF of old backing file Denis V. Lunev
2023-05-25 10:37     ` Andrey Drobyshev
2023-05-23 16:24 ` [PATCH 2/2] qemu-iotests: 024: add rebasing test case for overlay_size > backing_size Andrey Drobyshev via

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=20230523162458.704266-2-andrey.drobyshev@virtuozzo.com \
    --to=qemu-devel@nongnu.org \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=den@virtuozzo.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@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).