On Sun, 17 Nov 2019 12:28:38 +0100 Laurent Bigonville <bi...@debian.org>
wrote:
> Package: libvirt-daemon-system
> Version: 5.6.0-2
> Severity: minor
> 
> Hello,
> 
> During boot, systemd complains that the .service and .socket files are
> pointing to /var/run instead of /run:
> 
> systemd[1]: /lib/systemd/system/virtlockd.socket:6: ListenStream= references 
> a path below legacy directory /var/run/, updating 
> /var/run/libvirt/virtlockd-sock → /run/libvirt/virtlockd-sock; please update 
> the unit file accordingly.
> systemd[1]: /lib/systemd/system/virtlockd-admin.socket:8: ListenStream= 
> references a path below legacy directory /var/run/, updating 
> /var/run/libvirt/virtlockd-admin-sock → /run/libvirt/virtlockd-admin-sock; 
> please update the unit file accordingly.
> systemd[1]: /lib/systemd/system/libvirtd-admin.socket:8: ListenStream= 
> references a path below legacy directory /var/run/, updating 
> /var/run/libvirt/libvirt-admin-sock → /run/libvirt/libvirt-admin-sock; please 
> update the unit file accordingly.
> systemd[1]: /lib/systemd/system/libvirtd-ro.socket:8: ListenStream= 
> references a path below legacy directory /var/run/, updating 
> /var/run/libvirt/libvirt-sock-ro → /run/libvirt/libvirt-sock-ro; please 
> update the unit file accordingly.
> systemd[1]: /lib/systemd/system/libvirtd.socket:6: ListenStream= references a 
> path below legacy directory /var/run/, updating /var/run/libvirt/libvirt-sock 
> → /run/libvirt/libvirt-sock; please update the unit file accordingly.
> systemd[1]: /lib/systemd/system/virtlogd.socket:6: ListenStream= references a 
> path below legacy directory /var/run/, updating 
> /var/run/libvirt/virtlogd-sock → /run/libvirt/virtlogd-sock; please update 
> the unit file accordingly.
> systemd[1]: /lib/systemd/system/virtlogd-admin.socket:8: ListenStream= 
> references a path below legacy directory /var/run/, updating 
> /var/run/libvirt/virtlogd-admin-sock → /run/libvirt/virtlogd-admin-sock; 
> please update the unit file accordingly.
> 
> 
> /run is supported in debian for quite some times, that can be used I
> guess.


I've updated the code to use runstatedir.
What remains is to use --runstatedir=/run in debian/rules.

I then noticed that upstream made similar changes as well. So once we
get a newer release of libvirt, this should be supported ootb.


But since I already did the work, I'm attaching the patches, just in
case you decide to keep 5.6 in unstable for a while longer.

Michael
From 80a821f040807e5cf4b1bd0d9c9905d960203de4 Mon Sep 17 00:00:00 2001
From: Michael Biebl <bi...@debian.org>
Date: Wed, 15 Jan 2020 14:25:38 +0100
Subject: [PATCH 1/4] Search and replace to use runstatedir instead
 localstatedir

find . -type f | xargs sed -i 's#@localstatedir@/run#@runstatedir@#'
find . -type f | xargs sed -i 's#LOCALSTATEDIR "/run#RUNSTATEDIR "#'
find . -type f | xargs sed -i 's#LOCALSTATEDIR/run#RUNSTATEDIR#'
---
 src/bhyve/bhyve_utils.h               |  2 +-
 src/libvirt-admin.c                   |  2 +-
 src/libvirtd.8.in                     | 16 ++++++++--------
 src/libxl/libxl_conf.h                |  2 +-
 src/locking/lock_daemon.c             |  8 ++++----
 src/locking/lock_driver_lockd.c       |  2 +-
 src/locking/virtlockd-admin.socket.in |  2 +-
 src/locking/virtlockd.pod             |  8 ++++----
 src/locking/virtlockd.socket.in       |  2 +-
 src/logging/log_daemon.c              |  8 ++++----
 src/logging/log_manager.c             |  2 +-
 src/logging/virtlogd-admin.socket.in  |  2 +-
 src/logging/virtlogd.pod              |  8 ++++----
 src/logging/virtlogd.socket.in        |  2 +-
 src/lxc/lxc_conf.h                    |  2 +-
 src/network/bridge_driver.c           |  4 ++--
 src/network/leaseshelper.c            |  2 +-
 src/nwfilter/nwfilter_dhcpsnoop.c     |  2 +-
 src/nwfilter/nwfilter_driver.c        |  4 ++--
 src/remote/libvirtd-admin.socket.in   |  2 +-
 src/remote/libvirtd-ro.socket.in      |  2 +-
 src/remote/libvirtd.pod               | 10 +++++-----
 src/remote/libvirtd.socket.in         |  2 +-
 src/remote/remote_daemon.c            |  8 ++++----
 src/remote/remote_driver.h            |  4 ++--
 src/storage/storage_driver.c          |  2 +-
 src/util/virhostdev.c                 |  2 +-
 src/virtlockd.8.in                    | 12 ++++++------
 src/virtlogd.8.in                     | 12 ++++++------
 src/vz/vz_driver.c                    |  2 +-
 30 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index 3d212e3..8dda606 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -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;
diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c
index 74dedf6..f487b84 100644
--- a/src/libvirt-admin.c
+++ b/src/libvirt-admin.c
@@ -142,7 +142,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")) {
diff --git a/src/libvirtd.8.in b/src/libvirtd.8.in
index 2df31d9..195cdd4 100644
--- a/src/libvirtd.8.in
+++ b/src/libvirtd.8.in
@@ -200,11 +200,11 @@ On receipt of \fB\s-1SIGHUP\s0\fR libvirtd will reload its configuration.
 .IX Item "@sysconfdir@/libvirt/libvirtd.conf"
 The default configuration file used by libvirtd, unless overridden on the
 command line using the \fB\-f\fR|\fB\-\-config\fR option.
-.IP "\fI@localstatedir@/run/libvirt/libvirt\-sock\fR" 4
-.IX Item "@localstatedir@/run/libvirt/libvirt-sock"
+.IP "\fI@runstatedir@/libvirt/libvirt\-sock\fR" 4
+.IX Item "@runstatedir@/libvirt/libvirt-sock"
 .PD 0
-.IP "\fI@localstatedir@/run/libvirt/libvirt\-sock\-ro\fR" 4
-.IX Item "@localstatedir@/run/libvirt/libvirt-sock-ro"
+.IP "\fI@runstatedir@/libvirt/libvirt\-sock\-ro\fR" 4
+.IX Item "@runstatedir@/libvirt/libvirt-sock-ro"
 .PD
 The sockets libvirtd will use.
 .IP "\fI@sysconfdir@/pki/CA/cacert.pem\fR" 4
@@ -216,8 +216,8 @@ The \s-1TLS\s0 \fBServer\fR certificate libvirtd will use.
 .IP "\fI@sysconfdir@/pki/libvirt/private/serverkey.pem\fR" 4
 .IX Item "@sysconfdir@/pki/libvirt/private/serverkey.pem"
 The \s-1TLS\s0 \fBServer\fR private key libvirtd will use.
-.IP "\fI@localstatedir@/run/libvirtd.pid\fR" 4
-.IX Item "@localstatedir@/run/libvirtd.pid"
+.IP "\fI@runstatedir@/libvirtd.pid\fR" 4
+.IX Item "@runstatedir@/libvirtd.pid"
 The \s-1PID\s0 file to use, unless overridden by the \fB\-p\fR|\fB\-\-pid\-file\fR option.
 .SS "When run as \fBnon-root\fP."
 .IX Subsection "When run as non-root."
@@ -262,8 +262,8 @@ To start libvirtd, instructing it to daemonize and create a \s-1PID\s0 file:
 .PP
 .Vb 4
 \& # 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
 \& #
 .Ve
 .SH "BUGS"
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 552f039..27badfb 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -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"
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 1044832..8a6a8c5 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -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;
@@ -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())) {
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index f6371f3..164f83e 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -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;
diff --git a/src/locking/virtlockd-admin.socket.in b/src/locking/virtlockd-admin.socket.in
index cd70722..c66e0f9 100644
--- a/src/locking/virtlockd-admin.socket.in
+++ b/src/locking/virtlockd-admin.socket.in
@@ -5,7 +5,7 @@ BindsTo=virtlockd.socket
 After=virtlockd.socket
 
 [Socket]
-ListenStream=@localstatedir@/run/libvirt/virtlockd-admin-sock
+ListenStream=@runstatedir@/libvirt/virtlockd-admin-sock
 Service=virtlockd.service
 SocketMode=0600
 
diff --git a/src/locking/virtlockd.pod b/src/locking/virtlockd.pod
index de0eb8a..0b9f758 100644
--- a/src/locking/virtlockd.pod
+++ b/src/locking/virtlockd.pod
@@ -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
diff --git a/src/locking/virtlockd.socket.in b/src/locking/virtlockd.socket.in
index d701b27..52014f4 100644
--- a/src/locking/virtlockd.socket.in
+++ b/src/locking/virtlockd.socket.in
@@ -3,7 +3,7 @@ Description=Virtual machine lock manager socket
 Before=libvirtd.service
 
 [Socket]
-ListenStream=@localstatedir@/run/libvirt/virtlockd-sock
+ListenStream=@runstatedir@/libvirt/virtlockd-sock
 SocketMode=0600
 
 [Install]
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 4103f2c..b6babd4 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -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;
@@ -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())) {
diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c
index eb0a32b..1613d1f 100644
--- a/src/logging/log_manager.c
+++ b/src/logging/log_manager.c
@@ -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;
diff --git a/src/logging/virtlogd-admin.socket.in b/src/logging/virtlogd-admin.socket.in
index 672bd74..5c0fb18 100644
--- a/src/logging/virtlogd-admin.socket.in
+++ b/src/logging/virtlogd-admin.socket.in
@@ -5,7 +5,7 @@ BindsTo=virtlogd.socket
 After=virtlogd.socket
 
 [Socket]
-ListenStream=@localstatedir@/run/libvirt/virtlogd-admin-sock
+ListenStream=@runstatedir@/libvirt/virtlogd-admin-sock
 Service=virtlogd.service
 SocketMode=0600
 
diff --git a/src/logging/virtlogd.pod b/src/logging/virtlogd.pod
index 5e44f84..01dde99 100644
--- a/src/logging/virtlogd.pod
+++ b/src/logging/virtlogd.pod
@@ -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
diff --git a/src/logging/virtlogd.socket.in b/src/logging/virtlogd.socket.in
index ae48cda..9749a33 100644
--- a/src/logging/virtlogd.socket.in
+++ b/src/logging/virtlogd.socket.in
@@ -3,7 +3,7 @@ Description=Virtual machine log manager socket
 Before=libvirtd.service
 
 [Socket]
-ListenStream=@localstatedir@/run/libvirt/virtlogd-sock
+ListenStream=@runstatedir@/libvirt/virtlogd-sock
 SocketMode=0600
 
 [Install]
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index e26ca22..12a201d 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -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"
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 41fa89a..8433137 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -744,9 +744,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,
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 2a10fbf..b2dddae 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -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 */
diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index d8a1e7f..0c73f1e 100644
--- a/src/nwfilter/nwfilter_dhcpsnoop.c
+++ b/src/nwfilter/nwfilter_dhcpsnoop.c
@@ -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"
 
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 530e4f5..124f7d8 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -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) {
diff --git a/src/remote/libvirtd-admin.socket.in b/src/remote/libvirtd-admin.socket.in
index 307c9ba..745d640 100644
--- a/src/remote/libvirtd-admin.socket.in
+++ b/src/remote/libvirtd-admin.socket.in
@@ -7,7 +7,7 @@ After=libvirtd.socket
 [Socket]
 # The directory must match the /etc/libvirt/libvirtd.conf unix_sock_dir setting
 # when using systemd version < 227
-ListenStream=@localstatedir@/run/libvirt/libvirt-admin-sock
+ListenStream=@runstatedir@/libvirt/libvirt-admin-sock
 Service=libvirtd.service
 SocketMode=0600
 
diff --git a/src/remote/libvirtd-ro.socket.in b/src/remote/libvirtd-ro.socket.in
index 876daf0..937409e 100644
--- a/src/remote/libvirtd-ro.socket.in
+++ b/src/remote/libvirtd-ro.socket.in
@@ -7,7 +7,7 @@ After=libvirtd.socket
 [Socket]
 # The directory must match the /etc/libvirt/libvirtd.conf unix_sock_dir setting
 # when using systemd version < 227
-ListenStream=@localstatedir@/run/libvirt/libvirt-sock-ro
+ListenStream=@runstatedir@/libvirt/libvirt-sock-ro
 Service=libvirtd.service
 SocketMode=0666
 
diff --git a/src/remote/libvirtd.pod b/src/remote/libvirtd.pod
index 4721e0f..4988f0f 100644
--- a/src/remote/libvirtd.pod
+++ b/src/remote/libvirtd.pod
@@ -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
diff --git a/src/remote/libvirtd.socket.in b/src/remote/libvirtd.socket.in
index 2ee4d7d..5815e4a 100644
--- a/src/remote/libvirtd.socket.in
+++ b/src/remote/libvirtd.socket.in
@@ -5,7 +5,7 @@ Before=libvirtd.service
 [Socket]
 # The directory must match the /etc/libvirt/libvirtd.conf unix_sock_dir setting
 # when using systemd version < 227
-ListenStream=@localstatedir@/run/libvirt/libvirt-sock
+ListenStream=@runstatedir@/libvirt/libvirt-sock
 Service=libvirtd.service
 SocketMode=0666
 
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index d887b7a..b2f1dd0 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -231,9 +231,9 @@ daemonUnixSocketPaths(struct daemonConfig *config,
         }
     } else {
         if (privileged) {
-            if (VIR_STRDUP(*sockfile, LOCALSTATEDIR "/run/libvirt/libvirt-sock") < 0 ||
-                VIR_STRDUP(*rosockfile, LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro") < 0 ||
-                VIR_STRDUP(*admsockfile, LOCALSTATEDIR "/run/libvirt/libvirt-admin-sock") < 0)
+            if (VIR_STRDUP(*sockfile, RUNSTATEDIR "/libvirt/libvirt-sock") < 0 ||
+                VIR_STRDUP(*rosockfile, RUNSTATEDIR "/libvirt/libvirt-sock-ro") < 0 ||
+                VIR_STRDUP(*admsockfile, RUNSTATEDIR "/libvirt/libvirt-admin-sock") < 0)
                 goto cleanup;
         } else {
             mode_t old_umask;
@@ -1134,7 +1134,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;
         }
diff --git a/src/remote/remote_driver.h b/src/remote/remote_driver.h
index 8c7da6b..d65b724 100644
--- a/src/remote/remote_driver.h
+++ b/src/remote/remote_driver.h
@@ -31,8 +31,8 @@ unsigned long remoteVersion(void);
 #define LIBVIRTD_LISTEN_ADDR NULL
 #define LIBVIRTD_TLS_PORT "16514"
 #define LIBVIRTD_TCP_PORT "16509"
-#define LIBVIRTD_PRIV_UNIX_SOCKET LOCALSTATEDIR "/run/libvirt/libvirt-sock"
-#define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCALSTATEDIR "/run/libvirt/libvirt-sock-ro"
+#define LIBVIRTD_PRIV_UNIX_SOCKET RUNSTATEDIR "/libvirt/libvirt-sock"
+#define LIBVIRTD_PRIV_UNIX_SOCKET_RO RUNSTATEDIR "/libvirt/libvirt-sock-ro"
 #define LIBVIRTD_USER_UNIX_SOCKET "libvirt-sock"
 #define LIBVIRTD_CONFIGURATION_FILE SYSCONFDIR "/libvirt/libvirtd.conf"
 
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 03ac6a6..d223781 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -273,7 +273,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();
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index a3647a6..8123397 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -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 */
 
diff --git a/src/virtlockd.8.in b/src/virtlockd.8.in
index e3e3a6f..b1c3a6b 100644
--- a/src/virtlockd.8.in
+++ b/src/virtlockd.8.in
@@ -189,11 +189,11 @@ upgrades of the virtlockd service.
 .IX Item "@sysconfdir@/libvirt/virtlockd.conf"
 The default configuration file used by virtlockd, unless overridden on the
 command line using the \fB\-f\fR|\fB\-\-config\fR option.
-.IP "\fI@localstatedir@/run/libvirt/virtlockd\-sock\fR" 4
-.IX Item "@localstatedir@/run/libvirt/virtlockd-sock"
+.IP "\fI@runstatedir@/libvirt/virtlockd\-sock\fR" 4
+.IX Item "@runstatedir@/libvirt/virtlockd-sock"
 The sockets libvirtd will use.
-.IP "\fI@localstatedir@/run/virtlockd.pid\fR" 4
-.IX Item "@localstatedir@/run/virtlockd.pid"
+.IP "\fI@runstatedir@/virtlockd.pid\fR" 4
+.IX Item "@runstatedir@/virtlockd.pid"
 The \s-1PID\s0 file to use, unless overridden by the \fB\-p\fR|\fB\-\-pid\-file\fR option.
 .SS "When run as \fBnon-root\fP."
 .IX Subsection "When run as non-root."
@@ -229,8 +229,8 @@ To start virtlockd, instructing it to daemonize and create a \s-1PID\s0 file:
 .PP
 .Vb 4
 \& # 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
 \& #
 .Ve
 .SH "BUGS"
diff --git a/src/virtlogd.8.in b/src/virtlogd.8.in
index 5970f95..d1ca358 100644
--- a/src/virtlogd.8.in
+++ b/src/virtlogd.8.in
@@ -189,11 +189,11 @@ upgrades of the virtlogd service.
 .IX Item "@sysconfdir@/libvirt/virtlogd.conf"
 The default configuration file used by virtlogd, unless overridden on the
 command line using the \fB\-f\fR|\fB\-\-config\fR option.
-.IP "\fI@localstatedir@/run/libvirt/virtlogd\-sock\fR" 4
-.IX Item "@localstatedir@/run/libvirt/virtlogd-sock"
+.IP "\fI@runstatedir@/libvirt/virtlogd\-sock\fR" 4
+.IX Item "@runstatedir@/libvirt/virtlogd-sock"
 The sockets libvirtd will use.
-.IP "\fI@localstatedir@/run/virtlogd.pid\fR" 4
-.IX Item "@localstatedir@/run/virtlogd.pid"
+.IP "\fI@runstatedir@/virtlogd.pid\fR" 4
+.IX Item "@runstatedir@/virtlogd.pid"
 The \s-1PID\s0 file to use, unless overridden by the \fB\-p\fR|\fB\-\-pid\-file\fR option.
 .SS "When run as \fBnon-root\fP."
 .IX Subsection "When run as non-root."
@@ -229,8 +229,8 @@ To start virtlogd, instructing it to daemonize and create a \s-1PID\s0 file:
 .PP
 .Vb 4
 \& # 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
 \& #
 .Ve
 .SH "BUGS"
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index f5d05a7..67b90b8 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -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;
 
-- 
2.25.0

From bfcf5f317c7b11a91877ec02e14e845b6986f44f Mon Sep 17 00:00:00 2001
From: Michael Biebl <bi...@debian.org>
Date: Wed, 15 Jan 2020 15:35:49 +0100
Subject: [PATCH 2/4] Fix Makefiles to use runstatedir

grep for usages of LOCALSTATEDIR and localstatedir and replace where
appropriate.
---
 src/Makefile.am             |  2 +-
 src/libxl/Makefile.inc.am   |  4 ++--
 src/locking/Makefile.inc.am | 10 +++++-----
 src/logging/Makefile.inc.am |  6 +++---
 src/lxc/Makefile.inc.am     |  4 ++--
 src/network/Makefile.inc.am |  4 ++--
 src/qemu/Makefile.inc.am    |  8 ++++----
 src/remote/Makefile.inc.am  | 12 ++++++------
 8 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 4a8cae1..e8c10cd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -802,7 +802,7 @@ endif WITH_LIBVIRTD
 %.8: %.8.in $(top_srcdir)/configure.ac
 	$(AM_V_GEN)sed \
 		-e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
-		-e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+		-e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 		< $< > $@-t && \
 	mv $@-t $@
 
diff --git a/src/libxl/Makefile.inc.am b/src/libxl/Makefile.inc.am
index 7f60b44..08ed482 100644
--- a/src/libxl/Makefile.inc.am
+++ b/src/libxl/Makefile.inc.am
@@ -85,12 +85,12 @@ INSTALL_DATA_DIRS += libxl
 
 install-data-libxl:
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/libxl"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/libxl"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/libxl"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/libxl"
 
 uninstall-data-libxl:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/libxl" ||:
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/libxl" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/libxl" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/libxl" ||:
 
 endif WITH_LIBXL
diff --git a/src/locking/Makefile.inc.am b/src/locking/Makefile.inc.am
index 46ab11c..22c01df 100644
--- a/src/locking/Makefile.inc.am
+++ b/src/locking/Makefile.inc.am
@@ -211,7 +211,7 @@ INSTALL_DATA_DIRS += locking
 install-data-locking:
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/lockd"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/lockd/files"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/lockd"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/lockd"
 if WITH_SANLOCK
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/sanlock"
 endif WITH_SANLOCK
@@ -219,7 +219,7 @@ endif WITH_SANLOCK
 uninstall-data-locking:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/lockd/files" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/lockd" ||:
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/lockd" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/lockd" ||:
 if WITH_SANLOCK
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/sanlock" ||:
 endif WITH_SANLOCK
@@ -306,14 +306,14 @@ virtlockd.service: locking/virtlockd.service.in $(top_builddir)/config.status
 
 virtlockd.socket: locking/virtlockd.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 virtlockd-admin.socket: locking/virtlockd-admin.socket.in \
                         $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
@@ -322,7 +322,7 @@ virtlockd.8.in: locking/virtlockd.pod
 	if grep 'POD ERROR' $@-t1; then rm $@-t1; exit 1; fi && \
 	sed \
 		-e 's|SYSCONFDIR|\@sysconfdir\@|g' \
-		-e 's|LOCALSTATEDIR|\@localstatedir\@|g' \
+		-e 's|RUNSTATEDIR|\@runstatedir\@|g' \
 		< $@-t1 > $@-t2 && \
 	rm -f $@-t1 && \
 	mv $@-t2 $@
diff --git a/src/logging/Makefile.inc.am b/src/logging/Makefile.inc.am
index d57394c..d567fa4 100644
--- a/src/logging/Makefile.inc.am
+++ b/src/logging/Makefile.inc.am
@@ -125,7 +125,7 @@ virtlogd.8.in: logging/virtlogd.pod
 	if grep 'POD ERROR' $@-t1; then rm $@-t1; exit 1; fi && \
 	sed \
 		-e 's|SYSCONFDIR|\@sysconfdir\@|g' \
-		-e 's|LOCALSTATEDIR|\@localstatedir\@|g' \
+		-e 's|RUNSTATEDIR|\@runstatedir\@|g' \
 		< $@-t1 > $@-t2 && \
 	rm -f $@-t1 && \
 	mv $@-t2 $@
@@ -138,13 +138,13 @@ virtlogd.service: logging/virtlogd.service.in $(top_builddir)/config.status
 
 virtlogd.socket: logging/virtlogd.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 virtlogd-admin.socket: logging/virtlogd-admin.socket.in \
                        $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
diff --git a/src/lxc/Makefile.inc.am b/src/lxc/Makefile.inc.am
index f27827c..b96704f 100644
--- a/src/lxc/Makefile.inc.am
+++ b/src/lxc/Makefile.inc.am
@@ -174,12 +174,12 @@ INSTALL_DATA_DIRS += lxc
 
 install-data-lxc:
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/lxc"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/lxc"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/lxc"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/lxc"
 
 uninstall-data-lxc:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/lxc" ||:
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/lxc" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/lxc" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/lxc" ||:
 
 endif WITH_LXC
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index ca516c3..fe5b030 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -74,7 +74,7 @@ UUID=$(shell uuidgen 2>/dev/null)
 install-data-network:
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/network"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/dnsmasq"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/network"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/network"
 	$(MKDIR_P) "$(DESTDIR)$(confdir)/qemu/networks/autostart"
 	$(INSTALL_DATA) $(srcdir)/network/default.xml \
 	  $(DESTDIR)$(confdir)/qemu/networks/default.xml
@@ -100,7 +100,7 @@ uninstall-data-network:
 	rmdir "$(DESTDIR)$(confdir)/qemu/networks/autostart" || :
 	rmdir "$(DESTDIR)$(confdir)/qemu/networks" || :
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/network" ||:
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/network" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/network" ||:
 if WITH_FIREWALLD_ZONE
 	rm -f  $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
 endif WITH_FIREWALLD_ZONE
diff --git a/src/qemu/Makefile.inc.am b/src/qemu/Makefile.inc.am
index 254ba07..cb1cb84 100644
--- a/src/qemu/Makefile.inc.am
+++ b/src/qemu/Makefile.inc.am
@@ -133,20 +133,20 @@ INSTALL_DATA_DIRS += qemu
 
 install-data-qemu:
 	$(MKDIR_P) -m 0751 "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/qemu"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/qemu"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/qemu"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/swtpm"
-	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/qemu/swtpm"
+	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/qemu/swtpm"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/swtpm/libvirt/qemu"
 
 uninstall-data-qemu:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu" ||:
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/qemu" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/qemu" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/qemu" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/swtpm"
-	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/qemu/swtpm" ||:
+	rmdir "$(DESTDIR)$(runstatedir)/libvirt/qemu/swtpm" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/log/swtpm/libvirt/qemu" ||:
 
 endif WITH_QEMU
diff --git a/src/remote/Makefile.inc.am b/src/remote/Makefile.inc.am
index 75b7290..7b8c8bb 100644
--- a/src/remote/Makefile.inc.am
+++ b/src/remote/Makefile.inc.am
@@ -266,7 +266,7 @@ endif WITH_SASL
 
 libvirtd.service: remote/libvirtd.service.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    -e 's|[@]sbindir[@]|$(sbindir)|g' \
 	    -e 's|[@]sysconfdir[@]|$(sysconfdir)|g' \
 	    < $< > $@-t && \
@@ -274,31 +274,31 @@ libvirtd.service: remote/libvirtd.service.in $(top_builddir)/config.status
 
 libvirtd.socket: remote/libvirtd.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 libvirtd-ro.socket: remote/libvirtd-ro.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 libvirtd-admin.socket: remote/libvirtd-admin.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 libvirtd-tcp.socket: remote/libvirtd-tcp.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
 libvirtd-tls.socket: remote/libvirtd-tls.socket.in $(top_builddir)/config.status
 	$(AM_V_GEN)sed \
-	    -e 's|[@]localstatedir[@]|$(localstatedir)|g' \
+	    -e 's|[@]runstatedir[@]|$(runstatedir)|g' \
 	    < $< > $@-t && \
 	    mv $@-t $@
 
-- 
2.25.0

From 73f8ae8e4a52dc13d6de1d2063abaf6e47b1650e Mon Sep 17 00:00:00 2001
From: Michael Biebl <bi...@debian.org>
Date: Wed, 15 Jan 2020 15:58:05 +0100
Subject: [PATCH 3/4] Fix remaining parts of the source code to use RUNSTATEDIR

grep for usages of LOCALSTATEDIR and replace where appropriate.
---
 src/interface/interface_backend_netcf.c | 2 +-
 src/interface/interface_backend_udev.c  | 2 +-
 src/locking/lock_daemon.c               | 8 ++++----
 src/logging/log_daemon.c                | 8 ++++----
 src/node_device/node_device_hal.c       | 2 +-
 src/node_device/node_device_udev.c      | 2 +-
 src/qemu/qemu_conf.c                    | 4 ++--
 src/remote/remote_daemon.c              | 4 ++--
 src/secret/secret_driver.c              | 2 +-
 9 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 0000587..577c9a9 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -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;
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index fea5108..18d3603 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -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;
diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index 8a6a8c5..e84deda 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -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"
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index b6babd4..5a18bc2 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -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"
diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c
index 1f3f867..49bc8c2 100644
--- a/src/node_device/node_device_hal.c
+++ b/src/node_device/node_device_hal.c
@@ -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;
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 8bc63c5..a10ad6d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -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;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8853578..4556e27 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -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,
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index b2f1dd0..c09f7d9 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -899,7 +899,7 @@ daemonUsage(const char *argv0, bool privileged)
                   "      Server private key: %s\n"
                   "\n"
                   "    PID file (unless overridden by -p):\n"
-                  "      %s/run/libvirtd.pid\n"
+                  "      %s/libvirtd.pid\n"
                   "\n"),
                 LIBVIRTD_CONFIGURATION_FILE,
                 LIBVIRTD_PRIV_UNIX_SOCKET,
@@ -907,7 +907,7 @@ daemonUsage(const char *argv0, bool privileged)
                 LIBVIRT_CACERT,
                 LIBVIRT_SERVERCERT,
                 LIBVIRT_SERVERKEY,
-                LOCALSTATEDIR);
+                RUNSTATEDIR);
     } else {
         fprintf(stderr, "%s",
                 _("\n"
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 0af2bce..cec9620 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -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;
-- 
2.25.0

From 7f7566613092f947ca662c3741cc9800ca2b6832 Mon Sep 17 00:00:00 2001
From: Michael Biebl <bi...@debian.org>
Date: Wed, 15 Jan 2020 15:58:22 +0100
Subject: [PATCH 4/4] Update virPidFileConstructPath to use runstatedir

---
 src/locking/lock_daemon.c  | 2 +-
 src/logging/log_daemon.c   | 2 +-
 src/remote/remote_daemon.c | 2 +-
 src/util/virpidfile.c      | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c
index e84deda..ac242bf 100644
--- a/src/locking/lock_daemon.c
+++ b/src/locking/lock_daemon.c
@@ -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."));
diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 5a18bc2..f74e900 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -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."));
diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c
index c09f7d9..d21453f 100644
--- a/src/remote/remote_daemon.c
+++ b/src/remote/remote_daemon.c
@@ -1089,7 +1089,7 @@ int main(int argc, char **argv) {
 
     if (!pid_file &&
         virPidFileConstructPath(privileged,
-                                LOCALSTATEDIR,
+                                RUNSTATEDIR,
                                 "libvirtd",
                                 &pid_file) < 0) {
         VIR_ERROR(_("Can't determine pid file path."));
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 999bccb..6484c76 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -495,7 +495,7 @@ virPidFileConstructPath(bool privileged,
                            "%s", _("No statedir specified"));
             return -1;
         }
-        if (virAsprintf(pidfile, "%s/run/%s.pid", statedir, progname) < 0)
+        if (virAsprintf(pidfile, "%s/%s.pid", statedir, progname) < 0)
             return -1;
     } else {
         if (!(rundir = virGetUserRuntimeDirectory()))
-- 
2.25.0

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to