summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
diff options
context:
space:
mode:
authorJonathan Bauer2018-04-17 17:12:26 +0200
committerJonathan Bauer2018-04-17 17:12:26 +0200
commitfef4222e5aca364dae71bbbd084c3dc311d2a18f (patch)
tree1f98bcb91a6daa0f6f24bc7a7701a941255bd8cf /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
parent[dnbd3] create fuse group (diff)
downloadmltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.tar.gz
mltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.tar.xz
mltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.zip
[*] detect_cpu_flag as generic run-virt function
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index 2336718a..54aceee5 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -451,8 +451,6 @@ check_dep() {
isset ONEOF && return 1 || return 0
}
-
-
# TODO: This is only used once in the whole script:
# to cleanup the os string stored in the xml
# Since the rework of this script, the os strings come from
@@ -486,3 +484,20 @@ dir_on_tmpfs() {
done
return 0
}
+
+# Helper to detect given cpu flags.
+# If more than one flag is given, assume that matching
+# any of them is sufficient.
+# Returns 0 if detected, 1 otherwise.
+detect_cpu_flag() {
+ if [ "$#" -eq 0 ]; then
+ writelog "${FUNCNAME[0]} requires at least one argument, 0 given."
+ return 1
+ fi
+ local flags=$1
+ while [ "$#" -ne 0 ]; do
+ flags="$flags|$1"
+ shift
+ done
+ grep -m1 -qE '^flags\s*:.*\b('"${flags}"')\b' /proc/cpuinfo
+}