From nobody Wed May 14 05:51:54 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 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