]> git.proxmox.com Git - pve-common.git/commitdiff
Include CPU flags in read_cpuinfo
authorStefan Reiter <s.reiter@proxmox.com>
Wed, 17 Jul 2019 13:03:43 +0000 (15:03 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 23 Jul 2019 06:46:49 +0000 (08:46 +0200)
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
src/PVE/ProcFSTools.pm

index 1b98b1eab54b72ec1a6164625be62e0af671c7fc..027aa3ad1bc5140926e8367dc07f76b7f6469bf9 100644 (file)
@@ -29,6 +29,7 @@ sub read_cpuinfo {
        mhz => 0,
        cpus => 1,
        sockets => 1,
        mhz => 0,
        cpus => 1,
        sockets => 1,
+       flags => '',
     };
 
     my $fh = IO::File->new ($fn, "r");
     };
 
     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};
            $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;
        }
     }
 
        } 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;
     $res->{sockets} = scalar(keys %$idhash) || 1;
 
     $res->{cpus} = $count;
 
     $fh->close;
-    
+
     $cpuinfo = $res;
 
     return $res;
     $cpuinfo = $res;
 
     return $res;