]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tpm: add a QOM TPM interface
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 9 Oct 2017 22:56:01 +0000 (00:56 +0200)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Thu, 19 Oct 2017 15:42:32 +0000 (11:42 -0400)
This will simplify backend / interface objects relationship, so the
frontend interface will simply have to implement the TPM QOM interface.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
backends/tpm.c
hw/tpm/tpm_int.h
hw/tpm/tpm_tis.c

index dc7c831ff8a63ea2c7127d0c267a356a8cf7061e..87c5c091797453e9d3480d6916e2864263947e63 100644 (file)
@@ -17,6 +17,7 @@
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "sysemu/tpm.h"
+#include "hw/tpm/tpm_int.h"
 #include "qemu/thread.h"
 
 static void tpm_backend_worker_thread(gpointer data, gpointer user_data)
@@ -209,9 +210,16 @@ static const TypeInfo tpm_backend_info = {
     .abstract = true,
 };
 
+static const TypeInfo tpm_if_info = {
+    .name = TYPE_TPM_IF,
+    .parent = TYPE_INTERFACE,
+    .class_size = sizeof(TPMIfClass),
+};
+
 static void register_types(void)
 {
     type_register_static(&tpm_backend_info);
+    type_register_static(&tpm_if_info);
 }
 
 type_init(register_types);
index e231d0eb4f0b73cdd69bf6506b3b7816399d9bc2..eb02e7760c3d12da5311a5fc26438d5897fc5770 100644 (file)
 #define TPM_TPM_INT_H
 
 #include "qemu/osdep.h"
+#include "qom/object.h"
+
+#define TYPE_TPM_IF "tpm-if"
+#define TPM_IF_CLASS(klass) \
+    OBJECT_CLASS_CHECK(TPMIfClass, (klass), TYPE_TPM_IF)
+#define TPM_IF_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(TPMIfClass, (obj), TYPE_TPM_IF)
+#define TPM_IF(obj) \
+    INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
+
+typedef struct TPMIf {
+    Object parent_obj;
+} TPMIf;
+
+typedef struct TPMIfClass {
+    InterfaceClass parent_class;
+} TPMIfClass;
 
 #define TPM_STANDARD_CMDLINE_OPTS               \
     { \
index d84eec48b4af1aede59e6634ca73e65b0a39191e..dbb50043acccca3eccfdcbeab4c189bdd307ae62 100644 (file)
@@ -1123,6 +1123,10 @@ static const TypeInfo tpm_tis_info = {
     .instance_size = sizeof(TPMState),
     .instance_init = tpm_tis_initfn,
     .class_init  = tpm_tis_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_TPM_IF },
+        { }
+    }
 };
 
 static void tpm_tis_register(void)