From f94943344fd6416e3c8ccfa03c3922508f5a2d55 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 28 Jun 2018 15:06:58 +1000 Subject: [PATCH] Call kpartx remove in umount, not cleanup Similar to I697bfbf042816c5ddf170bde9534cc4f0c7279ff, the order of things called is "dib-block-device umount" *then* "dib-block-device cleanup". Because we're doing the "kpartx -d" here in cleanup, it means that the loop-device is removed in umount phase from level0/localloop.py, then afterwards we try and remove the partitions. Change-Id: I7af3c5cf66afd81a481f454b5207af552ad52a32 TODO: a test case to ensure the ordering --- diskimage_builder/block_device/level1/partition.py | 3 +++ diskimage_builder/block_device/level1/partitioning.py | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/diskimage_builder/block_device/level1/partition.py b/diskimage_builder/block_device/level1/partition.py index 54c76926..c79a688c 100644 --- a/diskimage_builder/block_device/level1/partition.py +++ b/diskimage_builder/block_device/level1/partition.py @@ -84,5 +84,8 @@ class PartitionNode(NodeBase): def create(self): self.partitioning.create() + def umount(self): + self.partitioning.umount() + def cleanup(self): self.partitioning.cleanup() diff --git a/diskimage_builder/block_device/level1/partitioning.py b/diskimage_builder/block_device/level1/partitioning.py index bc2a728e..86924647 100644 --- a/diskimage_builder/block_device/level1/partitioning.py +++ b/diskimage_builder/block_device/level1/partitioning.py @@ -215,13 +215,15 @@ class Partitioning(PluginBase): return - def cleanup(self): + def umount(self): # remove the partition mappings made for the parent # block-device by create() above. this is called from the - # child PartitionNode umount/delete/cleanup. Thus every - # partition calls it, but we only want to do it once and our - # gate. + # child PartitionNode umount. Thus every partition calls it, + # but we only want to do it once and our gate. if not self.already_cleaned: self.already_cleaned = True exec_sudo(["kpartx", "-d", self.state['blockdev'][self.base]['device']]) + + def cleanup(self): + pass