summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSimon Rettberg2019-10-18 13:10:56 +0200
committerSimon Rettberg2019-10-18 13:10:56 +0200
commit33560245dccbe638761790f3e6b786abcb402248 (patch)
tree1036de18f99a30a48639831df8d59a12e0e7e3bf /core
parent[hardware-stats] id44 check for /tmp/virt not /tmp (diff)
downloadmltk-33560245dccbe638761790f3e6b786abcb402248.tar.gz
mltk-33560245dccbe638761790f3e6b786abcb402248.tar.xz
mltk-33560245dccbe638761790f3e6b786abcb402248.zip
[vmware-version-check] Check if VT-x SVM is enabled at all first
Diffstat (limited to 'core')
-rwxr-xr-xcore/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version50
1 files changed, 37 insertions, 13 deletions
diff --git a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version
index 82bd7d50..0165191d 100755
--- a/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version
+++ b/core/modules/vmware-version-check/data/opt/openslx/bin/vmware-get-supported-version
@@ -5,18 +5,42 @@
export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin
-get_supported_version() {
- local vendor="$( awk '$1 == "vendor_id" {print $NF;exit}' /proc/cpuinfo )"
- local version=12
- if [ "$vendor" = "GenuineIntel" ]; then
- modprobe msr
- flag="$( rdmsr --bitfield 5:5 0x485 )"
- [ "$flag" = 1 ] && version=15
- elif [ "$vendor" = "AuthenticAMD" ]; then
- family="$( awk '$1$2 == "cpufamily" {print $NF;exit}' /proc/cpuinfo )"
- [ "$family" -ge 21 ] && version=15
+VIRTTYPE=$(grep -m1 '^flags\s*:' /proc/cpuinfo | grep -wo -e svm -e vmx)
+
+if [ -z "$VIRTTYPE" ]; then
+ echo 12
+ exit 0
+fi
+
+modprobe msr
+
+VT=
+if [ "$VIRTTYPE" = "vmx" ]; then # intel
+ BIT1=$(rdmsr --bitfield 0:0 0x3a 2>/dev/null || echo "fail")
+ BIT2=$(rdmsr --bitfield 2:2 0x3a 2>/dev/null || echo "fail")
+ if [ "$BIT1" = "0" ] || [ "$BIT2" = "1" ]; then
+ VT="ENABLED"
+ fi
+elif [ "$VIRTTYPE" = "svm" ]; then # amd
+ BIT=$(rdmsr --bitfield 4:4 0xc0010114 2>/dev/null || echo "fail")
+ if [ "$BIT" = "0" ]; then
+ VT="ENABLED"
fi
- echo "$version"
-}
+fi
+
+if [ "$VT" != "ENABLED" ]; then
+ echo 12
+ exit 0
+fi
+
+version=12
+if [ "$VIRTTYPE" = "vmx" ]; then
+ flag="$( rdmsr --bitfield 5:5 0x485 )"
+ [ "$flag" = "1" ] && version=15
+elif [ "$VIRTTYPE" = "svm" ]; then
+ family="$( awk '$1$2 == "cpufamily" {print $NF;exit}' /proc/cpuinfo )"
+ [ "$family" -ge 21 ] && version=15
+fi
+
+echo "$version"
-get_supported_version