]> xenbits.xensource.com Git - libvirt.git/commitdiff
libvirtd: Move pid_file_fd setup to before run_dir
authorJohn Ferlan <jferlan@redhat.com>
Mon, 6 Nov 2017 21:51:02 +0000 (16:51 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Sat, 18 Nov 2017 12:51:43 +0000 (07:51 -0500)
Once we have forked the daemon successfully, let's claim the pidfile
immediately rather than waiting for setup of run_dir.

daemon/libvirtd.c

index 589b32192e3d654052a6df3ea86708115c197ad6..4fc33ba0d4d03d2aa4591cf4a4a34c58bae3dbdf 100644 (file)
@@ -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;