Allow xendomains script to work with xl list -l This patch inserts a line feed after each comma in the output from xl list -l, allows there not to be a space between "name" and "domid" keys and their value, and accepts the "Xen saved domain" value as a valid header for a saved xen image if xl is being used. Signed-off-by: Michael Young --- xen-4.2.2/tools/hotplug/Linux/init.d/xendomains.orig 2013-03-21 17:55:42.000000000 +0000 +++ xen-4.2.2/tools/hotplug/Linux/init.d/xendomains 2013-04-09 00:09:22.784700367 +0100 @@ -212,9 +212,9 @@ elif [[ "$1" =~ '(domid' ]]; then id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/') elif [[ "$1" =~ '"name":' ]]; then - name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/') + name=$(echo $1 | sed -e 's/^.*"name": *"\(.*\)",$/\1/') elif [[ "$1" =~ '"domid":' ]]; then - id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/') + id=$(echo $1 | sed -e 's/^.*"domid": *\(.*\),$/\1/') fi [ -n "$name" -a -n "$id" ] && return 0 || return 1 @@ -233,7 +233,7 @@ RC=0 ;; esac - done < <($CMD list -l | grep $LIST_GREP) + done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP) return $RC } @@ -255,7 +255,7 @@ for dom in $XENDOMAINS_SAVE/*; do if [ -f $dom ] ; then HEADER=`head -c 16 $dom | head -n 1 2> /dev/null` - if [ $HEADER = "LinuxGuestRecord" ]; then + if [ "$HEADER" = "LinuxGuestRecord" ] || [ "$CMD" = "xl" -a "$HEADER" = "Xen saved domain" ]; then echo -n " ${dom##*/}" XMR=`$CMD restore $dom 2>&1 1>/dev/null` #$CMD restore $dom @@ -315,7 +315,7 @@ if test "$state" != "-b---d" -a "$state" != "-----d"; then return 1; fi - done < <($CMD list -l | grep $LIST_GREP) + done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP) return 0 } @@ -446,7 +446,7 @@ fi kill $WDOG_PID >/dev/null 2>&1 fi - done < <($CMD list -l | grep $LIST_GREP) + done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP) # NB. this shuts down ALL Xen domains (politely), not just the ones in # AUTODIR/* @@ -483,7 +483,7 @@ return 0 ;; esac - done < <($CMD list -l | grep $LIST_GREP) + done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP) return 1 }