All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] allow xendomains to work for xl list -l
@ 2013-04-09 20:05 M A Young
  2013-04-10 13:00 ` Ian Campbell
  2013-04-11 11:38 ` Ian Jackson
  0 siblings, 2 replies; 13+ messages in thread
From: M A Young @ 2013-04-09 20:05 UTC (permalink / raw)
  To: xen-devel; +Cc: Ian Jackson, Ian Campbell, Stefano Stabellini

[-- Attachment #1: Type: TEXT/PLAIN, Size: 645 bytes --]

I have discovered a few problems when using the 
tools/hotplug/Linux/init.d/xendomains startup script if you use xl instead 
of xm.
>From xen 4.2 onwards xl list -l gives a JSON format output containing no 
spaces or line feeds, but the xendomains script expects the older format 
(of xl in xen 4.1 and xm) of one key-value pair per line.
This patch adds a new line after each comma in the output of xl list -l 
before processing it further, allows there to be not to be a space between 
the key and value format used by xl list -l and accepts the "Xen saved 
domain" as a valid header for a saved xen image if xl is being used.

 	Michael Young

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2482 bytes --]

Allow xendomains script to work with xl list -l

This patch inserts a line feed after each comma in the output from
xl list -l, allows there not to be a space between "name" and "domid" keys
and their value, and accepts the "Xen saved domain" value as a valid header
for a saved xen image if xl is being used.

Signed-off-by: Michael Young <m.a.young@durham.ac.uk>

--- xen-4.2.2/tools/hotplug/Linux/init.d/xendomains.orig	2013-03-21 17:55:42.000000000 +0000
+++ xen-4.2.2/tools/hotplug/Linux/init.d/xendomains	2013-04-09 00:09:22.784700367 +0100
@@ -212,9 +212,9 @@
     elif [[ "$1" =~ '(domid' ]]; then
         id=$(echo $1 | sed -e 's/^.*(domid \(.*\))$/\1/')
     elif [[ "$1" =~ '"name":' ]]; then
-        name=$(echo $1 | sed -e 's/^.*"name": "\(.*\)",$/\1/')
+        name=$(echo $1 | sed -e 's/^.*"name": *"\(.*\)",$/\1/')
     elif [[ "$1" =~ '"domid":' ]]; then
-        id=$(echo $1 | sed -e 's/^.*"domid": \(.*\),$/\1/')
+        id=$(echo $1 | sed -e 's/^.*"domid": *\(.*\),$/\1/')
     fi
 
     [ -n "$name" -a -n "$id" ] && return 0 || return 1
@@ -233,7 +233,7 @@
 		RC=0
 		;;
 	esac
-    done < <($CMD list -l | grep $LIST_GREP)
+    done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP)
     return $RC
 }
 
@@ -255,7 +255,7 @@
         for dom in $XENDOMAINS_SAVE/*; do
             if [ -f $dom ] ; then
                 HEADER=`head -c 16 $dom | head -n 1 2> /dev/null`
-                if [ $HEADER = "LinuxGuestRecord" ]; then
+                if [ "$HEADER" = "LinuxGuestRecord" ] || [ "$CMD" = "xl" -a "$HEADER" = "Xen saved domain" ]; then
                     echo -n " ${dom##*/}"
                     XMR=`$CMD restore $dom 2>&1 1>/dev/null`
                     #$CMD restore $dom
@@ -315,7 +315,7 @@
 	if test "$state" != "-b---d" -a "$state" != "-----d"; then
 	    return 1;
 	fi
-    done < <($CMD list -l | grep $LIST_GREP)
+    done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP)
     return 0
 }
 
@@ -446,7 +446,7 @@
 	    fi
 	    kill $WDOG_PID >/dev/null 2>&1
 	fi
-    done < <($CMD list -l | grep $LIST_GREP)
+    done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP)
 
     # NB. this shuts down ALL Xen domains (politely), not just the ones in
     # AUTODIR/*
@@ -483,7 +483,7 @@
 		return 0
 		;;
 	esac
-    done < <($CMD list -l | grep $LIST_GREP)
+    done < <($CMD list -l | sed -e "s/,/,\n/g" | grep $LIST_GREP)
     return 1
 }
 

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

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-04-12 11:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-09 20:05 [PATCH] allow xendomains to work for xl list -l M A Young
2013-04-10 13:00 ` Ian Campbell
2013-04-10 13:04   ` Ian Campbell
2013-04-10 23:15   ` M A Young
2013-04-11  7:57     ` Ian Campbell
2013-04-11 23:02       ` M A Young
2013-04-12 11:41         ` Ian Campbell
2013-04-11 12:46     ` [PATCH] allow xendomains to work for xl list -l [and 1 more messages] Ian Jackson
2013-04-11 13:10       ` Ian Campbell
2013-04-11 15:56         ` Ian Jackson
2013-04-11 22:06   ` [PATCH] allow xendomains to work for xl list -l M A Young
2013-04-12  8:03     ` Ian Campbell
2013-04-11 11:38 ` Ian Jackson

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.