From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uyods-00050U-Tt for qemu-devel@nongnu.org; Mon, 15 Jul 2013 15:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uyodr-0000vi-TI for qemu-devel@nongnu.org; Mon, 15 Jul 2013 15:41:04 -0400 Received: from e06smtp18.uk.ibm.com ([195.75.94.114]:38409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uyodr-0000sp-Jj for qemu-devel@nongnu.org; Mon, 15 Jul 2013 15:41:03 -0400 Received: from /spool/local by e06smtp18.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Jul 2013 20:35:05 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id C60771B08023 for ; Mon, 15 Jul 2013 20:40:58 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r6FJelgF52035796 for ; Mon, 15 Jul 2013 19:40:47 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r6FJev4S029071 for ; Mon, 15 Jul 2013 13:40:58 -0600 From: Christian Borntraeger Date: Mon, 15 Jul 2013 21:41:19 +0200 Message-Id: <1373917279-15360-1-git-send-email-borntraeger@de.ibm.com> Subject: [Qemu-devel] [PATCH 02/12] trace+libvirt: start trace processing thread in final child process List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: Christian Borntraeger , Michael Mueller , qemu-devel@nongnu.org, =?UTF-8?q?Llu=C3=ADs?= From: Michael Mueller 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) This results in stale qemu processes. Fix this by deferring trace initialization. Signed-off-by: Michael Mueller [Christian Borntraeger: white space fixes] Signed-off-by: Christian Borntraeger --- vl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 25b8f2f..3c24108 100644 --- a/vl.c +++ b/vl.c @@ -3935,8 +3935,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 @@ -4429,6 +4431,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(); -- 1.8.1.4