From b3d2dae261768c00b5d92203351ff6dd7cde468e Mon Sep 17 00:00:00 2001 Message-Id: From: Michal Privoznik Date: Tue, 12 Jul 2022 15:58:17 +0200 Subject: [PATCH] qemu: Report supported TPM version in domcaps Now that we have everything prepared, we can start detecting supported TPM versions and setting corresponding values in backendModel struct. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/340 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2103119 Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa (cherry picked from commit 430ab88ab17727ac9774ee5b47f09f69c57add73) Signed-off-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2c3be3ecec..8586930266 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6368,9 +6368,18 @@ virQEMUCapsFillDomainDeviceTPMCaps(virQEMUCaps *qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH)) VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendModel, VIR_DOMAIN_TPM_TYPE_PASSTHROUGH); - if (virTPMHasSwtpm() && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR)) - VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendModel, VIR_DOMAIN_TPM_TYPE_EMULATOR); + if (virTPMHasSwtpm()) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR)) + VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendModel, VIR_DOMAIN_TPM_TYPE_EMULATOR); + if (virTPMSwtpmSetupCapsGet(VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2)) { + VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendVersion, VIR_DOMAIN_TPM_VERSION_1_2); + tpm->backendVersion.report = true; + } + if (virTPMSwtpmSetupCapsGet(VIR_TPM_SWTPM_SETUP_FEATURE_TPM_2_0)) { + VIR_DOMAIN_CAPS_ENUM_SET(tpm->backendVersion, VIR_DOMAIN_TPM_VERSION_2_0); + tpm->backendVersion.report = true; + } + } /* * Need at least one frontend if it is to be usable by applications -- 2.35.1