Bug#1036589: hw-detect: Investigate expanding virtualization detection
Cyril Brulebois <kibi@debian.org> (2023-05-23):
> The hw-detect.finish-install.d/08hw-detect script was inspired by
> systemd's detect_vm function, and that part was last touched in 2019.
>
> There were many changes in systemd, and it might make sense to catch up.
> Its dmi_vendor_table looks like this currently:
>
> ...
>
> This means a few additions compared to our detect_virt_dmi_entry()
> function. That being said, we're talking about a finish-install script,
> which tries to run systemd-detect-virt inside target, which is part of
> systemd. So in the general case, we shouldn't have to rely on our
> fallback…
Untested patch attached.
Perhaps Devuan and other non-systemd distros would use the fallback?
Thank you!
Daniel Lewart
Urbana, Illinois
diff -ru a/hw-detect.finish-install.d/08hw-detect b/hw-detect.finish-install.d/08hw-detect
--- a/hw-detect.finish-install.d/08hw-detect 2023-03-13 05:43:20.000000000 -0500
+++ b/hw-detect.finish-install.d/08hw-detect 2024-12-24 22:00:00.000000000 -0600
@@ -9,16 +9,24 @@
if [ ! -e "$entry" ]; then
return
fi
- case "$(cat $entry)" in
- KVM*) echo "kvm";;
- QEMU*) echo "qemu";;
- VMware*) echo "vmware";;
- VMW*) echo "vmware";;
- innotek*) echo "oracle";;
- Xen*) echo "xen";;
- Bochs*) echo "bochs";;
- Parallels*) echo "parallels";;
- BHYVE*) echo "bhyve";;
+ case "$(cat "$entry")" in
+ "KVM"*) echo "kvm";;
+ "OpenStack"*) echo "kvm";;
+ "KubeVirt"*) echo "kvm";;
+ "Amazon EC2"*) echo "amazon";;
+ "QEMU"*) echo "qemu";;
+ "VMware"*) echo "vmware";;
+ "VMW"*) echo "vmware";;
+ "innotek GmbH"*) echo "oracle";;
+ "VirtualBox"*) echo "oracle";;
+ "Oracle Corporation"*) echo "oracle";;
+ "Xen"*) echo "xen";;
+ "Bochs"*) echo "bochs";;
+ "Parallels"*) echo "parallels";;
+ "BHYVE"*) echo "bhyve";;
+ "Hyper-V"*) echo "microsoft";;
+ "Apple Virtualization"*) echo "apple";;
+ "Google Compute Engine"*) echo "google";;
esac
}
@@ -26,9 +34,10 @@
local path
local result
for path in /sys/class/dmi/id/product_name \
- /sys/class/dmi/id/sys_vendor \
+ /sys/class/dmi/id/sys_vendor \
/sys/class/dmi/id/board_vendor \
- /sys/class/dmi/id/bios_vendor; do
+ /sys/class/dmi/id/bios_vendor \
+ /sys/class/dmi/id/product_version; do
result=$(detect_virt_dmi_entry $path)
if [ -n "$result" ]; then
echo "$result"
Reply to: