Skip to content

Commit

Permalink
Do not fail when kpartx is not available
Browse files Browse the repository at this point in the history
We don't need to fail just because kpartx is missing, we can just
log warning and not activate the partitions.
  • Loading branch information
vojtechtrefny committed Oct 31, 2023
1 parent b75fddd commit 46ac2a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions blivet/devices/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,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

0 comments on commit 46ac2a4

Please sign in to comment.