
On 08/21/2018 06:23 PM, John Ferlan wrote:
Commit 39cef12a9 altered/fixed the inputvol processing to create a multistep process when using an inputvol to create an encrypted output volume; however, it unnecessarily assumed/restricted the inputvol to be of 'raw' format only.
Modify the processing code to allow the inputvol format to be checked and used in order to create the encrypted volume.
Signed-off-by: John Ferlan <jferlan@redhat.com> --- src/storage/storage_util.c | 15 +++++++++++-- .../luks-convert-qcow2.argv | 9 ++++++++ tests/storagevolxml2argvtest.c | 4 ++++ tests/storagevolxml2xmlin/vol-file-qcow2.xml | 21 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 tests/storagevolxml2argvdata/luks-convert-qcow2.argv create mode 100644 tests/storagevolxml2xmlin/vol-file-qcow2.xml
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index b32e3ccf7d..cc49a5b9f7 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -699,6 +699,7 @@ storagePloopResize(virStorageVolDefPtr vol, struct _virStorageBackendQemuImgInfo { int format; const char *type; + const char *inputType; const char *path; unsigned long long size_arg; unsigned long long allocation; @@ -1021,6 +1022,15 @@ virStorageBackendCreateQemuImgSetInfo(virStoragePoolObjPtr pool, return -1; }
+ if (inputvol && + !(info->inputType = + virStorageFileFormatTypeToString(inputvol->target.format))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown inputvol storage vol type %d"), + inputvol->target.format); + return -1; + } + if (info->preallocate && info->format != VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("metadata preallocation only available with qcow2")); @@ -1080,6 +1090,7 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, struct _virStorageBackendQemuImgInfo info = { .format = vol->target.format, .type = NULL, + .inputType = NULL, .path = vol->target.path, .allocation = vol->target.allocation, .encryption = !!vol->target.encryption, @@ -1152,8 +1163,8 @@ virStorageBackendCreateQemuImgCmdFromVol(virStoragePoolObjPtr pool, virCommandAddArgFormat(cmd, "%lluK", info.size_arg); } else { /* source */ - virCommandAddArgFormat(cmd, "driver=raw,file.filename=%s", - info.inputPath); + virCommandAddArgFormat(cmd, "driver=%s,file.filename=%s", + info.inputType, info.inputPath);
so if inputvol == NULL in virStorageBackendCreateQemuImgSetInfo then info.inputType is also NULL. Don't we need something like: info.inputType ? info.inputType : "raw" (I wish we could use GNU extensions and write is as info.inputType ?: "raw" ) Michal