qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michael Tokarev <mjt@tls.msk.ru>
Subject: [Qemu-devel] [PULL 2/6] vl.c: move pidfile creation up the line
Date: Thu, 10 Nov 2016 18:52:38 +0100	[thread overview]
Message-ID: <1478800362-18138-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1478800362-18138-1-git-send-email-pbonzini@redhat.com>

From: Michael Tokarev <mjt@tls.msk.ru>

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>
Message-Id: <1478096330-18081-1-git-send-email-mjt@msgid.tls.msk.ru>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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

  parent reply	other threads:[~2016-11-10 17:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 17:52 [Qemu-devel] [PULL 0/6] QEMU patches for 2.8.0-rc0 Paolo Bonzini
2016-11-10 17:52 ` [Qemu-devel] [PULL 1/6] target-i386: fix typo Paolo Bonzini
2016-11-10 17:52 ` Paolo Bonzini [this message]
2016-11-10 17:52 ` [Qemu-devel] [PULL 3/6] target-i386/machine: fix migrate faile because of Hyper-V HV_X64_MSR_VP_RUNTIME Paolo Bonzini
2016-11-10 17:52 ` [Qemu-devel] [PULL 4/6] qdev: fix use-after-free regression from becdfa00cfa Paolo Bonzini
2016-11-10 17:52 ` [Qemu-devel] [PULL 5/6] target-i386: document how x86 gdb_num_core_regs is computed Paolo Bonzini
2016-11-10 17:52 ` [Qemu-devel] [PULL 6/6] nbd: Don't inf-loop on early EOF Paolo Bonzini
2016-11-11 12:51 ` [Qemu-devel] [PULL 0/6] QEMU patches for 2.8.0-rc0 Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478800362-18138-3-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).