tracing: start trace processing thread in final child process

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]
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Michael Mueller 2013-09-23 16:36:54 +02:00 committed by Stefan Hajnoczi
parent 0169c51155
commit 8a745f2a92

8
vl.c
View file

@ -3879,9 +3879,11 @@ int main(int argc, char **argv, char **envp)
qemu_set_log(mask); qemu_set_log(mask);
} }
if (!is_daemonized()) {
if (!trace_backend_init(trace_events, trace_file)) { if (!trace_backend_init(trace_events, trace_file)) {
exit(1); exit(1);
} }
}
/* If no data_dir is specified then try to find it relative to the /* If no data_dir is specified then try to find it relative to the
executable path. */ executable path. */
@ -4379,6 +4381,12 @@ int main(int argc, char **argv, char **envp)
os_setup_post(); os_setup_post();
if (is_daemonized()) {
if (!trace_backend_init(trace_events, trace_file)) {
exit(1);
}
}
main_loop(); main_loop();
bdrv_close_all(); bdrv_close_all();
pause_all_vcpus(); pause_all_vcpus();