From c79b5453a64a6d8699033e381b19402bb42606b4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 13 Dec 2021 13:28:36 +0100 Subject: [vmware-common] Set video memory size if not found ...cap to sane min/max if found in source vmx, depending on host memory size. --- .../plugins/vmware/includes/write_final_vmx.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'core/modules/vmware-common') diff --git a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc index 698382f5..2a023fa2 100644 --- a/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc +++ b/core/modules/vmware-common/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc @@ -274,6 +274,22 @@ setup_graphics() { EOF ;; esac + local vram max_vram exists + # VM_MEM in MB + max_vram="$(( (VM_MEM / 4) * 1024 ))" + (( max_vram > 2097152 )) && max_vram=2097152 + vram=$( < "${TMPCONFIG}" grep -m1 -i '^svga\.graphicsMemoryKB' \ + | sed -r 's/^[^=]+//;s/^(\s|=|")*//;s/(\s|")+$//' ) + existing="$vram" + if [ -z "$vram" ] || (( vram > max_vram )); then + vram="$max_vram" + fi + (( vram < 131072 )) && vram=131072 + if [ -z "$existing" ]; then + echo 'svga.graphicsMemoryKB = "'"$vram"'"' >> "${TMPCONFIG}" + else + sed -i 's/^svga\.graphicsMemoryKB.*$/svga.graphicsMemoryKB = "'"$vram"'"/' "${TMPCONFIG}" + fi # Killing duplicate lines (output much nicer than sort -u): awk '!a[$0]++' "${TMPCONFIG}" > "${TMPCONFIG}.tmp" && mv -f "${TMPCONFIG}.tmp" "${TMPCONFIG}" -- cgit v1.2.3-55-g7522