AlmaLinux changes: Enable Btrfs support

This commit is contained in:
Neal Gompa 2025-11-08 03:34:20 +00:00 committed by root
commit 3239b7e6ea
3 changed files with 100 additions and 255 deletions

View File

@ -1,252 +0,0 @@
From 3a35d48fb823bae87d044234b199e1dde64e7666 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 29 Oct 2025 11:00:41 +0100
Subject: [PATCH] Temporarily reintroduce the safe_dbus module
Anaconda imports SafeDBusError from this and doing a joint release
in RHEL would be too complicated.
Related: RHEL-115005
---
blivet/safe_dbus.py | 229 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 229 insertions(+)
create mode 100644 blivet/safe_dbus.py
diff --git a/blivet/safe_dbus.py b/blivet/safe_dbus.py
new file mode 100644
index 00000000..1bade46b
--- /dev/null
+++ b/blivet/safe_dbus.py
@@ -0,0 +1,229 @@
+#
+# Copyright (C) 2013-2015 Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details. You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Vratislav Podzimek <vpodzime@redhat.com>
+#
+# This module was taken from the sources of the Anaconda installer.
+#
+
+"""Module providing thread-safe and mainloop-safe DBus operations."""
+
+import gi
+gi.require_version("GLib", "2.0")
+gi.require_version("Gio", "2.0")
+
+from gi.repository import GLib, Gio
+
+import os
+
+DEFAULT_DBUS_TIMEOUT = -1
+DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
+DBUS_INTRO_IFACE = "org.freedesktop.DBus.Introspectable"
+
+
+class SafeDBusError(Exception):
+ """Class for exceptions defined in this module."""
+
+
+class DBusCallError(SafeDBusError):
+ """Class for the errors related to calling methods over DBus."""
+
+
+class DBusPropertyError(DBusCallError):
+ """Class for the errors related to getting property values over DBus."""
+
+
+def get_new_system_connection():
+ """Return a new connection to the system bus."""
+
+ return Gio.DBusConnection.new_for_address_sync(
+ Gio.dbus_address_get_for_bus_sync(Gio.BusType.SYSTEM, None),
+ Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT |
+ Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION,
+ None, None)
+
+
+def get_new_session_connection():
+ """
+ Get a connection handle for the per-user-login-session message bus.
+
+ !!! RUN THIS EARLY !!! like, before any other threads start. Connections to
+ the session bus must be made with the effective UID of the login user,
+ which in live installs is not the UID of anaconda. This means we need to
+ call seteuid in this method, and doing that after threads have started will
+ probably do something weird.
+
+ Live installs use consolehelper to run as root, which sets the original
+ UID in $USERHELPER_UID.
+
+ :return: the session connection handle
+ :rtype: Gio.DBusConnection
+ :raise DBusCallError: if some DBus related error appears
+ :raise OSError: if unable to set the effective UID
+ """
+
+ old_euid = None
+ if "USERHELPER_UID" in os.environ:
+ old_euid = os.geteuid()
+ os.seteuid(int(os.environ["USERHELPER_UID"]))
+
+ try:
+ connection = Gio.DBusConnection.new_for_address_sync(
+ Gio.dbus_address_get_for_bus_sync(Gio.BusType.SESSION, None),
+ Gio.DBusConnectionFlags.AUTHENTICATION_CLIENT |
+ Gio.DBusConnectionFlags.MESSAGE_BUS_CONNECTION,
+ None, None)
+ except GLib.GError as gerr:
+ raise DBusCallError("Unable to connect to session bus: %s" % gerr)
+ finally:
+ if old_euid is not None:
+ os.seteuid(old_euid)
+
+ if connection.is_closed():
+ raise DBusCallError("Connection is closed")
+
+ return connection
+
+
+def call_sync(service, obj_path, iface, method, args,
+ connection=None, fds=None, timeout=DEFAULT_DBUS_TIMEOUT):
+ """
+ Safely call a given method on a given object of a given service over DBus
+ passing given arguments. If a connection is given, it is used, otherwise a
+ new connection is established. Safely means that it is a synchronous,
+ thread-safe call not using any main loop.
+
+ :param service: DBus service to use
+ :type service: str
+ :param obj_path: object path of the object to call method on
+ :type obj_path: str
+ :param iface: interface to use
+ :type iface: str
+ :param method: name of the method to call
+ :type method: str
+ :param args: arguments to pass to the method
+ :type args: GVariant
+ :param connection: connection to use (if None, a new connection is
+ established)
+ :type connection: Gio.DBusConnection
+ :param fds: list of file descriptors for the call
+ :type: Gio.UnixFDList
+ :param timeout: timeout in milliseconds for the call (-1 for default timeout)
+ :type timeout: int
+ :return: unpacked value returned by the method
+ :rtype: tuple with elements that depend on the method
+ :raise DBusCallError: if some DBus related error appears
+
+ """
+
+ if not connection:
+ try:
+ connection = get_new_system_connection()
+ except GLib.GError as gerr:
+ raise DBusCallError("Unable to connect to system bus: %s" % gerr)
+
+ if connection.is_closed():
+ raise DBusCallError("Connection is closed")
+
+ try:
+ ret = connection.call_with_unix_fd_list_sync(service, obj_path, iface, method, args,
+ None, Gio.DBusCallFlags.NONE,
+ timeout, fds, None)
+ except GLib.GError as gerr:
+ msg = "Failed to call %s method on %s with %s arguments: %s" % \
+ (method, obj_path, args, gerr.message) # pylint: disable=no-member
+ raise DBusCallError(msg)
+
+ if ret is None:
+ msg = "No return from %s method on %s with %s arguments" % (method, obj_path, args)
+ raise DBusCallError(msg)
+
+ return ret[0].unpack()
+
+
+def get_property_sync(service, obj_path, iface, prop_name,
+ connection=None):
+ """
+ Get value of a given property of a given object provided by a given service.
+
+ :param service: DBus service to use
+ :type service: str
+ :param obj_path: object path
+ :type obj_path: str
+ :param iface: interface to use
+ :type iface: str
+ :param prop_name: name of the property
+ :type prop_name: str
+ :param connection: connection to use (if None, a new connection is
+ established)
+ :type connection: Gio.DBusConnection
+ :return: unpacked value of the property
+ :rtype: tuple with elements that depend on the type of the property
+ :raise DBusCallError: when the internal dbus_call_safe_sync invocation
+ raises an exception
+ :raise DBusPropertyError: when the given object doesn't have the given
+ property
+
+ """
+
+ args = GLib.Variant('(ss)', (iface, prop_name))
+ ret = call_sync(service, obj_path, DBUS_PROPS_IFACE, "Get", args,
+ connection)
+ if ret is None:
+ msg = "No value for the %s object's property %s" % (obj_path, prop_name)
+ raise DBusPropertyError(msg)
+
+ return ret
+
+
+def get_properties_sync(service, obj_path, iface, connection=None):
+ """
+ Get all properties of a given object provided by a given service.
+
+ :param service: DBus service to use
+ :type service: str
+ :param obj_path: object path
+ :type obj_path: str
+ :param iface: interface to use
+ :type iface: str
+ :param connection: connection to use (if None, a new connection is
+ established)
+ :type connection: Gio.DBusConnection
+ :return: unpacked value of the property
+ :rtype: tuple with elements that depend on the type of the property
+ :raise DBusCallError: when the internal dbus_call_safe_sync invocation
+ raises an exception
+
+ """
+
+ args = GLib.Variant('(s)', (iface,))
+ ret = call_sync(service, obj_path, DBUS_PROPS_IFACE, "GetAll", args,
+ connection)
+
+ return ret
+
+
+def check_object_available(service, obj_path, iface=None):
+ intro_data = call_sync(service, obj_path, DBUS_INTRO_IFACE, "Introspect", None)
+ node_info = Gio.DBusNodeInfo.new_for_xml(intro_data[0])
+ if not iface:
+ # just check if any interface is available (there are none for
+ # non-existing objects)
+ return bool(node_info.interfaces)
+ else:
+ return any(intface.name == iface for intface in node_info.interfaces)
+
--
2.51.0

View File

@ -0,0 +1,91 @@
From f496c4c42d4ba4331909b0a9c7749cf9f581840d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
Date: Fri, 17 Oct 2025 14:21:06 +0200
Subject: [PATCH 1/2] iSCSI: don't crash when LUN ID >= 256
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
When LUN ID >= 256, systemd udev function format_lun_number() generates
an address of the form "lun-0x...".
Due to this, using int(lun) fails with a backtrace.
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
Resolves: RHEL-122305
---
blivet/devices/disk.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
index d9907fda3..04800e54d 100644
--- a/blivet/devices/disk.py
+++ b/blivet/devices/disk.py
@@ -28,6 +28,7 @@
from gi.repository import GLib
import os
+import re
from collections import namedtuple
from .. import errors
@@ -354,8 +355,17 @@ def __init__(self, device, **kwargs):
self.offload = kwargs.pop("offload")
name = kwargs.pop("name")
self.target = kwargs.pop("target")
+ lun = kwargs.pop("lun")
try:
- self.lun = int(kwargs.pop("lun"))
+ self.lun = int(lun)
+ except ValueError:
+ # See systemd udev function format_lun_number()
+ m = re.fullmatch('0x([0-9a-fA-F]{4})([0-9a-fA-F]{4})00000000', lun)
+ if m is None:
+ log.warning("Failed to extract hex from lun '%s'", lun)
+ self.lun = None
+ else:
+ self.lun = int(m.group(1), 16) + (1 << 16) * int(m.group(2), 16)
except TypeError as e:
log.warning("Failed to set lun attribute of iscsi disk: %s", e)
self.lun = None
From 0a5a1bbb6e180cba9be6e70869129e5123aebd85 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 20 Oct 2025 11:19:39 +0200
Subject: [PATCH 2/2] tests: Add a simple test case for parsing iSCSI lun
Related: RHEL-122305
---
tests/unit_tests/devices_test/disk_test.py | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/tests/unit_tests/devices_test/disk_test.py b/tests/unit_tests/devices_test/disk_test.py
index e414aeb4c..f6a011200 100644
--- a/tests/unit_tests/devices_test/disk_test.py
+++ b/tests/unit_tests/devices_test/disk_test.py
@@ -1,7 +1,7 @@
import unittest
from unittest.mock import patch
-from blivet.devices import DiskDevice
+from blivet.devices import DiskDevice, iScsiDiskDevice
from blivet.devicelibs import disk as disklib
from blivet.devicelibs import raid
from blivet.size import Size
@@ -47,3 +47,16 @@ def test_disk_raid_properties(self):
self.assertIsNone(test3.raid_level)
self.assertIsNone(test3.raid_stripe_size)
self.assertIsNone(test3.raid_disk_count)
+
+
+class iScsiDiskDeviceTestCase(unittest.TestCase):
+ def test_iscsi_lun(self):
+ kwargs = {"node": "", "ibft": "", "nic": "", "initiator": "",
+ "offload": False, "name": "", "target": "",
+ "address": "", "port": "", "iface": "", "id_path": ""}
+
+ disk1 = iScsiDiskDevice("test1", lun="1", **kwargs)
+ self.assertEqual(disk1.lun, 1)
+
+ disk2 = iScsiDiskDevice("test1", lun="0x0101000000000000", **kwargs)
+ self.assertEqual(disk2.lun, 257)

View File

@ -5,7 +5,7 @@ Version: 3.13.0
#%%global prerelease .b2
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
Release: 2%{?prerelease}%{?dist}.alma.1
Release: 3%{?prerelease}%{?dist}.alma.1
Epoch: 1
License: LGPL-2.1-or-later
%global realname blivet
@ -17,7 +17,7 @@ Source1: http://github.com/storaged-project/blivet/releases/download/%{realname}
Patch0: 0001-remove-btrfs-plugin.patch
%endif
Patch1: 0002-Temporarily-reintroduce-the-safe_dbus-module.patch
Patch2: 0002-iSCSI-dont-crash-when-LUN-ID-256.patch
# Versions of required components (done so we make sure the buildrequires
# match the requires versions of things).
@ -115,9 +115,15 @@ make DESTDIR=%{buildroot} install
%{python3_sitelib}/*
%changelog
* Fri Oct 31 2025 Neal Gompa <ngompa@almalinux.org> - 1:3.13.0-2.alma.1
* Sat Nov 08 2025 Neal Gompa <ngompa@almalinux.org> - 1:3.13.0-3.alma.1
- AlmaLinux changes: Enable Btrfs support
* Mon Nov 03 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.13.0-3
- iSCSI: don't crash when LUN ID >= 256
Resolves: RHEL-122305
- Remove the safe_dbus module
Related: RHEL-122305
* Wed Oct 29 2025 Vojtech Trefny <vtrefny@redhat.com> - 3.13.0-2
- Temporarily reintroduce the safe_dbus module
Related: RHEL-115005