From nobody Tue Feb 10 10:21:27 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 15264737927931000.6866014442928; Wed, 16 May 2018 05:29:52 -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 33382387227; Wed, 16 May 2018 12:29:51 +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 E2B5B177D3; Wed, 16 May 2018 12:29:50 +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 91DFC1801247; Wed, 16 May 2018 12:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4GCTbQE001401 for ; Wed, 16 May 2018 08:29:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4042E2010CBB; Wed, 16 May 2018 12:29:37 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-88.phx2.redhat.com [10.3.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id F197A2010CB2 for ; Wed, 16 May 2018 12:29:36 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Wed, 16 May 2018 08:29:30 -0400 Message-Id: <20180516122931.30854-4-jferlan@redhat.com> In-Reply-To: <20180516122931.30854-1-jferlan@redhat.com> References: <20180516122931.30854-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 3/4] storage_util: Don't assume "luks" encryption for resize 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.29]); Wed, 16 May 2018 12:29:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similar to encrypted image creation/conversion resizing the volume requires providing different parameters for luks and qcow[2] encryption. Alter storageBackendResizeQemuImgImageOpts to take the @type parameter filled in during storageBackendResizeQemuImg to either the current type or "luks" for a RAW image and use that to generate the "driver=3D%s" value and to determine whether to use "encrypt.key-secret" or "key-secret". Signed-off-by: John Ferlan --- src/storage/storage_util.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 29adf0cdbe..b7b86d76cb 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1088,20 +1088,26 @@ storageBackendCreateQemuImgSecretObject(virCommandP= tr cmd, =20 =20 /* Add a --image-opts to the qemu-img resize command line: - * --image-opts driver=3Dluks,file.filename=3D$volpath,key-secret=3D$se= cretAlias - * - * NB: format=3Draw is assumed + * --image-opts driver=3D%s,\ + * [encrypt.]key-secret=3D$secretAlias,\ + * file.filename=3D$volpath */ static int storageBackendResizeQemuImgImageOpts(virCommandPtr cmd, + const char *type, const char *path, const char *secretAlias) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; char *commandStr =3D NULL; =20 - virBufferAsprintf(&buf, "driver=3Dluks,key-secret=3D%s,file.filename= =3D", - secretAlias); + virBufferAsprintf(&buf, "driver=3D%s,", type); + if (STREQ(type, "luks")) + virBufferAsprintf(&buf, "key-secret=3D%s,", secretAlias); + else + virBufferAsprintf(&buf, "encrypt.key-secret=3D%s,", secretAlias); + virBufferAddLit(&buf, "file.filename=3D"); + virQEMUBuildBufferEscapeComma(&buf, path); =20 if (virBufferCheckError(&buf) < 0) { @@ -2403,7 +2409,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, int ret =3D -1; char *img_tool =3D NULL; virCommandPtr cmd =3D NULL; - const char *type; + const char *type =3D virStorageFileFormatTypeToString(vol->target.form= at); char *secretPath =3D NULL; char *secretAlias =3D NULL; =20 @@ -2417,8 +2423,6 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, if (vol->target.encryption) { if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW) type =3D "luks"; - else - type =3D virStorageFileFormatTypeToString(vol->target.format); =20 storageBackendLoadDefaultSecrets(vol); =20 @@ -2448,7 +2452,7 @@ storageBackendResizeQemuImg(virStoragePoolObjPtr pool, secretAlias) < 0) goto cleanup; =20 - if (storageBackendResizeQemuImgImageOpts(cmd, vol->target.path, + if (storageBackendResizeQemuImgImageOpts(cmd, type, vol->target.pa= th, secretAlias) < 0) goto cleanup; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list