diff options
author | Jonathan Bauer | 2018-04-17 17:12:26 +0200 |
---|---|---|
committer | Jonathan Bauer | 2018-04-17 17:12:26 +0200 |
commit | fef4222e5aca364dae71bbbd084c3dc311d2a18f (patch) | |
tree | 1f98bcb91a6daa0f6f24bc7a7701a941255bd8cf /core/modules | |
parent | [dnbd3] create fuse group (diff) | |
download | mltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.tar.gz mltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.tar.xz mltk-fef4222e5aca364dae71bbbd084c3dc311d2a18f.zip |
[*] detect_cpu_flag as generic run-virt function
Diffstat (limited to 'core/modules')
4 files changed, 19 insertions, 8 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 +} diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc index 224a2b96..1db67e08 100755 --- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc +++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc @@ -92,10 +92,6 @@ finalize_machine_config() { set_attr "/VirtualBox/Machine/Hardware/BIOS/IOAPIC" "enabled" "true" fi - detect_cpu_flag() { - grep -m1 '^flags\s*:' /proc/cpuinfo | grep -qw -e "$1" - } - # PAE support? local PAE_SUPPORT="false" detect_cpu_flag "pae" && PAE_SUPPORT="true" diff --git a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc index a7d3d837..a03d9a92 100644 --- a/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc +++ b/core/modules/vmware/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc @@ -255,7 +255,7 @@ finalize_hardware() { # Enable nested virtualization if not specified in remote vmx if [ -e "/run/hwinfo" ] && ! grep -qi '^vhv\.enable' "${TMPCONFIG}" \ - && grep -qE '^flags\s*:.*\b(ept|npt)\b' "/proc/cpuinfo" \ + && detect_cpu_flag "ept" "npt" \ && [ "$VM_HW_VERSION" -ge "9" ]; then . "/run/hwinfo" [ "${HW_KVM}" = "ENABLED" ] && echo 'vhv.enable = "TRUE"' >> "${TMPCONFIG}" diff --git a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc index a7d3d837..a03d9a92 100644 --- a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc +++ b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc @@ -255,7 +255,7 @@ finalize_hardware() { # Enable nested virtualization if not specified in remote vmx if [ -e "/run/hwinfo" ] && ! grep -qi '^vhv\.enable' "${TMPCONFIG}" \ - && grep -qE '^flags\s*:.*\b(ept|npt)\b' "/proc/cpuinfo" \ + && detect_cpu_flag "ept" "npt" \ && [ "$VM_HW_VERSION" -ge "9" ]; then . "/run/hwinfo" [ "${HW_KVM}" = "ENABLED" ] && echo 'vhv.enable = "TRUE"' >> "${TMPCONFIG}" |