From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhigang Wang Subject: [PATCH 1 of 4] fix state Date: Wed, 08 Jun 2011 17:45:13 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: zhigang.x.wang@oracle.com List-Id: xen-devel@lists.xenproject.org # HG changeset patch # User Zhigang Wang # Date 1307569476 14400 # Node ID be4f09fff517c1973d643635c9f40574a693da1a # Parent 37c77bacb52aa7795978b994f9d371b979b2cb07 fix state This patch fixes the state problem of xendomains service: 1. Bash regex: if [[ "(state -b----)" =~ '(state' ]]; then echo "works"; fi works on bash 4.x, not 3.x. Put it into a variable works for both: state_re="\(state"; if [[ "(state -b----)" =~ $state_re ]]; then echo "works"; fi 2. Fix: "state" as well as "name" and "id", is used but never defined. Signed-off-by: Zhigang Wang diff -r 37c77bacb52a -r be4f09fff517 tools/hotplug/Linux/init.d/xendomains --- a/tools/hotplug/Linux/init.d/xendomains Mon May 23 17:38:28 2011 +0100 +++ b/tools/hotplug/Linux/init.d/xendomains Wed Jun 08 17:44:36 2011 -0400 @@ -204,15 +204,21 @@ rdnames() parseln() { - if [[ "$1" =~ '(domain' ]]; then + domain_re="\(domain" + name_re="\(name" + domid_re="\(domid" + state_re="\(state" + if [[ "$1" =~ $domain_re ]]; then name=;id= - else if [[ "$1" =~ '(name' ]]; then + else if [[ "$1" =~ $name_re ]]; then name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/') - else if [[ "$1" =~ '(domid' ]]; then + else if [[ "$1" =~ $domid_re ]]; then id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/') - fi; fi; fi + else if [[ "$1" =~ $state_re ]]; then + state=$(echo $1 | sed -e 's/^.*(state \(.*\))$/\1/') + fi; fi; fi; fi - [ -n "$name" -a -n "$id" ] && return 0 || return 1 + [ -n "$name" -a -n "$id" -a -n "$state" ] && return 0 || return 1 } is_running() @@ -228,7 +234,7 @@ is_running() RC=0 ;; esac - done < <($CMD list -l | grep '(\(domain\|domid\|name\)') + done < <($CMD list -l | grep '(\(domain\|domid\|name\|state\)') return $RC } @@ -310,7 +316,7 @@ all_zombies() if test "$state" != "-b---d" -a "$state" != "-----d"; then return 1; fi - done < <($CMD list -l | grep '(\(domain\|domid\|name\)') + done < <($CMD list -l | grep '(\(domain\|domid\|name\|state\)') return 0 } @@ -441,7 +447,7 @@ stop() fi kill $WDOG_PID >/dev/null 2>&1 fi - done < <($CMD list -l | grep '(\(domain\|domid\|name\)') + done < <($CMD list -l | grep '(\(domain\|domid\|name\|state\)') # NB. this shuts down ALL Xen domains (politely), not just the ones in # AUTODIR/* @@ -478,7 +484,7 @@ check_domain_up() return 0 ;; esac - done < <($CMD list -l | grep '(\(domain\|domid\|name\)') + done < <($CMD list -l | grep '(\(domain\|domid\|name\|state\)') return 1 }