shirou / gopsutil

psutil for golang
Other
10.66k stars 1.59k forks source link

`Virtualization` is inconsistent when `HOST_PROC` is defined #1736

Open pgimalac opened 1 month ago

pgimalac commented 1 month ago

In a container where the host's /proc is mounted and given by the HOST_PROC environment variable, what is host.Virtualization supposed to return ? Is it supposed to give information about the host or about the container ?

The function checks a lot of files to get information, some about the host (eg. $HOST_PROC/cpuinfo) and some about the current process (which relate to the container, eg. $HOST_PROC/self/cgroup), which is inconsistent.

In particular when called inside an lxc container with HOST_PROC given then it will still show lxc (despite the host itself not being virtualized).