From: Ian Murray Subject: [Patch] Fixes for xl support in xendomains start-up/shutdown script Date: Thu, 16 Jun 2011 01:03:49 +0100 (BST) Message-ID: <810998.69888.qm@web28108.mail.ukl.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi,=0A=0AFirst time posting on the devel list so please accept my apologies= for lack of =0Aetiquette or any faux pas I make.=0A=0ASince using Xen 4.1 = compiled from source, I noticed that the xendomains start-up =0Ascript was = not behaving properly. A bit of a google revealed that an attempt had =0Abe= en made patch it to use xl if available or fallback to xm, but this wasn't = =0Aenough to make the script work at the this point in time. Observations a= re that =0A'xl list -l' has introduced extra response information that thre= w the script =0Abecause of false hits on some regex stuff. Also the header = of the save/restore =0Afile seems to have changed. I tweaked the regex and = edded an extra variable to =0Acompare against the new header text if using = xl.=0A=0AI haven't thoroughly tested the patch against every combination of= domains =0Asysreq'd nor have a I tested for its backward compatibility wit= h xm. However, =0Afor xl, it appears to work for auto starts, saves and res= tores. Tested against =0AXen 4.1.1 (thank-you and please keep up the good w= ork) on Scientific Linux 6.0 =0ADom0.=0A=0AI also ought to state that I am = not an expert in bash/regex/Xen so the patch may =0Anot be the most elegant= , etc.=0A=0AThanks for reading,=0A=0ASigned-off-by: Ian MURRAY =0A=0A--- xendomains.4.1.1 2011-06-16 01:31:44.929812576 +0100= =0A+++ xendomains.4.1.1.xlpatch 2011-06-16 01:32:22.077817600 +0100=0A@@= -27,11 +27,13 @@=0A # boots / shuts down.=0A ### END IN= IT INFO=0A =0A+HEADCOMP=3D"LinuxGuestRecord"=0A CMD=3Dxm=0A $CMD list &> /d= ev/null=0A if test $? -ne 0=0A then=0A CMD=3Dxl=0A+ HEADCOMP=3D"Xen = saved domain"=0A fi=0A =0A $CMD list &> /dev/null=0A@@ -204,7 +206,7 @@=0A = =0A parseln()=0A {=0A- if [[ "$1" =3D~ '(domain' ]]; then=0A+ if [[ "= $1" =3D '(domain' ]]; then=0A name=3D;id=3D=0A else if [[ "$1" = =3D~ '(name' ]]; then=0A name=3D$(echo $1 | sed -e 's/^.*(name \(.*= \))$/\1/')=0A@@ -228,7 +230,7 @@=0A RC=3D0=0A ;;=0A esa= c=0A- done < <($CMD list -l | grep '(\(domain\|domid\|name\)')=0A+ do= ne < <($CMD list -l | grep '(\(domain$\|domid\|name\)')=0A return $RC= =0A }=0A =0A@@ -250,7 +252,7 @@=0A for dom in $XENDOMAINS_SAVE/*; d= o=0A if [ -f $dom ] ; then=0A HEADER=3D`head -c= 16 $dom | head -n 1 2> /dev/null`=0A- if [ $HEADER =3D "Lin= uxGuestRecord" ]; then=0A+ if [ "$HEADER" =3D "$HEADCOMP" ];= then=0A echo -n " ${dom##*/}"=0A X= MR=3D`$CMD restore $dom 2>&1 1>/dev/null`=0A #$CMD rest= ore $dom=0A@@ -310,7 +312,7 @@=0A if test "$state" !=3D "-b---d" -a "$s= tate" !=3D "-----d"; then=0A return 1;=0A fi=0A- done < <($C= MD list -l | grep '(\(domain\|domid\|name\)')=0A+ done < <($CMD list -l = | grep '(\(domain$\|domid\|name\)')=0A return 0=0A }=0A =0A@@ -441,7 +4= 43,7 @@=0A fi=0A kill $WDOG_PID >/dev/null 2>&1=0A fi= =0A- done < <($CMD list -l | grep '(\(domain\|domid\|name\)')=0A+ don= e < <($CMD list -l | grep '(\(domain$\|domid\|name\)')=0A =0A # NB. thi= s shuts down ALL Xen domains (politely), not just the ones in=0A # AUTO= DIR/*=0A@@ -478,7 +480,7 @@=0A return 0=0A ;;=0A esac= =0A- done < <($CMD list -l | grep '(\(domain\|domid\|name\)')=0A+ don= e < <($CMD list -l | grep '(\(domain$\|domid\|name\)')=0A return 1=0A }