qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-trivial] [PATCH v2] vl.c: move pidfile creation up the line
@ 2016-11-02 14:18 Michael Tokarev
  2016-11-02 14:22 ` [Qemu-trivial] [Qemu-devel] " Daniel P. Berrange
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michael Tokarev @ 2016-11-02 14:18 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Markus Armbruster, 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 <mjt@tls.msk.ru>
---
 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);
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-03  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 14:18 [Qemu-trivial] [PATCH v2] vl.c: move pidfile creation up the line Michael Tokarev
2016-11-02 14:22 ` [Qemu-trivial] [Qemu-devel] " Daniel P. Berrange
2016-11-03  7:35 ` Markus Armbruster
2016-11-03  8:41 ` [Qemu-trivial] " Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).