From 299aa1686f46938b2e555fcbcf9789ae95cbc8b4 Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Fri, 13 Nov 2015 14:36:44 +0100 Subject: [PATCH] Teardown all descendants devices before tearing disk images down DM maps cannot be removed while they are in use so in order to make them removable, we need to teardown all devices "built" on top of them first. This makes our examples (and possibly some tests) better clean after themselves. --- blivet/devicetree.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blivet/devicetree.py b/blivet/devicetree.py index fe10aa599..b44bcbb52 100644 --- a/blivet/devicetree.py +++ b/blivet/devicetree.py @@ -1048,6 +1048,11 @@ def setup_disk_images(self): def teardown_disk_images(self): """ Tear down any disk image stacks. """ + for dev_name in self.disk_images.keys(): + dm_device = self.get_device_by_name(dev_name) + descendants = self.get_dependent_devices(dm_device) + for dev in reversed(descendants): + dev.teardown(recursive=True) self._populator.teardown_disk_images() @property