[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] storage: replace the deprecated option of qemu-img.



qemu-img silently disable "-e", so we can't use it for volume
encryption anymore, change it into "-o encryption=on".

I'm afraid of it will inroduce compatibility problem for older
qemu without "-o" option, but "-o" option is already used in the
codes, seems it's fine.

* src/storage/storage_backend.c
---
 src/storage/storage_backend.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 2eede74..c381444 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -778,7 +778,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
             imgargv[8] = vol->target.path;
             imgargv[9] = size;
             if (vol->target.encryption != NULL)
-                imgargv[10] = "-e";
+                imgargv[10] = "-o encryption=on";
             break;

         case QEMU_IMG_BACKING_FORMAT_OPTIONS:
@@ -786,13 +786,18 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
                 virReportOOMError();
                 goto cleanup;
             }
+
+            if (vol->target.encryption != NULL) {
+                if (virAsprintf(&optflag, ",encryption=on") < 0) {
+                    virReportOOMError();
+                    goto cleanup;
+                }
+            }
+
             imgargv[6] = "-o";
             imgargv[7] = optflag;
             imgargv[8] = vol->target.path;
             imgargv[9] = size;
-            if (vol->target.encryption != NULL)
-                imgargv[10] = "-e";
-            break;

         default:
             VIR_INFO("Unable to set backing store format for %s with %s",
@@ -800,7 +805,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
             imgargv[6] = vol->target.path;
             imgargv[7] = size;
             if (vol->target.encryption != NULL)
-                imgargv[8] = "-e";
+                imgargv[8] = "-o encryption=on";
         }

         ret = virStorageBackendCreateExecCommand(pool, vol, imgargv);
@@ -817,7 +822,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
             NULL
         };
         if (vol->target.encryption != NULL)
-            imgargv[6] = "-e";
+            imgargv[6] = "-o encryption=on";

         ret = virStorageBackendCreateExecCommand(pool, vol, imgargv);
     }
--
1.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]