summaryrefslogtreecommitdiffstats
path: root/remote/modules
diff options
context:
space:
mode:
authorSimon Rettberg2016-03-22 14:35:46 +0100
committerSimon Rettberg2016-03-22 14:35:46 +0100
commit65674c3d8915b2170b3a4f8c0722cf14dee52947 (patch)
tree81c743a69850ba45b5d4308693c81075d221a7c0 /remote/modules
parent[run-virt] Default to vmware shared folder for homedir for backwards compat (diff)
downloadtm-scripts-65674c3d8915b2170b3a4f8c0722cf14dee52947.tar.gz
tm-scripts-65674c3d8915b2170b3a4f8c0722cf14dee52947.tar.xz
tm-scripts-65674c3d8915b2170b3a4f8c0722cf14dee52947.zip
[run-virt/hwstats/vmware] Only enable KVM in guest if hw supports it
Otherwise vmware will refuse to start the virtual machine.
Diffstat (limited to 'remote/modules')
-rwxr-xr-xremote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats15
-rw-r--r--remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc22
-rw-r--r--remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc8
3 files changed, 33 insertions, 12 deletions
diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index ce910a2b..0331cada 100755
--- a/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -129,13 +129,13 @@ fi
# A) Read system model and manufacturer
dmidec() {
- local MODEL=$(dmidecode "$@" | sed 's/\s\s*/ /g;s/^ //;s/ $//')
- case "$MODEL" in
+ local LMODEL=$(dmidecode "$@" 2>/dev/null | sed 's/\s\s*/ /g;s/^ //;s/ $//')
+ case "$LMODEL" in
""|*"Product Name"*|*"be filled"*|"unknown"|*"product name"*)
- MODEL="Unknown"
+ LMODEL="Unknown"
;;
esac
- echo "$MODEL"
+ echo "$LMODEL"
}
MODEL=$(dmidec -s system-product-name)
MANUF=$(dmidec -s system-manufacturer)
@@ -180,6 +180,13 @@ EOF
[ -n "$ALLSMART" ] && rm -f -- "$ALLSMART"
+# Put some info in local file for later use
+cat > "/run/hwinfo" <<HORST
+HW_KVM='${VT}'
+HW_ID44='${ID44}'
+HW_MBRAM='${RAM}'
+HORST
+
# Fire away
for DELAY in 1 1 0; do
if curl --data-urlencode "type=~poweron" --data-urlencode "uuid=$UUID" --data-urlencode "macaddr=$MAC" \
diff --git a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
index e74423ec..09430718 100644
--- a/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
+++ b/remote/modules/run-virt/data/opt/openslx/scripts/includes/setup_virtual_floppy.inc
@@ -16,7 +16,12 @@ mkfs.fat "${FLOPPYIMG}" || mkfs.vfat "${FLOPPYIMG}" || mkdosfs "${FLOPPYIMG}"
# Create file with resolution information etc.
. "/opt/openslx/inc/shares"
-[ -z "$SHARE_REMAP_MODE" ] && SHARE_REMAP_MODE="3"
+if [ -z "$SHARE_REMAP_MODE" ]; then
+ SHARE_REMAP_MODE_INI="0"
+ SHARE_REMAP_MODE="3"
+else
+ SHARE_REMAP_MODE_INI="$SHARE_REMAP_MODE"
+fi
[ -z "$SHARE_CREATE_MISSING_REMAP" ] && SHARE_CREATE_MISSING_REMAP="1"
RESOLUTION=$(xrandr | grep -o -E 'connected\s*(primary)?\s*[0-9]+x[0-9]+\+0\+0' \
| grep -o -E -m1 '[0-9]+x[0-9]+')
@@ -25,7 +30,7 @@ cat > "${TMPDIR}/geraffel.ini" <<-HIER
[openslx]
resolution=${RESOLUTION}
createMissingRemap=${SHARE_CREATE_MISSING_REMAP}
-remapMode=${SHARE_REMAP_MODE}
+remapMode=${SHARE_REMAP_MODE_INI}
homeDrive=${SHARE_HOME_DRIVE}
[remap]
@@ -36,8 +41,14 @@ media=${SHARE_MEDIA}
other=${SHARE_OTHER}
HIER
+# Legacy: hostres.txt
+cat > "${TMPDIR}/hostres.txt" <<-HIER
+${RESOLUTION}
+This file is deprecated! Use geraffel.ini
+HIER
+
# Create file for network shares to mount
-SHARES="${TMPDIR}/shares.dat"
+declare -rg SHARES="${TMPDIR}/shares.dat"
touch "${SHARES}"
chmod 0600 "${SHARES}"
if pwdaemon --query "${TMPHOME}/.pwsocket" > "${SHARES}"; then
@@ -54,9 +65,8 @@ if pwdaemon --query "${TMPHOME}/.pwsocket" > "${SHARES}"; then
fi
# Copy all them files into floppy image
-mcopy -i "${FLOPPYIMG}" "${TMPDIR}/geraffel.ini" "::/"
+mcopy -i "${FLOPPYIMG}" "${TMPDIR}/geraffel.ini" "${TMPDIR}/hostres.txt" "${SHARES}" "::/"
mcopy -i "${FLOPPYIMG}" "$VMCHOOSER_DIR/data/openslx.exe" "::/"
-mcopy -i "${FLOPPYIMG}" "${SHARES}" "::/"
-rm -f -- "${SHARES}"
+rm -f -- "${SHARES}" "${TMPDIR}/geraffel.ini" "${TMPDIR}/hostres.txt"
unset SHARES VAR NETHOME
diff --git a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc
index d86a707a..1c7aa533 100644
--- a/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc
+++ b/remote/modules/vmware/data/opt/openslx/vmchooser/vmware/includes/parse_vmx.inc
@@ -128,8 +128,12 @@ if [ -n "$SLX_EXAM" ]; then
fi
# Enable nested virtualization if not specified in remote vmx
-grep -qi '^vhv\.enable' "${TMPDIR}/${IMGUUID}" || echo 'vhv.enable = "TRUE"' >> "${TMPDIR}/${IMGUUID}"
-grep -qi '^vpmc\.enable' "${TMPDIR}/${IMGUUID}" || echo 'vpmc.enable = "TRUE"' >> "${TMPDIR}/${IMGUUID}"
+if [ -e "/run/hwinfo" ] && ! grep -qi '^vhv\.enable' "${TMPDIR}/${IMGUUID}"; then
+ . "/run/hwinfo"
+ [ "${HW_KVM}" = "ENABLED" ] && echo 'vhv.enable = "TRUE"' >> "${TMPDIR}/${IMGUUID}"
+fi
+# TODO: Need a way to check if supported by hardware before enabling!
+#grep -qi '^vpmc\.enable' "${TMPDIR}/${IMGUUID}" || echo 'vpmc.enable = "TRUE"' >> "${TMPDIR}/${IMGUUID}"
# Killing duplicate lines (output much nicer than sort -u):
awk '!a[$0]++' "${TMPDIR}/${IMGUUID}" > "${TMPDIR}/${IMGUUID}.tmp" && mv "${TMPDIR}/${IMGUUID}.tmp" "${TMPDIR}/${IMGUUID}"