From 3a67bb81b8d6ab8f4a4bae5fe0762f5ad180e226 Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 21 Apr 2023 18:23:25 +0200 Subject: [PATCH 1/3] _QEMU_PID --- run/power.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/run/power.sh b/run/power.sh index 93a592d..f246602 100644 --- a/run/power.sh +++ b/run/power.sh @@ -19,8 +19,9 @@ _trap(){ done } -_graceful_shutdown(){ +_graceful_shutdown() { + [ ! -f "{_QEMU_PID}" ] && return [ -f "${_QEMU_SHUTDOWN_COUNTER}" ] && return set +e @@ -45,18 +46,19 @@ _graceful_shutdown(){ AGENT="${STORAGE}/${BASE}.agent" [ -f "$AGENT" ] && AGENT_VERSION=$(cat "${AGENT}") || AGENT_VERSION=1 - if ((AGENT_VERSION < 2)); then + if ((AGENT_VERSION > 1)); then + + # Send a NMI interrupt which will be detected by the kernel + echo 'nmi' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" > /dev/null + + else echo echo "Please update the VirtualDSM Agent to allow gracefull shutdowns..." + kill -15 $(cat "${_QEMU_PID}") pkill -f qemu-system-x86_64 - else - - # Send a NMI interrupt which will be detected by the kernel - echo 'nmi' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}" > /dev/null - fi fi From 66c254f6b421ba7e269dbfb22e5a66f98bd5279d Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 21 Apr 2023 18:24:19 +0200 Subject: [PATCH 2/3] _QEMU_PID --- run/power.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run/power.sh b/run/power.sh index f246602..c969288 100644 --- a/run/power.sh +++ b/run/power.sh @@ -21,7 +21,7 @@ _trap(){ _graceful_shutdown() { - [ ! -f "{_QEMU_PID}" ] && return + [ ! -f "${_QEMU_PID}" ] && return [ -f "${_QEMU_SHUTDOWN_COUNTER}" ] && return set +e From 50f8f6e6af5d784e798589e81df82e04c412ebbc Mon Sep 17 00:00:00 2001 From: Kroese Date: Fri, 21 Apr 2023 18:28:16 +0200 Subject: [PATCH 3/3] _QEMU_PID --- run/power.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run/power.sh b/run/power.sh index c969288..abcb528 100644 --- a/run/power.sh +++ b/run/power.sh @@ -56,7 +56,8 @@ _graceful_shutdown() { echo echo "Please update the VirtualDSM Agent to allow gracefull shutdowns..." - kill -15 $(cat "${_QEMU_PID}") + PID=$(cat "${_QEMU_PID}") + kill -15 "${PID}" pkill -f qemu-system-x86_64 fi