From nobody Mon May 25 12:51:50 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=1776758983; cv=none; d=zohomail.com; s=zohoarc; b=SvCBJZ+fZQzggpQOfG3HbQS6kRsVdRiBUrJ8cY0RlQsd5pCW88bbhaDEqXDRjTiZIwkd4aBaALtgFUUZHG1v2NTs+1tgBUjxAM0If9vqEiIt8NR7AyQdj8e7/Prt16C2dKQpNxfE7Af2gZ00q8+X5TlEaBIhCm0lgifq+gzT2zQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1776758983; 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=ZVIOjmm6LV2DLYFHfTFDkvyY9zIoM+mnZe2nAhD225g=; b=GHSTAW/XZ7hXyDhoMaGVTwxHVQqGylxvf3LHp9/Cj5pqLMI/s2nHtNPhgbBtiZ7+KJ0tpfSfiNPENPadmvQ6F1Is9ixyxRsXbpMkesNxVob2W6dF3P2XrMmjbQNLDIF7yyid2x9tM07zR5vid7Jrxf/nyQVCvT9+2k6fX63ggB0= 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 1776758983789931.7757271059311; Tue, 21 Apr 2026 01:09:43 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 199A43F2F3; Tue, 21 Apr 2026 04:09:42 -0400 (EDT) Received: from [172.19.199.6] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id C83534190B; Tue, 21 Apr 2026 03:58:53 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 939F1417F9; Tue, 21 Apr 2026 01:39:53 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 511CA41822 for ; Tue, 21 Apr 2026 01:39:52 -0400 (EDT) Received: from mx-prod-mc-05.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-688-cP0HJFoTPXC1fEU96KLalg-1; Tue, 21 Apr 2026 01:39:50 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8AA2D195608B for ; Tue, 21 Apr 2026 05:39:49 +0000 (UTC) Received: from sparimi-thinkpadt14gen5.bengluru.csb (unknown [10.67.32.81]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD9F2180047F; Tue, 21 Apr 2026 05:39:47 +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,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=1776749991; 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=ZVIOjmm6LV2DLYFHfTFDkvyY9zIoM+mnZe2nAhD225g=; b=Tm3i4NgpsC/x3CXQku7GFHKV/kVUPErWI5yTlXCURTg0pmqwPrmBSSbmYu5e+4Zj2vcdzD BhJ5Vs0nufIRC1XCkHrZ5kLQG0Lanq/z/DWmkdc4CZVGtFP5VsRGXUIUJM3HGvz82lBC6k a7CFCurE34aJFzvtV58IjIjCxBmGu98= X-MC-Unique: cP0HJFoTPXC1fEU96KLalg-1 X-Mimecast-MFC-AGG-ID: cP0HJFoTPXC1fEU96KLalg_1776749989 To: devel@lists.libvirt.org Subject: [PATCH v5] vmx: configure TPM device in the XML Date: Tue, 21 Apr 2026 11:08:47 +0530 Message-ID: <20260421053859.26547-2-sparimi@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: wZQIK5UQ-zrIYLGoYk03XBWP6TaXI8z-_LqR0r3mlfw_1776749989 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: B3GCVPCOG7TQKHISL2E7544C3TYRURXQ X-Message-ID-Hash: B3GCVPCOG7TQKHISL2E7544C3TYRURXQ X-Mailman-Approved-At: Tue, 21 Apr 2026 07:58:20 +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: 1776758984867154100 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 specified in the document 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 | 31 +++++++++++++++++++++++++++++++ tests/vmx2xmldata/vtpm.vmx | 22 ++++++++++++++++++++++ tests/vmx2xmldata/vtpm.xml | 32 ++++++++++++++++++++++++++++++++ tests/vmx2xmltest.c | 2 ++ 4 files changed, 87 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..bec985aef3 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,15 @@ virVMXParseConfig(virVMXContext *ctx, =20 def->nvideos =3D 1; =20 + /* def:tpms */ + { + virDomainTPMDef *tpm =3D NULL; + if (virVMXParseTPM(conf, &tpm) < 0) + goto cleanup; + if (tpm) + VIR_APPEND_ELEMENT(def->tpms, def->ntpms, tpm); + } + /* def:sounds */ /* FIXME */ =20 @@ -3367,6 +3377,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