[Pkg-xen-changes] r987 - trunk/xen/debian

Bastian Blank waldi at alioth.debian.org
Sun Apr 22 20:13:11 UTC 2012


Author: waldi
Date: Sun Apr 22 20:13:10 2012
New Revision: 987

Log:
debian/xen-utils-common.xendomains.init
- Use more LSB output.
- Replace stop code.

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 19:28:06 2012	(r986)
+++ trunk/xen/debian/xen-utils-common.xendomains.init	Sun Apr 22 20:13:10 2012	(r987)
@@ -250,124 +250,54 @@
     echo -e .
 }
 
-stop()
+coproc_timeout()
 {
-    exec 3>&2 2> /dev/null
-    
-    # Collect list of domains to shut down
-    if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
-	rdnames
-    fi
-    echo -n "Shutting down Xen domains:"
-    while read id name rest; do
-	echo -n " $name"
-	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
-	    eval "
-	    case \"\$name\" in
-		($NAMES)
-		    # nothing
-		    ;;
-		(*)
-		    echo -e '(skip)'
-		    continue
-		    ;;
-	    esac
-	    "
-	fi
-	# XENDOMAINS_SYSRQ chould be something like just "s" 
-	# or "s e i u" or even "s e s i u o"
-	# for the latter, you should set XENDOMAINS_USLEEP to 1200000 or so
-	if test -n "$XENDOMAINS_SYSRQ"; then
-	    for sysrq in $XENDOMAINS_SYSRQ; do
-		echo -n "(SR-$sysrq)"
-		XMR=`xen sysrq $id $sysrq 2>&1 1>/dev/null`
-		if test $? -ne 0; then
-		    echo -e "\nAn error occurred while doing sysrq on domain:\n$XMR\n"
-		    rc_failed $?
-		    echo -n '!'
-		fi
-		# usleep just ignores empty arg
-		usleep $XENDOMAINS_USLEEP
-	    done
-	fi
-	if test "$state" = "-b---d" -o "$state" = "-----d"; then
-	    echo -n "(zomb)"
-	    continue
-	fi
-	if test -n "$XENDOMAINS_MIGRATE"; then
-	    echo -n "(migr)"
-	    watchdog_xencmd migrate &
-	    WDOG_PID=$!
-	    XMR=`xen migrate $id $XENDOMAINS_MIGRATE 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while migrating domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-
-		kill $WDOG_PID >/dev/null 2>&1
-	    else
-		kill $WDOG_PID >/dev/null 2>&1
-		
-		echo -e .
-		usleep 1000
-		continue
-	    fi
-	fi
-	if test -n "$XENDOMAINS_SAVE"; then
-	    echo -n "(save)"
-	    watchdog_xencmd save &
-	    WDOG_PID=$!
-	    mkdir -p "$XENDOMAINS_SAVE"
-	    XMR=`xen save $id $XENDOMAINS_SAVE/$name 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while saving domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-		kill $WDOG_PID >/dev/null 2>&1
-	    else
-		kill $WDOG_PID >/dev/null 2>&1
-		echo -e .
-		usleep 1000
-		continue
-	    fi
-	fi
-	if test -n "$XENDOMAINS_SHUTDOWN"; then
-	    # XENDOMAINS_SHUTDOWN should be "--halt --wait"
-	    echo -n "(shut)"
-	    watchdog_xencmd shutdown &
-	    WDOG_PID=$!
-	    XMR=`xen shutdown $id $XENDOMAINS_SHUTDOWN 2>&1 1>/dev/null`
-	    if test $? -ne 0; then
-		echo -e "\nAn error occurred while shutting down domain:\n$XMR\n"
-		rc_failed $?
-		echo -e '!'
-	    fi
-	    kill $WDOG_PID >/dev/null 2>&1
-	fi
-    done < <(/usr/lib/xen-common/bin/xen-init-list)
+  for no in `seq 0 $XENDOMAINS_STOP_MAXWAIT`; do
+    if [ -z "$COPROC_PID" ]; then return 0; fi
+    sleep 1
+    log_action_cont_msg
+  done
+  kill "$COPROC_PID" >/dev/null 2>&1
+  return 1
+}
 
-    # NB. this shuts down ALL Xen domains (politely), not just the ones in
-    # AUTODIR/*
-    # This is because it's easier to do ;-) but arguably if this script is run
-    # on system shutdown then it's also the right thing to do.
-    if ! all_zombies && test -n "$XENDOMAINS_SHUTDOWN_ALL"; then
-	# XENDOMAINS_SHUTDOWN_ALL should be "--all --halt --wait"
-	echo -n " SHUTDOWN_ALL "
-	watchdog_xencmd shutdown 1 false &
-	WDOG_PID=$!
-	XMR=`xen shutdown $XENDOMAINS_SHUTDOWN_ALL 2>&1 1>/dev/null`
-	if test $? -ne 0; then
-	    echo -e "\nAn error occurred while shutting down all domains: $XMR\n"
-	    rc_failed $?
-	    echo -e '!'
-	fi
-	kill $WDOG_PID >/dev/null 2>&1
-    fi
+do_stop_migrate()
+{
+  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
+    log_action_end_msg $?
+  done < <(/usr/lib/xen-common/bin/xen-init-list)
+}
+
+do_stop_save()
+{
+  while read id name rest; do
+    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
+    log_action_end_msg $?
+  done < <(/usr/lib/xen-common/bin/xen-init-list)
+}
+
+do_stop_shutdown_all()
+{
+  log_action_begin_msg "Shutting down all Xen domains"
+  coproc xen shutdown --all $XENDOMAINS_SHUTDOWN_ALL 2>&1 1>/dev/null
+  coproc_timeout
+  log_action_end_msg $?
+}
+
+do_stop()
+{
+  if test -n "$XENDOMAINS_MIGRATE"; then do_stop_migrate; fi
+  if test -n "$XENDOMAINS_SAVE"; then do_stop_save; fi
+  do_stop_shutdown_all
 
-    # Unconditionally delete lock file
-    rm -f $LOCKFILE
-    
-    exec 2>&3
+  # Unconditionally delete lock file
+  rm -f $LOCKFILE
 }
 
 check_domain_up()
@@ -425,7 +355,7 @@
 
 restart()
 {
-    stop
+  do_stop
     start
 }
 
@@ -443,8 +373,7 @@
 	;;
 
     stop)
-	stop
-	rc_status -v
+      do_stop
 	;;
 
     restart)



More information about the Pkg-xen-changes mailing list