diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2017-11-06 19:39:00 +0100 |
---|---|---|
committer | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2017-12-14 23:39:13 -0500 |
commit | 8a89c9ac15981c2d15ce4ee6d6ad67da58824a04 (patch) | |
tree | 0934508cd312e375675a7977026be1d77dc346d3 /backends/tpm.c | |
parent | 67af320cd653a107c0bbdf0d2e6c51b24403c64d (diff) | |
download | qemu-8a89c9ac15981c2d15ce4ee6d6ad67da58824a04.zip qemu-8a89c9ac15981c2d15ce4ee6d6ad67da58824a04.tar.gz qemu-8a89c9ac15981c2d15ce4ee6d6ad67da58824a04.tar.bz2 |
tpm-backend: store TPMIf interface, improve backend_init()
Store the TPM interface, the actual object may be different from
TPMState. Keep a reference on the interface, and check the backend
wasn't already initialized.
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>
Diffstat (limited to 'backends/tpm.c')
-rw-r--r-- | backends/tpm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/backends/tpm.c b/backends/tpm.c index 1e416d7..86f0e7e 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -43,9 +43,15 @@ enum TpmType tpm_backend_get_type(TPMBackend *s) return k->type; } -int tpm_backend_init(TPMBackend *s, TPMState *state) +int tpm_backend_init(TPMBackend *s, TPMIf *tpmif) { - s->tpm_state = state; + if (s->tpmif) { + return -1; + } + + s->tpmif = tpmif; + object_ref(OBJECT(tpmif)); + s->had_startup_error = false; return 0; @@ -193,6 +199,7 @@ static void tpm_backend_instance_finalize(Object *obj) { TPMBackend *s = TPM_BACKEND(obj); + object_unref(OBJECT(s->tpmif)); g_free(s->id); tpm_backend_thread_end(s); } |