summaryrefslogtreecommitdiffstats
path: root/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins
diff options
context:
space:
mode:
authorJonathan Bauer2018-04-13 18:13:25 +0200
committerJonathan Bauer2018-04-13 18:13:25 +0200
commit0ed5e3423df24d5edac94288538033b7763f6dbc (patch)
tree6c2830b01ebccfb9ab1309881732c08a9f8de514 /core/modules/vbox-src/data/opt/openslx/vmchooser/plugins
parent[run-virt] error msg for missing plugin dir (diff)
downloadmltk-0ed5e3423df24d5edac94288538033b7763f6dbc.tar.gz
mltk-0ed5e3423df24d5edac94288538033b7763f6dbc.tar.xz
mltk-0ed5e3423df24d5edac94288538033b7763f6dbc.zip
[vbox-src] more vbox plugin fixes
* use HW_CORES from /run/hwinfo * add usb attach script [WIP] * udev rule to trigger attach script when usb is connected * edit_attr -> set_attr now always creating missing nodes/attributes ...and prolly more I cant think of now ...
Diffstat (limited to 'core/modules/vbox-src/data/opt/openslx/vmchooser/plugins')
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/finalize_machine_config.inc55
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc8
-rwxr-xr-xcore/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc41
3 files changed, 76 insertions, 28 deletions
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 c5704f8c..ab9cd643 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
@@ -31,14 +31,6 @@ finalize_machine_config() {
sed -i 's,%OpenSLX_CPU%,'"${CPU_CORES}"',g' $TMPCONFIG
sed -i 's,%OpenSLX_MEMORY%,'"${VM_MEM}"',g' $TMPCONFIG
- # Add a node for the SharedFolder
- add_node "/VirtualBox/Machine/Hardware" "SharedFolders"
- add_node \
- "/VirtualBox/Machine/Hardware/SharedFolders" "SharedFolder" \
- "name=${HOME_SHARE_NAME}" \
- "hostPath=${HOME_SHARE_PATH}" \
- "writable=true" \
- "autoMount=true"
# Add a HardDisk node for the snapshot
add_node \
"/VirtualBox/Machine/MediaRegistry/HardDisks/HardDisk" "HardDisk" \
@@ -46,6 +38,7 @@ finalize_machine_config() {
"location=$VBOX_SNAPSHOT_DIR/{${SNAPSHOT_UUID}}.vdi" \
"format=VDI" \
"type=Normal"
+
# add storage controller and 2 floppies to it
add_node \
"/VirtualBox/Machine/StorageControllers" "StorageController" \
@@ -71,20 +64,54 @@ finalize_machine_config() {
'/VirtualBox/Machine/StorageControllers/StorageController/AttachedDevice[@device="1"]' "Image" \
"uuid={${SLX_FLOPPY_UUID}}"
- # set Virtual Memory value
- edit_attr "/VirtualBox/Machine/Hardware/Display" "VRAMSize" "${GUESTVRAM}"
- edit_attr --create "/VirtualBox/Machine/Hardware/Display" "accelerate2DVideo" "true"
+
+ # Add a node for the SharedFolder
+ add_node "/VirtualBox/Machine/Hardware" "SharedFolders"
+ if [ -n "${HOME_SHARE_NAME}" -a -n "${HOME_SHARE_PATH}" -a -d "${HOME_SHARE_PATH}" ]; then
+ add_node \
+ "/VirtualBox/Machine/Hardware/SharedFolders" "SharedFolder" \
+ "name=${HOME_SHARE_NAME}" \
+ "hostPath=${HOME_SHARE_PATH}" \
+ "writable=true" \
+ "autoMount=true"
+ fi
# set the MAC address
- edit_attr "/VirtualBox/Machine/Hardware/Network/Adapter" "MACAddress" "${VM_VDE_MAC_ADDR}"
+ set_attr "/VirtualBox/Machine/Hardware/Network/Adapter" "MACAddress" "${VM_VDE_MAC_ADDR}"
# check if KVM is available and activate it if so
if source /run/hwinfo && [ "${HW_KVM}" = "ENABLED" ]; then
- edit_attr --create "/VirtualBox/Machine/Hardware/Paravirt" "provider" "KVM"
+ set_attr "/VirtualBox/Machine/Hardware/Paravirt" "provider" "KVM"
fi
+
# activate IOAPIC needed for multi core (?)
if [ $CPU_CORES -gt 1 ]; then
- edit_attr --create "/VirtualBox/Machine/Hardware/BIOS/IOAPIC" "enabled" "true"
+ set_attr "/VirtualBox/Machine/Hardware/BIOS/IOAPIC" "enabled" "true"
+ fi
+
+ # PAE support?
+ local PAE_SUPPORT="$(grep -oE '\s+pae\s+' /proc/cpuinfo)"
+ local PAE_ENABLE="true"
+ [ -z "$PAE_SUPPORT" ] && PAE_ENABLE="false"
+ set_attr "/VirtualBox/Machine/Hardware/CPU/PAE" "enabled" "${PAE_ENABLE}"
+
+ # LongMode?
+ local LM_SUPPORT="$(grep -oE '\s+lm\s+' /proc/cpuinfo)"
+ local LM_ENABLE="true"
+ [ -z "$LM_SUPPORT" ] && LM_ENABLE="false"
+ set_attr "/VirtualBox/Machine/Hardware/CPU/LongMode" "enabled" "${LM_ENABLE}"
+
+ # Page size extensions?
+ local PSE_SUPPORT="$(grep -oE '\s+pse\s+' /proc/cpuinfo)"
+ local PSE_ENABLE="true"
+ [ -z "$PSE_SUPPORT" ] && PSE_ENABLE="false"
+ set_attr "/VirtualBox/Machine/Hardware/CPU/HardwareVirtExLargePages" "enabled" "${PSE_ENABLE}"
+
+ # EXPERIMENTAL: check for USB 3 support
+ local XHCI_OK="$(lsusb -t | grep xhci)"
+ if [ -n "$XHCI_OK" ]; then
+ del_node "/VirtualBox/Machine/Hardware/USB"
+ add_node "/VirtualBox/Machine/Hardware/USB/Controllers" "Controller" "name=xHCI" "type=XHCI"
fi
cp $TMPCONFIG /tmp/vbox-last-config
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
index ec720551..def5280c 100755
--- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
+++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/guest_hardware_limits.inc
@@ -110,8 +110,14 @@ set_hardware_limits() {
declare -rg GUESTVRAM=$MAXVRAM
+ # check /run/hwinfo for CORE not THREADS
+ # vbox seems to only want maximum cores = number of
+ # physical cores of the cpu, so use that
+ if [ -e /run/hwinfo ]; then
+ . /run/hwinfo
+ notempty HW_CORES && CPU_CORES="$HW_CORES"
+ fi
[ "${CPU_CORES}" -gt "{MAXCORES}" ] && CPU_CORES="${MAXCORES}"
-
[ "${VM_MEM}" -gt "${MAXMEM}" ] && VM_MEM="${MAXMEM}"
return 0
diff --git a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc
index d30a0408..a1da3016 100755
--- a/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc
+++ b/core/modules/vbox-src/data/opt/openslx/vmchooser/plugins/virtualbox/includes/init_core.inc
@@ -47,26 +47,32 @@ add_node() {
${ATTRS_OPTS} \
"${TMPCONFIG}"
}
-# edit_attr [--create] <node_xpath> <attr=value>
-# --create would create the node if it does not exist
-edit_attr() {
- local CREATE=
- if [ "$1" = "--create" ]; then
- CREATE=yo
- shift
- fi
+# set_attr <node_xpath> <attr> <value>
+set_attr() {
if [ $# -ne 3 ]; then
writelog "${FUNCNAME[0]} requires 3 args, $# given."
cleanexit 1
fi
- if notempty CREATE && ! node_exists "$1"; then
+ if ! node_exists "$1"; then
+ writelog "Node $1 missing"
add_node "${1%/*}" "${1##*/}" \
"$2=$3"
else
- xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \
- -u "$(print_namespaced "x" "$1")/@$2" \
- -v "$3" \
- "${TMPCONFIG}"
+ if ! attr_exists "$1" "$2"; then
+ writelog "Attr $2 of $1 missing"
+ xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \
+ -i "$(print_namespaced "x" "$1")" \
+ -t attr -n "$2" -v "$3" \
+ "${TMPCONFIG}"
+ writelog "Returned with $?"
+ else
+ writelog "Attr $2 exists"
+ xmlstarlet ed -L -N x="${VBOX_NAMESPACE}" \
+ -u "$(print_namespaced "x" "$1")/@$2" \
+ -v "$3" \
+ "${TMPCONFIG}"
+ writelog "Returned with $?"
+ fi
fi
}
del_node() {
@@ -78,6 +84,15 @@ del_node() {
-d "$(print_namespaced "x" "$1")" \
"${TMPCONFIG}"
}
+attr_exists() {
+ if [ $# -ne 2 ]; then
+ writelog "${FUNCNAME[0]} requires node and attribute as args, $# given."
+ cleanexit 1
+ fi
+ xmlstarlet -q sel -N x="${VBOX_NAMESPACE}" \
+ -t -v "$(print_namespaced "x" "$1")/@$2" \
+ "${TMPCONFIG}"
+}
node_exists() {
if [ $# -ne 1 ]; then
writelog "${FUNCNAME[0]} requires one arg, $# given."