From a45dffbce1a71b0f0f5c784f2ecbe64a9b7ea8b3 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 19:47:19 +0200 Subject: [PATCH 1/5] Allow running without KVM in debug mode --- run/run.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/run/run.sh b/run/run.sh index 01e6ab1..fc2cc8a 100755 --- a/run/run.sh +++ b/run/run.sh @@ -49,17 +49,22 @@ if [ -e /dev/kvm ] && sh -c 'echo -n > /dev/kvm' &> /dev/null; then fi fi -[ -z "${KVM_OPTS}" ] && echo "Error: KVM acceleration is disabled.." && exit 88 +if [ -z "${KVM_OPTS}" ]; then + KVM_OPTS="-machine usb=off" + if [ "$DEBUG" != "Y" ]; then + echo "Error: KVM acceleration is disabled.." && exit 88 + fi +fi -DEF_OPTS="-nographic" RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1" -EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0,bus=pcie.0,addr=0x4 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0" +DEF_OPTS="-nographic -nodefaults -pidfile ${_QEMU_PID} -overcommit mem-lock=off" +EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0" ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${KVM_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}" set -m ( - qemu-system-x86_64 ${ARGS} & echo $! > ${_QEMU_PID} + qemu-system-x86_64 ${ARGS} & ) set +m From 4c8c8c2c567189e64d945a2ffe05b5a49ef1b027 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 19:53:23 +0200 Subject: [PATCH 2/5] Pidfile --- run/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/run.sh b/run/run.sh index fc2cc8a..b2905bb 100755 --- a/run/run.sh +++ b/run/run.sh @@ -58,13 +58,13 @@ fi RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1" -DEF_OPTS="-nographic -nodefaults -pidfile ${_QEMU_PID} -overcommit mem-lock=off" +DEF_OPTS="-nographic -nodefaults -overcommit mem-lock=off" EXTRA_OPTS="-device virtio-balloon-pci,id=balloon0 -object rng-random,id=rng0,filename=/dev/urandom -device virtio-rng-pci,rng=rng0" ARGS="${DEF_OPTS} ${CPU_OPTS} ${RAM_OPTS} ${KVM_OPTS} ${MON_OPTS} ${SERIAL_OPTS} ${NET_OPTS} ${DISK_OPTS} ${EXTRA_OPTS}" set -m ( - qemu-system-x86_64 ${ARGS} & + qemu-system-x86_64 ${ARGS} & echo $! > ${_QEMU_PID} ) set +m From e753be91338510a0a6b5810c44294695982649af Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 19:54:15 +0200 Subject: [PATCH 3/5] Quotes --- run/network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/network.sh b/run/network.sh index a89bf9a..dad2de8 100644 --- a/run/network.sh +++ b/run/network.sh @@ -58,7 +58,7 @@ fi [ ! -c /dev/net/tun ] && echo "Error: TUN network interface not available..." && exit 85 -if [ $DEBUG = "Y" ]; then +if [ "$DEBUG" = "Y" ]; then ifconfig ip link ip route @@ -92,7 +92,7 @@ else [[ -z $(hostname -d) ]] || DNSMASQ_OPTS="$DNSMASQ_OPTS --dhcp-option=option:domain-name,$(hostname -d)" fi -if [ $DEBUG = "Y" ]; then +if [ "$DEBUG" = "Y" ]; then echo "$DNSMASQ $DNSMASQ_OPTS" fi From e1f056e141e190164916adaae3c2c37c58e61559 Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 19:59:56 +0200 Subject: [PATCH 4/5] KVM --- run/run.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/run/run.sh b/run/run.sh index b2905bb..1e32a91 100755 --- a/run/run.sh +++ b/run/run.sh @@ -50,10 +50,9 @@ if [ -e /dev/kvm ] && sh -c 'echo -n > /dev/kvm' &> /dev/null; then fi if [ -z "${KVM_OPTS}" ]; then - KVM_OPTS="-machine usb=off" - if [ "$DEBUG" != "Y" ]; then - echo "Error: KVM acceleration is disabled.." && exit 88 - fi + KVM_OPTS="-machine type=q35,usb=off" + echo "Error: KVM acceleration is disabled.." + [ "$DEBUG" != "Y" ] && exit 88 fi RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') From 61959fe899c9d46a8707ab6e5607774b4f9d691e Mon Sep 17 00:00:00 2001 From: Kroese Date: Wed, 19 Apr 2023 20:12:03 +0200 Subject: [PATCH 5/5] KVM --- run/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run/run.sh b/run/run.sh index 1e32a91..8d07e3c 100755 --- a/run/run.sh +++ b/run/run.sh @@ -45,16 +45,16 @@ KVM_OPTS="" if [ -e /dev/kvm ] && sh -c 'echo -n > /dev/kvm' &> /dev/null; then if [[ $(grep -e vmx -e svm /proc/cpuinfo) ]]; then - KVM_OPTS="-machine type=q35,usb=off,accel=kvm -enable-kvm -cpu host" + KVM_OPTS=",accel=kvm -enable-kvm -cpu host" fi fi if [ -z "${KVM_OPTS}" ]; then - KVM_OPTS="-machine type=q35,usb=off" echo "Error: KVM acceleration is disabled.." [ "$DEBUG" != "Y" ] && exit 88 fi +KVM_OPTS="-machine type=q35,usb=off${KVM_OPTS}" RAM_OPTS=$(echo "-m ${RAM_SIZE}" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g') CPU_OPTS="-smp ${CPU_CORES},sockets=1,cores=${CPU_CORES},threads=1" DEF_OPTS="-nographic -nodefaults -overcommit mem-lock=off"