modelled after setup_systemd_preset, which unfortunately doesn't work for static units, since those are skipped by `systemctl preset-all` which runs on first boot.
our Debian-based templates already come with those masking symlinks in place. Signed-off-by: Fabian Grünbichler <f.gruenbich...@proxmox.com> --- Notes: noticed while testing the openEuler template src/PVE/LXC/Setup/Base.pm | 23 +++++++++++++++++++++++ src/PVE/LXC/Setup/CentOS.pm | 2 ++ src/PVE/LXC/Setup/OpenEuler.pm | 1 + 3 files changed, 26 insertions(+) diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm index 084b039..decd62a 100644 --- a/src/PVE/LXC/Setup/Base.pm +++ b/src/PVE/LXC/Setup/Base.pm @@ -352,6 +352,29 @@ sub setup_systemd_preset { ); } +# some units cannot be disabled via presets because they are static +# this helper can be called as part of template_fixup to explicitly mask them instead +sub setup_systemd_disable_static_units { + my ($self, $extra_units) = @_; + + # some don't make sense in CTs, child-plugins can add extra units via $extra_preset + my $units = [ + 'sys-kernel-config.mount', + 'sys-kernel-debug.mount', + ]; + + if (defined($extra_units)) { + for my $unit (@$extra_units) { + push @$units, $unit; + } + } + + for my $unit (@$units) { + $self->ct_symlink('/dev/null', "/etc/systemd/system/$unit") + if !$self->ct_file_exists("/etc/systemd/system/$unit"); + } +} + sub setup_securetty { my ($self, $conf, @add) = @_; diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm index 2ad1f0c..fee0745 100644 --- a/src/PVE/LXC/Setup/CentOS.pm +++ b/src/PVE/LXC/Setup/CentOS.pm @@ -121,6 +121,8 @@ sub template_fixup { $self->setup_securetty($conf); $self->remove_lxc_name_from_etc_hosts(); + + $self->setup_systemd_disable_static_units(); } sub setup_init { diff --git a/src/PVE/LXC/Setup/OpenEuler.pm b/src/PVE/LXC/Setup/OpenEuler.pm index b34b957..9bfd5c4 100644 --- a/src/PVE/LXC/Setup/OpenEuler.pm +++ b/src/PVE/LXC/Setup/OpenEuler.pm @@ -24,6 +24,7 @@ sub template_fixup { my ($self, $conf) = @_; $self->remove_lxc_name_from_etc_hosts(); + $self->setup_systemd_disable_static_units(['dev-mqueue.mount']); } sub setup_init { -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel