[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 1 of 4] fix state



# HG changeset patch
# User Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
# 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 <zhigang.x.wang@xxxxxxxxxx>

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
 }
 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.