]> git.proxmox.com Git - pve-common.git/commitdiff
cpuset: further factorization
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 30 Mar 2020 14:30:34 +0000 (16:30 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 31 Mar 2020 06:50:10 +0000 (08:50 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/CpuSet.pm

index fe36536badc8bdb50fdcf97a4e67ab0892da2a4d..1f41e8f6825b6f63b9d5a06d0b70481ddc4e4d84 100644 (file)
@@ -14,18 +14,25 @@ sub new {
     return $self;
 }
 
-# Create a new set with the contents of a cgroup-v1 subdirectory
+# Create a new set with the contents of a cgroup-v1 subdirectory.
 sub new_from_cgroup {
     my ($class, $cgroup, $effective) = @_;
 
+    return $class->new_from_path("/sys/fs/cgroup/cpuset/$cgroup", $effective);
+}
+
+# Create a new set from the contents of a complete path to a cgroup directory.
+sub new_from_path {
+    my ($class, $path, $effective) = @_;
+
     my $kind = $effective ? 'effective_cpus' : 'cpus';
 
-    my $filename = "/sys/fs/cgroup/cpuset/$cgroup/cpuset.$kind";
+    my $filename = "$path/cpuset.$kind";
     my $set_text = PVE::Tools::file_read_firstline($filename) // '';
 
     my ($count, $members) = parse_cpuset($set_text);
 
-    die "got empty cpuset for cgroup '$cgroup'\n"
+    die "got empty cpuset for cgroup '$path'\n"
        if !$count;
 
     return $class->new($members);