From 65674c3d8915b2170b3a4f8c0722cf14dee52947 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 22 Mar 2016 14:35:46 +0100 Subject: [run-virt/hwstats/vmware] Only enable KVM in guest if hw supports it Otherwise vmware will refuse to start the virtual machine. --- .../opt/openslx/scripts/systemd-hardware_stats | 15 +++++++++++---- .../scripts/includes/setup_virtual_floppy.inc | 22 ++++++++++++++++------ .../vmchooser/vmware/includes/parse_vmx.inc | 8 ++++++-- 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'remote/modules') 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" < "${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}" -- cgit v1.2.3-55-g7522