feat: Do not send ACPI during setup

This commit is contained in:
Kroese 2024-01-24 01:46:10 +01:00 committed by GitHub
parent c7fd8bae36
commit d61f4a393a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,7 @@ QEMU_PID="/run/shm/qemu.pid"
QEMU_LOG="/run/shm/qemu.log" QEMU_LOG="/run/shm/qemu.log"
QEMU_OUT="/run/shm/qemu.out" QEMU_OUT="/run/shm/qemu.out"
QEMU_END="/run/shm/qemu.end" QEMU_END="/run/shm/qemu.end"
QEMU_PTY="/run/shm/qemu.pty"
rm -f /run/shm/qemu.* rm -f /run/shm/qemu.*
touch "$QEMU_LOG" touch "$QEMU_LOG"
@ -29,7 +30,7 @@ finish() {
if [ -f "$QEMU_PID" ]; then if [ -f "$QEMU_PID" ]; then
pid=$(<"$QEMU_PID") pid=$(<"$QEMU_PID")
echo && error "Forcefully terminating Windows, reason: $reason..." error "Forcefully terminating Windows, reason: $reason..."
{ kill -15 "$pid" || true; } 2>/dev/null { kill -15 "$pid" || true; } 2>/dev/null
while isAlive "$pid"; do while isAlive "$pid"; do
@ -44,8 +45,8 @@ finish() {
closeNetwork closeNetwork
sleep 1 sleep 0.5
echo && echo " Shutdown completed!" echo " Shutdown completed!"
exit "$reason" exit "$reason"
} }
@ -95,15 +96,15 @@ _graceful_shutdown() {
set +e set +e
if [ -f "$QEMU_END" ]; then if [ -f "$QEMU_END" ]; then
echo && info "Received $1 while already shutting down..." info "Received $1 while already shutting down..."
return return
fi fi
touch "$QEMU_END" touch "$QEMU_END"
echo && info "Received $1, sending ACPI shutdown signal..." info "Received $1, sending ACPI shutdown signal..."
if [ ! -f "$QEMU_PID" ]; then if [ ! -f "$QEMU_PID" ]; then
echo && error "QEMU PID file does not exist?" error "QEMU PID file does not exist?"
finish "$code" && return "$code" finish "$code" && return "$code"
fi fi
@ -111,10 +112,20 @@ _graceful_shutdown() {
pid=$(<"$QEMU_PID") pid=$(<"$QEMU_PID")
if ! isAlive "$pid"; then if ! isAlive "$pid"; then
echo && error "QEMU process does not exist?" error "QEMU process does not exist?"
finish "$code" && return "$code" finish "$code" && return "$code"
fi fi
if [ -f "$QEMU_PTY" ]; then
if ! grep -Fq "Windows Boot Manager" "$QEMU_PTY"; then
info "Cannot send ACPI signal during Windows setup, aborting..."
finish "$code" && return "$code"
else
rm -f "$STORAGE/$BASE"
touch "$STORAGE/windows.boot"
fi
fi
# Send ACPI shutdown signal # Send ACPI shutdown signal
echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null
@ -136,7 +147,7 @@ _graceful_shutdown() {
done done
if [ "$cnt" -ge "$QEMU_TIMEOUT" ]; then if [ "$cnt" -ge "$QEMU_TIMEOUT" ]; then
echo && error "Shutdown timeout reached, aborting..." error "Shutdown timeout reached, aborting..."
fi fi
finish "$code" && return "$code" finish "$code" && return "$code"