mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 21:40:01 +08:00
Prevent re-entry
This commit is contained in:
parent
ecfe8377ff
commit
d94bfca658
10
power.sh
10
power.sh
@ -5,9 +5,13 @@ set -eu
|
|||||||
|
|
||||||
QEMU_MONPORT=7100
|
QEMU_MONPORT=7100
|
||||||
QEMU_POWERDOWN_TIMEOUT=50
|
QEMU_POWERDOWN_TIMEOUT=50
|
||||||
|
|
||||||
_QEMU_PID=/run/qemu.pid
|
_QEMU_PID=/run/qemu.pid
|
||||||
_QEMU_SHUTDOWN_COUNTER=/run/qemu.counter
|
_QEMU_SHUTDOWN_COUNTER=/run/qemu.counter
|
||||||
|
|
||||||
|
rm -f "${_QEMU_PID}"
|
||||||
|
rm -f "${_QEMU_SHUTDOWN_COUNTER}"
|
||||||
|
|
||||||
# Allows for troubleshooting signals sent to the process
|
# Allows for troubleshooting signals sent to the process
|
||||||
_trap(){
|
_trap(){
|
||||||
func="$1" ; shift
|
func="$1" ; shift
|
||||||
@ -19,7 +23,9 @@ _trap(){
|
|||||||
_graceful_shutdown(){
|
_graceful_shutdown(){
|
||||||
|
|
||||||
local QEMU_MONPORT="${QEMU_MONPORT:-7100}"
|
local QEMU_MONPORT="${QEMU_MONPORT:-7100}"
|
||||||
local QEMU_POWERDOWN_TIMEOUT="${QEMU_POWERDOWN_TIMEOUT:-120}"
|
local QEMU_POWERDOWN_TIMEOUT="${QEMU_POWERDOWN_TIMEOUT:-50}"
|
||||||
|
|
||||||
|
[ -f "${_QEMU_SHUTDOWN_COUNTER}" ] && return
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
echo "Received $1 signal, shutting down..."
|
echo "Received $1 signal, shutting down..."
|
||||||
@ -64,7 +70,7 @@ _graceful_shutdown(){
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo "Quitting..."
|
echo "Quitting..."
|
||||||
echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null || true
|
echo 'quit' | nc -q 1 -w 1 localhost "${QEMU_MONPORT:-7100}">/dev/null || true
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user