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