From nobody Sun May 24 22:55:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1776758405; cv=none; d=zohomail.com; s=zohoarc; b=Jua4x0CpCbZAMmNZ5M7eiX6P9a0avNIviLW9USd8GUsQ7+rmK+yDRYgpSHEpCvrAcDzfrdzxG8mYsMUcW//7/uUVJ0vOtyBgBJKjJh7CzEx2f4qAOLgCgbbEJGPCb/+e2tupQdez0Nc2RQeyklnJ8pdVxwYAOqQgSxicxNnSNXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776758405; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=bPQgjcApTsK7n/46YTztDQqBaheLBO3CNCqs/laHoxg=; b=liOK+0ODuD8gENPx0emfUmeAp+zRF6fJbX7/sHBMItiBRa6O4Q/sOC9dbNIVMGWCldzlDUyFMzwy59AtBrrB3hHBDmHu8XLWyp78+v6niRQyEkW6qV5A24hmNaODGiDjU5rFwjL1noAC+8hjEfiNsNb/OfeyOAzHFr0U6Sp2m14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1776758404974372.59318793013733; Tue, 21 Apr 2026 01:00:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4419C41897; Tue, 21 Apr 2026 04:00:03 -0400 (EDT) Received: from [172.19.199.6] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 0C61F41962; Tue, 21 Apr 2026 03:58:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A20784180F; Mon, 20 Apr 2026 08:31:39 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2A7373F2F8 for ; Mon, 20 Apr 2026 08:31:36 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-p9Wol2fvOLOIcERH4xC_gw-1; Mon, 20 Apr 2026 08:31:35 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6DAD1801BEC for ; Mon, 20 Apr 2026 12:31:29 +0000 (UTC) Received: from sparimi-thinkpadt14gen5.bengluru.csb (unknown [10.67.32.98]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B46851955F21; Mon, 20 Apr 2026 12:31:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776688296; 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; bh=bPQgjcApTsK7n/46YTztDQqBaheLBO3CNCqs/laHoxg=; b=KmJEcgAh60Mznd8cZfhaeJML7VcNtGvpZ/BGH2Vvv61U4rdgxfXV424jefZppHijXxjdz5 uGnz5gwtqWUDtzk9O5iCXsViy9Hp/u3jM/qG8jDtikeobz5VKgsMhqaMR1CTEAes4qrOfE BJPiE0SMGAzJMwy1+OtnlZPYxhB3Axw= X-MC-Unique: p9Wol2fvOLOIcERH4xC_gw-1 X-Mimecast-MFC-AGG-ID: p9Wol2fvOLOIcERH4xC_gw_1776688294 To: devel@lists.libvirt.org Subject: [PATCH v3] vmx: configure TPM device in the XML Date: Mon, 20 Apr 2026 17:49:43 +0530 Message-ID: <20260420123115.196998-1-sparimi@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: HJsLHd2gtNAXL25Sjudm0GcNEeVGlN4MUuAjoruqSkg_1776688294 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-MailFrom: sparimi@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: OMQREJEBTISDOGMCUJEXUMZNCQJJT5VV X-Message-ID-Hash: OMQREJEBTISDOGMCUJEXUMZNCQJJT5VV X-Mailman-Approved-At: Tue, 21 Apr 2026 07:58:19 +0000 CC: Srihari Parimi X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Srihari Parimi via Devel Reply-To: Srihari Parimi X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1776758408582154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Parses vtpm.present from VMX files and converts to libvirt TPM device with CRB model and emulator backend. VMware vTPM uses TPM 2.0 as described in the link below https://techdocs.broadcom.com/us/en/vmware-cis/vsphere/vsphere/8-0/vsphere-= security/securing-virtual-machines-with-virtual-trusted-platform-module/vtp= m-overview.html Default to the CRB interface for TPM 2.0 systems to improve performance and follow industry standards over legacy TIS. Signed-off-by: Srihari Parimi --- src/vmx/vmx.c | 34 ++++++++++++++++++++++++++++++++++ tests/vmx2xmldata/vtpm.vmx | 22 ++++++++++++++++++++++ tests/vmx2xmldata/vtpm.xml | 32 ++++++++++++++++++++++++++++++++ tests/vmx2xmltest.c | 2 ++ 4 files changed, 90 insertions(+) create mode 100644 tests/vmx2xmldata/vtpm.vmx create mode 100644 tests/vmx2xmldata/vtpm.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 57dfd57cfc..9873794568 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -599,6 +599,7 @@ static int virVMXParseSerial(virVMXContext *ctx, virCon= f *conf, int port, static int virVMXParseParallel(virVMXContext *ctx, virConf *conf, int port, virDomainChrDef **def); static int virVMXParseSVGA(virConf *conf, virDomainVideoDef **def); +static int virVMXParseTPM(virConf *conf, virDomainTPMDef **def); =20 static int virVMXFormatVNC(virDomainGraphicsDef *def, virBuffer *buffer); static int virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDef *def, @@ -1938,6 +1939,18 @@ virVMXParseConfig(virVMXContext *ctx, =20 def->nvideos =3D 1; =20 + /* def:tpms */ + { + virDomainTPMDef *tpm =3D NULL; + if (virVMXParseTPM(conf, &tpm) < 0) + goto cleanup; + + VIR_DEBUG("Is vtpm present: %s", + (tpm !=3D NULL) ? "yes" : "no"); + if (tpm) + VIR_APPEND_ELEMENT(def->tpms, def->ntpms, tpm); + } + /* def:sounds */ /* FIXME */ =20 @@ -3367,6 +3380,27 @@ virVMXParseSVGA(virConf *conf, virDomainVideoDef **d= ef) return result; } =20 +static int +virVMXParseTPM(virConf *conf, virDomainTPMDef **def) +{ + bool vtpm_present =3D false; + + /* vmx:vtpm.present */ + if (virVMXGetConfigBoolean(conf, "vtpm.present", &vtpm_present, + false, true) < 0) { + return -1; + } + + if (!vtpm_present) + return 0; + + *def =3D g_new0(virDomainTPMDef, 1); + (*def)->type =3D VIR_DOMAIN_TPM_TYPE_EMULATOR; + (*def)->model =3D VIR_DOMAIN_TPM_MODEL_CRB; + (*def)->data.emulator.version =3D VIR_DOMAIN_TPM_VERSION_2_0; + + return 0; +} =20 =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * diff --git a/tests/vmx2xmldata/vtpm.vmx b/tests/vmx2xmldata/vtpm.vmx new file mode 100644 index 0000000000..6e2fd725b7 --- /dev/null +++ b/tests/vmx2xmldata/vtpm.vmx @@ -0,0 +1,22 @@ +config.version =3D "8" +virtualHW.version =3D "19" +displayName =3D "test-vtpm" +memsize =3D "4096" +numvcpus =3D "2" +guestOS =3D "windows9-64" + +# Disk Configuration +scsi0.present =3D "TRUE" +scsi0.virtualDev =3D "lsisas1068" +scsi0:0.present =3D "TRUE" +scsi0:0.deviceType =3D "scsi-hardDisk" +scsi0:0.fileName =3D "test_disk.vmdk" + +# vTPM configuration +vtpm.present =3D "TRUE" + +# Network Configuration +ethernet0.present =3D "TRUE" +ethernet0.connectionType =3D "nat" +ethernet0.virtualDev =3D "e1000e" +ethernet0.addressType =3D "generated" diff --git a/tests/vmx2xmldata/vtpm.xml b/tests/vmx2xmldata/vtpm.xml new file mode 100644 index 0000000000..cbb23ce673 --- /dev/null +++ b/tests/vmx2xmldata/vtpm.xml @@ -0,0 +1,32 @@ + + test-vtpm + 00000000-0000-0000-0000-000000000000 + 4194304 + 4194304 + 2 + + hvm + + + destroy + restart + destroy + + + + +
+ + + + + + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index fcca765bed..3ffc04fda4 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -243,6 +243,8 @@ mymain(void) =20 DO_TEST("firmware-efi"); =20 + DO_TEST("vtpm"); + ctx.datacenterPath =3D "folder1/folder2/datacenter1"; =20 DO_TEST("datacenterpath"); --=20 2.53.0