Am 02.09.25 um 1:23 PM schrieb Daniel Kral:
> The address sizes line is taken from the kernel's implementation of
> /proc/cpuinfo in arch/x86/kernel/cpu/proc.c.
> 
> Signed-off-by: Daniel Kral <d.k...@proxmox.com>
> ---
>  src/PVE/ProcFSTools.pm | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/PVE/ProcFSTools.pm b/src/PVE/ProcFSTools.pm
> index 9bfac2c..41efd1f 100644
> --- a/src/PVE/ProcFSTools.pm
> +++ b/src/PVE/ProcFSTools.pm
> @@ -32,6 +32,8 @@ sub read_cpuinfo {
>          cpus => 1,
>          sockets => 1,
>          flags => '',
> +        phys_bits => 0,
> +        virt_bits => 0,
>      };
>  
>      my $fh = IO::File->new($fn, "r");
> @@ -54,6 +56,9 @@ sub read_cpuinfo {
>              $idhash->{$1} = 1 if not defined($idhash->{$1});
>          } elsif ($line =~ m/^cpu cores\s*:\s*(\d+)\s*$/i) {
>              $idhash->{$cpuid} = $1 if defined($idhash->{$cpuid});
> +        } elsif ($line =~ m/^address sizes\t: (\d+) bits physical, (\d+) 
> bits virtual$/i) {

I'd prefer to match whitespaces with \s* and also allow whitespaces at
the end like is done in the regex for CPU cores. This is for
future-proofing, because e.g. the file could get a new option with a
long name for which additional tabs will be introduced.

> +            $res->{phys_bits} = $1 if !$res->{phys_bits};
> +            $res->{virt_bits} = $2 if !$res->{virt_bits};
>          }
>      }
>  



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to