aboutsummaryrefslogtreecommitdiff
path: root/tpm.c
diff options
context:
space:
mode:
authorAmarnath Valluri <amarnath.valluri@intel.com>2017-09-29 14:10:17 +0300
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-10-13 07:34:33 -0400
commitf59864ba3aedd26aef7c84545cc1e565caccebf7 (patch)
tree983a625007c81afa85697b95fc7b9a33ce73e2a1 /tpm.c
parent93330cf542b920b6ea5fea8120a08b76bb353113 (diff)
tpm-backend: Add new API to read backend TpmInfo
TPM configuration options are backend implementation details and shall not be part of base TPMBackend object, and these shall not be accessed directly outside of the class, hence added a new interface method, get_tpm_options() to TPMDriverOps., which shall be implemented by the derived classes to return configured tpm options. A new tpm backend api - tpm_backend_query_tpm() which uses _get_tpm_options() to prepare TpmInfo. Signed-off-by: Amarnath Valluri <amarnath.valluri@intel.com> Reviewed-by: Stefan Berger <stefanb@linux.vnet.ibm.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Diffstat (limited to 'tpm.c')
-rw-r--r--tpm.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/tpm.c b/tpm.c
index db14849b20..3b8c7ed3b6 100644
--- a/tpm.c
+++ b/tpm.c
@@ -202,36 +202,6 @@ static const TPMDriverOps *tpm_driver_find_by_type(enum TpmType type)
return be_drivers[type];
}
-static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv)
-{
- TPMInfo *res = g_new0(TPMInfo, 1);
- TPMPassthroughOptions *tpo;
-
- res->id = g_strdup(drv->id);
- res->model = drv->fe_model;
- res->options = g_new0(TpmTypeOptions, 1);
-
- switch (tpm_backend_get_type(drv)) {
- case TPM_TYPE_PASSTHROUGH:
- res->options->type = TPM_TYPE_OPTIONS_KIND_PASSTHROUGH;
- tpo = g_new0(TPMPassthroughOptions, 1);
- res->options->u.passthrough.data = tpo;
- if (drv->path) {
- tpo->path = g_strdup(drv->path);
- tpo->has_path = true;
- }
- if (drv->cancel_path) {
- tpo->cancel_path = g_strdup(drv->cancel_path);
- tpo->has_cancel_path = true;
- }
- break;
- case TPM_TYPE__MAX:
- break;
- }
-
- return res;
-}
-
/*
* Walk the list of active TPM backends and collect information about them
* following the schema description in qapi-schema.json.
@@ -246,7 +216,7 @@ TPMInfoList *qmp_query_tpm(Error **errp)
continue;
}
info = g_new0(TPMInfoList, 1);
- info->value = qmp_query_tpm_inst(drv);
+ info->value = tpm_backend_query_tpm(drv);
if (!cur_item) {
head = cur_item = info;