mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-11-06 18:13:43 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19aa313753 | ||
|
|
9db12cd25f | ||
|
|
69e785e6ee | ||
|
|
159fce6839 |
26
src/entry.sh
26
src/entry.sh
@@ -24,10 +24,30 @@ if [[ "$CONSOLE" == [Yy]* ]]; then
|
||||
fi
|
||||
|
||||
[[ "$DEBUG" == [Yy1]* ]] && info "$VERS" && set -x
|
||||
qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS}
|
||||
|
||||
msg=$(qemu-system-x86_64 -daemonize -pidfile "$QEMU_PID" ${ARGS:+ $ARGS})
|
||||
{ set +x; } 2>/dev/null
|
||||
cat /dev/pts/1 2>/dev/null & wait $! || true
|
||||
|
||||
if [[ "$msg" != "char"* || "$msg" != *"serial0)" ]]; then
|
||||
echo "$msg"
|
||||
fi
|
||||
|
||||
dev="${msg#*/dev/p}"
|
||||
dev="/dev/p${dev%% *}"
|
||||
|
||||
if [ ! -c "$dev" ]; then
|
||||
dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000')
|
||||
dev="${dev#*charserial0}"
|
||||
dev="${dev#*pty:}"
|
||||
dev="${dev%%$'\n'*}"
|
||||
dev="${dev%%$'\r'*}"
|
||||
fi
|
||||
|
||||
if [ ! -c "$dev" ]; then
|
||||
error "Device '$dev' not found!"
|
||||
finish 34
|
||||
fi
|
||||
|
||||
cat "$dev" 2>/dev/null & wait $! || true
|
||||
|
||||
sleep 1
|
||||
finish 0
|
||||
|
||||
16
src/power.sh
16
src/power.sh
@@ -35,7 +35,7 @@ finish() {
|
||||
if [ -f "$QEMU_PID" ]; then
|
||||
|
||||
pid="$(cat "$QEMU_PID")"
|
||||
echo && error "Forcefully quitting QEMU process, reason: $reason..."
|
||||
echo && error "Forcefully terminating QEMU process, reason: $reason..."
|
||||
{ kill -15 "$pid" || true; } 2>/dev/null
|
||||
|
||||
while isAlive "$pid"; do
|
||||
@@ -51,7 +51,7 @@ finish() {
|
||||
closeNetwork
|
||||
|
||||
sleep 1
|
||||
echo && info "Shutdown completed!"
|
||||
echo && echo "❯ Shutdown completed!"
|
||||
|
||||
exit "$reason"
|
||||
}
|
||||
@@ -61,10 +61,14 @@ _graceful_shutdown() {
|
||||
local code=$?
|
||||
local pid cnt response
|
||||
|
||||
[ -f "$QEMU_COUNT" ] && return
|
||||
echo 0 > "$QEMU_COUNT"
|
||||
|
||||
set +e
|
||||
|
||||
if [ -f "$QEMU_COUNT" ]; then
|
||||
echo && info "Ignored $1 signal, already shutting down..."
|
||||
return
|
||||
fi
|
||||
|
||||
echo 0 > "$QEMU_COUNT"
|
||||
echo && info "Received $1 signal, sending shutdown command..."
|
||||
|
||||
if [ ! -f "$QEMU_PID" ]; then
|
||||
@@ -94,7 +98,7 @@ _graceful_shutdown() {
|
||||
|
||||
response="${response#*message\"\: \"}"
|
||||
[ -z "$response" ] && response="second signal"
|
||||
echo && error "Forcefully quitting because of: ${response%%\"*}"
|
||||
echo && error "Forcefully terminating because of: ${response%%\"*}"
|
||||
{ kill -15 "$pid" || true; } 2>/dev/null
|
||||
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user