Skip to content

Commit

Permalink
Don't crash in populate when blockdev plugins are missing
Browse files Browse the repository at this point in the history
Co-authored-by: Vojtech Trefny <[email protected]>
  • Loading branch information
dwlehman and vojtechtrefny committed Oct 18, 2024
1 parent 6331e78 commit 9f14224
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions blivet/populator/helpers/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from ...devices import NVMeNamespaceDevice, NVMeFabricsNamespaceDevice
from ...devices import device_path_to_name
from ...storage_log import log_method_call
from ...tasks import availability
from .devicepopulator import DevicePopulator

import logging
Expand Down Expand Up @@ -151,6 +152,7 @@ class MDBiosRaidDevicePopulator(DiskDevicePopulator):
_device_class = MDBiosRaidArrayDevice

@classmethod
@availability.blockdev_md_required()
def match(cls, data):
return (super(MDBiosRaidDevicePopulator, MDBiosRaidDevicePopulator).match(data) and
udev.device_get_md_container(data))
Expand Down
2 changes: 2 additions & 0 deletions blivet/populator/helpers/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from ... import udev
from ...devices import DMDevice
from ...storage_log import log_method_call
from ...tasks import availability
from .devicepopulator import DevicePopulator

import logging
Expand All @@ -33,6 +34,7 @@ class DMDevicePopulator(DevicePopulator):
priority = 50

@classmethod
@availability.blockdev_dm_required()
def match(cls, data):
return (udev.device_is_dm(data) and
not udev.device_is_dm_partition(data) and
Expand Down
2 changes: 2 additions & 0 deletions blivet/populator/helpers/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
from ... import udev
from ...devices import FileDevice, LoopDevice
from ...storage_log import log_method_call
from ...tasks import availability
from .devicepopulator import DevicePopulator


class LoopDevicePopulator(DevicePopulator):
@classmethod
@availability.blockdev_loop_required()
def match(cls, data):
return udev.device_is_loop(data)

Expand Down
10 changes: 8 additions & 2 deletions blivet/populator/helpers/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from ...flags import flags
from ...size import Size
from ...storage_log import log_method_call
from ...tasks.availability import BLOCKDEV_LVM_PLUGIN_VDO
from ...tasks import availability
from .devicepopulator import DevicePopulator
from .formatpopulator import FormatPopulator

Expand All @@ -45,6 +45,7 @@

class LVMDevicePopulator(DevicePopulator):
@classmethod
@availability.blockdev_lvm_required()
def match(cls, data):
return udev.device_is_dm_lvm(data)

Expand Down Expand Up @@ -87,6 +88,11 @@ class LVMFormatPopulator(FormatPopulator):
priority = 100
_type_specifier = "lvmpv"

@classmethod
@availability.blockdev_lvm_required()
def match(cls, data, device):
return super(cls, cls).match(data, device)

def _get_kwargs(self):
kwargs = super(LVMFormatPopulator, self)._get_kwargs()

Expand Down Expand Up @@ -247,7 +253,7 @@ def add_lv(lv):
lv_parents = [self._devicetree.get_device_by_device_id("LVM-" + pool_device_name)]
elif lv_attr[0] == 'd':
# vdo pool
if BLOCKDEV_LVM_PLUGIN_VDO.available:
if availability.BLOCKDEV_LVM_PLUGIN_VDO.available:
pool_info = blockdev.lvm.vdo_info(vg_name, lv_name)
if pool_info:
lv_kwargs["compression"] = pool_info.compression
Expand Down
7 changes: 7 additions & 0 deletions blivet/populator/helpers/mdraid.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from ...errors import DeviceError, NoParentsError, MDRaidError
from ...flags import flags
from ...storage_log import log_method_call
from ...tasks import availability
from .devicepopulator import DevicePopulator
from .formatpopulator import FormatPopulator

Expand All @@ -43,6 +44,7 @@

class MDDevicePopulator(DevicePopulator):
@classmethod
@availability.blockdev_md_required()
def match(cls, data):
return (udev.device_is_md(data) and
not udev.device_get_md_container(data))
Expand Down Expand Up @@ -99,6 +101,11 @@ class MDFormatPopulator(FormatPopulator):
priority = 100
_type_specifier = "mdmember"

@classmethod
@availability.blockdev_md_required()
def match(cls, data, device):
return super(cls, cls).match(data, device)

def _get_kwargs(self):
kwargs = super(MDFormatPopulator, self)._get_kwargs()
kwargs["biosraid"] = udev.device_is_biosraid_member(self.data)
Expand Down

0 comments on commit 9f14224

Please sign in to comment.