]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: add TPM devices to domain capabilities
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 23 Nov 2021 17:17:20 +0000 (17:17 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 1 Dec 2021 12:14:03 +0000 (12:14 +0000)
This adds reporting of available TPM models and backends to the domain
capabilities schema

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
docs/schemas/domaincaps.rng
src/conf/domain_capabilities.c
src/conf/domain_capabilities.h

index 8b5267f74141cbe2af568df4b3512dbe75a24f6c..1b6122507feba76fa3a229e9ba9b89f334a750cb 100644 (file)
       <optional>
         <ref name="filesystem"/>
       </optional>
+      <optional>
+        <ref name="tpm"/>
+      </optional>
     </element>
   </define>
 
     </element>
   </define>
 
+  <define name="tpm">
+    <element name="tpm">
+      <ref name="supported"/>
+      <ref name="enum"/>
+    </element>
+  </define>
+
   <define name="features">
     <element name="features">
       <optional>
index 1766129092556b6f0af73df8a6a8bcc27172c5b8..fef1326190a3f3ff6793d49110e30dd20e84f4c1 100644 (file)
@@ -533,6 +533,19 @@ virDomainCapsDeviceRNGFormat(virBuffer *buf,
 }
 
 
+static void
+virDomainCapsDeviceTPMFormat(virBuffer *buf,
+                             const virDomainCapsDeviceTPM *tpm)
+{
+    FORMAT_PROLOGUE(tpm);
+
+    ENUM_PROCESS(tpm, model, virDomainTPMModelTypeToString);
+    ENUM_PROCESS(tpm, backendModel, virDomainTPMBackendTypeToString);
+
+    FORMAT_EPILOGUE(tpm);
+}
+
+
 static void
 virDomainCapsDeviceFilesystemFormat(virBuffer *buf,
                                     const virDomainCapsDeviceFilesystem *filesystem)
@@ -652,6 +665,7 @@ virDomainCapsFormat(const virDomainCaps *caps)
     virDomainCapsDeviceHostdevFormat(&buf, &caps->hostdev);
     virDomainCapsDeviceRNGFormat(&buf, &caps->rng);
     virDomainCapsDeviceFilesystemFormat(&buf, &caps->filesystem);
+    virDomainCapsDeviceTPMFormat(&buf, &caps->tpm);
 
     virBufferAdjustIndent(&buf, -2);
     virBufferAddLit(&buf, "</devices>\n");
index d44acdcd01a91a0988a815e0bac77b82b5b15d34..2fcad87fd8a58def33e130f6fc6b2dfd22fafd9f 100644 (file)
@@ -120,6 +120,15 @@ struct _virDomainCapsDeviceRNG {
     virDomainCapsEnum backendModel;   /* virDomainRNGBackend */
 };
 
+STATIC_ASSERT_ENUM(VIR_DOMAIN_TPM_MODEL_LAST);
+STATIC_ASSERT_ENUM(VIR_DOMAIN_TPM_TYPE_LAST);
+typedef struct _virDomainCapsDeviceTPM virDomainCapsDeviceTPM;
+struct _virDomainCapsDeviceTPM {
+    virTristateBool supported;
+    virDomainCapsEnum model;   /* virDomainTPMModel */
+    virDomainCapsEnum backendModel;   /* virDomainTPMBackendType */
+};
+
 STATIC_ASSERT_ENUM(VIR_DOMAIN_FS_DRIVER_TYPE_LAST);
 typedef struct _virDomainCapsDeviceFilesystem virDomainCapsDeviceFilesystem;
 struct _virDomainCapsDeviceFilesystem {
@@ -211,6 +220,7 @@ struct _virDomainCaps {
     virDomainCapsDeviceHostdev hostdev;
     virDomainCapsDeviceRNG rng;
     virDomainCapsDeviceFilesystem filesystem;
+    virDomainCapsDeviceTPM tpm;
     /* add new domain devices here */
 
     virDomainCapsFeatureGIC gic;