public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates
Date: Fri,  8 Nov 2024 14:18:30 +0100	[thread overview]
Message-ID: <20241108131830.467949-2-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20241108131830.467949-1-f.gruenbichler@proxmox.com>

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.gruenbichler@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

  reply	other threads:[~2024-11-08 13:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 13:18 [pve-devel] [PATCH container 1/2] fix #5720: add setup support for openEuler Fabian Grünbichler
2024-11-08 13:18 ` Fabian Grünbichler [this message]
2024-11-08 13:40   ` [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates Thomas Lamprecht
2024-11-08 13:47     ` Fabian Grünbichler
2024-11-08 13:53 ` [pve-devel] applied-series: [PATCH container 1/2] fix #5720: add setup support for openEuler Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241108131830.467949-2-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal