[libvirt] [PATCH 08/12] storage_util: Split backing_fmt set in storageBackendCreateQemuImgOpts

John Ferlan posted 12 patches 7 years ago
[libvirt] [PATCH 08/12] storage_util: Split backing_fmt set in storageBackendCreateQemuImgOpts
Posted by John Ferlan 7 years ago
The only way backing_fmts could be set is if the info->format was
not RAW (see storageBackendCreateQemuImgSetBacking), so let's just
extract it from the if/else surrounding the application of the
encryption options.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/storage/storage_util.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index c72fd47024..cedec10403 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -822,12 +822,13 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionInfoDefPtr enc,
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
+    if (info.backingPath)
+        virBufferAsprintf(&buf, "backing_fmt=%s,",
+                          virStorageFileFormatTypeToString(info.backingFormat));
+
     if (info.format == VIR_STORAGE_FILE_RAW && enc) {
         virQEMUBuildQemuImgKeySecretOpts(&buf, enc, info.secretAlias);
     } else {
-        if (info.backingPath)
-            virBufferAsprintf(&buf, "backing_fmt=%s,",
-                              virStorageFileFormatTypeToString(info.backingFormat));
         if (info.encryption)
             virBufferAddLit(&buf, "encryption=on,");
         if (info.preallocate) {
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/12] storage_util: Split backing_fmt set in storageBackendCreateQemuImgOpts
Posted by Peter Krempa 6 years, 12 months ago
On Tue, May 08, 2018 at 08:48:01 -0400, John Ferlan wrote:
> The only way backing_fmts could be set is if the info->format was
> not RAW (see storageBackendCreateQemuImgSetBacking), so let's just
> extract it from the if/else surrounding the application of the
> encryption options.

Well, technically backingFmt and backing path only make sense for
non-RAW disks. The condition below is weird though. The code was
introduced by a combination of the commits adding LUKS support and then
reverting the type.

Given that prior to those commits it was indeed always executed, we can
safely change it.

ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list