From ca0c50a1e67c679af4ea3ba1ca5ab0f196e0c3a7 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 5 Jul 2021 17:37:40 +0200 Subject: [PATCH] pve6to7: handle undefined ostype Signed-off-by: Thomas Lamprecht --- PVE/CLI/pve6to7.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/PVE/CLI/pve6to7.pm b/PVE/CLI/pve6to7.pm index 5e97a3c5..da15ef7d 100644 --- a/PVE/CLI/pve6to7.pm +++ b/PVE/CLI/pve6to7.pm @@ -903,7 +903,7 @@ sub check_containers_cgroup_compat { } my $supports_cgroupv2 = sub { - my ($conf, $rootdir) = @_; + my ($conf, $rootdir, $ctid) = @_; my $get_systemd_version = sub { my ($self) = @_; @@ -939,8 +939,10 @@ sub check_containers_cgroup_compat { }; my $ostype = $conf->{ostype}; - if ($ostype eq 'devuan' || $ostype eq 'alpine') { - return 1; + if (!defined($ostype)) { + log_warn("Found CT ($ctid) without 'ostype' set!"); + } elsif ($ostype eq 'devuan' || $ostype eq 'alpine') { + return 1; # no systemd, no cgroup problems } my $lxc_setup = PVE::LXC::Setup->new($conf, $rootdir); @@ -979,7 +981,7 @@ sub check_containers_cgroup_compat { my $rootdir = "/proc/$pid/root"; my $conf = PVE::LXC::Config->load_config($ctid); - my $ret = eval { $supports_cgroupv2->($conf, $rootdir) }; + my $ret = eval { $supports_cgroupv2->($conf, $rootdir, $ctid) }; if (my $err = $@) { log_warn("Failed to get cgroup support status for CT $ctid - $err"); next; @@ -997,7 +999,7 @@ sub check_containers_cgroup_compat { eval { $conf = PVE::LXC::Config->load_config($ctid); $rootdir = PVE::LXC::mount_all($ctid, $storage_cfg, $conf); - $ret = $supports_cgroupv2->($conf, $rootdir); + $ret = $supports_cgroupv2->($conf, $rootdir, $ctid); }; if (my $err = $@) { log_warn("Failed to load config and mount CT $ctid - $err");