From nobody Mon May 12 13:59:15 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1695142769; cv=none; d=zohomail.com; s=zohoarc; b=FFDtr47wHXcKmkYicu8HeuDz1BE6kflWuxOCMlOHPPeawjgb3/A0YSQ4DQrGBJlSTYMinvZZd+fssE9gK336L/kJeZkBRha0+lmlxtaAleCnY9qGnNG1oYU9ftAhWbyr2Z69U71GLeA3pAnUpJgRQ8wuNwqSZf1mFKPoLOY9ikc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695142769; 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=0wyP/0D+MIoxM0LgqNvAFfSCdlM/RxEYcWuMlaXP98k=; b=OwTLnzp72bgV/0kbXxuVVst8qodLgC5YtpIc60fYfzgt8jZ4S4rn8LiH+TBHs8QUzY0ID5knTZieGP2AypHz5S0aIgYO+aebSKmaLZ9tzOjsOyvc28cALx2IrnaDFFhq8rQAANFh4pGfTzqOTJerR8l6g3YsxATaTBq5OgA4KHg= 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+importer2=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 1695142769458152.45738982122828; Tue, 19 Sep 2023 09:59:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qie3E-0003hn-Mo; Tue, 19 Sep 2023 12:58:17 -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 1qie3B-0003eM-Gf; Tue, 19 Sep 2023 12:58:13 -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 1qie37-0002Md-G3; Tue, 19 Sep 2023 12:58:13 -0400 Received: from [130.117.225.1] (helo=dev005.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1qidzZ-00DUte-2z; Tue, 19 Sep 2023 18:57:54 +0200 To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, hreitz@redhat.com, kwolf@redhat.com, eblake@redhat.com, andrey.drobyshev@virtuozzo.com, den@virtuozzo.com Subject: [PATCH v3 3/8] qemu-img: rebase: use backing files' BlockBackend for buffer alignment Date: Tue, 19 Sep 2023 19:57:59 +0300 Message-Id: <20230919165804.439110-4-andrey.drobyshev@virtuozzo.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230919165804.439110-1-andrey.drobyshev@virtuozzo.com> References: <20230919165804.439110-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+importer2=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 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1695142770826100011 Content-Type: text/plain; charset="utf-8" Since commit bb1c05973cf ("qemu-img: Use qemu_blockalign"), buffers for the data read from the old and new backing files are aligned using BlockDriverState (or BlockBackend later on) referring to the target image. However, this isn't quite right, because buf_new is only being used for reading from the new backing, while buf_old is being used for both reading from the old backing and writing to the target. Let's take that into accou= nt and use more appropriate values as alignments. Signed-off-by: Andrey Drobyshev --- qemu-img.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 50660ba920..4dc91505bf 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3750,8 +3750,13 @@ static int img_rebase(int argc, char **argv) int64_t n; float local_progress =3D 0; =20 - buf_old =3D blk_blockalign(blk, IO_BUF_SIZE); - buf_new =3D blk_blockalign(blk, IO_BUF_SIZE); + if (blk_old_backing && bdrv_opt_mem_align(blk_bs(blk_old_backing))= > + bdrv_opt_mem_align(blk_bs(blk))) { + buf_old =3D blk_blockalign(blk_old_backing, IO_BUF_SIZE); + } else { + buf_old =3D blk_blockalign(blk, IO_BUF_SIZE); + } + buf_new =3D blk_blockalign(blk_new_backing, IO_BUF_SIZE); =20 size =3D blk_getlength(blk); if (size < 0) { --=20 2.39.3