smt: Fix check to detect if a system is running virtually
Commit Message
/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 | 5 +++++
src/initscripts/system/smt | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -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
@@ -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