Patchwork [V2,6/9] Implement qemu_thread_join function

login
register
mail settings
Submitter Stefan Berger
Date March 30, 2011, 7:42 p.m.
Message ID <20110330194237.957531180@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/88965/
State New
Headers show

Comments

Stefan Berger - March 30, 2011, 7:42 p.m.
This patch provides support for 'joining a thread' by wrapping the POSIX
pthread_join with qemu_thread_join.

Since the backend implementation is based on threads and I am stopping
and starting that thread during operations like 'snapshot resume', I
do use this functionality to synchronize with the TPM thread's termination
before terminating the TPM, creating a new one and loading previous state
from the time of the snapshot into the TPM.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

---
 qemu-thread-posix.c |    5 +++++
 qemu-thread.h       |    1 +
 2 files changed, 6 insertions(+)

Patch

Index: qemu-git/qemu-thread-posix.c
===================================================================
--- qemu-git.orig/qemu-thread-posix.c
+++ qemu-git/qemu-thread-posix.c
@@ -147,3 +147,8 @@  void qemu_thread_exit(void *retval)
 {
     pthread_exit(retval);
 }
+
+int qemu_thread_join(QemuThread *thread, void **retval)
+{
+    return pthread_join(thread->thread, retval);
+}
Index: qemu-git/qemu-thread.h
===================================================================
--- qemu-git.orig/qemu-thread.h
+++ qemu-git/qemu-thread.h
@@ -35,5 +35,6 @@  void qemu_thread_create(QemuThread *thre
 void qemu_thread_get_self(QemuThread *thread);
 int qemu_thread_is_self(QemuThread *thread);
 void qemu_thread_exit(void *retval);
+int qemu_thread_join(QemuThread *thread, void **retval);
 
 #endif