From: Ian Murray Subject: [PATCH] [RFC] Fix RegEx Issues with xendomains for both SXP and JSON outputs of lx list -l Date: Thu, 20 Jun 2013 13:00:29 +0100 (BST) Message-ID: <1371729629.55562.YahooMailNeo@web171306.mail.ir2.yahoo.com> References: <51C22E81.1010902@yahoo.co.uk> <1371717529.84197.YahooMailNeo@web171304.mail.ir2.yahoo.com> <1371726771.98221.YahooMailNeo@web171306.mail.ir2.yahoo.com> Reply-To: Ian Murray Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1371726771.98221.YahooMailNeo@web171306.mail.ir2.yahoo.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: "xen-devel@lists.xen.org" Cc: Ian Campbell , David Sutton , Joshua Tuttle List-Id: xen-devel@lists.xenproject.org (Resent, as Yahoo seems to silently drop sentemail with the subject startin= g with a square open bracket. Space inserted - apologies if received more t= han once) Modifications to xendomains so that it correctly identifies a new domain entry when parsing the output of xl list -l. For both SXP and JSON outputs, it was failing to spot a new domain entry and was saving the second domain under a filename generated from the first domain's name. I have listed this as RFC because although it is a patch against 4.3RC5, I have not had a chance to test against RC5, only 4.2.2. I won't get an opportunity until the weekend, so I invite comment and anybody to give it a test against RC5. Ian C has already commented elsewhere that the xl list -l JSON output has been altered between 4.2.x and 4.3RC5, so this might affect the indentation (the 4 spaces in the middle of the LIST_GREP variable) - the trigger for new domain data is '=A0=A0=A0 {' in J= SON version (in at least 4.2.2) and '(domain' in SXP version. Not tested against xm. It seems there is a problem in 4.2.2's implementation of SXP output of xl list -l in that all domain ID's are outputted as -1. Ian C suggested applying a change that originally went into 4.3 to resolve this issue. This seemed to do the trick (see thread [Xen-users] DomU suspension/hibernation ) Thanks to David Sutton for tracking through the issues with me and Ian C for guidance and assistance. Signed-off-by: Ian Murray diff --git a/tools/hotplug/Linux/init.d/xendomains b/tools/hotplug/Linux/init.d/xendomains index 730541e..38371af 100644 --- a/tools/hotplug/Linux/init.d/xendomains +++ b/tools/hotplug/Linux/init.d/xendomains @@ -206,7 +206,7 @@ rdnames() =A0=A0=A0=A0=A0 done =A0 } -LIST_GREP=3D'((domain\|(domid\|(name\|^{$\|"name":\|"domid":' +LIST_GREP=3D'(domain\|(domid\|(name\|^=A0=A0=A0 {$\|"name":\|"domid":' =A0 parseln() =A0 { =A0=A0=A0=A0=A0 if [[ "$1" =3D~ '(domain' ]] || [[ "$1" =3D "{" ]]; then @@ -237,7 +237,7 @@ is_running() =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 RC=3D0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;; =A0=A0=A0=A0=A0=A0=A0 esac -=A0=A0=A0 done < <($CMD list -l | grep $LIST_GREP) +=A0=A0=A0 done < <($CMD list -l | grep "$LIST_GREP") =A0=A0=A0=A0=A0 return $RC =A0 } @@ -319,7 +319,7 @@ all_zombies() =A0=A0=A0=A0=A0=A0=A0 if test "$state" !=3D "-b---d" -a "$state" !=3D "----= -d"; then =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 1; =A0=A0=A0=A0=A0=A0=A0 fi -=A0=A0=A0 done < <($CMD list -l | grep $LIST_GREP) +=A0=A0=A0 done < <($CMD list -l | grep "$LIST_GREP") =A0=A0=A0=A0=A0 return 0 =A0 } @@ -450,7 +450,7 @@ stop() =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 fi =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 kill $WDOG_PID >/dev/null 2>&1 =A0=A0=A0=A0=A0=A0=A0 fi -=A0=A0=A0 done < <($CMD list -l | grep $LIST_GREP) +=A0=A0=A0 done < <($CMD list -l | grep "$LIST_GREP") =A0=A0=A0=A0=A0 # NB. this shuts down ALL Xen domains (politely), not just = the ones in =A0=A0=A0=A0=A0 # AUTODIR/* @@ -487,7 +487,7 @@ check_domain_up() =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0 =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ;; =A0=A0=A0=A0=A0=A0=A0 esac -=A0=A0=A0 done < <($CMD list -l | grep $LIST_GREP) +=A0=A0=A0 done < <($CMD list -l | grep "$LIST_GREP") =A0=A0=A0=A0=A0 return 1 =A0 }