public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container 1/2] fix #5720: add setup support for openEuler
@ 2024-11-08 13:18 Fabian Grünbichler
  2024-11-08 13:18 ` [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates 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
  0 siblings, 2 replies; 5+ messages in thread
From: Fabian Grünbichler @ 2024-11-08 13:18 UTC (permalink / raw)
  To: pve-devel

openEuler is centOS-derived Linux distribution. the LXC project builds a
template for it that mostly works out of the box.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    did some basic smoke testing using
    openeuler-24.09-default_20241028_amd64.tar.xz from images.linuxcontainers.org

 src/PVE/LXC/Setup.pm           |  5 +++++
 src/PVE/LXC/Setup/Makefile     |  1 +
 src/PVE/LXC/Setup/OpenEuler.pm | 35 ++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 src/PVE/LXC/Setup/OpenEuler.pm

diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm
index 3a937a9..dc58990 100644
--- a/src/PVE/LXC/Setup.pm
+++ b/src/PVE/LXC/Setup.pm
@@ -18,6 +18,7 @@ use PVE::LXC::Setup::Gentoo;
 use PVE::LXC::Setup::SUSE;
 use PVE::LXC::Setup::Ubuntu;
 use PVE::LXC::Setup::NixOS;
+use PVE::LXC::Setup::OpenEuler;
 use PVE::LXC::Setup::Unmanaged;
 
 my $plugins = {
@@ -28,6 +29,7 @@ my $plugins = {
     devuan    => 'PVE::LXC::Setup::Devuan',
     fedora    => 'PVE::LXC::Setup::Fedora',
     gentoo    => 'PVE::LXC::Setup::Gentoo',
+    openeuler => 'PVE::LXC::Setup::OpenEuler',
     opensuse  => 'PVE::LXC::Setup::SUSE',
     ubuntu    => 'PVE::LXC::Setup::Ubuntu',
     nixos     => 'PVE::LXC::Setup::NixOS',
@@ -39,6 +41,7 @@ my $plugin_alias = {
     'opensuse-leap' => 'opensuse',
     'opensuse-tumbleweed' => 'opensuse',
     'opensuse-slowroll' => 'opensuse',
+    'openEuler' => 'openeuler',
     arch => 'archlinux',
     sles => 'opensuse',
 };
@@ -80,6 +83,8 @@ my $autodetect_type = sub {
 	return "gentoo";
     } elsif (-d  "$rootdir/nix/store") {
 	return "nixos";
+    } elsif (-f "$rootdir/etc/openEuler-release") {
+	return "openeuler";
     } elsif (-f "$rootdir/etc/os-release") {
 	die "unable to detect OS distribution\n";
     } else {
diff --git a/src/PVE/LXC/Setup/Makefile b/src/PVE/LXC/Setup/Makefile
index df1cf97..688b547 100644
--- a/src/PVE/LXC/Setup/Makefile
+++ b/src/PVE/LXC/Setup/Makefile
@@ -11,6 +11,7 @@ SOURCES=\
     SUSE.pm		\
     Ubuntu.pm		\
     NixOS.pm		\
+    OpenEuler.pm	\
     Unmanaged.pm	\
 
 .PHONY: install
diff --git a/src/PVE/LXC/Setup/OpenEuler.pm b/src/PVE/LXC/Setup/OpenEuler.pm
new file mode 100644
index 0000000..b34b957
--- /dev/null
+++ b/src/PVE/LXC/Setup/OpenEuler.pm
@@ -0,0 +1,35 @@
+package PVE::LXC::Setup::OpenEuler;
+
+use strict;
+use warnings;
+
+use PVE::LXC::Setup::CentOS;
+use base qw(PVE::LXC::Setup::CentOS);
+
+sub new {
+    my ($class, $conf, $rootdir, $os_release) = @_;
+
+    my $version = $os_release->{VERSION_ID};
+    # we cannot really win anything by actively dying on newer versions so only check lower boundary.
+    die "unsupported openEuler release '$version'\n" if !defined($version) || $version < 24;
+
+    my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+
+    $conf->{ostype} = "openeuler";
+
+    return bless $self, $class;
+}
+
+sub template_fixup {
+    my ($self, $conf) = @_;
+
+    $self->remove_lxc_name_from_etc_hosts();
+}
+
+sub setup_init {
+    my ($self, $conf) = @_;
+    $self->setup_container_getty_service($conf);
+    $self->setup_systemd_preset();
+}
+
+1;
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates
  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
  2024-11-08 13:40   ` Thomas Lamprecht
  2024-11-08 13:53 ` [pve-devel] applied-series: [PATCH container 1/2] fix #5720: add setup support for openEuler Thomas Lamprecht
  1 sibling, 1 reply; 5+ messages in thread
From: Fabian Grünbichler @ 2024-11-08 13:18 UTC (permalink / raw)
  To: pve-devel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates
  2024-11-08 13:18 ` [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates Fabian Grünbichler
@ 2024-11-08 13:40   ` Thomas Lamprecht
  2024-11-08 13:47     ` Fabian Grünbichler
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Lamprecht @ 2024-11-08 13:40 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Grünbichler

Am 08/11/2024 um 14:18 schrieb Fabian Grünbichler:
> 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.

yeah, I added symlinking those units to /dev/null in the DAB and AAB
image builders, but thanks for providing the generic way.

> 
> 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;
> +	}
> +    }
> +

would apply this with the following squashed in as there's no need for
allocations/copies here, if you have no objection?

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index decd62a..bb084af 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -363,13 +363,7 @@ sub setup_systemd_disable_static_units {
        'sys-kernel-debug.mount',
     ];
 
-    if (defined($extra_units)) {
-       for my $unit (@$extra_units) {
-           push @$units, $unit;
-       }
-    }
-
-    for my $unit (@$units) {
+    for my $unit ($units->@*, $extra_units->@*) {
        $self->ct_symlink('/dev/null', "/etc/systemd/system/$unit")
            if !$self->ct_file_exists("/etc/systemd/system/$unit");
     }


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates
  2024-11-08 13:40   ` Thomas Lamprecht
@ 2024-11-08 13:47     ` Fabian Grünbichler
  0 siblings, 0 replies; 5+ messages in thread
From: Fabian Grünbichler @ 2024-11-08 13:47 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion


> Thomas Lamprecht <t.lamprecht@proxmox.com> hat am 08.11.2024 14:40 CET geschrieben:
> 
>  
> Am 08/11/2024 um 14:18 schrieb Fabian Grünbichler:
> > 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.
> 
> yeah, I added symlinking those units to /dev/null in the DAB and AAB
> image builders, but thanks for providing the generic way.

I didn't check all distros, there might be others that would also benefit (or at least, become a bit less noisy). But given that this is mainly to cleanup the container journal/systemctl status, it's not super important.

> > 
> > 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;
> > +	}
> > +    }
> > +
> 
> would apply this with the following squashed in as there's no need for
> allocations/copies here, if you have no objection?

yes, fine by me :)

> diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
> index decd62a..bb084af 100644
> --- a/src/PVE/LXC/Setup/Base.pm
> +++ b/src/PVE/LXC/Setup/Base.pm
> @@ -363,13 +363,7 @@ sub setup_systemd_disable_static_units {
>         'sys-kernel-debug.mount',
>      ];
>  
> -    if (defined($extra_units)) {
> -       for my $unit (@$extra_units) {
> -           push @$units, $unit;
> -       }
> -    }
> -
> -    for my $unit (@$units) {
> +    for my $unit ($units->@*, $extra_units->@*) {
>         $self->ct_symlink('/dev/null', "/etc/systemd/system/$unit")
>             if !$self->ct_file_exists("/etc/systemd/system/$unit");
>      }


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [pve-devel] applied-series: [PATCH container 1/2] fix #5720: add setup support for openEuler
  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 ` [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates Fabian Grünbichler
@ 2024-11-08 13:53 ` Thomas Lamprecht
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-11-08 13:53 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Grünbichler

Am 08/11/2024 um 14:18 schrieb Fabian Grünbichler:
> openEuler is centOS-derived Linux distribution. the LXC project builds a
> template for it that mostly works out of the box.
> 
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> 
> Notes:
>     did some basic smoke testing using
>     openeuler-24.09-default_20241028_amd64.tar.xz from images.linuxcontainers.org
> 
>  src/PVE/LXC/Setup.pm           |  5 +++++
>  src/PVE/LXC/Setup/Makefile     |  1 +
>  src/PVE/LXC/Setup/OpenEuler.pm | 35 ++++++++++++++++++++++++++++++++++
>  3 files changed, 41 insertions(+)
>  create mode 100644 src/PVE/LXC/Setup/OpenEuler.pm
> 
>

applied series, thanks!


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-11-08 13:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH container 2/2] setup: add helper to disable static units when fixing up templates Fabian Grünbichler
2024-11-08 13:40   ` 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

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