feat: Improve shutdown (#448)

* feat: Improve shutdown
This commit is contained in:
Kroese
2023-12-10 09:22:35 +01:00
committed by GitHub
parent 03d2665725
commit b9f3e52ba4
6 changed files with 19 additions and 10 deletions

View File

@@ -33,11 +33,12 @@ _graceful_shutdown() {
# echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null
# Send shutdown command to guest agent via serial port
response=$(curl -sk -m 30 -S http://127.0.0.1:2210/read?command=6 2>&1)
url="http://127.0.0.1:2210/read?command=6&timeout=50"
response=$(curl -sk -m 60 -S "$url" 2>&1)
if [[ ! "$response" =~ "\"success\"" ]]; then
echo && error "Failed to send shutdown command ( $response )."
echo && error "Failed to send shutdown command (${response#*message\"\: \"})."
kill -15 "$(cat "$QEMU_PID")"
pkill -f qemu-system-x86_64 || true
@@ -64,7 +65,9 @@ _graceful_shutdown() {
echo && echo " Quitting..."
echo 'quit' | nc -q 1 -w 1 localhost "$QEMU_PORT" >/dev/null 2>&1 || true
pkill -f host.bin || true
closeNetwork
sleep 1
return
}