Skip to content

Commit

Permalink
Merge pull request #1165 from vojtechtrefny/3.8-devel_kpartx-dependency
Browse files Browse the repository at this point in the history
Fix DMDevice hard dependency on kpartx
  • Loading branch information
vojtechtrefny authored Nov 1, 2023
2 parents 6c5fdbc + 46ac2a4 commit e02a6b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion blivet/devices/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class MultipathDevice(DMDevice):
_packages = ["device-mapper-multipath"]
_partitionable = True
_is_disk = True
_external_dependencies = [availability.MULTIPATH_APP]
_external_dependencies = [availability.MULTIPATH_APP, availability.KPARTX_APP]

def __init__(self, name, fmt=None, size=None, wwn=None,
parents=None, sysfs_path=''):
Expand Down
12 changes: 8 additions & 4 deletions blivet/devices/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ class DMDevice(StorageDevice):
""" A device-mapper device """
_type = "dm"
_dev_dir = "/dev/mapper"
_external_dependencies = [
availability.KPARTX_APP,
availability.BLOCKDEV_DM_PLUGIN
]
_external_dependencies = [availability.BLOCKDEV_DM_PLUGIN]

def __init__(self, name, fmt=None, size=None, dm_uuid=None, uuid=None,
target=None, exists=False, parents=None, sysfs_path=''):
Expand Down Expand Up @@ -130,13 +127,20 @@ def get_dm_node(self):

def setup_partitions(self):
log_method_call(self, name=self.name)
if not availability.KPARTX_APP.available:
log.warning("'kpartx' not available, not activating partitions on %s", self.path)
return

rc = util.run_program(["kpartx", "-a", "-s", self.path])
if rc:
raise errors.DMError("partition activation failed for '%s'" % self.name)
udev.settle()

def teardown_partitions(self):
log_method_call(self, name=self.name)
if not availability.KPARTX_APP.available:
log.warning("'kpartx' not available, not deactivating partitions on %s", self.path)
return
rc = util.run_program(["kpartx", "-d", "-s", self.path])
if rc:
raise errors.DMError("partition deactivation failed for '%s'" % self.name)
Expand Down
8 changes: 3 additions & 5 deletions tests/unit_tests/devices_test/lvm_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,9 @@ def test_vdo_dependencies(self):
size=blivet.size.Size("40 GiB"))

# Dependencies check: for VDO types these should be combination of "normal"
# LVM dependencies (LVM libblockdev plugin + kpartx and DM plugin from DMDevice)
# LVM dependencies (LVM libblockdev plugin and DM plugin from DMDevice)
# and LVM VDO technology from the LVM plugin
lvm_vdo_dependencies = ["kpartx",
"libblockdev dm plugin",
lvm_vdo_dependencies = ["libblockdev dm plugin",
"libblockdev lvm plugin",
"libblockdev lvm plugin (vdo technology)"]
pool_deps = [d.name for d in vdopool.external_dependencies]
Expand All @@ -930,8 +929,7 @@ def test_vdo_dependencies(self):
size=blivet.size.Size("1 GiB"))

normalvl_deps = [d.name for d in normallv.external_dependencies]
six.assertCountEqual(self, normalvl_deps, ["kpartx",
"libblockdev dm plugin",
six.assertCountEqual(self, normalvl_deps, ["libblockdev dm plugin",
"libblockdev lvm plugin"])

with patch("blivet.devices.lvm.LVMVDOPoolMixin._external_dependencies",
Expand Down

0 comments on commit e02a6b8

Please sign in to comment.