From nobody Mon Feb 9 10:55:11 2026 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=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1725952061369850.1540041268722; Tue, 10 Sep 2024 00:07:41 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4831C17C1; Tue, 10 Sep 2024 03:07:40 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A5D5B1928; Tue, 10 Sep 2024 03:06:36 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 06728192C; Tue, 10 Sep 2024 03:06:32 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 29431194D for ; Tue, 10 Sep 2024 03:06:23 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-cfgoEov6OcKcpkR2t-vKeA-1; Tue, 10 Sep 2024 03:06:20 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16EEE19560B5; Tue, 10 Sep 2024 07:06:19 +0000 (UTC) Received: from localhost (unknown [10.39.208.23]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C4A1D1956054; Tue, 10 Sep 2024 07:06:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725951982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xdLCw1B3UlFx4YZxs5PTWoL5QGwEO7Bq68TELdKD550=; b=LsUv0nju7iIb8vd3DOeLjN5+idNKY04A/uWPpGn0n/kLyM1j1gVE7pJehEoGuzqMFnoO97 AawKf51eOaMPk76A5TgPVbrhHmLrNVxL+ddfUq2rzbCs5ZKkHmptqCoXTkyDepCw+BGlM2 jqrSLneaUVJTqHhjPuTetfLUJ9+U6t4= X-MC-Unique: cfgoEov6OcKcpkR2t-vKeA-1 From: marcandre.lureau@redhat.com To: devel@lists.libvirt.org Subject: [PATCH v2 3/4] schema: add TPM emulator Date: Tue, 10 Sep 2024 11:05:59 +0400 Message-ID: <20240910070600.1426810-4-marcandre.lureau@redhat.com> In-Reply-To: <20240910070600.1426810-1-marcandre.lureau@redhat.com> References: <20240910070600.1426810-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LVUQZ6RFHORUAC3U3OTJOZ6L2TBYIN6F X-Message-ID-Hash: LVUQZ6RFHORUAC3U3OTJOZ6L2TBYIN6F X-MailFrom: marcandre.lureau@redhat.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: stefanb@us.ibm.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= 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: 1725952062196116600 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau Learn to parse a directory for the TPM state. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Stefan Berger --- docs/formatdomain.rst | 3 +++ src/conf/domain_conf.c | 13 ++++++++++--- src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 15 ++++++++++++--- tests/qemuxmlconfdata/tpm-emulator-tpm2-enc.xml | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 4818113bc2..24dcc6daaa 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -8183,6 +8183,9 @@ Example: usage of the TPM Emulator =20 This attribute requires that swtpm v0.7 or later is installed. =20 + ``dir`` + The path to the TPM state storage directory. + :since:`Since v10.8.0` =20 ``persistent_state`` diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 18c58d16dc..d1e9e4a50c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10865,13 +10865,16 @@ virDomainTPMDefParseXML(virDomainXMLOption *xmlop= t, =20 source_node =3D virXPathNode("./backend/source", ctxt); if (source_node) { - path =3D virXMLPropString(source_node, "file"); + if ((path =3D virXMLPropString(source_node, "file"))) { + def->data.emulator.storage_type =3D VIR_DOMAIN_TPM_STORAGE= _FILE; + } else if ((path =3D virXMLPropString(source_node, "dir"))) { + def->data.emulator.storage_type =3D VIR_DOMAIN_TPM_STORAGE= _DIR; + } if (!path) { virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing TPM file source")); + _("missing TPM file or directory source")); goto error; } - def->data.emulator.storage_type =3D VIR_DOMAIN_TPM_STORAGE_FIL= E; def->data.emulator.storagepath =3D g_steal_pointer(&path); } =20 @@ -25084,6 +25087,10 @@ virDomainTPMDefFormat(virBuffer *buf, virBufferAsprintf(&backendChildBuf, "= \n", def->data.emulator.storagepath); break; + case VIR_DOMAIN_TPM_STORAGE_DIR: + virBufferAsprintf(&backendChildBuf, "\= n", + def->data.emulator.storagepath); + break; case VIR_DOMAIN_TPM_STORAGE_DEFAULT: break; } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 371e6ecf6c..4e4ae2e048 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1465,6 +1465,7 @@ typedef enum { =20 typedef enum { VIR_DOMAIN_TPM_STORAGE_DEFAULT, + VIR_DOMAIN_TPM_STORAGE_DIR, VIR_DOMAIN_TPM_STORAGE_FILE, } virDomainTPMStorage; =20 diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 62d3f0e6fe..f6b47ae97e 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -5985,9 +5985,18 @@ - - - + + + + + + + + + + + + diff --git a/tests/qemuxmlconfdata/tpm-emulator-tpm2-enc.xml b/tests/qemuxm= lconfdata/tpm-emulator-tpm2-enc.xml index 9c2279b28b..016c68296c 100644 --- a/tests/qemuxmlconfdata/tpm-emulator-tpm2-enc.xml +++ b/tests/qemuxmlconfdata/tpm-emulator-tpm2-enc.xml @@ -30,6 +30,7 @@ +