From 03c6ce0fc9bc8599fb82ca39aeea2e1f145d9bec Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 15 Jan 2008 11:19:14 +0000 Subject: [PATCH] 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 --- tools/python/xen/xend/server/DevController.py | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/python/xen/xend/server/DevController.py b/tools/python/xen/xend/server/DevController.py index 927dabaa6..1f0c83206 100644 --- 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)) -- 2.39.5