This commit is contained in:
Kroese 2023-04-12 00:19:35 +02:00 committed by GitHub
parent 9ad1676f20
commit c5f7f56d9e

View file

@ -25,29 +25,8 @@ _graceful_shutdown(){
echo "Received $1 signal, shutting down..." echo "Received $1 signal, shutting down..."
echo 0 > "${_QEMU_SHUTDOWN_COUNTER}" echo 0 > "${_QEMU_SHUTDOWN_COUNTER}"
# Don't send the powerdown signal because vDSM ignores ACPI signals # Send the shutdown (system_powerdown) command to the QMP monitor
# echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null
# Send shutdown command to guest agent tools instead via serial port
RESPONSE=$(curl -s -m 2 -S http://127.0.0.1:2210/write?command=6 2>&1)
if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then
echo "Could not send shutdown command to guest, error: $RESPONSE"
FILE="${IMG}/agent.ver"
[ ! -f "$FILE" ] && echo "1" > "$FILE"
AGENT_VERSION=$(cat "${FILE}")
if ((AGENT_VERSION < 2)); then
echo "Please update the agent to allow gracefull shutdowns..."
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
while [ "$(cat ${_QEMU_SHUTDOWN_COUNTER})" -lt "${QEMU_POWERDOWN_TIMEOUT}" ]; do while [ "$(cat ${_QEMU_SHUTDOWN_COUNTER})" -lt "${QEMU_POWERDOWN_TIMEOUT}" ]; do