Author: waldi Date: Sun Apr 22 20:36:09 2012 New Revision: 988 Log: debian/xen-utils-common.xendomains.init - Remove old watchdog function. - Use SIGINT to kill process. - Move timeout definition. Modified: trunk/xen/debian/xen-utils-common.xendomains.init Modified: trunk/xen/debian/xen-utils-common.xendomains.init =============================================================================--- trunk/xen/debian/xen-utils-common.xendomains.init Sun Apr 22 20:13:10 2012 (r987) +++ trunk/xen/debian/xen-utils-common.xendomains.init Sun Apr 22 20:36:09 2012 (r988) @@ -220,44 +220,16 @@ return 0 } -# Wait for max $XENDOMAINS_STOP_MAXWAIT for $CMD $1 to finish; -# if it has not exited by that time kill it, so the init script will -# succeed within a finite amount of time; if $2 is nonnull, it will -# kill the command as well as soon as no domain (except for zombies) -# are left (used for shutdown --all). Third parameter, if any, suppresses -# output of dots per working state (formatting issues) -watchdog_xencmd() -{ - if test -z "$XENDOMAINS_STOP_MAXWAIT" -o "$XENDOMAINS_STOP_MAXWAIT" = "0"; then - exit - fi - - usleep 20000 - for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do - # exit if $CMD save/migrate/shutdown is finished - PSAX=`ps axlw | grep "xen $1" | grep -v grep` - if test -z "$PSAX"; then exit; fi - if ! test -n "$3"; then echo -n ''.''; fi - sleep 1 - # go to kill immediately if there''s only zombies left - if all_zombies && test -n "$2"; then break; fi - done - sleep 1 - read PSF PSUID PSPID PSPPID < <(echo "$PSAX") - # kill $CMD $1 - kill $PSPID >/dev/null 2>&1 - - echo -e . -} - coproc_timeout() { - for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do + TIMEOUT="$1" + for no in $(seq 0 $TIMEOUT); do if [ -z "$COPROC_PID" ]; then return 0; fi sleep 1 log_action_cont_msg done - kill "$COPROC_PID" >/dev/null 2>&1 + kill -INT "$COPROC_PID" >/dev/null 2>&1 + wait $COPROC_PID return 1 } @@ -266,7 +238,7 @@ while read id name rest; do log_action_begin_msg "Migrating Xen domain $name ($id)" coproc xen migrate $id $XENDOMAINS_MIGRATE 2>&1 1>/dev/null - coproc_timeout + coproc_timeout "$XENDOMAINS_STOP_MAXWAIT" log_action_end_msg $? done < <(/usr/lib/xen-common/bin/xen-init-list) } @@ -277,7 +249,7 @@ log_action_begin_msg "Saving Xen domain $name ($id)" mkdir -p "$XENDOMAINS_SAVE" coproc xen save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null - coproc_timeout + coproc_timeout "$XENDOMAINS_STOP_MAXWAIT" log_action_end_msg $? done < <(/usr/lib/xen-common/bin/xen-init-list) } @@ -286,7 +258,7 @@ { log_action_begin_msg "Shutting down all Xen domains" coproc xen shutdown --all $XENDOMAINS_SHUTDOWN_ALL 2>&1 1>/dev/null - coproc_timeout + coproc_timeout "$XENDOMAINS_STOP_MAXWAIT" log_action_end_msg $? }