From nobody Sun Feb 8 19:56:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1583771116; cv=none; d=zohomail.com; s=zohoarc; b=DOJXumHJN6fBcpv67hwzKGSCxba6rGqCEefsnaRZerr7v33YU/iervQBEr9UqSwZnpBYDXh1kWTMvdyZXUmmUj8+7eyQN5yw6ZHoeIXkFq3tk1mVMlKozfp1fmfv8YVFWrnJOBfSX3AckM9wN2z/4NuRm3moNkX2tf1s1toEG5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583771116; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=otP0+h/3koUSo2KN3I8G9bxKMPzQ//uv8Joz/U/uasM=; b=fx+57Gt4vbYIrc9jtNhictxcr8cxakwlIvFLRfdnowjY3fTz/AAlTUkTS7ztouboslHERN1vlx9Tw/ZN2tc3Q51Q78XpYjoPZWtwGDYf2ivdeBBDmTlKAz7ntlG4nw+8ogC/YPCNPRUno3VN5x4G4hBQ9qQ25ZDHtslf+rRdLQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1583771116214154.10740679436685; Mon, 9 Mar 2020 09:25:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-327--FO1r9R-PDuxdamtvn0AKw-1; Mon, 09 Mar 2020 12:23:54 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30400800D5C; Mon, 9 Mar 2020 16:23:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0581D60C05; Mon, 9 Mar 2020 16:23:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A8F6C1800B6D; Mon, 9 Mar 2020 16:23:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 029GNMae020766 for ; Mon, 9 Mar 2020 12:23:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id E481990779; Mon, 9 Mar 2020 16:23:22 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B32B9051C for ; Mon, 9 Mar 2020 16:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583771115; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=otP0+h/3koUSo2KN3I8G9bxKMPzQ//uv8Joz/U/uasM=; b=J4dwbvPeKQZUNEzIi5i7uf0F5k42YS6aWiJdpiUtsHdxsIMkIn5aUJTjLQ4nqbO5xLMZfz Lf1xdExYa0affr4CdJSgyCvd3IlyTfdglqJ+vHnDw6OUFWVzPyjRG8iaVXPEeEUY5IdAAn 4fJOIWz2q/ncV6UUAwHS1PWExbb//CY= X-MC-Unique: -FO1r9R-PDuxdamtvn0AKw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/30] qemuDomainSecretAESSetupFromSecret: Use 'qemuAliasForSecret' Date: Mon, 9 Mar 2020 17:22:50 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: J=C3=A1n Tomko --- 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 pr= iv, * 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 i= s 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 @seclook= updef - * 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 cas= es. */ 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 =3D virGetConnectSecret(); qemuDomainSecretInfoPtr secinfo; - g_autofree char *alias =3D NULL; + g_autofree char *alias =3D qemuAliasForSecret(srcalias, secretuse); uint8_t *secret =3D NULL; size_t secretlen =3D 0; if (!conn) return NULL; - if (!(alias =3D qemuDomainGetSecretAESAlias(srcalias, isLuks))) - return NULL; - if (virSecretGetSecretString(conn, seclookupdef, usageType, &secret, &= secretlen) < 0) return NULL; @@ -1682,9 +1680,9 @@ qemuDomainSecretInfoTLSNew(qemuDomainObjPrivatePtr pr= iv, } seclookupdef.type =3D 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(qemuDomainObjP= rivatePtr priv, &src->auth->se= clookupdef); } else { srcPriv->secinfo =3D qemuDomainSecretAESSetupFromSecret(priv, = aliasprotocol, + NULL, usageTyp= e, src->aut= h->username, - &src->au= th->seclookupdef, - false); + &src->au= th->seclookupdef); } if (!srcPriv->secinfo) @@ -1787,10 +1785,10 @@ qemuDomainSecretStorageSourcePrepare(qemuDomainObjP= rivatePtr priv, if (hasEnc) { if (!(srcPriv->encinfo =3D qemuDomainSecretAESSetupFromSecret(priv= , aliasformat, + "luks", VIR_SE= CRET_USAGE_TYPE_VOLUME, NULL, - &src->= encryption->secrets[0]->seclookupdef, - true))) + &src->= encryption->secrets[0]->seclookupdef))) return -1; } @@ -1851,10 +1849,10 @@ qemuDomainSecretHostdevPrepare(qemuDomainObjPrivate= Ptr priv, } else { srcPriv->secinfo =3D qemuDomainSecretAESSetupFromSecret(pr= iv, host= dev->info->alias, + NULL, usag= eType, src-= >auth->username, - &src= ->auth->seclookupdef, - fals= e); + &src= ->auth->seclookupdef); } if (!srcPriv->secinfo) --=20 2.24.1