From nobody Fri Nov 22 04:44:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1731519832583745.5685157315984; Wed, 13 Nov 2024 09:43:52 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7A1D317ED; Wed, 13 Nov 2024 12:43:51 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B102A19B3; Wed, 13 Nov 2024 12:40:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 9D53E19B9; Wed, 13 Nov 2024 12:40:14 -0500 (EST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 23D671748 for ; Wed, 13 Nov 2024 12:40:07 -0500 (EST) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ADEA45G022275; Wed, 13 Nov 2024 17:40:06 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42vwmqh0e9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 17:40:04 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ADGPCvt029688; Wed, 13 Nov 2024 17:40:03 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 42tkjm6jcu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Nov 2024 17:40:03 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ADHe35644106236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2024 17:40:03 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12C8D58055; Wed, 13 Nov 2024 17:40:03 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB87C5805D; Wed, 13 Nov 2024 17:40:02 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Nov 2024 17:40:02 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=c8+ucjwL69adE2cCr rWsjsVOUMVJDw0kgQicj07VT5w=; b=jifqjPPxJCQqGZ4RW7m6q73g6kys5LD9/ MGv4mIi0wqgP65BVm9IiwO3YidxwJqJoTRwC3QgDzWslwHu3kNDMa/1t6ZG6GozS mLRBrM3eBm6A2214cIvBh1oDAIdpmQfxdCS2WL7QfVFcY4v7/nd32iQDdx/lenHZ B7y2udRYy3AK+KlIUvjexvi08o5Np/AvadOnlxHowsLY26R5bqPcFEG6iDUHAZiO pT65YIZQj7mxrSNhu/bz7a2/oqpSpF9c99D1N49Z4jZs+JlCsrV+d+dmz1U+Jml2 f5dHF345zEt2nmDssxRWasv9OHtu8VJE2fag/3CRLZuRsSWSvOStg== From: Stefan Berger To: devel@lists.libvirt.org Subject: [PATCH v4 06/11] conf: Add support for profile parameter on TPM emulator in domain XML Date: Wed, 13 Nov 2024 12:39:46 -0500 Message-ID: <20241113173951.813781-7-stefanb@linux.ibm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113173951.813781-1-stefanb@linux.ibm.com> References: <20241113173951.813781-1-stefanb@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: FoYmJl-3Bnf6HH1vJWQ5pLpCfyzkqfGq X-Proofpoint-GUID: FoYmJl-3Bnf6HH1vJWQ5pLpCfyzkqfGq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 mlxscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411130146 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: OUSJJB2CLVM534H2QXXICAUK5XUXISRY X-Message-ID-Hash: OUSJJB2CLVM534H2QXXICAUK5XUXISRY X-MailFrom: stefanb@linux.ibm.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 CC: marcandre.lureau@redhat.com, Stefan Berger X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731519833454116600 Content-Type: text/plain; charset="utf-8" Extend the parser and XML builder with support for the profile parameter and its remove_disabled attribute. Signed-off-by: Stefan Berger --- src/conf/domain_conf.c | 36 ++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/conf/domain_validate.c | 7 +++++++ 3 files changed, 45 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index a5627ada88..7d91e3e958 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3478,6 +3478,7 @@ void virDomainTPMDefFree(virDomainTPMDef *def) g_free(def->data.emulator.source_path); g_free(def->data.emulator.logfile); virBitmapFree(def->data.emulator.activePcrBanks); + g_free(def->data.emulator.profile_source); break; case VIR_DOMAIN_TPM_TYPE_EXTERNAL: virObjectUnref(def->data.external.source); @@ -10786,6 +10787,15 @@ virDomainSmartcardDefParseXML(virDomainXMLOption *= xmlopt, * * * + * + * A profile for a TPM 2.0 can be added like this: + * + * + * + * + * + * + * */ static virDomainTPMDef * virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, @@ -10805,6 +10815,8 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, g_autofree xmlNodePtr *backends =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; g_autofree char *type =3D NULL; + virDomainTPMProfileRemoveDisabled profile_remove_disabled; + xmlNodePtr profile; int bank; =20 if (!(def =3D virDomainTPMDefNew(xmlopt))) @@ -10911,6 +10923,22 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlopt, } virBitmapSetBitExpand(def->data.emulator.activePcrBanks, bank); } + + if ((profile =3D virXPathNode("./backend/profile[1]", ctxt))) { + def->data.emulator.profile_source =3D virXMLPropString(profile= , "source"); + if (!def->data.emulator.profile_source) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("missing profile= source")); + goto error; + } + if (virXMLPropEnum(profile, "remove_disabled", + virDomainTPMProfileRemoveDisabledTypeFromSt= ring, + VIR_XML_PROP_NONZERO, + &profile_remove_disabled) < 0) + goto error; + if (profile_remove_disabled !=3D VIR_DOMAIN_TPM_PROFILE_REMOVE= _DISABLED_NONE) + def->data.emulator.profile_remove_disabled =3D + virDomainTPMProfileRemoveDisabledTypeToString(profile_= remove_disabled); + } break; case VIR_DOMAIN_TPM_TYPE_EXTERNAL: if (!(type =3D virXPathString("string(./backend/source/@type)", ct= xt))) { @@ -25106,6 +25134,14 @@ virDomainTPMDefFormat(virBuffer *buf, virDomainTPMSourceTypeTypeToString(def->data= .emulator.source_type)); virBufferEscapeString(&backendChildBuf, " path=3D'%s'/>\n", de= f->data.emulator.source_path); } + if (def->data.emulator.profile_source) { + virBufferAsprintf(&backendChildBuf, "data.emulator.profile_source); + if (def->data.emulator.profile_remove_disabled) + virBufferAsprintf(&backendChildBuf, " remove_disabled=3D'%s= '", + def->data.emulator.profile_remove_disable= d); + virBufferAddLit(&backendChildBuf, "/>\n"); + } break; case VIR_DOMAIN_TPM_TYPE_EXTERNAL: if (def->data.external.source->type =3D=3D VIR_DOMAIN_CHR_TYPE_UNI= X) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e1103c3655..bd2740af26 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1492,6 +1492,8 @@ struct _virDomainTPMEmulatorDef { bool hassecretuuid; bool persistent_state; virBitmap *activePcrBanks; + char *profile_source; /* 'source' profile was created from */ + const char *profile_remove_disabled; }; =20 struct _virDomainTPMDef { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b8ae9ed79d..7573430b6b 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -3026,6 +3026,13 @@ virDomainTPMDevValidate(const virDomainTPMDef *tpm) virDomainTPMVersionTypeToString(VIR_DOMAIN_TPM_= VERSION_2_0)); return -1; } + if (tpm->data.emulator.profile_source && + tpm->data.emulator.version !=3D VIR_DOMAIN_TPM_VERSION_2_0) { + virReportError(VIR_ERR_XML_ERROR, + _(" requires TPM version '%1$s'"), + virDomainTPMVersionTypeToString(VIR_DOMAIN_TPM_= VERSION_2_0)); + return -1; + } break; =20 case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: --=20 2.47.0