[libvirt] [PATCH 07/38] qemu: domain: Use qemuDomainSecretInfoNewPlain only for unencrypted secrets

Ján Tomko jtomko at redhat.com
Wed May 30 16:20:33 UTC 2018


On Wed, May 30, 2018 at 02:41:03PM +0200, Peter Krempa wrote:
>Move the logic that determines which secret shall be used into the
>caller and make this function work only for plain secrets.
>
>This untangles the control flow by only checking relevant data.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_domain.c | 94 ++++++++++++--------------------------------------
> 1 file changed, 22 insertions(+), 72 deletions(-)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index d9b10ae96d..e4588f7428 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -1308,94 +1308,33 @@ qemuDomainSupportsEncryptedSecret(qemuDomainObjPrivatePtr priv)

[...]

> /* qemuDomainSecretInfoNewPlain:
>- * @priv: pointer to domain private object
>- * @srcAlias: Alias base to use for TLS object
>  * @usageType: Secret usage type
>  * @username: username for plain secrets (only)

Now is a good time to remove the plain secrets reference.

>  * @looupdef: lookup def describing secret

And maybe fix the typo while you're here.

>- * @isLuks: boolean for luks lookup
>  *
>  * Helper function to create a secinfo to be used for secinfo consumers. This
>- * possibly sets up a 'plain' (unencrypted) secret for legacy consumers.
>+ * up a 'plain' (unencrypted) secret for legacy consumers.

You dropped 'sets' here.

>  *
>  * Returns @secinfo on success, NULL on failure. Caller is responsible
>  * to eventually free @secinfo.
>  */
> static qemuDomainSecretInfoPtr
>-qemuDomainSecretInfoNewPlain(qemuDomainObjPrivatePtr priv,
>-                             const char *srcAlias,
>-                             virSecretUsageType usageType,
>+qemuDomainSecretInfoNewPlain(virSecretUsageType usageType,
>                              const char *username,
>-                             virSecretLookupTypeDefPtr lookupDef,
>-                             bool isLuks)
>+                             virSecretLookupTypeDefPtr lookupDef)
> {
>     qemuDomainSecretInfoPtr secinfo = NULL;
>
>     if (VIR_ALLOC(secinfo) < 0)
>         return NULL;
>
>-    if (qemuDomainSecretSetup(priv, secinfo, srcAlias, usageType,
>-                              username, lookupDef, isLuks) < 0)
>-        goto error;
>-
>-    if (!username && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_PLAIN) {
>-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
>-                       _("encrypted secrets are not supported"));
>-        goto error;

Good to see this condition go.

>+    if (qemuDomainSecretPlainSetup(secinfo, usageType, username, lookupDef) < 0) {
>+        qemuDomainSecretInfoFree(&secinfo);
>+        return NULL;
>     }
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180530/e5199312/attachment-0001.sig>


More information about the libvir-list mailing list