From nobody Thu May 15 11:26:35 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1508421392704322.60122042480293; Thu, 19 Oct 2017 06:56:32 -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 2E7666CB24; Thu, 19 Oct 2017 13:56: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 01D3FDF018; Thu, 19 Oct 2017 13:56: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 C217E410B5; Thu, 19 Oct 2017 13:56:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9JDuTZb030069 for ; Thu, 19 Oct 2017 09:56:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id F212DC329C; Thu, 19 Oct 2017 13:56:28 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-116-118.phx2.redhat.com [10.3.116.118]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB415C6866 for ; Thu, 19 Oct 2017 13:56:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2E7666CB24 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: John Ferlan To: libvir-list@redhat.com Date: Thu, 19 Oct 2017 09:56:11 -0400 Message-Id: <20171019135613.32442-3-jferlan@redhat.com> In-Reply-To: <20171019135613.32442-1-jferlan@redhat.com> References: <20171019135613.32442-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [REPOST PATCH 2/4] storage: Introduce virStorageBackendCreateVolUsingQemuImg 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.27]); Thu, 19 Oct 2017 13:56:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Create a shim that will allow other backends to make use of qemu-img functionality to create or possibly modify the volume. Signed-off-by: John Ferlan --- src/storage/storage_util.c | 42 ++++++++++++++++++++++++++++++++++++++++++ src/storage/storage_util.h | 8 ++++++++ 2 files changed, 50 insertions(+) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 5252e429fd..e9bafd3b15 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1409,6 +1409,48 @@ storageBackendCreateQemuImg(virConnectPtr conn, return ret; } =20 + +/** + * virStorageBackendCreateVolUsingQemuImg + * @conn: Connection pointer + * @pool: Storage Pool Object + * @vol: Volume definition + * @inputvol: Volume to use for creation + * @flags: Flags for creation options + * + * A shim to storageBackendCreateQemuImg to allow other backends to + * utilize qemu-img processing in order to create or alter the volume. + * + * NB: If a volume target format is not supplied (per usual for some + * backends), temporarily adjust the format to be RAW. Once completed, + * reset the format back to NONE. + * + * Returns: 0 on success, -1 on failure. + */ +int +virStorageBackendCreateVolUsingQemuImg(virConnectPtr conn, + virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + unsigned int flags) +{ + int ret =3D -1; + bool changeFormat =3D false; + + if (vol->target.format =3D=3D VIR_STORAGE_FILE_NONE) { + vol->target.format =3D VIR_STORAGE_FILE_RAW; + changeFormat =3D true; + } + + ret =3D storageBackendCreateQemuImg(conn, pool, vol, inputvol, flags); + + if (changeFormat) + vol->target.format =3D VIR_STORAGE_FILE_NONE; + + return ret; +} + + virStorageBackendBuildVolFrom virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol) diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h index 00793ff3a4..dc7e62517b 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -27,6 +27,14 @@ # include "storage_backend.h" =20 /* File creation/cloning functions used for cloning between backends */ + +int +virStorageBackendCreateVolUsingQemuImg(virConnectPtr conn, + virStoragePoolObjPtr pool, + virStorageVolDefPtr vol, + virStorageVolDefPtr inputvol, + unsigned int flags); + virStorageBackendBuildVolFrom virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol, virStorageVolDefPtr inputvol); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list