[libvirt] [PATCH 1/5] libvirtd: Move pid_file_fd setup to before run_dir

John Ferlan posted 5 patches 7 years, 6 months ago
[libvirt] [PATCH 1/5] libvirtd: Move pid_file_fd setup to before run_dir
Posted by John Ferlan 7 years, 6 months ago
Once we have forked the daemon successfully, let's claim the pidfile
immediately rather than waiting for setup of run_dir.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 daemon/libvirtd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 589b32192e..4fc33ba0d4 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1258,6 +1258,12 @@ int main(int argc, char **argv) {
         }
     }
 
+    /* Try to claim the pidfile, exiting if we can't */
+    if ((pid_file_fd = virPidFileAcquirePath(pid_file, false, getpid())) < 0) {
+        ret = VIR_DAEMON_ERR_PIDFILE;
+        goto cleanup;
+    }
+
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
         if (VIR_STRDUP_QUIET(run_dir, LOCALSTATEDIR "/run/libvirt") < 0) {
@@ -1286,12 +1292,6 @@ int main(int argc, char **argv) {
     }
     umask(old_umask);
 
-    /* Try to claim the pidfile, exiting if we can't */
-    if ((pid_file_fd = virPidFileAcquirePath(pid_file, false, getpid())) < 0) {
-        ret = VIR_DAEMON_ERR_PIDFILE;
-        goto cleanup;
-    }
-
     if (virNetlinkStartup() < 0) {
         ret = VIR_DAEMON_ERR_INIT;
         goto cleanup;
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/5] libvirtd: Move pid_file_fd setup to before run_dir
Posted by Erik Skultety 7 years, 6 months ago
On Tue, Nov 07, 2017 at 09:39:52PM -0500, John Ferlan wrote:
> Once we have forked the daemon successfully, let's claim the pidfile
> immediately rather than waiting for setup of run_dir.
>
> Signed-off-by: John Ferlan <jferlan@redhat.com>

Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list