From nobody Sat May 4 07:58:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1497555363658617.7414333517006; Thu, 15 Jun 2017 12:36:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8CD94E4D0; Thu, 15 Jun 2017 19:36:01 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7064458823; Thu, 15 Jun 2017 19:36:00 +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 6695A4BB7F; Thu, 15 Jun 2017 19:35:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5FJVDah020898 for ; Thu, 15 Jun 2017 15:31:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C72B19E9A; Thu, 15 Jun 2017 19:31:13 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A3DE19E38 for ; Thu, 15 Jun 2017 19:31:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A8CD94E4D0 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A8CD94E4D0 From: John Ferlan To: libvir-list@redhat.com Date: Thu, 15 Jun 2017 15:31:05 -0400 Message-Id: <20170615193105.29877-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] util: Force reading of meta data to get encryption capacity value 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 15 Jun 2017 19:36:02 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1371892 As it turns out the volume create, build, and refresh path was not peeking at the meta data, so immediately after a create operation the value display= ed for capacity was still incorrect. However, if a pool refresh was done the correct value was fetched as a result of a meta data peek. The reason is it seems historically if the file type is RAW then peeking at the file just took the physical value for the capacity. However, since we know if it's an encrypted file, then peeking at the meta data will be required in order to get a true capacity value. So check for encryption in the source and if present, use the meta data in order to fill in the capacity value and set the payload_offset. Signed-off-by: John Ferlan --- src/util/virstoragefile.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index e82a7fb..11c3625 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -3446,13 +3446,16 @@ virStorageSourceUpdateCapacity(virStorageSourcePtr = src, src->format =3D format; } =20 - if (format =3D=3D VIR_STORAGE_FILE_RAW) + if (format =3D=3D VIR_STORAGE_FILE_RAW && !src->encryption) { src->capacity =3D src->physical; - else if ((meta =3D virStorageFileGetMetadataFromBuf(src->path, buf, - len, format, NULL))) + } else if ((meta =3D virStorageFileGetMetadataFromBuf(src->path, buf, + len, format, NULL)= )) { src->capacity =3D meta->capacity ? meta->capacity : src->physical; - else + if (src->encryption && meta->encryption) + src->encryption->payload_offset =3D meta->encryption->payload_= offset; + } else { goto cleanup; + } =20 if (src->encryption && src->encryption->payload_offset !=3D -1) src->capacity -=3D src->encryption->payload_offset * 512; --=20 2.9.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list