[pve-devel] [PATCH container] use timedatectl to retrieve container host timezone

Stefan Mayr stefan at mayr-stefan.de
Wed Dec 31 11:27:42 CET 2025


In addition to fixing #7175 this also switches the /etc/timezone
dependency of the LXC integration to timedatectl.
One less dependency on that code in the INotify module.

Suggested-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
Suggested-by: Maximiliano Sandroval <m.sandoval at proxmox.com>
Signed-off-by: Stefan Mayr <stefan at mayr-stefan.de>
---
 src/PVE/LXC/Setup.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 87330c4..0d00376 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -127,7 +127,10 @@ sub new {
 
     # Cache some host files we need access to:
     $plugin->{host_resolv_conf} = PVE::INotify::read_file('resolvconf');
-    $plugin->{host_timezone} = PVE::INotify::read_file('timezone');
+    PVE::Tools::run_command(
+        ['timedatectl', 'show', '--property=Timezone', '--value'],
+        outfunc => sub { $plugin->{host_timezone} //= shift },
+    );
 
     abs_path('/etc/localtime') =~ m|^(/.+)| or die "invalid /etc/localtime\n"; # untaint
     $plugin->{host_localtime} = $1;
-- 
2.34.1




More information about the pve-devel mailing list