From 755182d9f38b23ff8e13dbcb81f52c3f51aaeebc Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 8 Oct 2025 13:37:53 +0200 Subject: [PATCH] Implement KVM support validation in reset.sh Add KVM support checks and error handling --- src/reset.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/reset.sh b/src/reset.sh index dacab64..2016317 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -141,6 +141,55 @@ if [[ "$RAM_CHECK" != [Nn]* ]] && (( (RAM_WANTED + RAM_SPARE) > RAM_AVAIL )); th info "$msg" fi +# Check KVM support + +if [[ "$KVM" == [Nn]* ]]; then + warn "KVM acceleration is disabled, this will cause the machine to run about 10 times slower!" +else + if [[ "${ARCH,,}" != "amd64" ]]; then + KVM="N" + warn "your CPU architecture is ${ARCH^^} and cannot provide KVM acceleration for x64 instructions, so the machine will run about 10 times slower." + fi +fi + +if [[ "$KVM" != [Nn]* ]]; then + + KVM_ERR="" + + if [ ! -e /dev/kvm ]; then + KVM_ERR="(/dev/kvm is missing)" + else + if ! sh -c 'echo -n > /dev/kvm' &> /dev/null; then + KVM_ERR="(/dev/kvm is unwriteable)" + else + flags=$(sed -ne '/^flags/s/^.*: //p' /proc/cpuinfo) + if ! grep -qw "vmx\|svm" <<< "$flags"; then + KVM_ERR="(not enabled in BIOS)" + fi + fi + fi + + if [ -n "$KVM_ERR" ]; then + KVM="N" + if [[ "$OSTYPE" =~ ^darwin ]]; then + warn "you are using macOS which has no KVM support, so the machine will run about 10 times slower." + else + kernel=$(uname -a) + case "${kernel,,}" in + *"microsoft"* ) + error "Please bind '/dev/kvm' as a volume in the optional container settings when using Docker Desktop." ;; + *"synology"* ) + error "Please make sure that Synology VMM (Virtual Machine Manager) is installed and that '/dev/kvm' is binded to this container." ;; + *) + error "KVM acceleration is not available $KVM_ERR, this will cause the machine to run about 10 times slower." + error "See the FAQ for possible causes, or disable acceleration by adding the \"KVM=N\" variable (not recommended)." ;; + esac + [[ "$DEBUG" != [Yy1]* ]] && exit 88 + fi + fi + +fi + # Cleanup files rm -f /run/shm/qemu.* rm -f /run/shm/dsm.url @@ -149,6 +198,7 @@ rm -f /run/shm/dsm.url rm -rf /tmp/dsm rm -rf "$STORAGE/tmp" + : "${COM_PORT:="2210"}" # Comm port : "${MON_PORT:="7100"}" # Monitor port : "${WEB_PORT:="5000"}" # Webserver port