In summary of the commit mention 'vmx' as the driver instead of the obvious 'libvirt'
On Fri, Apr 17, 2026 at 11:45:15 +0530, Srihari Parimi via Devel wrote: > Parses vtpm.present from VMX files and converts to libvirt TPM > device with CRB model and emulator backend. VMware vTPM uses > TPM 2.0 with the CRB Do you know of any docs to point to for which version of TPM is used? > > Signed-off-by: Srihari Parimi <[email protected]> > --- > src/vmx/vmx.c | 50 ++++++++++++++++++++++++++++++++++++++ > tests/vmx2xmldata/vtpm.vmx | 22 +++++++++++++++++ > tests/vmx2xmldata/vtpm.xml | 32 ++++++++++++++++++++++++ > tests/vmx2xmltest.c | 2 ++ > 4 files changed, 106 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..9231968175 100644 > --- a/src/vmx/vmx.c > +++ b/src/vmx/vmx.c > @@ -599,6 +599,7 @@ static int virVMXParseSerial(virVMXContext *ctx, virConf > *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); > > static int virVMXFormatVNC(virDomainGraphicsDef *def, virBuffer *buffer); > static int virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDef *def, > @@ -1403,6 +1404,7 @@ virVMXParseConfig(virVMXContext *ctx, > char *guestOS = NULL; > bool smbios_reflecthost = false; > bool uefi_secureboot = false; > + bool vtpm_present = false; > int controller; > int bus; > int port; > @@ -1938,6 +1940,16 @@ virVMXParseConfig(virVMXContext *ctx, > > def->nvideos = 1; > > + /* def:tpms */ > + { > + virDomainTPMDef *tpm = NULL; > + if (virVMXParseTPM(conf, &tpm) < 0) > + goto cleanup; So this parses 'vtpm.present' > + > + if (tpm) > + VIR_APPEND_ELEMENT(def->tpms, def->ntpms, tpm); > + } > + > /* def:sounds */ > /* FIXME */ > > @@ -2001,6 +2013,18 @@ virVMXParseConfig(virVMXContext *ctx, > } > } > > + /* vmx: vtpm.present (optional) */ And inside the same function ... > + if (virVMXGetConfigBoolean(conf, "vtpm.present", > + &vtpm_present, false, true) < 0) { You parse it again ... > + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", > + _("Unable to parse vtpm.present")); > + goto cleanup; > + } > + if (vtpm_present) { > + VIR_DEBUG("Processing vtpm_present: %s", > + (vtpm_present == true) ? "yes" : "no"); just to add a debug statement? Can you explain this please? > + } > + > /* vmx:uefi.secureBoot.enabled */ > if (virVMXGetConfigBoolean(conf, "uefi.secureBoot.enabled", > &uefi_secureboot, false, true) < 0) { > @@ -3367,6 +3391,32 @@ virVMXParseSVGA(virConf *conf, virDomainVideoDef **def) > return result; > } > > +static int > +virVMXParseTPM(virConf *conf, virDomainTPMDef **def) > +{ > + bool vtpm_present = false; > + > + if (def == NULL || *def != NULL) { > + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument")); > + return -1; > + } The only caller always passes these, so this check isn't needed. > + > + /* vmx:vtpm.present */ > + if (virVMXGetConfigBoolean(conf, "vtpm.present", &vtpm_present, > + false, true) < 0) { > + return -1; > + } > + > + if (!vtpm_present) > + return 0; > + > + *def = g_new0(virDomainTPMDef, 1); > + (*def)->type = VIR_DOMAIN_TPM_TYPE_EMULATOR; > + (*def)->model = VIR_DOMAIN_TPM_MODEL_CRB; > + (*def)->data.emulator.version = VIR_DOMAIN_TPM_VERSION_2_0; > + > + return 0; > +} > > > /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > *
