[PATCH pve-common] tree-wide: change /var/run to /run and /var/lock to /run/lock

Jing Luo jing at jing.rocks
Sat Mar 22 16:17:14 CET 2025


"/var/run" and "/var/lock" are deprecated.

This is to comply with Debian Policy 9.1.4 "/run and /run/lock".
(https://www.debian.org/doc/debian-policy/ch-opersys.html#run-and-run-lock)

Signed-off-by: Jing Luo <jing at jing.rocks>
---
 src/PVE/Daemon.pm  | 4 ++--
 src/PVE/Network.pm | 2 +-
 src/PVE/Tools.pm   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Daemon.pm b/src/PVE/Daemon.pm
index 63fd5ee..e2dc0a7 100644
--- a/src/PVE/Daemon.pm
+++ b/src/PVE/Daemon.pm
@@ -3,7 +3,7 @@ package PVE::Daemon;
 # Abstract class to implement Daemons
 #
 # Features:
-# * lock and write PID file /var/run/$name.pid to make sure only
+# * lock and write PID file /run/$name.pid to make sure only
 #   one instance is running.
 # * keep lock open during restart
 # * correctly daemonize (redirect STDIN/STDOUT)
@@ -431,7 +431,7 @@ sub new {
 
 	$self = bless {
 	    name => $name,
-	    pidfile => "/var/run/${name}.pid",
+	    pidfile => "/run/${name}.pid",
 	    workers => {},
 	    old_workers => {},
 	}, $class;
diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm
index a004c04..35325c8 100644
--- a/src/PVE/Network.pm
+++ b/src/PVE/Network.pm
@@ -858,7 +858,7 @@ sub get_ip_from_hostname {
 
 sub lock_network {
     my ($code, @param) = @_;
-    my $res = lock_file('/var/lock/pve-network.lck', 10, $code, @param);
+    my $res = lock_file('/run/lock/pve-network.lck', 10, $code, @param);
     die $@ if $@;
     return $res;
 }
diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index df481ab..fe6c699 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -989,7 +989,7 @@ sub next_unused_port {
 	return $newport;
     };
 
-    my $p = lock_file('/var/lock/pve-ports.lck', 10, $code);
+    my $p = lock_file('/run/lock/pve-ports.lck', 10, $code);
     die $@ if $@;
 
     die "unable to find free port (${range_start}-${range_end})\n" if !$p;
-- 
2.49.0





More information about the pve-devel mailing list