From 568abb4bfb3c27fde9077f1e70dd83de0cbe484e Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Wed, 17 Jul 2019 15:03:43 +0200 Subject: [PATCH] Include CPU flags in read_cpuinfo Signed-off-by: Stefan Reiter --- src/PVE/ProcFSTools.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm index 1b98b1e..027aa3a 100644 --- a/src/PVE/ProcFSTools.pm +++ b/src/PVE/ProcFSTools.pm @@ -29,6 +29,7 @@ sub read_cpuinfo { mhz => 0, cpus => 1, sockets => 1, + flags => '', }; my $fh = IO::File->new ($fn, "r"); @@ -43,19 +44,22 @@ sub read_cpuinfo { $res->{model} = $1 if $res->{model} eq 'unknown'; } elsif ($line =~ m/^cpu\s+MHz\s*:\s*(\d+\.\d+)\s*$/i) { $res->{mhz} = $1 if !$res->{mhz}; - } elsif ($line =~ m/^flags\s*:.*(vmx|svm)/) { - $res->{hvm} = 1; # Hardware Virtual Machine (Intel VT / AMD-V) + } elsif ($line =~ m/^flags\s*:\s*(.*)$/) { + $res->{flags} = $1 if !length $res->{flags}; } elsif ($line =~ m/^physical id\s*:\s*(\d+)\s*$/i) { $idhash->{$1} = 1; } } + # Hardware Virtual Machine (Intel VT / AMD-V) + $res->{hvm} = $res->{flags} =~ m/\s(vmx|svm)\s/; + $res->{sockets} = scalar(keys %$idhash) || 1; $res->{cpus} = $count; $fh->close; - + $cpuinfo = $res; return $res; -- 2.39.2