From: Michael Tremer Date: Fri, 21 Aug 2020 09:51:10 +0000 (+0200) Subject: smt: Fix check to detect if a system is running virtually X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e457b13eaf61b2830919e3745df3956e2042640;p=people%2Fstevee%2Fipfire-2.x.git smt: Fix check to detect if a system is running virtually /sys/hypervisor exists when a host has loaded the kvm modules. Fixes: #12472 Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 30119918ca..234b798cf1 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -784,6 +784,11 @@ umount_ramdisk() { rm -rf "${path_tmpfs}" } +# Returns true when this system running in a virtual environment +running_on_hypervisor() { + grep -qE "^flags\s+:.*hypervisor" /proc/cpuinfo +} + # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/identify_ec2_instances.html running_on_ec2() { local uuid diff --git a/src/initscripts/system/smt b/src/initscripts/system/smt index bfa7d57b3e..274ec4bbaf 100644 --- a/src/initscripts/system/smt +++ b/src/initscripts/system/smt @@ -21,7 +21,7 @@ case "${1}" in fi 2>/dev/null # Do not disable SMT inside virtual machines - if [ -d "/sys/hypervisor" ]; then + if running_on_hypervisor; then exit 0 fi