WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Cleanup xenstore after console device teardown

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Cleanup xenstore after console device teardown
From: john.levon@xxxxxxx
Date: Sun, 13 Jan 2008 06:40:22 -0800
Delivery-date: Sun, 13 Jan 2008 06:40:57 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User john.levon@xxxxxxx
# Date 1200081658 28800
# Node ID 05096f5585fbfd1bac54b69a6920a698b4f40b54
# Parent  fc7a750bfdabdcca35f85cdb5eb4fc74d31f75e8
Cleanup xenstore after console device teardown

After the changes in 13616:b111908dd70b, DevController was leaking
xenstore entries every time we took down a console device, as there was
no equivalent to 'xenstore-rm -t' used in the hotplug scripts for "real"
devices. Implement the moral equivalent whenever removal is forced.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/tools/python/xen/xend/server/DevController.py 
b/tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py
+++ b/tools/python/xen/xend/server/DevController.py
@@ -231,11 +231,23 @@ class DevController:
         self.writeBackend(dev, 'state', str(xenbusState['Closing']))
 
         if force:
-            frontpath = self.frontendPath(dev)
-            backpath = xstransact.Read(frontpath, "backend")
-            if backpath:
-                xstransact.Remove(backpath)
-            xstransact.Remove(frontpath)
+            try:
+                frontpath = self.frontendPath(dev)
+                while True:
+                    t = xstransact()
+                    backpath = t.read("%s/backend" % frontpath)
+                    if backpath:
+                        t.remove(backpath)
+                        # tidy up empty directories
+                        while not t.list(backpath):
+                            t.remove(backpath)
+                            backpath = os.path.dirname(backpath)
+                    t.remove(frontpath)
+                    if t.commit():
+                        break
+            except:
+                t.abort()
+                raise
 
         self.vm._removeVm("device/%s/%d" % (self.deviceClass, dev))
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Cleanup xenstore after console device teardown, john . levon <=