From nobody Wed May 8 00:25:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1598662187; cv=none; d=zohomail.com; s=zohoarc; b=GvicxuL5Q5cI+NGEuD9CHO9+Ff1y8tkz75lMTvcutBk/k0PXSq0aP9dRAODo5kOf7E0cJP9YmXpOaa82LabiZF/+gq/wf8VobNrYCBxXQmIMck6J/Kna3Qu9kRdeHV0MFNGQDdWLBNQwWaWYKpY9pMLU5bcgCU2WSsE6qyPIWTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598662187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=XAxScdkyOynL7hLCPzj/i6FsShlLp0nlGiTxV+BT5Lo=; b=BOGKABBY72XZ08SHzW445MaYqx4tM+c9Mq5l979uDPxCsH7/4tUkh3sMy0EO556RHBdfkBZItAYmDIsoskHEbZfYWT4XBgewtH5IJr3uL34aBgizpdCN+Pso33VYb71JMCvgWLO5nB/w4UELzrlHAa9/Ix0E9mVNadyXxW+jyHc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1598662187003447.9284740778944; Fri, 28 Aug 2020 17:49:47 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-awOA-ATCPUyi7Nz4X-M0og-1; Fri, 28 Aug 2020 20:49:41 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0235E1074659; Sat, 29 Aug 2020 00:49:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E1517A3AB; Sat, 29 Aug 2020 00:49:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 70DA71826D2A; Sat, 29 Aug 2020 00:49:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 07T0nOkS006299 for ; Fri, 28 Aug 2020 20:49:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2EF35DA30; Sat, 29 Aug 2020 00:49:24 +0000 (UTC) Received: from localhost.localdomain (ovpn-114-137.ams2.redhat.com [10.36.114.137]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DE345D9D2; Sat, 29 Aug 2020 00:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598662186; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XAxScdkyOynL7hLCPzj/i6FsShlLp0nlGiTxV+BT5Lo=; b=H8mJiHLXH8ePfW+S5vSAOSCdA3TQdGBrtOOVs2EXvJMPIq0ATPOPFIhI5yFRMTy8jvEo/w 50zargs61xvQ+5LFHZeZ/crrNDQyLoV8r0vGSEZ74bGaTZ4fOnYq6Wt8XQXVC8L0AEivOC hhTt3VrWeJQNYPI6fBWZeHABLfu8Cfs= X-MC-Unique: awOA-ATCPUyi7Nz4X-M0og-1 From: Sebastian Mitterle To: libvir-list@redhat.com Subject: [PATCH] disk storage: fix allocation size for pool format dos Date: Sat, 29 Aug 2020 00:49:07 +0000 Message-Id: <20200829004907.4564-1-smitterl@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Sebastian Mitterle X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The changed condition was always false because the function was always called with boundary values 0. Use the free extent's start value to get its start offset from the cylinder boundary and determine if the needed size for allocation needs to be expanded too in case the offset doesn't fit within extra bytes for alignment. This fixes an issue where vol-create-from will call qemu-img convert to create a destination volume of same capacity as the source volume and qemu-img will error 'Cannot grow device files' due to the partition being too small for the source although both destination partition and source volume have the same capacity. Signed-off-by: Sebastian Mitterle Reviewed-by: Michal Privoznik --- src/storage/storage_backend_disk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index a6d4e41220..ec0679d353 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -691,7 +691,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPt= r pool, if (def->source.format =3D=3D VIR_STORAGE_POOL_DISK_DOS) { /* align to cylinder boundary */ neededSize +=3D extraBytes; - if ((*start % cylinderSize) > extraBytes) { + if ((dev->freeExtents[i].start % cylinderSize) > extraBytes) { /* add an extra cylinder if the offset can't fit within the extra bytes we have */ neededSize +=3D cylinderSize; --=20 2.25.2