From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4tWt-0004ty-5v for qemu-devel@nongnu.org; Thu, 10 Nov 2016 12:52:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4tWr-0003Lq-K3 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 12:52:51 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4tWr-0003LS-D7 for qemu-devel@nongnu.org; Thu, 10 Nov 2016 12:52:49 -0500 Received: by mail-wm0-x244.google.com with SMTP id a20so4610327wme.2 for ; Thu, 10 Nov 2016 09:52:49 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 10 Nov 2016 18:52:38 +0100 Message-Id: <1478800362-18138-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1478800362-18138-1-git-send-email-pbonzini@redhat.com> References: <1478800362-18138-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 2/6] vl.c: move pidfile creation up the line List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Tokarev From: Michael Tokarev With current code, pid file is open after various sockets, chardevs, fsdevs and the like. This causes interesting effects, for example when monitor is a unix-socket, and another qemu instance is already running, new qemu first "damages" the socket and next complain that it can't acquire the pid file and exits, making running qemu unreachable. Move pid file creation earlier, right after the call to os_daemonize(), where we know our process id (pid). Signed-off-by: Michael Tokarev Message-Id: <1478096330-18081-1-git-send-email-mjt@msgid.tls.msk.ru> Reviewed-by: Daniel P. Berrange Reviewed-by: Markus Armbruster Signed-off-by: Paolo Bonzini --- vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 319f641..d77dd86 100644 --- a/vl.c +++ b/vl.c @@ -4063,6 +4063,11 @@ int main(int argc, char **argv, char **envp) os_daemonize(); + if (pid_file && qemu_create_pidfile(pid_file) != 0) { + error_report("could not acquire pid file: %s", strerror(errno)); + exit(1); + } + if (qemu_init_main_loop(&main_loop_err)) { error_report_err(main_loop_err); exit(1); @@ -4340,11 +4345,6 @@ int main(int argc, char **argv, char **envp) } #endif - if (pid_file && qemu_create_pidfile(pid_file) != 0) { - error_report("could not acquire pid file: %s", strerror(errno)); - exit(1); - } - if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func, NULL, NULL)) { exit(0); -- 1.8.3.1