[PATCH 09/19] qemu: Remove authdef from secret setup

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

 



Rather than pass authdef, pass the 'authdef->username' and the
'&authdef->secdef'

Note that a username may be NULL.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 52cbc72..2c583d8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -808,7 +808,8 @@ qemuDomainHostdevPrivateDispose(void *obj)
  * @conn: Pointer to connection
  * @secinfo: Pointer to secret info
  * @secretUsageType: The virSecretUsageType
- * @authdef: Pointer to auth data
+ * @username: username to use for authentication (may be NULL)
+ * @secdef: Pointer to secdef data
  *
  * Taking a secinfo, fill in the plaintext information
  *
@@ -818,13 +819,14 @@ static int
 qemuDomainSecretPlainSetup(virConnectPtr conn,
                            qemuDomainSecretInfoPtr secinfo,
                            virSecretUsageType secretUsageType,
-                           virStorageAuthDefPtr authdef)
+                           const char *username,
+                           virSecretLookupTypeDefPtr secdef)
 {
     secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN;
-    if (VIR_STRDUP(secinfo->s.plain.username, authdef->username) < 0)
+    if (VIR_STRDUP(secinfo->s.plain.username, username) < 0)
         return -1;
 
-    return virSecretGetSecretString(conn, &authdef->secdef, secretUsageType,
+    return virSecretGetSecretString(conn, secdef, secretUsageType,
                                     &secinfo->s.plain.secret,
                                     &secinfo->s.plain.secretlen);
 }
@@ -836,7 +838,8 @@ qemuDomainSecretPlainSetup(virConnectPtr conn,
  * @secinfo: Pointer to secret info
  * @srcalias: Alias of the disk/hostdev used to generate the secret alias
  * @secretUsageType: The virSecretUsageType
- * @authdef: Pointer to auth data
+ * @username: username to use for authentication (may be NULL)
+ * @secdef: Pointer to secdef data
  *
  * Taking a secinfo, fill in the AES specific information using the
  *
@@ -848,7 +851,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
                          qemuDomainSecretInfoPtr secinfo,
                          const char *srcalias,
                          virSecretUsageType secretUsageType,
-                         virStorageAuthDefPtr authdef)
+                         const char *username,
+                         virSecretLookupTypeDefPtr secdef)
 {
     int ret = -1;
     uint8_t *raw_iv = NULL;
@@ -859,7 +863,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
     size_t ciphertextlen = 0;
 
     secinfo->type = VIR_DOMAIN_SECRET_INFO_TYPE_AES;
-    if (VIR_STRDUP(secinfo->s.aes.username, authdef->username) < 0)
+    if (VIR_STRDUP(secinfo->s.aes.username, username) < 0)
         return -1;
 
     if (!(secinfo->s.aes.alias = qemuDomainGetSecretAESAlias(srcalias)))
@@ -874,7 +878,7 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
         goto cleanup;
 
     /* Grab the unencoded secret */
-    if (virSecretGetSecretString(conn, &authdef->secdef, secretUsageType,
+    if (virSecretGetSecretString(conn, secdef, secretUsageType,
                                  &secret, &secretlen) < 0)
         goto cleanup;
 
@@ -909,7 +913,8 @@ qemuDomainSecretAESSetup(virConnectPtr conn,
  * @secinfo: Pointer to secret info
  * @srcalias: Alias of the disk/hostdev used to generate the secret alias
  * @secretUsageType: The virSecretUsageType
- * @authdef: Pointer to auth data
+ * @username: username to use for authentication (may be NULL)
+ * @secdef: Pointer to secdef data
  *
  * If we have the encryption API present and can support a secret object, then
  * build the AES secret; otherwise, build the Plain secret. This is the magic
@@ -924,17 +929,18 @@ qemuDomainSecretSetup(virConnectPtr conn,
                       qemuDomainSecretInfoPtr secinfo,
                       const char *srcalias,
                       virSecretUsageType secretUsageType,
-                      virStorageAuthDefPtr authdef)
+                      const char *username,
+                      virSecretLookupTypeDefPtr secdef)
 {
     if (virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) &&
         virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) &&
         secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH) {
         if (qemuDomainSecretAESSetup(conn, priv, secinfo, srcalias,
-                                     secretUsageType, authdef) < 0)
+                                     secretUsageType, username, secdef) < 0)
             return -1;
     } else {
         if (qemuDomainSecretPlainSetup(conn, secinfo, secretUsageType,
-                                       authdef) < 0)
+                                       username, secdef) < 0)
             return -1;
     }
     return 0;
@@ -1030,7 +1036,8 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn,
             goto error;
 
         if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias,
-                                  secretUsageType, src->auth) < 0)
+                                  secretUsageType, src->auth->username,
+                                  &src->auth->secdef) < 0)
             goto error;
 
         diskPriv->secinfo = secinfo;
@@ -1100,8 +1107,8 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
                 goto error;
 
             if (qemuDomainSecretSetup(conn, priv, secinfo, hostdev->info->alias,
-                                      secretUsageType,
-                                      iscsisrc->auth) < 0)
+                                      secretUsageType, iscsisrc->auth->username,
+                                      &iscsisrc->auth->secdef) < 0)
                 goto error;
 
             hostdevPriv->secinfo = secinfo;
-- 
2.5.5

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



[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]