]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Alter storageBackendCreateQemuImgSecretObject args
authorJohn Ferlan <jferlan@redhat.com>
Fri, 6 Oct 2017 15:06:13 +0000 (11:06 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 27 Oct 2017 09:31:19 +0000 (05:31 -0400)
Since all that was really needed was a couple of fields and building
the object can be more generic, let's alter the args a bit. This will
be useful shortly for adding the secret object for a volume resize
operation on a luks volume that will need a secret object.

src/storage/storage_util.c

index 52926adee772a5d3fe8aeee171c3898a2f4ae0ef..33f91f0b15ce4ee27a074b82333a198cf6f614be 100644 (file)
@@ -1120,17 +1120,14 @@ storageBackendCreateQemuImgSetOptions(virCommandPtr cmd,
  */
 static int
 storageBackendCreateQemuImgSecretObject(virCommandPtr cmd,
-                                        virStorageVolDefPtr vol,
-                                        struct _virStorageBackendQemuImgInfo *info)
+                                        const char *secretPath,
+                                        const char *secretAlias)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
     char *commandStr = NULL;
 
-    if (virAsprintf(&info->secretAlias, "%s_luks0", vol->name) < 0)
-        return -1;
-
-    virBufferAsprintf(&buf, "secret,id=%s,file=", info->secretAlias);
-    virQEMUBuildBufferEscapeComma(&buf, info->secretPath);
+    virBufferAsprintf(&buf, "secret,id=%s,file=", secretAlias);
+    virQEMUBuildBufferEscapeComma(&buf, secretPath);
 
     if (virBufferCheckError(&buf) < 0) {
         virBufferFreeAndReset(&buf);
@@ -1261,7 +1258,10 @@ virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
     if (info.format == VIR_STORAGE_FILE_RAW &&
         vol->target.encryption != NULL &&
         vol->target.encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) {
-        if (storageBackendCreateQemuImgSecretObject(cmd, vol, &info) < 0)
+        if (virAsprintf(&info.secretAlias, "%s_luks0", vol->name) < 0)
+            goto error;
+        if (storageBackendCreateQemuImgSecretObject(cmd, info.secretPath,
+                                                    info.secretAlias) < 0)
             goto error;
         enc = &vol->target.encryption->encinfo;
     }