From nobody Wed May 14 05:45:24 2025 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 1525783703839870.0282223457725; Tue, 8 May 2018 05:48:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C50DC047B94; Tue, 8 May 2018 12:48:22 +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 4D16A30BAAC4; Tue, 8 May 2018 12:48:22 +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 F22D8180BAE9; Tue, 8 May 2018 12:48:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w48CmEZB020512 for ; Tue, 8 May 2018 08:48:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 40D55272A6; Tue, 8 May 2018 12:48:14 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-94.phx2.redhat.com [10.3.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02A3016E46 for ; Tue, 8 May 2018 12:48:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:47:59 -0400 Message-Id: <20180508124805.2372-7-jferlan@redhat.com> In-Reply-To: <20180508124805.2372-1-jferlan@redhat.com> References: <20180508124805.2372-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 06/12] storage_util: Move secretPath generation 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 May 2018 12:48:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move generation of secretPath to storageBackendGenerateSecretData and simplify a bit since we know vol->target.encryption is set plus we have a local @enc. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 64d4d1d7d2..d20a109306 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1310,7 +1310,9 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, =20 =20 static int -storageBackendGenerateSecretData(virStorageVolDefPtr vol) +storageBackendGenerateSecretData(virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + char **secretPath) { virStorageEncryptionPtr enc =3D vol->target.encryption; =20 @@ -1325,6 +1327,12 @@ storageBackendGenerateSecretData(virStorageVolDefPtr= vol) return -1; } =20 + if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW && + enc->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { + if (!(*secretPath =3D storageBackendCreateQemuImgSecretPath(pool, = vol))) + return -1; + } + return 0; } =20 @@ -1350,17 +1358,9 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr poo= l, return -1; } =20 - if (storageBackendGenerateSecretData(vol) < 0) + if (storageBackendGenerateSecretData(pool, vol, &secretPath) < 0) goto cleanup; =20 - if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW && - vol->target.encryption && - vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { - if (!(secretPath =3D - storageBackendCreateQemuImgSecretPath(pool, vol))) - goto cleanup; - } - cmd =3D virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol, flags, create_tool, secretPath); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list