xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Zhigang Wang <zhigang.x.wang@oracle.com>
To: xen-devel@lists.xensource.com
Cc: zhigang.x.wang@oracle.com
Subject: [PATCH 1 of 4] fix state
Date: Wed, 08 Jun 2011 17:45:13 -0400	[thread overview]
Message-ID: <be4f09fff517c1973d64.1307569513@zhigang.us.oracle.com> (raw)
In-Reply-To: <patchbomb.1307569512@zhigang.us.oracle.com>

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

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
 }

  reply	other threads:[~2011-06-08 21:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08 21:45 [PATCH 0 of 4] fix xendomains service Zhigang Wang
2011-06-08 21:45 ` Zhigang Wang [this message]
2011-06-17 17:25   ` [PATCH 1 of 4] fix state Ian Jackson
2011-06-08 21:45 ` [PATCH 2 of 4] fix not functional eval Zhigang Wang
2011-06-21 16:44   ` Ian Jackson
2011-06-08 21:45 ` [PATCH 3 of 4] make xendomains service save/migrate vms under /etc/xen/auto only Zhigang Wang
2011-06-21 16:51   ` Ian Jackson
2011-06-08 21:45 ` [PATCH 4 of 4] always create a lockfile on xendomains service start Zhigang Wang
2011-06-21 16:55   ` Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be4f09fff517c1973d64.1307569513@zhigang.us.oracle.com \
    --to=zhigang.x.wang@oracle.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).