WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1 of 4] fix state
From: Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
Date: Wed, 08 Jun 2011 17:45:13 -0400
Cc: zhigang.x.wang@xxxxxxxxxx
Delivery-date: Wed, 08 Jun 2011 14:47:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1307569512@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1307569512@xxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.8.4+40-99a7cd924636
# 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