Skip to content

Commit

Permalink
Merge pull request #1167 from vojtechtrefny/3.9-devel_modprobe-libblo…
Browse files Browse the repository at this point in the history
…ckdev

fcoe/iscsi: Use libblockdev to laod modules instead of modprobe
  • Loading branch information
vojtechtrefny authored Nov 6, 2023
2 parents b9c683a + d050119 commit 357f6a0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
19 changes: 16 additions & 3 deletions blivet/fcoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
#

import os

import gi
gi.require_version("BlockDev", "3.0")

from gi.repository import BlockDev

from . import errors
from . import udev
from . import util
Expand All @@ -33,11 +39,18 @@
def has_fcoe():
global _fcoe_module_loaded
if not _fcoe_module_loaded:
util.run_program(["modprobe", "libfc"])
_fcoe_module_loaded = True
try:
BlockDev.utils.load_kernel_module("libfc", None)
except BlockDev.UtilsError as e:
log.error("failed to load libfc: %s", str(e))
else:
_fcoe_module_loaded = True
if "bnx2x" in util.lsmod():
log.info("fcoe: loading bnx2fc")
util.run_program(["modprobe", "bnx2fc"])
try:
BlockDev.utils.load_kernel_module("bnx2fc", None)
except BlockDev.UtilsError as e:
log.error("failed to load bnx2fc: %s", str(e))

return os.access("/sys/module/libfc", os.X_OK)

Expand Down
14 changes: 12 additions & 2 deletions blivet/iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@

import gi
gi.require_version("GLib", "2.0")
gi.require_version("BlockDev", "3.0")
from gi.repository import GLib
from gi.repository import BlockDev

import logging
log = logging.getLogger("blivet")
Expand Down Expand Up @@ -314,7 +316,10 @@ def _start_ibft(self):

# Make sure iscsi_ibft is loaded otherwise any atttempts will fail with
# 'Could not get list of targets from firmware. (err 21)'
util.run_program(['modprobe', '-a', 'iscsi_ibft'])
try:
BlockDev.utils.load_kernel_module("iscsi_ibft", None)
except BlockDev.UtilsError as e:
log.error("failed to load iscsi_ibft: %s", str(e))

args = GLib.Variant("(a{sv})", ([], ))
try:
Expand Down Expand Up @@ -394,7 +399,12 @@ def startup(self):
os.makedirs(fulldir, 0o755)

log.info("iSCSI startup")
util.run_program(['modprobe', '-a'] + ISCSI_MODULES)
for module in ISCSI_MODULES:
try:
BlockDev.utils.load_kernel_module(module, None)
except BlockDev.UtilsError as e:
log.error("failed to load %s: %s", module, str(e))

# iscsiuio is needed by Broadcom offload cards (bnx2i). Currently
# not present in iscsi-initiator-utils for Fedora.
iscsiuio = shutil.which('iscsiuio')
Expand Down

0 comments on commit 357f6a0

Please sign in to comment.