From nobody Wed May 1 15:13:53 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.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 1525783696085516.0689401227899; Tue, 8 May 2018 05:48:16 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 59AD132FEBC3; Tue, 8 May 2018 12:48:14 +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 27CE7601A4; Tue, 8 May 2018 12:48:14 +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 C5276180BAE8; Tue, 8 May 2018 12:48:13 +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 w48CmCdd020430 for ; Tue, 8 May 2018 08:48:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0DFB82719D; Tue, 8 May 2018 12:48:12 +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 C28B626FA4 for ; Tue, 8 May 2018 12:48:11 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:47:54 -0400 Message-Id: <20180508124805.2372-2-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 01/12] storage_util: Some code cleanup 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 08 May 2018 12:48:15 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Perform some code cleanup in areas that are about to be altered. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index bc048e3dff..4fddbf3f9e 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -874,7 +874,7 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr enc, =20 /* storageBackendCreateQemuImgCheckEncryption: * @format: format of file found - * @conn: pointer to connection + * @type: TypeToString of format.type * @vol: pointer to volume def * * Ensure the proper setup for encryption. @@ -1199,11 +1199,9 @@ virStorageBackendCreateQemuImgCmdFromVol(virStorageP= oolObjPtr pool, return NULL; =20 if (info.encryption && - storageBackendCreateQemuImgCheckEncryption(info.format, type, - vol) < 0) + storageBackendCreateQemuImgCheckEncryption(info.format, type, vol)= < 0) return NULL; =20 - /* Size in KB */ info.size_arg =3D VIR_DIV_UP(vol->target.capacity, 1024); =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 152578370083268.51299233624081; Tue, 8 May 2018 05:48:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C29D804E3; Tue, 8 May 2018 12:48:19 +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 2F3EF100195F; Tue, 8 May 2018 12:48:19 +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 D43AE4CAA7; Tue, 8 May 2018 12:48:18 +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 w48CmCpf020439 for ; Tue, 8 May 2018 08:48:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C402272A6; Tue, 8 May 2018 12:48:12 +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 35A2C26FA4 for ; Tue, 8 May 2018 12:48:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:47:55 -0400 Message-Id: <20180508124805.2372-3-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 02/12] storage_util: Cleanup usage of target.encryption 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 08 May 2018 12:48:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the !=3D NULL checks, use !! for setting info.encryption. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 4fddbf3f9e..cc1f6e7086 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -423,7 +423,7 @@ storageBackendCreateRaw(virStoragePoolObjPtr pool, reflink_copy =3D true; =20 =20 - if (vol->target.encryption !=3D NULL) { + if (vol->target.encryption) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("storage pool does not support encrypted volumes"= )); goto cleanup; @@ -707,7 +707,7 @@ storageBackendCreatePloop(virStoragePoolObjPtr pool ATT= RIBUTE_UNUSED, return -1; } =20 - if (vol->target.encryption !=3D NULL) { + if (vol->target.encryption) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("encrypted ploop volumes are not supported with " "ploop init")); @@ -1128,7 +1128,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, .format =3D vol->target.format, .path =3D vol->target.path, .allocation =3D vol->target.allocation, - .encryption =3D vol->target.encryption !=3D NULL, + .encryption =3D !!vol->target.encryption, .preallocate =3D !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADA= TA), .compat =3D vol->target.compat, .features =3D vol->target.features, @@ -1169,8 +1169,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, _("format features only available with qcow2")); return NULL; } - if (info.format =3D=3D VIR_STORAGE_FILE_RAW && - vol->target.encryption !=3D NULL) { + if (info.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption)= { if (inputvol) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("cannot use inputvol with encrypted raw volum= e")); @@ -1220,8 +1219,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, if (info.backingPath) virCommandAddArgList(cmd, "-b", info.backingPath, NULL); =20 - if (info.format =3D=3D VIR_STORAGE_FILE_RAW && - vol->target.encryption !=3D NULL && + if (info.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption = && vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { if (virAsprintf(&info.secretAlias, "%s_luks0", vol->name) < 0) goto error; @@ -1415,10 +1413,10 @@ virStorageBackendGetBuildVolFromFunction(virStorage= VolDefPtr vol, */ if ((vol->type =3D=3D VIR_STORAGE_VOL_FILE && (vol->target.format !=3D VIR_STORAGE_FILE_RAW || - vol->target.encryption !=3D NULL)) || + vol->target.encryption)) || (inputvol->type =3D=3D VIR_STORAGE_VOL_FILE && (inputvol->target.format !=3D VIR_STORAGE_FILE_RAW || - inputvol->target.encryption !=3D NULL))) { + inputvol->target.encryption))) { return storageBackendCreateQemuImg; } =20 @@ -2105,7 +2103,7 @@ storageBackendVolBuildLocal(virStoragePoolObjPtr pool, virStorageBackendBuildVolFrom create_func; =20 if (inputvol) { - if (vol->target.encryption !=3D NULL) { + if (vol->target.encryption) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("storage pool does not support " "building encrypted volumes from " --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 152578370696756.83493713300709; Tue, 8 May 2018 05:48:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C9323002477; Tue, 8 May 2018 12:48:25 +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 44C92608F0; Tue, 8 May 2018 12:48:25 +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 DC4514CAAD; Tue, 8 May 2018 12:48:24 +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 w48CmCc9020463 for ; Tue, 8 May 2018 08:48:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id E0A26272A9; Tue, 8 May 2018 12:48:12 +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 A2611272A6 for ; Tue, 8 May 2018 12:48:12 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:47:56 -0400 Message-Id: <20180508124805.2372-4-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 03/12] storage_util: Remove unnecessary check 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 08 May 2018 12:48:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id 'a48c71411' altered the logic a bit and didn't remove an unnecessary check as info.encryption is true when vol->target.encryption !=3D NULL, so if we enter the if segment with info.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption !=3D NULL, then there's no way info.encryption could be false. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index cc1f6e7086..4dd73f2734 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1175,11 +1175,6 @@ virStorageBackendCreateQemuImgCmdFromVol(virStorageP= oolObjPtr pool, _("cannot use inputvol with encrypted raw volum= e")); return NULL; } - if (!info.encryption) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing encryption description")); - return NULL; - } if (vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_F= ORMAT_LUKS) { type =3D "luks"; } else { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783713030798.1534861125981; Tue, 8 May 2018 05:48:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C4CF5F7A6; Tue, 8 May 2018 12:48:31 +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 3D83516E46; Tue, 8 May 2018 12:48:31 +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 DDCC34CAB0; Tue, 8 May 2018 12:48:30 +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 w48CmDaG020473 for ; Tue, 8 May 2018 08:48:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6641F16E46; Tue, 8 May 2018 12:48:13 +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 2027828DC2 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:57 -0400 Message-Id: <20180508124805.2372-5-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 04/12] storage_util: Rename virQEMUBuildLuksOpts 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 08 May 2018 12:48:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rename to storageBackendCreateQemuImgOpts - which is what it's doing. Signed-off-by: John Ferlan --- src/libvirt_private.syms | 2 +- src/storage/storage_util.c | 2 +- src/util/virqemu.c | 8 ++++---- src/util/virqemu.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f8883dc50d..20352ffe99 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2593,8 +2593,8 @@ virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; virQEMUBuildCommandLineJSONArrayNumbered; virQEMUBuildDriveCommandlineFromJSON; -virQEMUBuildLuksOpts; virQEMUBuildObjectCommandlineFromJSON; +virQEMUBuildQemuImgKeySecretOpts; =20 =20 # util/virrandom.h diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 4dd73f2734..37a649d17b 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -823,7 +823,7 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInf= oDefPtr enc, virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 if (info.format =3D=3D VIR_STORAGE_FILE_RAW && enc) { - virQEMUBuildLuksOpts(&buf, enc, info.secretAlias); + virQEMUBuildQemuImgKeySecretOpts(&buf, enc, info.secretAlias); } else { if (info.backingPath) virBufferAsprintf(&buf, "backing_fmt=3D%s,", diff --git a/src/util/virqemu.c b/src/util/virqemu.c index d6652262fe..04cd71605e 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -303,7 +303,7 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const c= har *str) =20 =20 /** - * virQEMUBuildLuksOpts: + * virQEMUBuildQemuImgKeySecretOpts: * @buf: buffer to build the string into * @enc: pointer to encryption info * @alias: alias to use @@ -323,9 +323,9 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const c= har *str) * */ void -virQEMUBuildLuksOpts(virBufferPtr buf, - virStorageEncryptionInfoDefPtr enc, - const char *alias) +virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf, + virStorageEncryptionInfoDefPtr enc, + const char *alias) { virBufferAsprintf(buf, "key-secret=3D%s,", alias); =20 diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 539d62ab14..2599481753 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -50,9 +50,9 @@ char *virQEMUBuildObjectCommandlineFromJSON(const char *t= ype, char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src); =20 void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str); -void virQEMUBuildLuksOpts(virBufferPtr buf, - virStorageEncryptionInfoDefPtr enc, - const char *alias) +void virQEMUBuildQemuImgKeySecretOpts(virBufferPtr buf, + virStorageEncryptionInfoDefPtr enc, + const char *alias) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); =20 #endif /* __VIR_QEMU_H_ */ --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783697722106.55044677739568; Tue, 8 May 2018 05:48:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BD154E90A; Tue, 8 May 2018 12:48:16 +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 4597C5D756; Tue, 8 May 2018 12:48:16 +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 00FD7180BAE6; Tue, 8 May 2018 12:48:15 +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 w48CmDlm020488 for ; Tue, 8 May 2018 08:48:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id CBC81272A6; Tue, 8 May 2018 12:48:13 +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 8E30016E46 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:58 -0400 Message-Id: <20180508124805.2372-6-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 05/12] storage_util: Generate the qcow secret earlier 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 08 May 2018 12:48:16 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Rather than having storageBackendCreateQemuImgCheckEncryption perform the virStorageGenerateQcowEncryption, let's just do that earlier during storageBackendCreateQemuImg so that the check helper is just a check helper rather doing something different based on whether the format is qcow[2] or raw based encryption. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 37a649d17b..64d4d1d7d2 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -901,10 +901,10 @@ storageBackendCreateQemuImgCheckEncryption(int format, _("too many secrets for qcow encryption")); return -1; } - if (enc->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT || - enc->nsecrets =3D=3D 0) { - if (virStorageGenerateQcowEncryption(vol) < 0) - return -1; + if (enc->nsecrets =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("no secret provided for qcow encryption")); + return -1; } } else if (format =3D=3D VIR_STORAGE_FILE_RAW) { if (enc->format !=3D VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { @@ -1309,6 +1309,26 @@ storageBackendCreateQemuImgSecretPath(virStoragePool= ObjPtr pool, } =20 =20 +static int +storageBackendGenerateSecretData(virStorageVolDefPtr vol) +{ + virStorageEncryptionPtr enc =3D vol->target.encryption; + + if (!enc) + return 0; + + if ((vol->target.format =3D=3D VIR_STORAGE_FILE_QCOW || + vol->target.format =3D=3D VIR_STORAGE_FILE_QCOW2) && + (enc->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT || + enc->nsecrets =3D=3D 0)) { + if (virStorageGenerateQcowEncryption(vol) < 0) + return -1; + } + + return 0; +} + + static int storageBackendCreateQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, @@ -1330,6 +1350,9 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, return -1; } =20 + if (storageBackendGenerateSecretData(vol) < 0) + goto cleanup; + 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) { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 From nobody Wed May 1 15:13:53 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.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 1525783710923436.2583426974302; Tue, 8 May 2018 05:48:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FA373003931; Tue, 8 May 2018 12:48:29 +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 173965D9C6; Tue, 8 May 2018 12:48:29 +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 BB1044CAB0; Tue, 8 May 2018 12:48:28 +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 w48CmEUg020540 for ; Tue, 8 May 2018 08:48:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id AB806272A6; 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 6C94E16E46 for ; Tue, 8 May 2018 12:48:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:00 -0400 Message-Id: <20180508124805.2372-8-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 07/12] storage_util: Remove luks distinction from secret path and alias 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 08 May 2018 12:48:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove the "luks" distinction as the code is about to become more generic and be able to support qcow encryption as well. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index d20a109306..c72fd47024 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1216,7 +1216,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, =20 if (info.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption = && vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_FORMA= T_LUKS) { - if (virAsprintf(&info.secretAlias, "%s_luks0", vol->name) < 0) + if (virAsprintf(&info.secretAlias, "%s_encrypt0", vol->name) < 0) goto error; if (storageBackendCreateQemuImgSecretObject(cmd, info.secretPath, info.secretAlias) < 0) @@ -1269,7 +1269,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, =20 if ((fd =3D mkostemp(secretPath, O_CLOEXEC)) < 0) { virReportSystemError(errno, "%s", - _("failed to open luks secret file for write"= )); + _("failed to open secret file for write")); goto error; } =20 @@ -1280,7 +1280,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, =20 if (safewrite(fd, secret, secretlen) < 0) { virReportSystemError(errno, "%s", - _("failed to write luks secret file")); + _("failed to write secret file")); goto error; } VIR_FORCE_CLOSE(fd); @@ -1290,7 +1290,7 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolO= bjPtr pool, if (chown(secretPath, vol->target.perms->uid, vol->target.perms->gid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to chown luks secret file")); + _("failed to chown secret file")); goto error; } } @@ -2331,7 +2331,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, storageBackendCreateQemuImgSecretPath(pool, vol))) goto cleanup; =20 - if (virAsprintf(&secretAlias, "%s_luks0", vol->name) < 0) + if (virAsprintf(&secretAlias, "%s_encrypt0", vol->name) < 0) goto cleanup; } =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783704600417.26958376648054; Tue, 8 May 2018 05:48:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2D1785542; Tue, 8 May 2018 12:48:22 +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 66C6316E46; 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 15D404CAA8; Tue, 8 May 2018 12:48:22 +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 w48CmF8q020562 for ; Tue, 8 May 2018 08:48:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1EC49272A6; Tue, 8 May 2018 12:48:15 +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 D415316E46 for ; Tue, 8 May 2018 12:48:14 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:01 -0400 Message-Id: <20180508124805.2372-9-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 08/12] storage_util: Split backing_fmt set in storageBackendCreateQemuImgOpts 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 08 May 2018 12:48:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The only way backing_fmts could be set is if the info->format was not RAW (see storageBackendCreateQemuImgSetBacking), so let's just extract it from the if/else surrounding the application of the encryption options. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c72fd47024..cedec10403 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -822,12 +822,13 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionI= nfoDefPtr enc, { virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 + if (info.backingPath) + virBufferAsprintf(&buf, "backing_fmt=3D%s,", + virStorageFileFormatTypeToString(info.backingFor= mat)); + if (info.format =3D=3D VIR_STORAGE_FILE_RAW && enc) { virQEMUBuildQemuImgKeySecretOpts(&buf, enc, info.secretAlias); } else { - if (info.backingPath) - virBufferAsprintf(&buf, "backing_fmt=3D%s,", - virStorageFileFormatTypeToString(info.backin= gFormat)); if (info.encryption) virBufferAddLit(&buf, "encryption=3Don,"); if (info.preallocate) { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783710698132.87926934783604; Tue, 8 May 2018 05:48:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 03E81313631A; Tue, 8 May 2018 12:48:29 +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 C1DC0608F0; Tue, 8 May 2018 12:48:28 +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 7C35F180BAEA; Tue, 8 May 2018 12:48:28 +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 w48CmFXw020587 for ; Tue, 8 May 2018 08:48:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 905F616E46; Tue, 8 May 2018 12:48:15 +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 47899272A6 for ; Tue, 8 May 2018 12:48:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:02 -0400 Message-Id: <20180508124805.2372-10-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 09/12] storage_util: Split preallocate set in storageBackendCreateQemuImgOpts 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 08 May 2018 12:48:29 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The only way preallocate could be set is if the info->format was not RAW (see storageBackendCreateQemuImgSetBacking), so let's just extract it from the if/else surrounding the application of the encryption options. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index cedec10403..bd8fb7ca92 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -831,12 +831,13 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionI= nfoDefPtr enc, } else { if (info.encryption) virBufferAddLit(&buf, "encryption=3Don,"); - if (info.preallocate) { - if (info.size_arg > info.allocation) - virBufferAddLit(&buf, "preallocation=3Dmetadata,"); - else - virBufferAddLit(&buf, "preallocation=3Dfalloc,"); - } + } + + if (info.preallocate) { + if (info.size_arg > info.allocation) + virBufferAddLit(&buf, "preallocation=3Dmetadata,"); + else + virBufferAddLit(&buf, "preallocation=3Dfalloc,"); } =20 if (info.nocow) --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783715949752.5369652711029; Tue, 8 May 2018 05:48:35 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E71723E6CE; Tue, 8 May 2018 12:48:34 +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 64360608F4; Tue, 8 May 2018 12:48:34 +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 202EC4CAB4; Tue, 8 May 2018 12:48:34 +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 w48CmGW6020597 for ; Tue, 8 May 2018 08:48:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E5BE2719D; Tue, 8 May 2018 12:48:16 +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 C14A2272A6 for ; Tue, 8 May 2018 12:48:15 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:03 -0400 Message-Id: <20180508124805.2372-11-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 10/12] storage_util: Move @type into _virStorageBackendQemuImgInfo 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 08 May 2018 12:48:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We're about to split up the code a bit more, so we'll need this to be in the local struct. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index bd8fb7ca92..c28f427a1a 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -794,6 +794,7 @@ storagePloopResize(virStorageVolDefPtr vol, */ struct _virStorageBackendQemuImgInfo { int format; + const char *type; const char *path; unsigned long long size_arg; unsigned long long allocation; @@ -1125,9 +1126,9 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, const char *secretPath) { virCommandPtr cmd =3D NULL; - const char *type; struct _virStorageBackendQemuImgInfo info =3D { .format =3D vol->target.format, + .type =3D NULL, .path =3D vol->target.path, .allocation =3D vol->target.allocation, .encryption =3D !!vol->target.encryption, @@ -1149,7 +1150,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, if (info.format =3D=3D VIR_STORAGE_FILE_ISO) info.format =3D VIR_STORAGE_FILE_RAW; =20 - if (!(type =3D virStorageFileFormatTypeToString(info.format))) { + if (!(info.type =3D virStorageFileFormatTypeToString(info.format))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown storage vol type %d"), info.format); @@ -1178,7 +1179,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, return NULL; } if (vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_F= ORMAT_LUKS) { - type =3D "luks"; + info.type =3D "luks"; } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only luks encryption is supported for raw fi= les")); @@ -1195,7 +1196,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, return NULL; =20 if (info.encryption && - storageBackendCreateQemuImgCheckEncryption(info.format, type, vol)= < 0) + storageBackendCreateQemuImgCheckEncryption(info.format, info.type,= vol) < 0) return NULL; =20 /* Size in KB */ @@ -1209,9 +1210,9 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePo= olObjPtr pool, =20 if (info.inputPath) virCommandAddArgList(cmd, "convert", "-f", info.inputFormatStr, - "-O", type, NULL); + "-O", info.type, NULL); else - virCommandAddArgList(cmd, "create", "-f", type, NULL); + virCommandAddArgList(cmd, "create", "-f", info.type, NULL); =20 if (info.backingPath) virCommandAddArgList(cmd, "-b", info.backingPath, NULL); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783720058623.4345536678568; Tue, 8 May 2018 05:48:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA31A30B8F87; Tue, 8 May 2018 12:48:38 +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 5B3A0608F0; Tue, 8 May 2018 12:48:38 +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 0F5C9180BAED; Tue, 8 May 2018 12:48:38 +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 w48CmGvw020607 for ; Tue, 8 May 2018 08:48:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72BC72719D; Tue, 8 May 2018 12:48:16 +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 36B5116E46 for ; Tue, 8 May 2018 12:48:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:04 -0400 Message-Id: <20180508124805.2372-12-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 11/12] storage_util: Introduce storageBackendCreateQemuImgSetInput 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 08 May 2018 12:48:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Split up virStorageBackendCreateQemuImgCmdFromVol into two parts. It's too long anyway and virStorageBackendCreateQemuImgCmdFromVol should just handle the command line processing. NB: Requires changing info.* into info->* references. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 114 +++++++++++++++++++++++++----------------= ---- 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index c28f427a1a..f7da6743b0 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1116,91 +1116,105 @@ storageBackendResizeQemuImgImageOpts(virCommandPtr= cmd, } =20 =20 -/* Create a qemu-img virCommand from the supplied arguments */ -virCommandPtr -virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, - virStorageVolDefPtr vol, - virStorageVolDefPtr inputvol, - unsigned int flags, - const char *create_tool, - const char *secretPath) +static int +virStorageBackendCreateQemuImgSetInfo(virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + struct _virStorageBackendQemuImgInfo= *info) { - virCommandPtr cmd =3D NULL; - struct _virStorageBackendQemuImgInfo info =3D { - .format =3D vol->target.format, - .type =3D NULL, - .path =3D vol->target.path, - .allocation =3D vol->target.allocation, - .encryption =3D !!vol->target.encryption, - .preallocate =3D !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADA= TA), - .compat =3D vol->target.compat, - .features =3D vol->target.features, - .nocow =3D vol->target.nocow, - .secretPath =3D secretPath, - .secretAlias =3D NULL, - }; - virStorageEncryptionInfoDefPtr enc =3D NULL; - - virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL); - /* Treat output block devices as 'raw' format */ if (vol->type =3D=3D VIR_STORAGE_VOL_BLOCK) - info.format =3D VIR_STORAGE_FILE_RAW; + info->format =3D VIR_STORAGE_FILE_RAW; =20 - if (info.format =3D=3D VIR_STORAGE_FILE_ISO) - info.format =3D VIR_STORAGE_FILE_RAW; + if (info->format =3D=3D VIR_STORAGE_FILE_ISO) + info->format =3D VIR_STORAGE_FILE_RAW; =20 - if (!(info.type =3D virStorageFileFormatTypeToString(info.format))) { + if (!(info->type =3D virStorageFileFormatTypeToString(info->format))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown storage vol type %d"), - info.format); - return NULL; + info->format); + return -1; } =20 - if (info.preallocate && info.format !=3D VIR_STORAGE_FILE_QCOW2) { + if (info->preallocate && info->format !=3D VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("metadata preallocation only available with qcow2= ")); - return NULL; + return -1; } - if (info.compat && info.format !=3D VIR_STORAGE_FILE_QCOW2) { + if (info->compat && info->format !=3D VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("compatibility option only available with qcow2")= ); - return NULL; + return -1; } - if (info.features && info.format !=3D VIR_STORAGE_FILE_QCOW2) { + if (info->features && info->format !=3D VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("format features only available with qcow2")); - return NULL; + return -1; } - if (info.format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption)= { + if (info->format =3D=3D VIR_STORAGE_FILE_RAW && vol->target.encryption= ) { if (inputvol) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("cannot use inputvol with encrypted raw volum= e")); - return NULL; + return -1; } if (vol->target.encryption->format =3D=3D VIR_STORAGE_ENCRYPTION_F= ORMAT_LUKS) { - info.type =3D "luks"; + info->type =3D "luks"; } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Only luks encryption is supported for raw fi= les")); - return NULL; + return -1; } } =20 if (inputvol && - storageBackendCreateQemuImgSetInput(inputvol, &info) < 0) - return NULL; + storageBackendCreateQemuImgSetInput(inputvol, info) < 0) + return -1; =20 if (virStorageSourceHasBacking(&vol->target) && - storageBackendCreateQemuImgSetBacking(pool, vol, inputvol, &info) = < 0) - return NULL; + storageBackendCreateQemuImgSetBacking(pool, vol, inputvol, info) <= 0) + return -1; =20 - if (info.encryption && - storageBackendCreateQemuImgCheckEncryption(info.format, info.type,= vol) < 0) - return NULL; + if (info->encryption && + storageBackendCreateQemuImgCheckEncryption(info->format, info->typ= e, + vol) < 0) + return -1; =20 /* Size in KB */ - info.size_arg =3D VIR_DIV_UP(vol->target.capacity, 1024); + info->size_arg =3D VIR_DIV_UP(vol->target.capacity, 1024); + + return 0; +} + + +/* Create a qemu-img virCommand from the supplied arguments */ +virCommandPtr +virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + unsigned int flags, + const char *create_tool, + const char *secretPath) +{ + virCommandPtr cmd =3D NULL; + struct _virStorageBackendQemuImgInfo info =3D { + .format =3D vol->target.format, + .type =3D NULL, + .path =3D vol->target.path, + .allocation =3D vol->target.allocation, + .encryption =3D !!vol->target.encryption, + .preallocate =3D !!(flags & VIR_STORAGE_VOL_CREATE_PREALLOC_METADA= TA), + .compat =3D vol->target.compat, + .features =3D vol->target.features, + .nocow =3D vol->target.nocow, + .secretPath =3D secretPath, + .secretAlias =3D NULL, + }; + virStorageEncryptionInfoDefPtr enc =3D NULL; + + virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL); + + if (virStorageBackendCreateQemuImgSetInfo(pool, vol, inputvol, &info) = < 0) + goto error; =20 cmd =3D virCommandNew(create_tool); =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Wed May 1 15:13:53 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.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 1525783717300499.09217451940117; Tue, 8 May 2018 05:48:37 -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 9DC963134BD8; Tue, 8 May 2018 12:48:35 +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 7403F30BAAC1; Tue, 8 May 2018 12:48:35 +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 30275180BAEA; Tue, 8 May 2018 12:48:35 +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 w48CmGKv020620 for ; Tue, 8 May 2018 08:48:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id D8B312719D; Tue, 8 May 2018 12:48:16 +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 9980C16E46 for ; Tue, 8 May 2018 12:48:16 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 8 May 2018 08:48:05 -0400 Message-Id: <20180508124805.2372-13-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 12/12] storage_util: Introduce storageBackendDoCreateQemuImg 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.45]); Tue, 08 May 2018 12:48:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Extract out command line setup and run from storageBackendCreateQemuImg as we'll need to run it twice soon. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index f7da6743b0..554fc757ed 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1354,6 +1354,31 @@ storageBackendGenerateSecretData(virStoragePoolObjPt= r pool, } =20 =20 +static int +storageBackendDoCreateQemuImg(virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + unsigned int flags, + const char *create_tool, + const char *secretPath) +{ + int ret; + virCommandPtr cmd; + + cmd =3D virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol, + flags, create_tool, + secretPath); + if (!cmd) + return -1; + + ret =3D virStorageBackendCreateExecCommand(pool, vol, cmd); + + virCommandFree(cmd); + + return ret; +} + + static int storageBackendCreateQemuImg(virStoragePoolObjPtr pool, virStorageVolDefPtr vol, @@ -1362,7 +1387,6 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr pool, { int ret =3D -1; char *create_tool; - virCommandPtr cmd; char *secretPath =3D NULL; =20 virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, -1); @@ -1378,15 +1402,8 @@ storageBackendCreateQemuImg(virStoragePoolObjPtr poo= l, if (storageBackendGenerateSecretData(pool, vol, &secretPath) < 0) goto cleanup; =20 - cmd =3D virStorageBackendCreateQemuImgCmdFromVol(pool, vol, inputvol, - flags, create_tool, - secretPath); - if (!cmd) - goto cleanup; - - ret =3D virStorageBackendCreateExecCommand(pool, vol, cmd); - - virCommandFree(cmd); + ret =3D storageBackendDoCreateQemuImg(pool, vol, inputvol, flags, + create_tool, secretPath); cleanup: if (secretPath) { unlink(secretPath); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list