summaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2017-11-06 19:39:02 +0100
committerStefan Berger <stefanb@linux.vnet.ibm.com>2017-12-14 23:39:14 -0500
commit689990598a710519eba37e4eb4d8bdebac1aa562 (patch)
treecf829e27700633dc8c18f2ff050e4b80cc4f72e7 /backends
parent36e8658924cec6427ca00f87ce86f65cfa705d69 (diff)
downloadqemu-689990598a710519eba37e4eb4d8bdebac1aa562.tar.gz
tpm-be: call request_completed() out of thread
Lift from the backend implementation the responsability to call the request_completed() callback outside of thread context. This also simplify frontend/interface work, as they no longer need to care whether the callback is called from a different thread. 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')
-rw-r--r--backends/tpm.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/backends/tpm.c b/backends/tpm.c
index 86f0e7e915..58f823d54c 100644
--- a/backends/tpm.c
+++ b/backends/tpm.c
@@ -18,14 +18,25 @@
#include "qapi/qmp/qerror.h"
#include "sysemu/tpm.h"
#include "qemu/thread.h"
+#include "qemu/main-loop.h"
+
+static void tpm_backend_request_completed_bh(void *opaque)
+{
+ TPMBackend *s = TPM_BACKEND(opaque);
+ TPMIfClass *tic = TPM_IF_GET_CLASS(s->tpmif);
+
+ tic->request_completed(s->tpmif);
+}
static void tpm_backend_worker_thread(gpointer data, gpointer 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);
+
+ qemu_bh_schedule(s->bh);
}
static void tpm_backend_thread_end(TPMBackend *s)
@@ -193,6 +204,7 @@ static void tpm_backend_instance_init(Object *obj)
tpm_backend_prop_set_opened,
NULL);
s->fe_model = -1;
+ s->bh = qemu_bh_new(tpm_backend_request_completed_bh, s);
}
static void tpm_backend_instance_finalize(Object *obj)
@@ -202,6 +214,7 @@ static void tpm_backend_instance_finalize(Object *obj)
object_unref(OBJECT(s->tpmif));
g_free(s->id);
tpm_backend_thread_end(s);
+ qemu_bh_delete(s->bh);
}
static const TypeInfo tpm_backend_info = {