mirror of https://github.com/xqemu/xqemu.git
tpm-be: update optional function pointers
QEMU code doesn't generally have assert() for mandatory callbacks/function pointers, probably because the crash is pretty obvious. Document the methods instead of going into the code. Make get_tpm_options() mandatory to implement (since all backend implementation have it). 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
69c07db046
commit
ebca2df783
|
@ -33,7 +33,6 @@ static void tpm_backend_worker_thread(gpointer data, gpointer user_data)
|
||||||
TPMBackend *s = TPM_BACKEND(user_data);
|
TPMBackend *s = TPM_BACKEND(user_data);
|
||||||
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
||||||
|
|
||||||
assert(k->handle_request != NULL);
|
|
||||||
k->handle_request(s, (TPMBackendCmd *)data);
|
k->handle_request(s, (TPMBackendCmd *)data);
|
||||||
|
|
||||||
qemu_bh_schedule(s->bh);
|
qemu_bh_schedule(s->bh);
|
||||||
|
@ -114,8 +113,6 @@ void tpm_backend_cancel_cmd(TPMBackend *s)
|
||||||
{
|
{
|
||||||
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
||||||
|
|
||||||
assert(k->cancel_cmd);
|
|
||||||
|
|
||||||
k->cancel_cmd(s);
|
k->cancel_cmd(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +136,6 @@ TPMVersion tpm_backend_get_tpm_version(TPMBackend *s)
|
||||||
{
|
{
|
||||||
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s);
|
||||||
|
|
||||||
assert(k->get_tpm_version);
|
|
||||||
|
|
||||||
return k->get_tpm_version(s);
|
return k->get_tpm_version(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,9 +147,7 @@ TPMInfo *tpm_backend_query_tpm(TPMBackend *s)
|
||||||
|
|
||||||
info->id = g_strdup(s->id);
|
info->id = g_strdup(s->id);
|
||||||
info->model = tic->model;
|
info->model = tic->model;
|
||||||
if (k->get_tpm_options) {
|
info->options = k->get_tpm_options(s);
|
||||||
info->options = k->get_tpm_options(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,15 +65,18 @@ struct TPMBackendClass {
|
||||||
|
|
||||||
TPMBackend *(*create)(QemuOpts *opts, const char *id);
|
TPMBackend *(*create)(QemuOpts *opts, const char *id);
|
||||||
|
|
||||||
/* start up the TPM on the backend */
|
/* start up the TPM on the backend - optional */
|
||||||
int (*startup_tpm)(TPMBackend *t);
|
int (*startup_tpm)(TPMBackend *t);
|
||||||
|
|
||||||
|
/* optional */
|
||||||
void (*reset)(TPMBackend *t);
|
void (*reset)(TPMBackend *t);
|
||||||
|
|
||||||
void (*cancel_cmd)(TPMBackend *t);
|
void (*cancel_cmd)(TPMBackend *t);
|
||||||
|
|
||||||
|
/* optional */
|
||||||
bool (*get_tpm_established_flag)(TPMBackend *t);
|
bool (*get_tpm_established_flag)(TPMBackend *t);
|
||||||
|
|
||||||
|
/* optional */
|
||||||
int (*reset_tpm_established_flag)(TPMBackend *t, uint8_t locty);
|
int (*reset_tpm_established_flag)(TPMBackend *t, uint8_t locty);
|
||||||
|
|
||||||
TPMVersion (*get_tpm_version)(TPMBackend *t);
|
TPMVersion (*get_tpm_version)(TPMBackend *t);
|
||||||
|
|
Loading…
Reference in New Issue