]> git.proxmox.com Git - pve-manager.git/commitdiff
pve6to7: handle undefined ostype
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 5 Jul 2021 15:37:40 +0000 (17:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 5 Jul 2021 15:43:32 +0000 (17:43 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
(cherry picked from commit 500ccca1a5cea8ccac2d18fb8d0b8ac8b5102768)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/CLI/pve6to7.pm

index 119e611fb1fb6b8fb0c4ffb03bc82a60ac08bf2e..94958108b56880052c608e04c884c4bd613054bc 100644 (file)
@@ -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");