diff mbox

tracing: start trace processing thread in final child process

Message ID 1379947014-14216-1-git-send-email-borntraeger@de.ibm.com
State New
Headers show

Commit Message

Christian Borntraeger Sept. 23, 2013, 2:36 p.m. UTC
From: Michael Mueller <mimu@linux.vnet.ibm.com>

When running with trace backend e.g. "simple" the writer thread needs to be
implemented in the same process context as the trace points that will be
processed. Under libvirtd control, qemu gets first started in daemonized
mode to privide its capabilities. Creating the writer thread in the initial
process context then leads to a dead lock because the thread gets termined
together with the initial parent. (-daemonize)

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
[minor whitespace fixes]
---
 vl.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi Sept. 24, 2013, 12:43 p.m. UTC | #1
On Mon, Sep 23, 2013 at 04:36:54PM +0200, Christian Borntraeger wrote:
> From: Michael Mueller <mimu@linux.vnet.ibm.com>
> 
> When running with trace backend e.g. "simple" the writer thread needs to be
> implemented in the same process context as the trace points that will be
> processed. Under libvirtd control, qemu gets first started in daemonized
> mode to privide its capabilities. Creating the writer thread in the initial
> process context then leads to a dead lock because the thread gets termined
> together with the initial parent. (-daemonize)
> 
> Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
> [minor whitespace fixes]
> ---
>  vl.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

Thanks, applied to my tracing tree:
https://github.com/stefanha/qemu/commits/tracing

Stefan
diff mbox

Patch

diff --git a/vl.c b/vl.c
index 4e709d5..93670c8 100644
--- a/vl.c
+++ b/vl.c
@@ -3863,8 +3863,10 @@  int main(int argc, char **argv, char **envp)
         qemu_set_log(mask);
     }
 
-    if (!trace_backend_init(trace_events, trace_file)) {
-        exit(1);
+    if (!is_daemonized()) {
+        if (!trace_backend_init(trace_events, trace_file)) {
+            exit(1);
+        }
     }
 
     /* If no data_dir is specified then try to find it relative to the
@@ -4358,6 +4360,12 @@  int main(int argc, char **argv, char **envp)
 
     os_setup_post();
 
+    if (is_daemonized()) {
+        if (!trace_backend_init(trace_events, trace_file)) {
+            exit(1);
+        }
+    }
+
     main_loop();
     bdrv_close_all();
     pause_all_vcpus();