]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
Cleanup xenstore after console device teardown
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 15 Jan 2008 11:19:14 +0000 (11:19 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 15 Jan 2008 11:19:14 +0000 (11:19 +0000)
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@sun.com>
tools/python/xen/xend/server/DevController.py

index 927dabaa6fd02a1aa4297a0b581ffd0d2b6b60cd..1f0c8320643cb50c0d6212a16e5ebea6c8ec9c08 100644 (file)
@@ -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))