All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Allow xendomains to handle domain names > 16 characters
Date: Mon, 18 Jun 2007 17:16:37 +0100	[thread overview]
Message-ID: <1182183397.13846.11.camel@blaa> (raw)

[-- Attachment #1: Type: text/plain, Size: 330 bytes --]

Hi,
	The xendomains init script parses the output of "xm list", and since xm
list restricts the length of domains to 16 characters the xendomain
script cannot handle long domain names.

	Attached is a patch to make it parse the output of "xm list -l"
instead.

   Signed-off-by: Mark McLoughlin <markmc@redhat.com>

Thanks,
Mark.

[-- Attachment #2: xen-xendomains-17chars.patch --]
[-- Type: text/x-patch, Size: 2367 bytes --]

Index: xen-unstable.hg/tools/examples/init.d/xendomains
===================================================================
--- xen-unstable.hg.orig/tools/examples/init.d/xendomains
+++ xen-unstable.hg/tools/examples/init.d/xendomains
@@ -182,25 +182,31 @@ rdnames()
 
 parseln()
 {
-    name=`echo "$1" | cut -c0-17`
-    name=${name%% *}
-    rest=`echo "$1" | cut -c18- `
-    read id mem cpu vcpu state tm < <(echo "$rest")
+    if [[ "$1" =~ "\(domain" ]]; then
+        name=;id=
+    else if [[ "$1" =~ "\(name" ]]; then
+        name=$(echo $1 | sed -e 's/^.*(name \(.*\))$/\1/')
+    else if [[ "$1" =~ "\(domid" ]]; then
+        id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
+    fi; fi; fi
+
+    [ -n "$name" -a -n "$id" ] && return 0 || return 1
 }
 
 is_running()
 {
     rdname $1
     RC=1
+    name=;id=
     while read LN; do
-	parseln "$LN"
+	parseln "$LN" || continue
 	if test $id = 0; then continue; fi
 	case $name in 
 	    ($NM)
 		RC=0
 		;;
 	esac
-    done < <(xm list | grep -v '^Name')
+    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
     return $RC
 }
 
@@ -267,13 +273,14 @@ start() 
 
 all_zombies()
 {
+    name=;id=
     while read LN; do
-	parseln "$LN"
+	parseln "$LN" || continue
 	if test $id = 0; then continue; fi
 	if test "$state" != "-b---d" -a "$state" != "-----d"; then
 	    return 1;
 	fi
-    done < <(xm list | grep -v '^Name')
+    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
     return 0
 }
 
@@ -309,8 +316,9 @@ stop()
 	rdnames
     fi
     echo -n "Shutting down Xen domains:"
+    name=;id=
     while read LN; do
-	parseln "$LN"
+	parseln "$LN" || continue
 	if test $id = 0; then continue; fi
 	echo -n " $name"
 	if test "$XENDOMAINS_AUTO_ONLY" = "true"; then
@@ -384,7 +392,7 @@ stop()
 	    fi
 	    kill $WDOG_PID >/dev/null 2>&1
 	fi
-    done < <(xm list | grep -v '^Name')
+    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
 
     # NB. this shuts down ALL Xen domains (politely), not just the ones in
     # AUTODIR/*
@@ -409,15 +417,16 @@ stop()
 
 check_domain_up()
 {
+    name=;id=
     while read LN; do
-	parseln "$LN"
+	parseln "$LN" || continue
 	if test $id = 0; then continue; fi
 	case $name in 
 	    ($1)
 		return 0
 		;;
 	esac
-    done < <(xm list | grep -v "^Name")
+    done < <(xm list -l | grep '(\(domain\|domid\|name\)')
     return 1
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2007-06-18 16:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1182183397.13846.11.camel@blaa \
    --to=markmc@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.