I notice that lxcfs is not installed. And lxd is not available in ArchLinux official repo, I install it from ArchLinuxCN repo. After install lxcfs, and start lxcfs.service, things works as expected.
Do lxd or lxc depends on lxcfs? Maybe there is a package issue in ArchLinux repo.
This key limits the number of cores that the container will be using.
It does not hide (at this time?) the number of cores of the CPU to show only those that you have specified.
I think that the parent process of the container is the one that will perform the limit of the number of cores, therefore even if the container sees 48 cores, it can’t touch all of them.
The containers do not have a full view of the hardware of the host, and whatever view they have, is controlled by LXCFS. It is up to what is supported currently by LXCFS, whether a container sees the full number of the cores, or a reduced number.
Here is the latest release of LXCFS, along with the list of changes,
You can see that in the recent changes, there is even better virtualization support for /proc/cpuinfo and other resources in /proc.
But which version of LXCFS does your LXD installation have?
If it is the snap (3.16), here is the command to check the version. If using the deb package, adapt the pathname accordingly.
You are reporting that on LXD 2.0, the container sees only the number of CPUs that you have set in limits.cpus. I verify that the same happens in LXD 3.16, therefore this feature (viewing the number of cores in /proc/cpuinfo) has been supported since at least LXD 2.0.
Apparently, in the case of ArchLinux and the packaging of LXD, the lxcfs package is likely recommended (not required), hence the users should manually check that it gets installed.