tpm-be: ask model to the TPM interface
No need to store the mode in the backend, or to let the frontend set it itself. 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>
This commit is contained in:
parent
0bd6c8a9cf
commit
191adc9476
|
@ -148,9 +148,10 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s)
|
||||||
{
|
{
|
||||||
TPMInfo *info = g_new0(TPMInfo, 1);
|
TPMInfo *info = g_new0(TPMInfo, 1);
|
||||||
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
||||||
|
TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);
|
||||||
|
|
||||||
info->id = g_strdup(s->id);
|
info->id = g_strdup(s->id);
|
||||||
info->model = s->fe_model;
|
info->model = tic->model;
|
||||||
if (k->get_tpm_options) {
|
if (k->get_tpm_options) {
|
||||||
info->options = k->get_tpm_options(s);
|
info->options = k->get_tpm_options(s);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +205,6 @@ static void tpm_backend_instance_init(Object *obj)
|
||||||
tpm_backend_prop_get_opened,
|
tpm_backend_prop_get_opened,
|
||||||
tpm_backend_prop_set_opened,
|
tpm_backend_prop_set_opened,
|
||||||
NULL);
|
NULL);
|
||||||
s->fe_model = -1;
|
|
||||||
s->bh = qemu_bh_new(tpm_backend_request_completed_bh, s);
|
s->bh = qemu_bh_new(tpm_backend_request_completed_bh, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1072,8 +1072,6 @@ static void tpm_tis_realizefn(DeviceState *dev, Error **errp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->be_driver->fe_model = TPM_MODEL_TPM_TIS;
|
|
||||||
|
|
||||||
if (tpm_backend_init(s->be_driver, TPM_IF(s), errp)) {
|
if (tpm_backend_init(s->be_driver, TPM_IF(s), errp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1108,6 +1106,7 @@ static void tpm_tis_class_init(ObjectClass *klass, void *data)
|
||||||
dc->props = tpm_tis_properties;
|
dc->props = tpm_tis_properties;
|
||||||
dc->reset = tpm_tis_reset;
|
dc->reset = tpm_tis_reset;
|
||||||
dc->vmsd = &vmstate_tpm_tis;
|
dc->vmsd = &vmstate_tpm_tis;
|
||||||
|
tc->model = TPM_MODEL_TPM_TIS;
|
||||||
tc->request_completed = tpm_tis_request_completed;
|
tc->request_completed = tpm_tis_request_completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct TPMIf {
|
||||||
typedef struct TPMIfClass {
|
typedef struct TPMIfClass {
|
||||||
InterfaceClass parent_class;
|
InterfaceClass parent_class;
|
||||||
|
|
||||||
|
enum TpmModel model;
|
||||||
void (*request_completed)(TPMIf *obj);
|
void (*request_completed)(TPMIf *obj);
|
||||||
} TPMIfClass;
|
} TPMIfClass;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ struct TPMBackend {
|
||||||
|
|
||||||
/* <public> */
|
/* <public> */
|
||||||
char *id;
|
char *id;
|
||||||
enum TpmModel fe_model;
|
|
||||||
|
|
||||||
QLIST_ENTRY(TPMBackend) list;
|
QLIST_ENTRY(TPMBackend) list;
|
||||||
};
|
};
|
||||||
|
|
3
tpm.c
3
tpm.c
|
@ -200,9 +200,10 @@ TPMInfoList *qmp_query_tpm(Error **errp)
|
||||||
TPMInfoList *info, *head = NULL, *cur_item = NULL;
|
TPMInfoList *info, *head = NULL, *cur_item = NULL;
|
||||||
|
|
||||||
QLIST_FOREACH(drv, &tpm_backends, list) {
|
QLIST_FOREACH(drv, &tpm_backends, list) {
|
||||||
if (!tpm_models[drv->fe_model]) {
|
if (!drv->tpmif) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
info = g_new0(TPMInfoList, 1);
|
info = g_new0(TPMInfoList, 1);
|
||||||
info->value = tpm_backend_query_tpm(drv);
|
info->value = tpm_backend_query_tpm(drv);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue