Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fcoe/iscsi: Use libblockdev to laod modules instead of modprobe #1167

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading