Received: from eggs.gnu.org ([2001:4830:134:3::10]:47968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c2Dao-000641-B3 for qemu-devel@nongnu.org; Thu, 03 Nov 2016 04:41:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c2Dan-0000AF-Jp for qemu-devel@nongnu.org; Thu, 03 Nov 2016 04:41:50 -0400 Sender: Paolo Bonzini References: <1478096330-18081-1-git-send-email-mjt@msgid.tls.msk.ru> From: Paolo Bonzini Message-ID: <3253b017-b854-a7ad-af1d-6a7f12e17f18@redhat.com> Date: Thu, 3 Nov 2016 09:41:39 +0100 MIME-Version: 1.0 In-Reply-To: <1478096330-18081-1-git-send-email-mjt@msgid.tls.msk.ru> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] vl.c: move pidfile creation up the line List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Tokarev , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Markus Armbruster On 02/11/2016 15:18, Michael Tokarev wrote: > 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 > --- > vl.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > v2: move the pid file creation even earlier, as per > comment by Markus Armbruster > > diff --git a/vl.c b/vl.c > index 368510f..ce7e998 100644 > --- a/vl.c > +++ b/vl.c > @@ -4058,6 +4058,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); > @@ -4335,11 +4340,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); > Queued, thanks. Paolo