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

2016-06-21 Thread Peter Krempa
On Mon, Jun 13, 2016 at 20:27:48 -0400, John Ferlan wrote:
> Rather than pass authdef, pass the 'authdef->username' and the
> '&authdef->secdef'
> 
> Note that a username may be NULL.
> 
> Signed-off-by: John Ferlan 
> ---
>  src/qemu/qemu_domain.c | 37 ++---
>  1 file changed, 22 insertions(+), 15 deletions(-)

ACK

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


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

2016-06-13 Thread John Ferlan
Rather than pass authdef, pass the 'authdef->username' and the
'&authdef->secdef'

Note that a username may be NULL.

Signed-off-by: John Ferlan 
---
 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,