]> git.proxmox.com Git - pve-container.git/commitdiff
pct: use CGroup submodule and new CpuSet methods
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 3 Apr 2020 14:37:23 +0000 (16:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 4 Apr 2020 17:39:02 +0000 (19:39 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/CLI/pct.pm

index 934d9aa3e482add4d9bcfb269c091261d802c692..95c6921d16f4c66b1ebe57f7361b5cdc3d0534b7 100755 (executable)
@@ -20,6 +20,7 @@ use PVE::API2::LXC;
 use PVE::API2::LXC::Config;
 use PVE::API2::LXC::Status;
 use PVE::API2::LXC::Snapshot;
+use PVE::LXC::CGroup;
 
 use base qw(PVE::CLIHandler);
 
@@ -701,12 +702,6 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       my $cgv1 = PVE::LXC::get_cgroup_subsystems();
-       if (!$cgv1->{cpuset}) {
-           print "cpuset cgroup not available\n";
-           return undef;
-       }
-
        my $ctlist = PVE::LXC::config_list();
 
        my $len = 0;
@@ -714,13 +709,22 @@ __PACKAGE__->register_method ({
        my $res = {};
 
        foreach my $vmid (sort keys %$ctlist) {
-           next if ! -d "/sys/fs/cgroup/cpuset/lxc/$vmid";
+           my $cgroup = PVE::LXC::CGroup->new($vmid);
 
-           my $cpuset = eval { PVE::CpuSet->new_from_cgroup("lxc/$vmid"); };
+           my ($cpuset, $path);
+           if (defined($path = $cgroup->get_path('cpuset'))) {
+               $cpuset = eval { PVE::CpuSet->new_from_path($path); };
+           } elsif (defined($path = $cgroup->get_path())) {
+               $cpuset = eval { PVE::CpuSet->new_from_path($path); };
+           } else {
+               # Container not running.
+               next;
+           }
            if (my $err = $@) {
                warn $err;
                next;
            }
+
            my @cpuset_members = $cpuset->members();
 
            my $line = ': ';