rtslib: disable the unsupported fabrics

Resolves: #1942057

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
This commit is contained in:
Maurizio Lombardi 2021-04-09 10:46:34 +02:00
parent 2b36e8fe13
commit c6876f4ede
5 changed files with 63 additions and 70 deletions

View File

@ -0,0 +1,24 @@
diff --git a/rtslib/fabric.py b/rtslib/fabric.py
index 02e156c..ff7387f 100644
--- a/rtslib/fabric.py
+++ b/rtslib/fabric.py
@@ -464,13 +464,13 @@ fabric_modules = {
"srpt": SRPTFabricModule,
"iscsi": ISCSIFabricModule,
"loopback": LoopbackFabricModule,
- "qla2xxx": Qla2xxxFabricModule,
- "sbp": SBPFabricModule,
- "tcm_fc": FCoEFabricModule,
+# "qla2xxx": Qla2xxxFabricModule,
+# "sbp": SBPFabricModule,
+# "tcm_fc": FCoEFabricModule,
# "usb_gadget": USBGadgetFabricModule, # very rare, don't show
- "vhost": VhostFabricModule,
- "xen-pvscsi": XenPvScsiFabricModule,
- "ibmvscsis": IbmvscsisFabricModule,
+# "vhost": VhostFabricModule,
+# "xen-pvscsi": XenPvScsiFabricModule,
+# "ibmvscsis": IbmvscsisFabricModule,
}
#

View File

@ -1,22 +0,0 @@
From 0fc13cd7b18ec571092bac9082459c5acebf65f8 Mon Sep 17 00:00:00 2001
From: Andy Grover <agrover@redhat.com>
Date: Tue, 8 Dec 2015 09:46:26 -0800
Subject: [PATCH] disable xen_pvscsi
---
rtslib/fabric.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rtslib/fabric.py b/rtslib/fabric.py
index 2887783..2eb6173 100644
--- a/rtslib/fabric.py
+++ b/rtslib/fabric.py
@@ -469,7 +469,7 @@ fabric_modules = {
"tcm_fc": FCoEFabricModule,
# "usb_gadget": USBGadgetFabricModule, # very rare, don't show
"vhost": VhostFabricModule,
- "xen-pvscsi": XenPvScsiFabricModule,
+# "xen-pvscsi": XenPvScsiFabricModule, # no xen on Fedora
"ibmvscsis": IbmvscsisFabricModule,
}

31
0002-default_dbroot.patch Normal file
View File

@ -0,0 +1,31 @@
diff --git a/rtslib/root.py b/rtslib/root.py
index 2c5cf43..34bc57d 100644
--- a/rtslib/root.py
+++ b/rtslib/root.py
@@ -166,21 +166,21 @@ class RTSRoot(CFSNode):
self._dbroot = self._default_dbroot
return
self._dbroot = fread(dbroot_path)
- if self._dbroot != self._preferred_dbroot:
+ if self._dbroot != self._default_dbroot:
if len(FabricModule.list_registered_drivers()) != 0:
# Writing to dbroot_path after drivers have been registered will make the kernel emit this error:
# db_root: cannot be changed: target drivers registered
from warnings import warn
warn("Cannot set dbroot to {}. Target drivers have already been registered."
- .format(self._preferred_dbroot))
+ .format(self._default_dbroot))
return
try:
- fwrite(dbroot_path, self._preferred_dbroot+"\n")
+ fwrite(dbroot_path, self._default_dbroot+"\n")
except:
- if not os.path.isdir(self._preferred_dbroot):
+ if not os.path.isdir(self._default_dbroot):
raise RTSLibError("Cannot set dbroot to {}. Please check if this directory exists."
- .format(self._preferred_dbroot))
+ .format(self._default_dbroot))
self._dbroot = fread(dbroot_path)
def _get_dbroot(self):

View File

@ -7,10 +7,11 @@ Name: python-rtslib
License: ASL 2.0 License: ASL 2.0
Summary: API for Linux kernel LIO SCSI target Summary: API for Linux kernel LIO SCSI target
Version: 2.1.74 Version: 2.1.74
Release: 2%{?dist} Release: 3%{?dist}
URL: https://github.com/open-iscsi/%{oname} URL: https://github.com/open-iscsi/%{oname}
Source: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz Source: %{url}/archive/v%{version}/%{oname}-%{version}.tar.gz
Patch0: 0001-disable-xen_pvscsi.patch Patch0: 0001-Turn-off-unsupported-fabrics.patch
Patch1: 0002-default_dbroot.patch
BuildArch: noarch BuildArch: noarch
%if %{with apidocs} %if %{with apidocs}
BuildRequires: epydoc BuildRequires: epydoc
@ -70,6 +71,7 @@ on system restart.
%prep %prep
%setup -q -n %{oname}-%{version} %setup -q -n %{oname}-%{version}
%patch0 -p1 %patch0 -p1
%patch1 -p1
%build %build
@ -126,6 +128,10 @@ install -m 644 doc/saveconfig.json.5 %{buildroot}%{_mandir}/man5/
%endif %endif
%changelog %changelog
* Fri Apr 09 2021 Maurizio Lombardi <mlombard@redhat.com> - 2.1.74-3
- Disable the unsupported fabrics
- set dbroot to /var/target as in RHEL8
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.74-2 * Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.1.74-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

View File

@ -1,46 +0,0 @@
diff --git a/rtslib/root.py b/rtslib/root.py
index 246c285..d558445 100644
--- a/rtslib/root.py
+++ b/rtslib/root.py
@@ -70,6 +70,7 @@ class RTSRoot(CFSNode):
base kernel modules (tcm)
'''
super(RTSRoot, self).__init__()
+ modprobe('configfs')
mount_configfs()
modprobe('target_core_mod')
self._create_in_cfs_ine('any')
@@ -247,7 +248,7 @@ class RTSRoot(CFSNode):
if not restore_file:
restore_file = default_save_file
- with open(from_file, "r") as f:
+ with open(restore_file, "r") as f:
config = json.loads(f.read())
return self.restore(config, clear_existing=True,
abort_on_error=abort_on_error)
diff --git a/scripts/targetctl b/scripts/targetctl
index db8e0d2..bdf59f4 100755
--- a/scripts/targetctl
+++ b/scripts/targetctl
@@ -42,8 +42,7 @@ def save(to_file):
RTSRoot().save_to_file(save_file=to_file)
def restore(from_file):
- errors = RTSRoot().restore_from_file(restore_file=from_file,
- clear_existing=True)
+ errors = RTSRoot().restore_from_file(restore_file=from_file)
if errors:
print("Restore failed, %d errors:" % len(errors), file=err)
diff --git a/setup.py b/setup.py
index 7f41d52..5886fbc 100755
--- a/setup.py
+++ b/setup.py
@@ -27,5 +27,6 @@ setup (
maintainer_email = 'agrover@redhat.com',
url = 'http://github.com/agrover/rtslib-fb',
packages = ['rtslib'],
+ scripts = ['scripts/targetctl'],
use_2to3 = True,
)