[PATCH 04/10] qemu: capabilities: Detect TPM related capabilities from 'qom-list-types'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Krempa <pkrempa@xxxxxxxxxx>

All the information needed to detect supported TPM front and backends
is present in the QOM types we already query, thus we don't need to
invoke specific commands for querying TPM stuff.

The only discrepancy is that there are 3 versions of 'tpm-tis' based on
the backed they use.

This patch reworks the probing but keeps the query commands in place.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 53 ++++++------------------------------
 1 file changed, 8 insertions(+), 45 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 75ce877b58..e7404ad27f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1427,6 +1427,13 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "amd-iommu", QEMU_CAPS_AMD_IOMMU },
     { "usb-bot", QEMU_CAPS_DEVICE_USB_BOT },
     { "tdx-guest", QEMU_CAPS_TDX_GUEST},
+    { "tpm-crb", QEMU_CAPS_DEVICE_TPM_CRB },
+    { "tpm-tis", QEMU_CAPS_DEVICE_TPM_TIS },
+    { "tpm-tis-device", QEMU_CAPS_DEVICE_TPM_TIS },
+    { "tpm-tis-i2c", QEMU_CAPS_DEVICE_TPM_TIS },
+    { "tpm-spapr", QEMU_CAPS_DEVICE_TPM_SPAPR },
+    { "tpm-emulator", QEMU_CAPS_DEVICE_TPM_EMULATOR },
+    { "tpm-passthrough", QEMU_CAPS_DEVICE_TPM_PASSTHROUGH },
 };


@@ -3381,44 +3388,12 @@ virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
 }


-struct tpmTypeToCaps {
-    int type;
-    virQEMUCapsFlags caps;
-};
-
-static const struct tpmTypeToCaps virQEMUCapsTPMTypesToCaps[] = {
-    {
-        .type = VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
-        .caps = QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
-    },
-    {
-        .type = VIR_DOMAIN_TPM_TYPE_EMULATOR,
-        .caps = QEMU_CAPS_DEVICE_TPM_EMULATOR,
-    },
-};
-
-const struct tpmTypeToCaps virQEMUCapsTPMModelsToCaps[] = {
-    {
-        .type = VIR_DOMAIN_TPM_MODEL_TIS,
-        .caps = QEMU_CAPS_DEVICE_TPM_TIS,
-    },
-    {
-        .type = VIR_DOMAIN_TPM_MODEL_CRB,
-        .caps = QEMU_CAPS_DEVICE_TPM_CRB,
-    },
-    {
-        .type = VIR_DOMAIN_TPM_MODEL_SPAPR,
-        .caps = QEMU_CAPS_DEVICE_TPM_SPAPR,
-    },
-};
-
 static int
-virQEMUCapsProbeQMPTPM(virQEMUCaps *qemuCaps,
+virQEMUCapsProbeQMPTPM(virQEMUCaps *qemuCaps G_GNUC_UNUSED,
                        qemuMonitor *mon)
 {
     g_auto(GStrv) models = NULL;
     g_auto(GStrv) types = NULL;
-    size_t i;

     if (qemuMonitorGetTPMModels(mon, &models) < 0)
         return -1;
@@ -3426,24 +3401,12 @@ virQEMUCapsProbeQMPTPM(virQEMUCaps *qemuCaps,
     if (!models)
         return 0;

-    for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMModelsToCaps); i++) {
-        const char *needle = virDomainTPMModelTypeToString(virQEMUCapsTPMModelsToCaps[i].type);
-        if (g_strv_contains((const char **)models, needle))
-            virQEMUCapsSet(qemuCaps, virQEMUCapsTPMModelsToCaps[i].caps);
-    }
-
     if (qemuMonitorGetTPMTypes(mon, &types) < 0)
         return -1;

     if (!types)
         return 0;

-    for (i = 0; i < G_N_ELEMENTS(virQEMUCapsTPMTypesToCaps); i++) {
-        const char *needle = virDomainTPMBackendTypeToString(virQEMUCapsTPMTypesToCaps[i].type);
-        if (g_strv_contains((const char **)types, needle))
-            virQEMUCapsSet(qemuCaps, virQEMUCapsTPMTypesToCaps[i].caps);
-    }
-
     return 0;
 }

-- 
2.51.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux