aboutsummaryrefslogtreecommitdiff
path: root/tpm.c
diff options
context:
space:
mode:
Diffstat (limited to 'tpm.c')
-rw-r--r--tpm.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/tpm.c b/tpm.c
index ab5d29e91e..61a434185a 100644
--- a/tpm.c
+++ b/tpm.c
@@ -23,13 +23,6 @@
static QLIST_HEAD(, TPMBackend) tpm_backends =
QLIST_HEAD_INITIALIZER(tpm_backends);
-static bool tpm_models[TPM_MODEL__MAX];
-
-void tpm_register_model(enum TpmModel model)
-{
- tpm_models[model] = true;
-}
-
static const TPMBackendClass *
tpm_be_find_by_type(enum TpmType type)
{
@@ -69,7 +62,7 @@ static void tpm_display_backend_drivers(void)
/*
* Find the TPM with the given Id
*/
-TPMBackend *qemu_find_tpm(const char *id)
+TPMBackend *qemu_find_tpm_be(const char *id)
{
TPMBackend *drv;
@@ -127,17 +120,12 @@ static int tpm_init_tpmdev(void *dummy, QemuOpts *opts, Error **errp)
return 1;
}
- drv = be->create(opts, id);
+ drv = be->create(opts);
if (!drv) {
return 1;
}
- tpm_backend_open(drv, &local_err);
- if (local_err) {
- error_report_err(local_err);
- return 1;
- }
-
+ drv->id = g_strdup(id);
QLIST_INSERT_HEAD(&tpm_backends, drv, list);
return 0;
@@ -200,9 +188,10 @@ TPMInfoList *qmp_query_tpm(Error **errp)
TPMInfoList *info, *head = NULL, *cur_item = NULL;
QLIST_FOREACH(drv, &tpm_backends, list) {
- if (!tpm_models[drv->fe_model]) {
+ if (!drv->tpmif) {
continue;
}
+
info = g_new0(TPMInfoList, 1);
info->value = tpm_backend_query_tpm(drv);
@@ -240,18 +229,16 @@ TpmTypeList *qmp_query_tpm_types(Error **errp)
return head;
}
-
TpmModelList *qmp_query_tpm_models(Error **errp)
{
- unsigned int i = 0;
TpmModelList *head = NULL, *prev = NULL, *cur_item;
+ GSList *e, *l = object_class_get_list(TYPE_TPM_IF, false);
+
+ for (e = l; e; e = e->next) {
+ TPMIfClass *c = TPM_IF_CLASS(e->data);
- for (i = 0; i < TPM_MODEL__MAX; i++) {
- if (!tpm_models[i]) {
- continue;
- }
cur_item = g_new0(TpmModelList, 1);
- cur_item->value = i;
+ cur_item->value = c->model;
if (prev) {
prev->next = cur_item;
@@ -261,6 +248,7 @@ TpmModelList *qmp_query_tpm_models(Error **errp)
}
prev = cur_item;
}
+ g_slist_free(l);
return head;
}