From nobody Sun Feb 8 11:45:40 2026 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1548870042926725.9863217373304; Wed, 30 Jan 2019 09:40:42 -0800 (PST) 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 9BDCA7AE8B; Wed, 30 Jan 2019 17:40:40 +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 5772F5C21A; Wed, 30 Jan 2019 17:40:40 +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 ABC4518033A2; Wed, 30 Jan 2019 17:40:38 +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 x0UHeaa1026476 for ; Wed, 30 Jan 2019 12:40:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1FC735D97E; Wed, 30 Jan 2019 17:40:36 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-64.ams2.redhat.com [10.36.112.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 476D05D97A; Wed, 30 Jan 2019 17:40:35 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Wed, 30 Jan 2019 17:40:23 +0000 Message-Id: <20190130174026.20675-4-berrange@redhat.com> In-Reply-To: <20190130174026.20675-1-berrange@redhat.com> References: <20190130174026.20675-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] storage: pass struct _virStorageBackendQemuImgInfo by reference 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: , Content-Type: text/plain; charset="utf-8" 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.25]); Wed, 30 Jan 2019 17:40:41 +0000 (UTC) The struct _virStorageBackendQemuImgInfo is quite large so it is preferrable to pass it by reference instead of by value. This requires us to stop modifying the "compat" field. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/storage/storage_util.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 37b3d58667..de6f8ec2bd 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -742,38 +742,40 @@ struct _virStorageBackendQemuImgInfo { static int storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr encinfo, char **opts, - struct _virStorageBackendQemuImgInfo info) + struct _virStorageBackendQemuImgInfo *info) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 - if (info.backingPath) + if (info->backingPath) virBufferAsprintf(&buf, "backing_fmt=3D%s,", - virStorageFileFormatTypeToString(info.backingFor= mat)); + virStorageFileFormatTypeToString(info->backingFo= rmat)); =20 if (encinfo) - virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info.secretAlias); + virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info->secretAlias); =20 - if (info.preallocate) { - if (info.size_arg > info.allocation) + if (info->preallocate) { + if (info->size_arg > info->allocation) virBufferAddLit(&buf, "preallocation=3Dmetadata,"); else virBufferAddLit(&buf, "preallocation=3Dfalloc,"); } =20 - if (info.nocow) + if (info->nocow) virBufferAddLit(&buf, "nocow=3Don,"); =20 - if (info.compat) - virBufferAsprintf(&buf, "compat=3D%s,", info.compat); + if (info->compat) + virBufferAsprintf(&buf, "compat=3D%s,", info->compat); + else if (info->format =3D=3D VIR_STORAGE_FILE_QCOW2) + virBufferAddLit(&buf, "compat=3D0.10,"); =20 - if (info.features && info.format =3D=3D VIR_STORAGE_FILE_QCOW2) { - if (virBitmapIsBitSet(info.features, + if (info->features && info->format =3D=3D VIR_STORAGE_FILE_QCOW2) { + if (virBitmapIsBitSet(info->features, VIR_STORAGE_FILE_FEATURE_LAZY_REFCOUNTS)) { - if (STREQ_NULLABLE(info.compat, "0.10")) { + if (STREQ_NULLABLE(info->compat, "0.10")) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("lazy_refcounts not supported with compat" " level %s"), - info.compat); + info->compat); goto error; } virBufferAddLit(&buf, "lazy_refcounts,"); @@ -942,13 +944,10 @@ storageBackendCreateQemuImgSetBacking(virStoragePoolO= bjPtr pool, static int storageBackendCreateQemuImgSetOptions(virCommandPtr cmd, virStorageEncryptionInfoDefPtr encin= fo, - struct _virStorageBackendQemuImgInfo= info) + struct _virStorageBackendQemuImgInfo= *info) { char *opts =3D NULL; =20 - if (info.format =3D=3D VIR_STORAGE_FILE_QCOW2 && !info.compat) - info.compat =3D "0.10"; - if (storageBackendCreateQemuImgOpts(encinfo, &opts, info) < 0) return -1; if (opts) @@ -1196,7 +1195,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, } =20 if (convertStep !=3D VIR_STORAGE_VOL_ENCRYPT_CONVERT) { - if (storageBackendCreateQemuImgSetOptions(cmd, encinfo, info) < 0) + if (storageBackendCreateQemuImgSetOptions(cmd, encinfo, &info) < 0) goto error; if (info.inputPath) virCommandAddArg(cmd, info.inputPath); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list