From nobody Mon Feb 9 05:13:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1684859168; cv=none; d=zohomail.com; s=zohoarc; b=TbUOu8if9hF5ZDzy+ATrH5H7wrc3XbjgfT+ImGu8n8V7olqyEdXDcD3uYfKVXSlGnj6CTh1vHwZaJq4Y2zpypGSZvckdtwZdHRJF3P4ZC78f8RarUaeK0Sr7dgfcVHAglBnBnS7A7RFw5xGQMXs55RvAsKE9yMyE8FV9oVjEUaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684859168; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=d0by9kHo/O3fQAH/vClzL5+KJARUT146PubXZGnTVus=; b=ioqEegHy5ud3N7CMe6ro23JAfVa3lx2w4Q/VQdAdnikGjJIbN80MZWproamIlC74VmDUBuIWEZlHcewox0s7bixKsNFwdbWYV7fPmHZdCze0+pr8N45W6H6uqjDGOIgMCjMUHCetiO7YPoJvjAtybW8s+WFst2FoeOq+XjnS+cM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1684859168016380.1738737224563; Tue, 23 May 2023 09:26:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1Up0-0005LI-Cs; Tue, 23 May 2023 12:25:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1Uou-0005JY-QY; Tue, 23 May 2023 12:25:10 -0400 Received: from relay.virtuozzo.com ([130.117.225.111]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1Uos-00076p-MR; Tue, 23 May 2023 12:25:08 -0400 Received: from dev005.ch-qa.vzint.dev ([172.29.1.10]) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1q1UnN-00DnIw-1X; Tue, 23 May 2023 18:24:48 +0200 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 Message-Id: <20230523162458.704266-2-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230523162458.704266-1-andrey.drobyshev@virtuozzo.com> References: <20230523162458.704266-1-andrey.drobyshev@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=130.117.225.111; envelope-from=andrey.drobyshev@virtuozzo.com; helo=relay.virtuozzo.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Andrey Drobyshev From: Andrey Drobyshev via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1684859169767100003 Content-Type: text/plain; charset="utf-8" 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 =3D 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 --- 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 the= re's + * no more mergeable data. + */ + break; + } if (!ret) { continue; } --=20 2.31.1