]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: honour the RUNSTATEDIR variable in all code
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 20 Aug 2019 15:05:12 +0000 (16:05 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 27 Aug 2019 09:23:13 +0000 (10:23 +0100)
All code using LOCALSTATEDIR "/run" is updated to use RUNSTATEDIR
instead. The exception is the remote driver client which still
uses LOCALSTATEDIR "/run". The client needs to connect to remote
machines which may not be using /run, so /var/run is more portable
due to the /var/run -> /run symlink.

Some duplicate paths in the apparmor code are also purged.

There's no functional change by default yet since both expressions
expand to the same value.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
31 files changed:
src/bhyve/bhyve_utils.h
src/interface/interface_backend_netcf.c
src/interface/interface_backend_udev.c
src/libvirt-admin.c
src/libxl/libxl_conf.h
src/locking/lock_daemon.c
src/locking/lock_driver_lockd.c
src/locking/virtlockd.pod
src/logging/log_daemon.c
src/logging/log_manager.c
src/logging/virtlogd.pod
src/lxc/lxc_conf.h
src/lxc/lxc_process.c
src/network/bridge_driver.c
src/network/leaseshelper.c
src/node_device/node_device_hal.c
src/node_device/node_device_udev.c
src/nwfilter/nwfilter_dhcpsnoop.c
src/nwfilter/nwfilter_driver.c
src/qemu/qemu_conf.c
src/remote/libvirtd.pod
src/remote/remote_daemon.c
src/remote/remote_daemon_dispatch.c
src/remote/remote_driver.c
src/secret/secret_driver.c
src/security/virt-aa-helper.c
src/storage/storage_driver.c
src/util/virhostdev.c
src/util/virpidfile.c
src/util/virsystemd.c
src/vz/vz_driver.c

index 3d212e3ccfa83cbb27c11937f971449101f9a9cd..8dda6062b537426698f0eaf4ef02c517d8f5ff03 100644 (file)
@@ -31,7 +31,7 @@
 
 #define BHYVE_AUTOSTART_DIR    SYSCONFDIR "/libvirt/bhyve/autostart"
 #define BHYVE_CONFIG_DIR       SYSCONFDIR "/libvirt/bhyve"
-#define BHYVE_STATE_DIR        LOCALSTATEDIR "/run/libvirt/bhyve"
+#define BHYVE_STATE_DIR        RUNSTATEDIR "/libvirt/bhyve"
 #define BHYVE_LOG_DIR          LOCALSTATEDIR "/log/libvirt/bhyve"
 
 typedef struct _virBhyveDriverConfig virBhyveDriverConfig;
index eb509ccc1394197a1300e44b837809070005ff83..9659e9fcf192b881c1bcb8299b3a8cacefc23ef7 100644 (file)
@@ -102,7 +102,7 @@ netcfStateInitialize(bool privileged,
 
     if (privileged) {
         if (virAsprintf(&driver->stateDir,
-                        "%s/run/libvirt/interface", LOCALSTATEDIR) < 0)
+                        "%s/libvirt/interface", RUNSTATEDIR) < 0)
             goto error;
     } else {
         VIR_AUTOFREE(char *) rundir = NULL;
index ef748540d1639c77e23317d5fd48ce91624d9996..ddc3de534718987da76e91158a21d407cde2280e 100644 (file)
@@ -1181,7 +1181,7 @@ udevStateInitialize(bool privileged,
 
     if (privileged) {
         if (virAsprintf(&driver->stateDir,
-                        "%s/run/libvirt/interface", LOCALSTATEDIR) < 0)
+                        "%s/libvirt/interface", RUNSTATEDIR) < 0)
             goto cleanup;
     } else {
         VIR_AUTOFREE(char *) rundir = NULL;
index 6ad4436bff41e4449acec6728cd15b88d6f88fc5..ba88f098240d69280dfa3dcdec1721b12c7122f8 100644 (file)
@@ -149,7 +149,7 @@ getSocketPath(virURIPtr uri)
         }
 
         if (STREQ_NULLABLE(uri->path, "/system")) {
-            if (virAsprintf(&sock_path, LOCALSTATEDIR "/run/libvirt/%s",
+            if (virAsprintf(&sock_path, RUNSTATEDIR "/libvirt/%s",
                             sockbase) < 0)
                 goto error;
         } else if (STREQ_NULLABLE(uri->path, "/session")) {
index 552f039d2ab3bb3558c872d1f47281b389bdab17..27badfb2928f912ebda16bc04dcacaa768648c21 100644 (file)
@@ -48,7 +48,7 @@
 #define LIBXL_CONFIG_BASE_DIR SYSCONFDIR "/libvirt"
 #define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl"
 #define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart"
-#define LIBXL_STATE_DIR LOCALSTATEDIR "/run/libvirt/libxl"
+#define LIBXL_STATE_DIR RUNSTATEDIR "/libvirt/libxl"
 #define LIBXL_LOG_DIR LOCALSTATEDIR "/log/libvirt/libxl"
 #define LIBXL_LIB_DIR LOCALSTATEDIR "/lib/libvirt/libxl"
 #define LIBXL_SAVE_DIR LIBXL_LIB_DIR "/save"
index 104483267f72c91326d3b7ef328e5ac7b4174ff1..ac242bf65cf47d0e394758065d57a0af9eba03b1 100644 (file)
@@ -447,8 +447,8 @@ virLockDaemonUnixSocketPaths(bool privileged,
                              char **adminSockfile)
 {
     if (privileged) {
-        if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/virtlockd-sock") < 0 ||
-            VIR_STRDUP(*adminSockfile, LOCALSTATEDIR "/run/libvirt/virtlockd-admin-sock") < 0)
+        if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlockd-sock") < 0 ||
+            VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlockd-admin-sock") < 0)
             goto error;
     } else {
         char *rundir = NULL;
@@ -831,7 +831,7 @@ virLockDaemonExecRestartStatePath(bool privileged,
                                   char **state_file)
 {
     if (privileged) {
-        if (VIR_STRDUP(*state_file, LOCALSTATEDIR "/run/virtlockd-restart-exec.json") < 0)
+        if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlockd-restart-exec.json") < 0)
             goto error;
     } else {
         char *rundir = NULL;
@@ -1062,14 +1062,14 @@ virLockDaemonUsage(const char *argv0, bool privileged)
                   "      %s/libvirt/virtlockd.conf\n"
                   "\n"
                   "    Sockets:\n"
-                  "      %s/run/libvirt/virtlockd-sock\n"
+                  "      %s/libvirt/virtlockd-sock\n"
                   "\n"
                   "    PID file (unless overridden by -p):\n"
-                  "      %s/run/virtlockd.pid\n"
+                  "      %s/virtlockd.pid\n"
                   "\n"),
                 SYSCONFDIR,
-                LOCALSTATEDIR,
-                LOCALSTATEDIR);
+                RUNSTATEDIR,
+                RUNSTATEDIR);
     } else {
         fprintf(stderr, "%s",
                 _("\n"
@@ -1221,7 +1221,7 @@ int main(int argc, char **argv) {
 
     if (!pid_file &&
         virPidFileConstructPath(privileged,
-                                LOCALSTATEDIR,
+                                RUNSTATEDIR,
                                 "virtlockd",
                                 &pid_file) < 0) {
         VIR_ERROR(_("Can't determine pid file path."));
@@ -1248,7 +1248,7 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
-        if (VIR_STRDUP_QUIET(run_dir, LOCALSTATEDIR "/run/libvirt") < 0)
+        if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0)
             goto no_memory;
     } else {
         if (!(run_dir = virGetUserRuntimeDirectory())) {
index f6371f30503b9d2a3154ebd9e071e8a2fa09aaa2..164f83eb4ba9f780e6f2637e69fcfc0ae56eff91 100644 (file)
@@ -124,7 +124,7 @@ static char *virLockManagerLockDaemonPath(bool privileged)
 {
     char *path;
     if (privileged) {
-        if (VIR_STRDUP(path, LOCALSTATEDIR "/run/libvirt/virtlockd-sock") < 0)
+        if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlockd-sock") < 0)
             return NULL;
     } else {
         char *rundir = NULL;
index de0eb8ac18e451dcf01d83e2314a2f5fa635d8d2..0b9f758e292e08a1da0506fef4e2f1e57e9c7519 100644 (file)
@@ -72,11 +72,11 @@ upgrades of the virtlockd service.
 The default configuration file used by virtlockd, unless overridden on the
 command line using the B<-f>|B<--config> option.
 
-=item F<LOCALSTATEDIR/run/libvirt/virtlockd-sock>
+=item F<RUNSTATEDIR/libvirt/virtlockd-sock>
 
 The sockets libvirtd will use.
 
-=item F<LOCALSTATEDIR/run/virtlockd.pid>
+=item F<RUNSTATEDIR/virtlockd.pid>
 
 The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
 
@@ -116,8 +116,8 @@ To retrieve the version of virtlockd:
 To start virtlockd, instructing it to daemonize and create a PID file:
 
  # virtlockd -d
- # ls -la LOCALSTATEDIR/run/virtlockd.pid
- -rw-r--r-- 1 root root 6 Jul  9 02:40 LOCALSTATEDIR/run/virtlockd.pid
+ # ls -la RUNSTATEDIR/virtlockd.pid
+ -rw-r--r-- 1 root root 6 Jul  9 02:40 RUNSTATEDIR/virtlockd.pid
  #
 
 =head1 BUGS
index 4103f2cefe36ee605f51142e39395d4c6bc5fa9e..f74e900aea740b98d8b26ac78a861ef0897daec2 100644 (file)
@@ -388,8 +388,8 @@ virLogDaemonUnixSocketPaths(bool privileged,
                             char **adminSockfile)
 {
     if (privileged) {
-        if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/virtlogd-sock") < 0 ||
-            VIR_STRDUP(*adminSockfile, LOCALSTATEDIR "/run/libvirt/virtlogd-admin-sock") < 0)
+        if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0 ||
+            VIR_STRDUP(*adminSockfile, RUNSTATEDIR "/libvirt/virtlogd-admin-sock") < 0)
             goto error;
     } else {
         char *rundir = NULL;
@@ -623,7 +623,7 @@ virLogDaemonExecRestartStatePath(bool privileged,
                                  char **state_file)
 {
     if (privileged) {
-        if (VIR_STRDUP(*state_file, LOCALSTATEDIR "/run/virtlogd-restart-exec.json") < 0)
+        if (VIR_STRDUP(*state_file, RUNSTATEDIR "/virtlogd-restart-exec.json") < 0)
             goto error;
     } else {
         char *rundir = NULL;
@@ -834,14 +834,14 @@ virLogDaemonUsage(const char *argv0, bool privileged)
                   "      %s/libvirt/virtlogd.conf\n"
                   "\n"
                   "    Sockets:\n"
-                  "      %s/run/libvirt/virtlogd-sock\n"
+                  "      %s/libvirt/virtlogd-sock\n"
                   "\n"
                   "    PID file (unless overridden by -p):\n"
-                  "      %s/run/virtlogd.pid\n"
+                  "      %s/virtlogd.pid\n"
                   "\n"),
                 SYSCONFDIR,
-                LOCALSTATEDIR,
-                LOCALSTATEDIR);
+                RUNSTATEDIR,
+                RUNSTATEDIR);
     } else {
         fprintf(stderr, "%s",
                 _("\n"
@@ -992,7 +992,7 @@ int main(int argc, char **argv) {
 
     if (!pid_file &&
         virPidFileConstructPath(privileged,
-                                LOCALSTATEDIR,
+                                RUNSTATEDIR,
                                 "virtlogd",
                                 &pid_file) < 0) {
         VIR_ERROR(_("Can't determine pid file path."));
@@ -1019,7 +1019,7 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
-        if (VIR_STRDUP_QUIET(run_dir, LOCALSTATEDIR "/run/libvirt") < 0)
+        if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0)
             goto no_memory;
     } else {
         if (!(run_dir = virGetUserRuntimeDirectory())) {
index eb0a32b4b62e49926581e138f946c1d9a7167049..1613d1f8a8c7b970cb3f5581b3db47a1713b5286 100644 (file)
@@ -45,7 +45,7 @@ virLogManagerDaemonPath(bool privileged)
 {
     char *path;
     if (privileged) {
-        if (VIR_STRDUP(path, LOCALSTATEDIR "/run/libvirt/virtlogd-sock") < 0)
+        if (VIR_STRDUP(path, RUNSTATEDIR "/libvirt/virtlogd-sock") < 0)
             return NULL;
     } else {
         char *rundir = NULL;
index 5e44f84a8516d107554ab9c339055a091c665a05..01dde99296ef6665da6864e33613e62c9cdf45a1 100644 (file)
@@ -72,11 +72,11 @@ upgrades of the virtlogd service.
 The default configuration file used by virtlogd, unless overridden on the
 command line using the B<-f>|B<--config> option.
 
-=item F<LOCALSTATEDIR/run/libvirt/virtlogd-sock>
+=item F<RUNSTATEDIR/libvirt/virtlogd-sock>
 
 The sockets libvirtd will use.
 
-=item F<LOCALSTATEDIR/run/virtlogd.pid>
+=item F<RUNSTATEDIR/virtlogd.pid>
 
 The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
 
@@ -116,8 +116,8 @@ To retrieve the version of virtlogd:
 To start virtlogd, instructing it to daemonize and create a PID file:
 
  # virtlogd -d
- # ls -la LOCALSTATEDIR/run/virtlogd.pid
- -rw-r--r-- 1 root root 6 Jul  9 02:40 LOCALSTATEDIR/run/virtlogd.pid
+ # ls -la RUNSTATEDIR/virtlogd.pid
+ -rw-r--r-- 1 root root 6 Jul  9 02:40 RUNSTATEDIR/virtlogd.pid
  #
 
 =head1 BUGS
index e26ca22d3cfc7d66879221a7c63141f2ed0e8393..12a201db381c3752801c32f90d4cf0d8e3e621ba 100644 (file)
@@ -38,7 +38,7 @@
 #define LXC_DRIVER_NAME "LXC"
 
 #define LXC_CONFIG_DIR SYSCONFDIR "/libvirt/lxc"
-#define LXC_STATE_DIR LOCALSTATEDIR "/run/libvirt/lxc"
+#define LXC_STATE_DIR RUNSTATEDIR "/libvirt/lxc"
 #define LXC_LOG_DIR LOCALSTATEDIR "/log/libvirt/lxc"
 #define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
 
index 3d03086ea74e478d8be5a62f05c1772ddd6a9898..cd65e7a0c0c9ba8e222d7a8d0ca49abeca551fac 100644 (file)
@@ -470,7 +470,7 @@ static int virLXCProcessSetupNamespaceNet(int ns_type, const char *name)
         return -1;
     }
 
-    if (virAsprintf(&path, "/var/run/netns/%s", name) < 0)
+    if (virAsprintf(&path, "%s/netns/%s", RUNSTATEDIR, name) < 0)
         return  -1;
     fd = open(path, O_RDONLY);
     VIR_FREE(path);
index 86e2035b8554ce650cef63607486fc42c70a381c..7b441846161a244b81f3ba5509d00d958b4f016f 100644 (file)
@@ -726,9 +726,9 @@ networkStateInitialize(bool privileged,
             VIR_STRDUP(network_driver->networkAutostartDir,
                        SYSCONFDIR "/libvirt/qemu/networks/autostart") < 0 ||
             VIR_STRDUP(network_driver->stateDir,
-                       LOCALSTATEDIR "/run/libvirt/network") < 0 ||
+                       RUNSTATEDIR "/libvirt/network") < 0 ||
             VIR_STRDUP(network_driver->pidDir,
-                       LOCALSTATEDIR "/run/libvirt/network") < 0 ||
+                       RUNSTATEDIR "/libvirt/network") < 0 ||
             VIR_STRDUP(network_driver->dnsmasqStateDir,
                        LOCALSTATEDIR "/lib/libvirt/dnsmasq") < 0 ||
             VIR_STRDUP(network_driver->radvdStateDir,
index 481f29aa59d89060bd4180e5b5aa65ef5496eede..5e04e16171d112f4d8cc60de9fb82823a7ca3973 100644 (file)
@@ -160,7 +160,7 @@ main(int argc, char **argv)
                     interface) < 0)
         goto cleanup;
 
-    if (VIR_STRDUP(pid_file, LOCALSTATEDIR "/run/leaseshelper.pid") < 0)
+    if (VIR_STRDUP(pid_file, RUNSTATEDIR "/leaseshelper.pid") < 0)
         goto cleanup;
 
     /* Try to claim the pidfile, exiting if we can't */
index d46e4e98f3790e25298821ccd0d75c387f6e4509..c613ca580873243a9662054c60d55b439bd01efe 100644 (file)
@@ -619,7 +619,7 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
 
     if (privileged) {
         if (virAsprintf(&driver->stateDir,
-                        "%s/run/libvirt/nodedev", LOCALSTATEDIR) < 0)
+                        "%s/libvirt/nodedev", RUNSTATEDIR) < 0)
             goto failure;
     } else {
         VIR_AUTOFREE(char *) rundir = NULL;
index adf60e45379a3e603f7e7f24a97d67b71f48b660..5550ee3a54c01143819c95896c2ccc66460cfc5a 100644 (file)
@@ -1830,7 +1830,7 @@ nodeStateInitialize(bool privileged,
 
     if (privileged) {
         if (virAsprintf(&driver->stateDir,
-                        "%s/run/libvirt/nodedev", LOCALSTATEDIR) < 0)
+                        "%s/libvirt/nodedev", RUNSTATEDIR) < 0)
             goto cleanup;
     } else {
         VIR_AUTOFREE(char *) rundir = NULL;
index d8a1e7f8a809579e51ba8bbb591f775c387ccd9e..2af8cfdd321cab139711987a261ae3294d81f83e 100644 (file)
@@ -29,7 +29,7 @@
  *      while :; do kill -SIGTERM `pidof dhclient`; dhclient eth0; ifconfig eth0; done
  *
  *   On the host check the lease file and that it's periodically shortened:
- *      cat /var/run/libvirt/network/nwfilter.leases; date +%s
+ *      cat $runstatedir/libvirt/network/nwfilter.leases; date +%s
  *
  *   On the host also check that the ebtables rules 'look' ok:
  *      ebtables -t nat -L
@@ -71,7 +71,7 @@ VIR_LOG_INIT("nwfilter.nwfilter_dhcpsnoop");
 
 #ifdef HAVE_LIBPCAP
 
-# define LEASEFILE_DIR LOCALSTATEDIR "/run/libvirt/network/"
+# define LEASEFILE_DIR RUNSTATEDIR "/libvirt/network/"
 # define LEASEFILE LEASEFILE_DIR "nwfilter.leases"
 # define TMPLEASEFILE LEASEFILE_DIR "nwfilter.ltmp"
 
index 607314343730a79a37d98e24c91143a4be059587..aef5bd4c7fcd9ca4e553f02549d3f55bc791d01d 100644 (file)
@@ -205,7 +205,7 @@ nwfilterStateInitialize(bool privileged,
 
     nwfilterDriverLock();
 
-    if (VIR_STRDUP(driver->stateDir, LOCALSTATEDIR "/run/libvirt/nwfilter") < 0)
+    if (VIR_STRDUP(driver->stateDir, RUNSTATEDIR "/libvirt/nwfilter") < 0)
         goto error;
 
     if (virFileMakePathWithMode(driver->stateDir, S_IRWXU) < 0) {
@@ -261,7 +261,7 @@ nwfilterStateInitialize(bool privileged,
         goto error;
     }
 
-    if (VIR_STRDUP(driver->bindingDir, LOCALSTATEDIR "/run/libvirt/nwfilter-binding") < 0)
+    if (VIR_STRDUP(driver->bindingDir, RUNSTATEDIR "/libvirt/nwfilter-binding") < 0)
         goto error;
 
     if (virFileMakePathWithMode(driver->bindingDir, S_IRWXU) < 0) {
index 295389333770d0a55d81b118197282056acef779..89c183e46acce5565a043bb570e5b73ad64aa15e 100644 (file)
@@ -142,11 +142,11 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged)
             goto error;
 
         if (virAsprintf(&cfg->stateDir,
-                      "%s/run/libvirt/qemu", LOCALSTATEDIR) < 0)
+                      "%s/libvirt/qemu", RUNSTATEDIR) < 0)
             goto error;
 
         if (virAsprintf(&cfg->swtpmStateDir,
-                       "%s/run/libvirt/qemu/swtpm", LOCALSTATEDIR) < 0)
+                       "%s/libvirt/qemu/swtpm", RUNSTATEDIR) < 0)
             goto error;
 
         if (virAsprintf(&cfg->cacheDir,
index 4721e0f4ecd7a0a2baef10ce84080aede696bca5..4988f0f7fa15e15ec39572851954441014a07caa 100644 (file)
@@ -84,9 +84,9 @@ On receipt of B<SIGHUP> libvirtd will reload its configuration.
 The default configuration file used by libvirtd, unless overridden on the
 command line using the B<-f>|B<--config> option.
 
-=item F<LOCALSTATEDIR/run/libvirt/libvirt-sock>
+=item F<RUNSTATEDIR/libvirt/libvirt-sock>
 
-=item F<LOCALSTATEDIR/run/libvirt/libvirt-sock-ro>
+=item F<RUNSTATEDIR/libvirt/libvirt-sock-ro>
 
 The sockets libvirtd will use.
 
@@ -102,7 +102,7 @@ The TLS B<Server> certificate libvirtd will use.
 
 The TLS B<Server> private key libvirtd will use.
 
-=item F<LOCALSTATEDIR/run/libvirtd.pid>
+=item F<RUNSTATEDIR/libvirtd.pid>
 
 The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
 
@@ -154,8 +154,8 @@ To retrieve the version of libvirtd:
 To start libvirtd, instructing it to daemonize and create a PID file:
 
  # libvirtd -d
- # ls -la LOCALSTATEDIR/run/libvirtd.pid
- -rw-r--r-- 1 root root 6 Jul  9 02:40 LOCALSTATEDIR/run/libvirtd.pid
+ # ls -la RUNSTATEDIR/libvirtd.pid
+ -rw-r--r-- 1 root root 6 Jul  9 02:40 RUNSTATEDIR/libvirtd.pid
  #
 
 =head1 BUGS
index 11384858705e1b9c02c5bd36d87ecfe4e90462d0..3edc357feaef2f3dc0c2cd6640b09dbbb669f944 100644 (file)
@@ -238,12 +238,12 @@ daemonUnixSocketPaths(struct daemonConfig *config,
         }
     } else {
         if (privileged) {
-            if (virAsprintf(sockfile, "%s/run/libvirt/%s-sock",
-                            LOCALSTATEDIR, SOCK_PREFIX) < 0 ||
-                virAsprintf(rosockfile, "%s/run/libvirt/%s-sock-ro",
-                            LOCALSTATEDIR, SOCK_PREFIX) < 0 ||
-                virAsprintf(admsockfile, "%s/run/libvirt/%s-admin-sock",
-                            LOCALSTATEDIR, SOCK_PREFIX) < 0)
+            if (virAsprintf(sockfile, "%s/libvirt/%s-sock",
+                            RUNSTATEDIR, SOCK_PREFIX) < 0 ||
+                virAsprintf(rosockfile, "%s/libvirt/%s-sock-ro",
+                            RUNSTATEDIR, SOCK_PREFIX) < 0 ||
+                virAsprintf(admsockfile, "%s/libvirt/%s-admin-sock",
+                            RUNSTATEDIR, SOCK_PREFIX) < 0)
                 goto cleanup;
         } else {
             mode_t old_umask;
@@ -945,11 +945,11 @@ daemonUsage(const char *argv0, bool privileged)
 
     fprintf(stderr, "    %s\n", _("Sockets:"));
     fprintf(stderr, "      %s/libvirt/%s-sock\n",
-            privileged ? LOCALSTATEDIR "/run" : "$XDG_RUNTIME_DIR",
+            privileged ? RUNSTATEDIR : "$XDG_RUNTIME_DIR",
             SOCK_PREFIX);
     if (privileged)
-        fprintf(stderr, "      %s/run/libvirt/%s-sock-ro\n",
-                LOCALSTATEDIR, SOCK_PREFIX);
+        fprintf(stderr, "      %s/libvirt/%s-sock-ro\n",
+                RUNSTATEDIR, SOCK_PREFIX);
     fprintf(stderr, "\n");
 
 #ifdef WITH_IP
@@ -969,7 +969,7 @@ daemonUsage(const char *argv0, bool privileged)
     fprintf(stderr, "    %s\n",
             _("PID file (unless overridden by -p):"));
     fprintf(stderr, "      %s/%s.pid\n",
-            privileged ? LOCALSTATEDIR "/run" : "$XDG_RUNTIME_DIR/libvirt",
+            privileged ? RUNSTATEDIR : "$XDG_RUNTIME_DIR/libvirt",
             DAEMON_NAME);
     fprintf(stderr, "\n");
 }
@@ -1149,7 +1149,7 @@ int main(int argc, char **argv) {
 
     if (!pid_file &&
         virPidFileConstructPath(privileged,
-                                LOCALSTATEDIR,
+                                RUNSTATEDIR,
                                 DAEMON_NAME,
                                 &pid_file) < 0) {
         VIR_ERROR(_("Can't determine pid file path."));
@@ -1194,7 +1194,7 @@ int main(int argc, char **argv) {
 
     /* Ensure the rundir exists (on tmpfs on some systems) */
     if (privileged) {
-        if (VIR_STRDUP_QUIET(run_dir, LOCALSTATEDIR "/run/libvirt") < 0) {
+        if (VIR_STRDUP_QUIET(run_dir, RUNSTATEDIR "/libvirt") < 0) {
             VIR_ERROR(_("Can't allocate memory"));
             goto cleanup;
         }
index 2d00a0cb77007e2508fed614e1c9a951f44bd911..fb8b95f3157cbf603234907222602eb0e1f64d24 100644 (file)
@@ -2192,8 +2192,8 @@ remoteDispatchProbeURI(bool readonly,
         for (i = 0; i < (ssize_t) ARRAY_CARDINALITY(drivers) && !*probeduri; i++) {
             VIR_AUTOFREE(char *) sockname = NULL;
 
-            if (virAsprintf(&sockname, "%s/run/libvirt/virt%sd-%s",
-                            LOCALSTATEDIR, drivers[i],
+            if (virAsprintf(&sockname, "%s/libvirt/virt%sd-%s",
+                            RUNSTATEDIR, drivers[i],
                             readonly ? "sock-ro" : "sock") < 0)
                 return -1;
 
index 32ff6229a6e460247c155653879a5c421c427145..8cc7ab3663036c810fe0e75a77102e668bf7b636 100644 (file)
@@ -789,6 +789,12 @@ remoteGetUNIXSocketHelper(remoteDriverTransport transport,
                         userdir, sock_prefix) < 0)
             return NULL;
     } else {
+        /* Intentionally do *NOT* use RUNSTATEDIR here. We might
+         * be connecting to a remote machine, and cannot assume
+         * the remote host has /run. The converse is ok though,
+         * any machine with /run will have a /var/run symlink.
+         * The portable option is to thus use $LOCALSTATEDIR/run
+         */
         if (virAsprintf(&sockname, "%s/run/libvirt/%s-%s",
                         LOCALSTATEDIR, sock_prefix,
                         flags & VIR_DRV_OPEN_REMOTE_RO ?
index 0d5ea05f56fc5683082777879ca36fbab0d44f82..7512a51c74069e31fd5d76d3570dffd68daa2d1c 100644 (file)
@@ -474,7 +474,7 @@ secretStateInitialize(bool privileged,
                         "%s/libvirt/secrets", SYSCONFDIR) < 0)
             goto error;
         if (virAsprintf(&driver->stateDir,
-                        "%s/run/libvirt/secrets", LOCALSTATEDIR) < 0)
+                        "%s/libvirt/secrets", RUNSTATEDIR) < 0)
             goto error;
     } else {
         VIR_AUTOFREE(char *) rundir = NULL;
index 60c9b75980701c89cc19ca421523aaf96962556d..3f9d775acce5e367eda9b23947e109eb2c32a00d 100644 (file)
@@ -1232,8 +1232,8 @@ get_files(vahControl * ctl)
 
             /* Unix socket for QEMU and swtpm to use */
             virBufferAsprintf(&buf,
-                "  \"/run/libvirt/qemu/swtpm/%s-swtpm.sock\" rw,\n",
-                shortName);
+                "  \"%s/libvirt/qemu/swtpm/%s-swtpm.sock\" rw,\n",
+                RUNSTATEDIR, shortName);
             /* Paths for swtpm to use: give it access to its state
              * directory, log, and PID files.
              */
@@ -1244,8 +1244,8 @@ get_files(vahControl * ctl)
                 "  \"%s/log/swtpm/libvirt/qemu/%s-swtpm.log\" a,\n",
                 LOCALSTATEDIR, ctl->def->name);
             virBufferAsprintf(&buf,
-                "  \"/run/libvirt/qemu/swtpm/%s-swtpm.pid\" rw,\n",
-                shortName);
+                "  \"%s/libvirt/qemu/swtpm/%s-swtpm.pid\" rw,\n",
+                RUNSTATEDIR, shortName);
 
             VIR_FREE(shortName);
             break;
@@ -1486,14 +1486,10 @@ main(int argc, char **argv)
                                   LOCALSTATEDIR, ctl->def->name);
                 virBufferAsprintf(&buf, "  \"%s/lib/libvirt/qemu/domain-%d-%.*s/*\" rw,\n",
                                   LOCALSTATEDIR, ctl->def->id, 20, ctl->def->name);
-                virBufferAsprintf(&buf, "  \"%s/run/libvirt/**/%s.pid\" rwk,\n",
-                                  LOCALSTATEDIR, ctl->def->name);
-                virBufferAsprintf(&buf, "  \"/run/libvirt/**/%s.pid\" rwk,\n",
-                                  ctl->def->name);
-                virBufferAsprintf(&buf, "  \"%s/run/libvirt/**/*.tunnelmigrate.dest.%s\" rw,\n",
-                                  LOCALSTATEDIR, ctl->def->name);
-                virBufferAsprintf(&buf, "  \"/run/libvirt/**/*.tunnelmigrate.dest.%s\" rw,\n",
-                                  ctl->def->name);
+                virBufferAsprintf(&buf, "  \"%s/libvirt/**/%s.pid\" rwk,\n",
+                                  RUNSTATEDIR, ctl->def->name);
+                virBufferAsprintf(&buf, "  \"%s/libvirt/**/*.tunnelmigrate.dest.%s\" rw,\n",
+                                  RUNSTATEDIR, ctl->def->name);
             }
             if (ctl->files)
                 virBufferAdd(&buf, ctl->files, -1);
index 30940b5dcf924ad122765a32936827f77aad3863..ce10b55ed07e4bde67f4b30d3407725b64a10659 100644 (file)
@@ -278,7 +278,7 @@ storageStateInitialize(bool privileged,
             VIR_STRDUP(driver->autostartDir,
                        SYSCONFDIR "/libvirt/storage/autostart") < 0 ||
             VIR_STRDUP(driver->stateDir,
-                       LOCALSTATEDIR "/run/libvirt/storage") < 0)
+                       RUNSTATEDIR "/libvirt/storage") < 0)
             goto error;
     } else {
         configdir = virGetUserConfigDirectory();
index 6ba91ae9e44e77958aa2211c00ab100d7eb43171..d710193b94d5e86d11c0ce29afa60844fa496ede 100644 (file)
@@ -41,7 +41,7 @@
 
 VIR_LOG_INIT("util.hostdev");
 
-#define HOSTDEV_STATE_DIR LOCALSTATEDIR "/run/libvirt/hostdevmgr"
+#define HOSTDEV_STATE_DIR RUNSTATEDIR "/libvirt/hostdevmgr"
 
 static virHostdevManagerPtr manager; /* global hostdev manager, never freed */
 
index 999bccbee42b5f7db91f8f08a65f3714a239b955..a600cfc6624592ed2507c6302e6b56f6b48b97d0 100644 (file)
@@ -479,7 +479,7 @@ int virPidFileRelease(const char *dir,
 
 int
 virPidFileConstructPath(bool privileged,
-                        const char *statedir,
+                        const char *runstatedir,
                         const char *progname,
                         char **pidfile)
 {
@@ -490,12 +490,12 @@ virPidFileConstructPath(bool privileged,
          * This is here just to allow calling this function with
          * statedir == NULL; of course only when !privileged.
          */
-        if (!statedir) {
+        if (!runstatedir) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           "%s", _("No statedir specified"));
+                           "%s", _("No runstatedir specified"));
             return -1;
         }
-        if (virAsprintf(pidfile, "%s/run/%s.pid", statedir, progname) < 0)
+        if (virAsprintf(pidfile, "%s/%s.pid", runstatedir, progname) < 0)
             return -1;
     } else {
         if (!(rundir = virGetUserRuntimeDirectory()))
index e75c5b835a569dbbb8dc28e1bcecdfed72e82735..2efc0dd72c7d6857d786c164aa7eb57f8d7924fb 100644 (file)
@@ -749,29 +749,40 @@ virSystemdActivationInitFromMap(virSystemdActivationPtr act,
             goto error;
         }
 
+        VIR_DEBUG("Got socket family %d for FD %d",
+                  addr.data.sa.sa_family, nextfd);
+
         for (i = 0; i < nmap && !name; i++) {
             if (map[i].name == NULL)
                 continue;
 
             if (addr.data.sa.sa_family == AF_INET) {
-                if (map[i].family == AF_INET &&
-                    addr.data.inet4.sin_port == htons(map[i].port))
-                    name = map[i].name;
+                if (map[i].family == AF_INET) {
+                    VIR_DEBUG("Expect %d got %d",
+                              map[i].port, ntohs(addr.data.inet4.sin_port));
+                    if (addr.data.inet4.sin_port == htons(map[i].port))
+                        name = map[i].name;
+                }
             } else if (addr.data.sa.sa_family == AF_INET6) {
                 /* NB use of AF_INET here is correct. The "map" struct
                  * only refers to AF_INET. The socket may be AF_INET
                  * or AF_INET6
                  */
-                if (map[i].family == AF_INET &&
-                    addr.data.inet6.sin6_port == htons(map[i].port))
-                    name = map[i].name;
+                if (map[i].family == AF_INET) {
+                    VIR_DEBUG("Expect %d got %d",
+                              map[i].port, ntohs(addr.data.inet6.sin6_port));
+                    if (addr.data.inet6.sin6_port == htons(map[i].port))
+                        name = map[i].name;
+                }
 #ifndef WIN32
             } else if (addr.data.sa.sa_family == AF_UNIX) {
-                if (map[i].family == AF_UNIX &&
-                    STREQLEN(map[i].path,
-                             addr.data.un.sun_path,
-                             sizeof(addr.data.un.sun_path)))
-                    name = map[i].name;
+                if (map[i].family == AF_UNIX) {
+                    VIR_DEBUG("Expect %s got %s", map[i].path, addr.data.un.sun_path);
+                    if (STREQLEN(map[i].path,
+                                 addr.data.un.sun_path,
+                                 sizeof(addr.data.un.sun_path)))
+                        name = map[i].name;
+                }
 #endif
             } else {
                 virReportError(VIR_ERR_INTERNAL_ERROR,
index da72b209d1740b4613c307a8539e60b801359f0b..a4f6c39cb7d71473fd280d2b4037c1ca4498ec5b 100644 (file)
@@ -60,7 +60,7 @@ VIR_LOG_INIT("parallels.parallels_driver");
 
 #define PRLCTL                      "prlctl"
 
-#define VZ_STATEDIR LOCALSTATEDIR "/run/libvirt/vz"
+#define VZ_STATEDIR RUNSTATEDIR "/libvirt/vz"
 
 static virClassPtr vzDriverClass;