diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 4165178b2f238cae68c29d427b7a633d12149a22..899a557588d810a0f1e15de67b8a694704f156ad 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -1439,6 +1439,48 @@ storageBackendCreateQemuImg(virConnectPtr conn, return ret; } + +/** + * 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 = -1; + bool changeFormat = false; + + if (vol->target.format == VIR_STORAGE_FILE_NONE) { + vol->target.format = VIR_STORAGE_FILE_RAW; + changeFormat = true; + } + + ret = storageBackendCreateQemuImg(conn, pool, vol, inputvol, flags); + + if (changeFormat) + vol->target.format = 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 00793ff3a4ba159d9ef356c6e26fc0623aa7b963..dc7e62517b4fc53670715d65a529f241c333d6d0 100644 --- a/src/storage/storage_util.h +++ b/src/storage/storage_util.h @@ -27,6 +27,14 @@ # include "storage_backend.h" /* 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);