From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shriram Rajagopalan Subject: Re: [PATCH 3 of 3] remus: handle exceptions while installing/unstalling net buffer Date: Thu, 23 Jun 2011 11:32:06 -0400 Message-ID: References: <9eed27800ff6a2e6d73f.1308749859@athos.nss.cs.ubc.ca> Reply-To: rshriram@cs.ubc.ca Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1921840456==" Return-path: In-Reply-To: <9eed27800ff6a2e6d73f.1308749859@athos.nss.cs.ubc.ca> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: ian.jackson@eu.citrix.com Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --===============1921840456== Content-Type: multipart/alternative; boundary=bcaec554dc5afed87a04a662cb62 --bcaec554dc5afed87a04a662cb62 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jun 22, 2011 at 9:37 AM, Shriram Rajagopalan wrote: > # HG changeset patch > # User Shriram Rajagopalan > # Date 1308749695 25200 > # Node ID 9eed27800ff6a2e6d73f138f20af072c1b41925e > # Parent 794ead1a2be0578d70c38f006e7ab61c7abe9203 > remus: handle exceptions while installing/unstalling net buffer > > Signed-off-by: Shriram Rajagopalan > > diff -r 794ead1a2be0 -r 9eed27800ff6 tools/python/xen/remus/device.py > --- a/tools/python/xen/remus/device.py Tue Jun 21 12:11:44 2011 -0700 > +++ b/tools/python/xen/remus/device.py Wed Jun 22 06:34:55 2011 -0700 > @@ -169,15 +169,25 @@ > self.vif = vif > # voodoo from > http://www.linuxfoundation.org/collaborate/workgroups/networking/ifb#Typical_Usage > util.runcmd('ip link set %s up' % self.devname) > - util.runcmd('tc qdisc add dev %s ingress' % vif.dev) > + try: > + util.runcmd('tc qdisc add dev %s ingress' % vif.dev) > + except util.PipeException, e: > + # check if error indicates that ingress qdisc > + # already exists on the vif. If so, ignore it. > + ignoreme = 'RTNETLINK answers: File exists' > + if ignoreme in str(e): > + pass > + else: > + raise e > util.runcmd('tc filter add dev %s parent ffff: proto ip pref 10 ' > 'u32 match u32 0 0 action mirred egress redirect ' > 'dev %s' % (vif.dev, self.devname)) > > def uninstall(self): > - util.runcmd('tc filter del dev %s parent ffff: proto ip pref 10 > u32' \ > - % self.vif.dev) > - util.runcmd('tc qdisc del dev %s ingress' % self.vif.dev) > + try: > + util.runcmd('tc qdisc del dev %s ingress' % self.vif.dev) > + except util.PipeException, e: > + pass > util.runcmd('ip link set %s down' % self.devname) > > class IMQBuffer(Netbuf): > @@ -373,9 +383,15 @@ > > def uninstall(self): > if self.installed: > - req = qdisc.delrequest(self.bufdevno, self.handle) > - self.rth.talk(req.pack()) > + try: > + req = qdisc.delrequest(self.bufdevno, self.handle) > + self.rth.talk(req.pack()) > + except IOError, e: > + pass > self.installed = False > > - self.bufdev.uninstall() > - self.pool.put(self.bufdev) > + try: > + self.bufdev.uninstall() > + except util.PipeException, e: > + pass > + self.pool.put(self.bufdev) > diff -r 794ead1a2be0 -r 9eed27800ff6 tools/python/xen/remus/util.py > --- a/tools/python/xen/remus/util.py Tue Jun 21 12:11:44 2011 -0700 > +++ b/tools/python/xen/remus/util.py Wed Jun 22 06:34:55 2011 -0700 > @@ -65,8 +65,10 @@ > proc.wait() > if proc.returncode: > print ' '.join(args) > - print stderr.strip() > - raise PipeException('%s failed' % args[0], proc.returncode) > + errmsg = stderr.strip() > + print errmsg > + raise PipeException('%s failed (errmsg: %s)' % (args[0], > errmsg), > + proc.returncode) > return stdout > except (OSError, IOError), inst: > raise PipeException('could not run %s' % args[0], inst.errno) > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > As Brendan pointed out, 90% of what I proposed to remove in patches 1 & 2 of this series might be useful for folks who want to hack on Remus or live migration code. I ll do the clean up later, more carefully. Ian, if you have no objection to this patch, could you take in this one alone and reject patches 1 & 2? Or do you want me to send this one separately again? shriram --bcaec554dc5afed87a04a662cb62 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Wed, Jun 22, 2011 at 9:37 AM, Shriram Rajagop= alan <rshriram@c= s.ubc.ca> wrote:
# HG changeset patch
# User Shriram Rajagopalan <rshrir= am@cs.ubc.ca>
# Date 1308749695 25200
# Node ID 9eed27800ff6a2e6d73f138f20af072c1b41925e
# Parent =A0794ead1a2be0578d70c38f006e7ab61c7abe9203
remus: handle exceptions while installing/unstalling net buffer

Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>

diff -r 794ead1a2be0 -r 9eed27800ff6 tools/python/xen/remus/device.py
--- a/tools/python/xen/remus/device.py =A0Tue Jun 21 12:11:44 2011 -0700 +++ b/tools/python/xen/remus/device.py =A0Wed Jun 22 06:34:55 2011 -0700 @@ -169,15 +169,25 @@
=A0 =A0 =A0 =A0 self.vif =3D vif
=A0 =A0 =A0 =A0 # voodoo from http:/= /www.linuxfoundation.org/collaborate/workgroups/networking/ifb#Typical_Usag= e
=A0 =A0 =A0 =A0 util.runcmd('ip link set %s up' % self.devname) - =A0 =A0 =A0 =A0util.runcmd('tc qdisc add dev %s ingress' % vif.de= v)
+ =A0 =A0 =A0 =A0try:
+ =A0 =A0 =A0 =A0 =A0 =A0util.runcmd('tc qdisc add dev %s ingress' = % vif.dev)
+ =A0 =A0 =A0 =A0except util.PipeException, e:
+ =A0 =A0 =A0 =A0 =A0 =A0# check if error indicates that ingress qdisc
+ =A0 =A0 =A0 =A0 =A0 =A0# already exists on the vif. If so, ignore it.
+ =A0 =A0 =A0 =A0 =A0 =A0ignoreme =3D 'RTNETLINK answers: File exists&#= 39;
+ =A0 =A0 =A0 =A0 =A0 =A0if ignoreme in str(e):
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pass
+ =A0 =A0 =A0 =A0 =A0 =A0else:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise e
=A0 =A0 =A0 =A0 util.runcmd('tc filter add dev %s parent ffff: proto i= p pref 10 '
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'u32 match u32 0 0 action mirr= ed egress redirect '
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'dev %s' % (vif.dev, self.= devname))

=A0 =A0 def uninstall(self):
- =A0 =A0 =A0 =A0util.runcmd('tc filter del dev %s parent ffff: proto i= p pref 10 u32' \
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% self.vif.dev)
- =A0 =A0 =A0 =A0util.runcmd('tc qdisc del dev %s ingress' % self.v= if.dev)
+ =A0 =A0 =A0 =A0try:
+ =A0 =A0 =A0 =A0 =A0 =A0util.runcmd('tc qdisc del dev %s ingress' = % self.vif.dev)
+ =A0 =A0 =A0 =A0except util.PipeException, e:
+ =A0 =A0 =A0 =A0 =A0 =A0pass
=A0 =A0 =A0 =A0 util.runcmd('ip link set %s down' % self.devname)<= br>
=A0class IMQBuffer(Netbuf):
@@ -373,9 +383,15 @@

=A0 =A0 def uninstall(self):
=A0 =A0 =A0 =A0 if self.installed:
- =A0 =A0 =A0 =A0 =A0 =A0req =3D qdisc.delrequest(self.bufdevno, self.handl= e)
- =A0 =A0 =A0 =A0 =A0 =A0self.rth.talk(req.pack())
+ =A0 =A0 =A0 =A0 =A0 =A0try:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0req =3D qdisc.delrequest(self.bufdevno, se= lf.handle)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.rth.talk(req.pack())
+ =A0 =A0 =A0 =A0 =A0 =A0except IOError, e:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pass
=A0 =A0 =A0 =A0 =A0 =A0 self.installed =3D False

- =A0 =A0 =A0 =A0self.bufdev.uninstall()
- =A0 =A0 =A0 =A0self.pool.put(self.bufdev)
+ =A0 =A0 =A0 =A0 =A0 =A0try:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0self.bufdev.uninstall()
+ =A0 =A0 =A0 =A0 =A0 =A0except util.PipeException, e:
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pass
+ =A0 =A0 =A0 =A0 =A0 =A0self.pool.put(self.bufdev)
diff -r 794ead1a2be0 -r 9eed27800ff6 tools/python/xen/remus/util.py
--- a/tools/python/xen/remus/util.py =A0 =A0Tue Jun 21 12:11:44 2011 -0700<= br> +++ b/tools/python/xen/remus/util.py =A0 =A0Wed Jun 22 06:34:55 2011 -0700<= br> @@ -65,8 +65,10 @@
=A0 =A0 =A0 =A0 proc.wait()
=A0 =A0 =A0 =A0 if proc.returncode:
=A0 =A0 =A0 =A0 =A0 =A0 print ' '.join(args)
- =A0 =A0 =A0 =A0 =A0 =A0print stderr.strip()
- =A0 =A0 =A0 =A0 =A0 =A0raise PipeException('%s failed' % args[0],= proc.returncode)
+ =A0 =A0 =A0 =A0 =A0 =A0errmsg =3D stderr.strip()
+ =A0 =A0 =A0 =A0 =A0 =A0print errmsg
+ =A0 =A0 =A0 =A0 =A0 =A0raise PipeException('%s failed (errmsg: %s)= 9; % (args[0], errmsg),
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0proc.retur= ncode)
=A0 =A0 =A0 =A0 return stdout
=A0 =A0 except (OSError, IOError), inst:
=A0 =A0 =A0 =A0 raise PipeException('could not run %s' % args[0], = inst.errno)

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

As Brendan pointed out, 90% of what I proposed to re= move
in patches 1 & 2 of this series might be useful for folks who w= ant to hack on Remus
or live migration code. I ll do the clean up later,= more carefully.

Ian, if you have no objection to this patch, could you take in this one= alone and
reject patches 1 & 2? Or do you want me to send this one separately aga= in?

shriram
--bcaec554dc5afed87a04a662cb62-- --===============1921840456== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --===============1921840456==--