[PATCH 10/30] qemuDomainSecretAESSetupFromSecret: Use 'qemuAliasForSecret'

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

 



Replace qemuDomainGetSecretAESAlias by the new function si that we can
reuse qemuDomainSecretAESSetupFromSecret also for setting up other kinds
of objects.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c2218871a7..c7432b3a98 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1571,34 +1571,32 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv,
  * qemuDomainSecretAESSetupFromSecret:
  * @priv: pointer to domain private object
  * @srcalias: Alias of the disk/hostdev used to generate the secret alias
+ * @secretuse: specific usage for the secret (may be NULL if main object is using it)
  * @usageType: The virSecretUsageType
  * @username: username to use for authentication (may be NULL)
  * @seclookupdef: Pointer to seclookupdef data
- * @isLuks: True/False for is for luks (alias generation)
  *
  * Looks up a secret in the secret driver based on @usageType and @seclookupdef
- * and builds qemuDomainSecretInfoPtr from it.
+ * and builds qemuDomainSecretInfoPtr from it. @use describes the usage of the
+ * secret in case if @srcalias requires more secrets for various usage cases.
  */
 static qemuDomainSecretInfoPtr
 qemuDomainSecretAESSetupFromSecret(qemuDomainObjPrivatePtr priv,
                                    const char *srcalias,
+                                   const char *secretuse,
                                    virSecretUsageType usageType,
                                    const char *username,
-                                   virSecretLookupTypeDefPtr seclookupdef,
-                                   bool isLuks)
+                                   virSecretLookupTypeDefPtr seclookupdef)
 {
     g_autoptr(virConnect) conn = virGetConnectSecret();
     qemuDomainSecretInfoPtr secinfo;
-    g_autofree char *alias = NULL;
+    g_autofree char *alias = qemuAliasForSecret(srcalias, secretuse);
     uint8_t *secret = NULL;
     size_t secretlen = 0;

     if (!conn)
         return NULL;

-    if (!(alias = qemuDomainGetSecretAESAlias(srcalias, isLuks)))
-        return NULL;
-
     if (virSecretGetSecretString(conn, seclookupdef, usageType, &secret, &secretlen) < 0)
         return NULL;

@@ -1682,9 +1680,9 @@ qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr priv,
     }
     seclookupdef.type = VIR_SECRET_LOOKUP_TYPE_UUID;

-    return qemuDomainSecretAESSetupFromSecret(priv, srcAlias,
+    return qemuDomainSecretAESSetupFromSecret(priv, srcAlias, NULL,
                                               VIR_SECRET_USAGE_TYPE_TLS,
-                                              NULL, &seclookupdef, false);
+                                              NULL, &seclookupdef);
 }


@@ -1775,10 +1773,10 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,
                                                             &src->auth->seclookupdef);
         } else {
             srcPriv->secinfo = qemuDomainSecretAESSetupFromSecret(priv, aliasprotocol,
+                                                                  NULL,
                                                                   usageType,
                                                                   src->auth->username,
-                                                                  &src->auth->seclookupdef,
-                                                                  false);
+                                                                  &src->auth->seclookupdef);
         }

         if (!srcPriv->secinfo)
@@ -1787,10 +1785,10 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjPrivatePtr priv,

     if (hasEnc) {
         if (!(srcPriv->encinfo = qemuDomainSecretAESSetupFromSecret(priv, aliasformat,
+                                                                    "luks",
                                                                     VIR_SECRET_USAGE_TYPE_VOLUME,
                                                                     NULL,
-                                                                    &src->encryption->secrets[0]->seclookupdef,
-                                                                    true)))
+                                                                    &src->encryption->secrets[0]->seclookupdef)))
               return -1;
     }

@@ -1851,10 +1849,10 @@ qemuDomainSecretHostdevPrepare(qemuDomainObjPrivatePtr priv,
             } else {
                 srcPriv->secinfo = qemuDomainSecretAESSetupFromSecret(priv,
                                                                       hostdev->info->alias,
+                                                                      NULL,
                                                                       usageType,
                                                                       src->auth->username,
-                                                                      &src->auth->seclookupdef,
-                                                                      false);
+                                                                      &src->auth->seclookupdef);
             }

             if (!srcPriv->secinfo)
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux