From ae97d5532d5a8a6754a940451c0b3bfa4bcd7f30 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 28 Oct 2016 17:43:41 +0200 Subject: [PATCH] CpuSet: read $MAX_CPUID from /proc/cpuinfo --- src/PVE/CpuSet.pm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/PVE/CpuSet.pm b/src/PVE/CpuSet.pm index 4004bb3..753b3cd 100644 --- a/src/PVE/CpuSet.pm +++ b/src/PVE/CpuSet.pm @@ -3,8 +3,20 @@ package PVE::CpuSet; use strict; use warnings; use PVE::Tools; +use PVE::ProcFSTools; -our $MAX_CPUID = 256; # should be enough for the next years +my $MAX_CPUID; + +sub max_cpuid { + + return $MAX_CPUID if defined($MAX_CPUID); + + my $cpuinfo = PVE::ProcFSTools::read_cpuinfo(); + + $MAX_CPUID = $cpuinfo->{cpus} || 1; + + return $MAX_CPUID; +} sub new { my ($this) = @_; @@ -12,7 +24,9 @@ sub new { my $class = ref($this) || $this; my $self = bless { members => {} }, $class; - + + max_cpuid() if !defined($MAX_CPUID); # initialize $MAX_CPUID + return $self; } -- 2.39.2