]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
smt: Fix check to detect if a system is running virtually
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Aug 2020 09:51:10 +0000 (11:51 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Aug 2020 09:52:15 +0000 (09:52 +0000)
/sys/hypervisor exists when a host has loaded the kvm modules.

Fixes: #12472
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/functions
src/initscripts/system/smt

index 30119918cadbe9245ef0db60ac30f1326a493caf..234b798cf1508148ccade26e21196e786180b099 100644 (file)
@@ -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
index bfa7d57b3e925f46053bbb6b63a90c5bec77b983..274ec4bbaf413dd74e09e1ad1af6310cee1026ae 100644 (file)
@@ -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