]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/virt.c
virt: Improve detection of EC2 metal instances
authorBenjamin Herrenschmidt <benh@amazon.com>
Fri, 3 Sep 2021 01:36:46 +0000 (11:36 +1000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 13 Sep 2021 16:44:20 +0000 (01:44 +0900)
commitf90eea7d18d9ebe88e6a66cd7a86b618def8945d
tree15ce46df20519da96bee66ae33721d14b8553e70
parentc116f23394261b03da3eaabded41e6b056a4d638
virt: Improve detection of EC2 metal instances

The current detection code relies on /sys/firmware/dmi/entries/0-0/raw
to disambiguate Amazon EC2 virtualized from metal instances.

Unfortunately this file is root only. Thus on a c6g.metal instance
(aarch64), we observe something like this:

$ systemd-detect-virt
amazon
$ sudo systemd-detect-virt
none

Only the latter is correct.

The right long term fix is to extend the kernel to expose the SMBIOS BIOS
Characteristics properly via /sys/class/dmi, but until this happens (and
for backwards compatibility when it does), we need a plan B.

This change implements such a workaround by falling back to using the
instance type from DMI and looking at the ".metal" string present on
metal instances.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
src/basic/virt.c