import python-blivet-3.1.0-18.el8
This commit is contained in:
parent
e6970a6137
commit
dcfe6beab6
@ -0,0 +1,65 @@
|
||||
From 5f7dbb212b4d6da4f8f2609ae1415e8630d031cd Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Mon, 13 May 2019 12:49:52 +0200
|
||||
Subject: [PATCH] Correctly handle non-unicode iSCSI initiator names
|
||||
|
||||
---
|
||||
blivet/iscsi.py | 4 +++-
|
||||
blivet/udev.py | 20 +++++++++++---------
|
||||
2 files changed, 14 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/blivet/iscsi.py b/blivet/iscsi.py
|
||||
index 74432505..f612cf15 100644
|
||||
--- a/blivet/iscsi.py
|
||||
+++ b/blivet/iscsi.py
|
||||
@@ -206,7 +206,9 @@ def initiator(self):
|
||||
if self._initiator != "":
|
||||
return self._initiator
|
||||
|
||||
- return self._call_initiator_method("GetInitiatorName")[0]
|
||||
+ # udisks returns initiatorname as a NULL terminated bytearray
|
||||
+ raw_initiator = bytes(self._call_initiator_method("GetInitiatorNameRaw")[0][:-1])
|
||||
+ return raw_initiator.decode("utf-8", errors="replace")
|
||||
|
||||
@initiator.setter
|
||||
@storaged_iscsi_required(critical=True, eval_mode=util.EvalMode.onetime)
|
||||
diff --git a/blivet/udev.py b/blivet/udev.py
|
||||
index 51b69b76..a70e3e08 100644
|
||||
--- a/blivet/udev.py
|
||||
+++ b/blivet/udev.py
|
||||
@@ -836,24 +836,26 @@ def device_get_iscsi_nic(info):
|
||||
|
||||
|
||||
def device_get_iscsi_initiator(info):
|
||||
- initiator = None
|
||||
+ initiator_name = None
|
||||
if device_is_partoff_iscsi(info):
|
||||
host = re.match(r'.*/(host\d+)', device_get_sysfs_path(info)).groups()[0]
|
||||
if host:
|
||||
initiator_file = "/sys/class/iscsi_host/%s/initiatorname" % host
|
||||
if os.access(initiator_file, os.R_OK):
|
||||
- initiator = open(initiator_file).read().strip()
|
||||
+ initiator = open(initiator_file, "rb").read().strip()
|
||||
+ initiator_name = initiator.decode("utf-8", errors="replace")
|
||||
log.debug("found offload iscsi initiatorname %s in file %s",
|
||||
- initiator, initiator_file)
|
||||
- if initiator.lstrip("(").rstrip(")").lower() == "null":
|
||||
- initiator = None
|
||||
- if initiator is None:
|
||||
+ initiator_name, initiator_file)
|
||||
+ if initiator_name.lstrip("(").rstrip(")").lower() == "null":
|
||||
+ initiator_name = None
|
||||
+ if initiator_name is None:
|
||||
session = device_get_iscsi_session(info)
|
||||
if session:
|
||||
initiator = open("/sys/class/iscsi_session/%s/initiatorname" %
|
||||
- session).read().strip()
|
||||
- log.debug("found iscsi initiatorname %s", initiator)
|
||||
- return initiator
|
||||
+ session, "rb").read().strip()
|
||||
+ initiator_name = initiator.decode("utf-8", errors="replace")
|
||||
+ log.debug("found iscsi initiatorname %s", initiator_name)
|
||||
+ return initiator_name
|
||||
|
||||
|
||||
# fcoe disks have ID_PATH in the form of:
|
@ -0,0 +1,27 @@
|
||||
From 408da7ad8eaedf9edb8dfa240af35a222fa8b481 Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Mon, 11 Mar 2019 13:29:04 +0100
|
||||
Subject: [PATCH] Do not crash if 'dm.get_member_raid_sets' fails (#1684851)
|
||||
|
||||
---
|
||||
blivet/populator/helpers/dmraid.py | 7 ++++++-
|
||||
1 file changed, 6 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/populator/helpers/dmraid.py b/blivet/populator/helpers/dmraid.py
|
||||
index c8cc3a8e..ed48bd66 100644
|
||||
--- a/blivet/populator/helpers/dmraid.py
|
||||
+++ b/blivet/populator/helpers/dmraid.py
|
||||
@@ -53,7 +53,12 @@ def run(self):
|
||||
minor = udev.device_get_minor(self.data)
|
||||
|
||||
# Have we already created the DMRaidArrayDevice?
|
||||
- rs_names = blockdev.dm.get_member_raid_sets(name, uuid, major, minor)
|
||||
+ try:
|
||||
+ rs_names = blockdev.dm.get_member_raid_sets(name, uuid, major, minor)
|
||||
+ except blockdev.DMError as e:
|
||||
+ log.error("Failed to get RAID sets information for '%s': %s", name, str(e))
|
||||
+ return
|
||||
+
|
||||
if len(rs_names) == 0:
|
||||
log.warning("dmraid member %s does not appear to belong to any "
|
||||
"array", self.device.name)
|
166
SOURCES/0023-Minor-cleanups-to-reduce-log-noise.patch
Normal file
166
SOURCES/0023-Minor-cleanups-to-reduce-log-noise.patch
Normal file
@ -0,0 +1,166 @@
|
||||
From c667dbb3ebf05eafeb4fb55d3ffa22d27c25420c Mon Sep 17 00:00:00 2001
|
||||
From: David Lehman <dlehman@redhat.com>
|
||||
Date: Wed, 24 Oct 2018 20:12:20 -0400
|
||||
Subject: [PATCH 1/3] Don't try to update sysfs path for non-block devices.
|
||||
(#1579375)
|
||||
|
||||
---
|
||||
blivet/devices/file.py | 3 +++
|
||||
blivet/devices/nfs.py | 3 +++
|
||||
blivet/devices/nodev.py | 3 +++
|
||||
3 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/blivet/devices/file.py b/blivet/devices/file.py
|
||||
index 55522c1d..fa3dfb8a 100644
|
||||
--- a/blivet/devices/file.py
|
||||
+++ b/blivet/devices/file.py
|
||||
@@ -132,6 +132,9 @@ def is_name_valid(self, name):
|
||||
# Override StorageDevice.is_name_valid to allow /
|
||||
return not('\x00' in name or name == '.' or name == '..')
|
||||
|
||||
+ def update_sysfs_path(self):
|
||||
+ pass
|
||||
+
|
||||
|
||||
class SparseFileDevice(FileDevice):
|
||||
|
||||
diff --git a/blivet/devices/nfs.py b/blivet/devices/nfs.py
|
||||
index 97cbe01e..a0142f91 100644
|
||||
--- a/blivet/devices/nfs.py
|
||||
+++ b/blivet/devices/nfs.py
|
||||
@@ -77,3 +77,6 @@ def update_size(self, newsize=None):
|
||||
def is_name_valid(self, name):
|
||||
# Override StorageDevice.is_name_valid to allow /
|
||||
return not('\x00' in name or name == '.' or name == '..')
|
||||
+
|
||||
+ def update_sysfs_path(self):
|
||||
+ pass
|
||||
diff --git a/blivet/devices/nodev.py b/blivet/devices/nodev.py
|
||||
index f6129258..f1b87392 100644
|
||||
--- a/blivet/devices/nodev.py
|
||||
+++ b/blivet/devices/nodev.py
|
||||
@@ -75,6 +75,9 @@ def destroy(self):
|
||||
def update_size(self, newsize=None):
|
||||
pass
|
||||
|
||||
+ def update_sysfs_path(self):
|
||||
+ pass
|
||||
+
|
||||
|
||||
class TmpFSDevice(NoDevice):
|
||||
|
||||
|
||||
From acb0953ad89327b3ffd3571b6d45565762548203 Mon Sep 17 00:00:00 2001
|
||||
From: David Lehman <dlehman@redhat.com>
|
||||
Date: Wed, 24 Oct 2018 20:27:22 -0400
|
||||
Subject: [PATCH 2/3] Only try to set selinux context for lost+found on ext
|
||||
file systems.
|
||||
|
||||
Related: rhbz#1579375
|
||||
---
|
||||
blivet/formats/fs.py | 19 ++++++++++++++-----
|
||||
tests/formats_test/selinux_test.py | 5 ++++-
|
||||
2 files changed, 18 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
|
||||
index 81e367f4..b915a2de 100644
|
||||
--- a/blivet/formats/fs.py
|
||||
+++ b/blivet/formats/fs.py
|
||||
@@ -569,11 +569,6 @@ def _post_setup(self, **kwargs):
|
||||
ret = util.reset_file_context(mountpoint, chroot)
|
||||
if not ret:
|
||||
log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.")
|
||||
- lost_and_found_context = util.match_path_context("/lost+found")
|
||||
- lost_and_found_path = os.path.join(mountpoint, "lost+found")
|
||||
- ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot)
|
||||
- if not ret:
|
||||
- log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)
|
||||
|
||||
def _pre_teardown(self, **kwargs):
|
||||
if not super(FS, self)._pre_teardown(**kwargs):
|
||||
@@ -840,6 +835,20 @@ class Ext2FS(FS):
|
||||
parted_system = fileSystemType["ext2"]
|
||||
_metadata_size_factor = 0.93 # ext2 metadata may take 7% of space
|
||||
|
||||
+ def _post_setup(self, **kwargs):
|
||||
+ super(Ext2FS, self)._post_setup(**kwargs)
|
||||
+
|
||||
+ options = kwargs.get("options", "")
|
||||
+ chroot = kwargs.get("chroot", "/")
|
||||
+ mountpoint = kwargs.get("mountpoint") or self.mountpoint
|
||||
+
|
||||
+ if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
||||
+ lost_and_found_context = util.match_path_context("/lost+found")
|
||||
+ lost_and_found_path = os.path.join(mountpoint, "lost+found")
|
||||
+ ret = util.set_file_context(lost_and_found_path, lost_and_found_context, chroot)
|
||||
+ if not ret:
|
||||
+ log.warning("Failed to set SELinux context for newly mounted filesystem lost+found directory at %s to %s", lost_and_found_path, lost_and_found_context)
|
||||
+
|
||||
register_device_format(Ext2FS)
|
||||
|
||||
|
||||
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py
|
||||
index 79c10327..028e084e 100644
|
||||
--- a/tests/formats_test/selinux_test.py
|
||||
+++ b/tests/formats_test/selinux_test.py
|
||||
@@ -43,7 +43,10 @@ def exec_mount_selinux_format(self, formt, *args):
|
||||
|
||||
blivet.flags.flags.selinux_reset_fcon = True
|
||||
fmt.setup(mountpoint="dummy") # param needed to pass string check
|
||||
- lsetfilecon.assert_called_with(ANY, lost_found_context)
|
||||
+ if isinstance(fmt, fs.Ext2FS):
|
||||
+ lsetfilecon.assert_called_with(ANY, lost_found_context)
|
||||
+ else:
|
||||
+ lsetfilecon.assert_not_called()
|
||||
|
||||
lsetfilecon.reset_mock()
|
||||
|
||||
|
||||
From 1b4e658f098bda3161ff0d5ffee07ea9be5c1d15 Mon Sep 17 00:00:00 2001
|
||||
From: David Lehman <dlehman@redhat.com>
|
||||
Date: Wed, 24 Oct 2018 20:33:36 -0400
|
||||
Subject: [PATCH 3/3] Don't try to set selinux context for nodev or vfat file
|
||||
systems.
|
||||
|
||||
Related: rhbz#1579375
|
||||
---
|
||||
blivet/formats/fs.py | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
|
||||
index b915a2de..6f09eaff 100644
|
||||
--- a/blivet/formats/fs.py
|
||||
+++ b/blivet/formats/fs.py
|
||||
@@ -76,6 +76,7 @@ class FS(DeviceFormat):
|
||||
_sync_class = fssync.UnimplementedFSSync
|
||||
_writelabel_class = fswritelabel.UnimplementedFSWriteLabel
|
||||
_writeuuid_class = fswriteuuid.UnimplementedFSWriteUUID
|
||||
+ _selinux_supported = True
|
||||
# This constant is aquired by testing some filesystems
|
||||
# and it's giving us percentage of space left after the format.
|
||||
# This number is more guess than precise number because this
|
||||
@@ -565,7 +566,7 @@ def _post_setup(self, **kwargs):
|
||||
chroot = kwargs.get("chroot", "/")
|
||||
mountpoint = kwargs.get("mountpoint") or self.mountpoint
|
||||
|
||||
- if flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
||||
+ if self._selinux_supported and flags.selinux and "ro" not in self._mount.mount_options(options).split(",") and flags.selinux_reset_fcon:
|
||||
ret = util.reset_file_context(mountpoint, chroot)
|
||||
if not ret:
|
||||
log.warning("Failed to reset SElinux context for newly mounted filesystem root directory to default.")
|
||||
@@ -902,6 +903,7 @@ class FATFS(FS):
|
||||
_metadata_size_factor = 0.99 # fat metadata may take 1% of space
|
||||
# FIXME this should be fat32 in some cases
|
||||
parted_system = fileSystemType["fat16"]
|
||||
+ _selinux_supported = False
|
||||
|
||||
def generate_new_uuid(self):
|
||||
ret = ""
|
||||
@@ -1235,6 +1237,7 @@ class NoDevFS(FS):
|
||||
""" nodev filesystem base class """
|
||||
_type = "nodev"
|
||||
_mount_class = fsmount.NoDevFSMount
|
||||
+ _selinux_supported = False
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
FS.__init__(self, **kwargs)
|
91
SOURCES/0024-Fix-util.detect_virt-function.patch
Normal file
91
SOURCES/0024-Fix-util.detect_virt-function.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From 471d43cbfe99db1c8246fb863e3ce49b3403fc61 Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Wed, 11 Sep 2019 10:48:19 +0200
|
||||
Subject: [PATCH] Fix util.detect_virt function
|
||||
|
||||
Fixed the systemd Manager object path, also get_property_sync
|
||||
returns a tuple so we need to check its first element.
|
||||
|
||||
Resolves: rhbz#1676935
|
||||
---
|
||||
blivet/util.py | 8 ++++----
|
||||
tests/formats_test/disklabel_test.py | 26 ++++++++++++++------------
|
||||
tests/util_test.py | 4 ++++
|
||||
3 files changed, 22 insertions(+), 16 deletions(-)
|
||||
|
||||
diff --git a/blivet/util.py b/blivet/util.py
|
||||
index 2932e8b5..27468992 100644
|
||||
--- a/blivet/util.py
|
||||
+++ b/blivet/util.py
|
||||
@@ -40,7 +40,7 @@ program_log_lock = Lock()
|
||||
|
||||
|
||||
SYSTEMD_SERVICE = "org.freedesktop.systemd1"
|
||||
-SYSTEMD_MANAGER_PATH = "/org/freedesktop/systemd1/Manager"
|
||||
+SYSTEMD_MANAGER_PATH = "/org/freedesktop/systemd1"
|
||||
SYSTEMD_MANAGER_IFACE = "org.freedesktop.systemd1.Manager"
|
||||
VIRT_PROP_NAME = "Virtualization"
|
||||
|
||||
@@ -1115,6 +1115,6 @@ def detect_virt():
|
||||
vm = safe_dbus.get_property_sync(SYSTEMD_SERVICE, SYSTEMD_MANAGER_PATH,
|
||||
SYSTEMD_MANAGER_IFACE, VIRT_PROP_NAME)
|
||||
except (safe_dbus.DBusCallError, safe_dbus.DBusPropertyError):
|
||||
- vm = None
|
||||
-
|
||||
- return vm in ('qemu', 'kvm')
|
||||
+ return False
|
||||
+ else:
|
||||
+ return vm[0] in ('qemu', 'kvm')
|
||||
diff --git a/tests/formats_test/disklabel_test.py b/tests/formats_test/disklabel_test.py
|
||||
index 4b105da6..94f3775f 100644
|
||||
--- a/tests/formats_test/disklabel_test.py
|
||||
+++ b/tests/formats_test/disklabel_test.py
|
||||
@@ -163,16 +163,18 @@ class DiskLabelTestCase(unittest.TestCase):
|
||||
arch.is_efi.return_value = False
|
||||
|
||||
arch.is_s390.return_value = True
|
||||
- with mock.patch.object(dl, '_label_type_size_check') as size_check:
|
||||
- size_check.return_value = True
|
||||
- with mock.patch("blivet.formats.disklabel.blockdev.s390") as _s390:
|
||||
- _s390.dasd_is_fba.return_value = False
|
||||
- self.assertEqual(dl._get_best_label_type(), "msdos")
|
||||
-
|
||||
- _s390.dasd_is_fba.return_value = True
|
||||
- self.assertEqual(dl._get_best_label_type(), "msdos")
|
||||
-
|
||||
- _s390.dasd_is_fba.return_value = False
|
||||
- dl._parted_device.type = parted.DEVICE_DASD
|
||||
- self.assertEqual(dl._get_best_label_type(), "dasd")
|
||||
+ with mock.patch('blivet.util.detect_virt') as virt:
|
||||
+ virt.return_value = False
|
||||
+ with mock.patch.object(dl, '_label_type_size_check') as size_check:
|
||||
+ size_check.return_value = True
|
||||
+ with mock.patch("blivet.formats.disklabel.blockdev.s390") as _s390:
|
||||
+ _s390.dasd_is_fba.return_value = False
|
||||
+ self.assertEqual(dl._get_best_label_type(), "msdos")
|
||||
+
|
||||
+ _s390.dasd_is_fba.return_value = True
|
||||
+ self.assertEqual(dl._get_best_label_type(), "msdos")
|
||||
+
|
||||
+ _s390.dasd_is_fba.return_value = False
|
||||
+ dl._parted_device.type = parted.DEVICE_DASD
|
||||
+ self.assertEqual(dl._get_best_label_type(), "dasd")
|
||||
arch.is_s390.return_value = False
|
||||
diff --git a/tests/util_test.py b/tests/util_test.py
|
||||
index 5fa3070e..9a2ff492 100644
|
||||
--- a/tests/util_test.py
|
||||
+++ b/tests/util_test.py
|
||||
@@ -37,6 +37,10 @@ class MiscTest(unittest.TestCase):
|
||||
# real deduplication
|
||||
self.assertEqual([1, 2, 3, 4, 5, 6], util.dedup_list([1, 2, 3, 4, 2, 2, 2, 1, 3, 5, 3, 6, 6, 2, 3, 1, 5]))
|
||||
|
||||
+ def test_detect_virt(self):
|
||||
+ in_virt = not util.run_program(["systemd-detect-virt", "--vm"])
|
||||
+ self.assertEqual(util.detect_virt(), in_virt)
|
||||
+
|
||||
|
||||
class TestDefaultNamedtuple(unittest.TestCase):
|
||||
def test_default_namedtuple(self):
|
||||
--
|
||||
2.20.1
|
||||
|
183
SOURCES/0025-Check-for-PV-sector-size-when-creating-new-VG.patch
Normal file
183
SOURCES/0025-Check-for-PV-sector-size-when-creating-new-VG.patch
Normal file
@ -0,0 +1,183 @@
|
||||
From 83a42f3e232c7c4a02deb3539972c82b6dca284b Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Fri, 4 Oct 2019 12:30:03 +0200
|
||||
Subject: [PATCH 1/2] Add a new "sector_size" property to storage devices.
|
||||
|
||||
This represents the logical sector size of the device.
|
||||
|
||||
Related: rhbz#1754446
|
||||
---
|
||||
blivet/devices/disk.py | 6 +++++-
|
||||
blivet/devices/md.py | 11 +++++++++++
|
||||
blivet/devices/partition.py | 7 +++++++
|
||||
blivet/devices/storage.py | 15 +++++++++++++++
|
||||
4 files changed, 38 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/devices/disk.py b/blivet/devices/disk.py
|
||||
index bf2f7a4f..7dfeabf0 100644
|
||||
--- a/blivet/devices/disk.py
|
||||
+++ b/blivet/devices/disk.py
|
||||
@@ -687,7 +687,7 @@ def __init__(self, device, **kwargs):
|
||||
"""
|
||||
self.mode = kwargs.pop("mode")
|
||||
self.devname = kwargs.pop("devname")
|
||||
- self.sector_size = kwargs.pop("sector_size")
|
||||
+ self._sector_size = kwargs.pop("sector_size")
|
||||
|
||||
DiskDevice.__init__(self, device, **kwargs)
|
||||
|
||||
@@ -710,3 +710,7 @@ def description(self):
|
||||
% {'devname': self.devname,
|
||||
'mode': self.mode,
|
||||
'path': self.path}
|
||||
+
|
||||
+ @property
|
||||
+ def sector_size(self):
|
||||
+ return self._sector_size
|
||||
diff --git a/blivet/devices/md.py b/blivet/devices/md.py
|
||||
index 6a837df0..0b6da980 100644
|
||||
--- a/blivet/devices/md.py
|
||||
+++ b/blivet/devices/md.py
|
||||
@@ -19,10 +19,13 @@
|
||||
# Red Hat Author(s): David Lehman <dlehman@redhat.com>
|
||||
#
|
||||
|
||||
+import math
|
||||
import os
|
||||
import six
|
||||
import time
|
||||
|
||||
+from six.moves import reduce
|
||||
+
|
||||
import gi
|
||||
gi.require_version("BlockDev", "2.0")
|
||||
|
||||
@@ -195,6 +198,14 @@ def level(self, value):
|
||||
|
||||
self._level = level
|
||||
|
||||
+ @property
|
||||
+ def sector_size(self):
|
||||
+ if not self.exists:
|
||||
+ # Least common multiple of parents' sector sizes
|
||||
+ return reduce(lambda a, b: a * b // math.gcd(a, b), (int(p.sector_size) for p in self.parents))
|
||||
+
|
||||
+ return super(MDRaidArrayDevice, self).sector_size
|
||||
+
|
||||
@property
|
||||
def chunk_size(self):
|
||||
if self.exists and self._chunk_size == Size(0):
|
||||
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
|
||||
index 623e1c9d..73daa76f 100644
|
||||
--- a/blivet/devices/partition.py
|
||||
+++ b/blivet/devices/partition.py
|
||||
@@ -729,6 +729,13 @@ def protected(self):
|
||||
def protected(self, value):
|
||||
self._protected = value
|
||||
|
||||
+ @property
|
||||
+ def sector_size(self):
|
||||
+ if self.disk:
|
||||
+ return self.disk.sector_size
|
||||
+
|
||||
+ return super(PartitionDevice, self).sector_size
|
||||
+
|
||||
def _pre_resize(self):
|
||||
if not self.exists:
|
||||
raise errors.DeviceError("device has not been created", self.name)
|
||||
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
|
||||
index e087fa64..91c5e60e 100644
|
||||
--- a/blivet/devices/storage.py
|
||||
+++ b/blivet/devices/storage.py
|
||||
@@ -190,6 +190,21 @@ def raw_device(self):
|
||||
""" The device itself, or when encrypted, the backing device. """
|
||||
return self
|
||||
|
||||
+ @property
|
||||
+ def sector_size(self):
|
||||
+ """ Logical sector (block) size of this device """
|
||||
+ if not self.exists:
|
||||
+ if self.parents:
|
||||
+ return self.parents[0].sector_size
|
||||
+ else:
|
||||
+ return LINUX_SECTOR_SIZE
|
||||
+
|
||||
+ block_size = util.get_sysfs_attr(self.sysfs_path, "queue/logical_block_size")
|
||||
+ if block_size:
|
||||
+ return int(block_size)
|
||||
+ else:
|
||||
+ return LINUX_SECTOR_SIZE
|
||||
+
|
||||
@property
|
||||
def controllable(self):
|
||||
return self._controllable and not flags.testing and not self.unavailable_type_dependencies()
|
||||
|
||||
From 9f81bd1ffb877862760223ba88f2086deebd2d06 Mon Sep 17 00:00:00 2001
|
||||
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||
Date: Fri, 4 Oct 2019 12:37:01 +0200
|
||||
Subject: [PATCH 2/2] Do not allow creating VGs with PVs with different sector
|
||||
size
|
||||
|
||||
New versions of LVM don't allow mixing PVs with different sector
|
||||
sizes in one VG.
|
||||
|
||||
Resolves: rhbz#1754446
|
||||
---
|
||||
blivet/devices/lvm.py | 12 ++++++++++++
|
||||
tests/devices_test/lvm_test.py | 13 ++++++++++++-
|
||||
2 files changed, 24 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
|
||||
index 4347f483..b9da286a 100644
|
||||
--- a/blivet/devices/lvm.py
|
||||
+++ b/blivet/devices/lvm.py
|
||||
@@ -356,6 +356,18 @@ def _remove_log_vol(self, lv):
|
||||
def _add_parent(self, parent):
|
||||
super(LVMVolumeGroupDevice, self)._add_parent(parent)
|
||||
|
||||
+ # we are creating new VG or adding a new PV to an existing (complete) one
|
||||
+ if not self.exists or (self.exists and self._complete):
|
||||
+ parent_sectors = set([p.sector_size for p in self.pvs] + [parent.sector_size])
|
||||
+ if len(parent_sectors) != 1:
|
||||
+ if not self.exists:
|
||||
+ msg = "The volume group %s cannot be created. Selected disks have " \
|
||||
+ "inconsistent sector sizes (%s)." % (self.name, parent_sectors)
|
||||
+ else:
|
||||
+ msg = "Disk %s cannot be added to this volume group. LVM doesn't " \
|
||||
+ "allow using physical volumes with inconsistent (logical) sector sizes." % parent.name
|
||||
+ raise ValueError(msg)
|
||||
+
|
||||
if (self.exists and parent.format.exists and
|
||||
len(self.parents) + 1 == self.pv_count):
|
||||
self._complete = True
|
||||
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
|
||||
index 8ed577f4..a32c1d83 100644
|
||||
--- a/tests/devices_test/lvm_test.py
|
||||
+++ b/tests/devices_test/lvm_test.py
|
||||
@@ -2,7 +2,7 @@
|
||||
import test_compat # pylint: disable=unused-import
|
||||
|
||||
import six
|
||||
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
|
||||
+from six.moves.mock import patch, PropertyMock # pylint: disable=no-name-in-module,import-error
|
||||
import unittest
|
||||
|
||||
import blivet
|
||||
@@ -352,6 +352,17 @@ def test_target_size(self):
|
||||
self.assertEqual(lv.target_size, orig_size)
|
||||
self.assertEqual(lv.size, orig_size)
|
||||
|
||||
+ def test_lvm_inconsistent_sector_size(self):
|
||||
+ pv = StorageDevice("pv1", fmt=blivet.formats.get_format("lvmpv"),
|
||||
+ size=Size("1024 MiB"))
|
||||
+ pv2 = StorageDevice("pv2", fmt=blivet.formats.get_format("lvmpv"),
|
||||
+ size=Size("1024 MiB"))
|
||||
+
|
||||
+ with patch("blivet.devices.StorageDevice.sector_size", new_callable=PropertyMock) as mock_property:
|
||||
+ mock_property.__get__ = lambda _mock, pv, _class: 512 if pv.name == "pv1" else 4096
|
||||
+ with six.assertRaisesRegex(self, ValueError, "The volume group testvg cannot be created."):
|
||||
+ LVMVolumeGroupDevice("testvg", parents=[pv, pv2])
|
||||
+
|
||||
|
||||
class TypeSpecificCallsTest(unittest.TestCase):
|
||||
def test_type_specific_calls(self):
|
@ -23,7 +23,7 @@ Version: 3.1.0
|
||||
|
||||
#%%global prerelease .b2
|
||||
# prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2
|
||||
Release: 13%{?prerelease}%{?dist}
|
||||
Release: 18%{?prerelease}%{?dist}
|
||||
Epoch: 1
|
||||
License: LGPLv2+
|
||||
Group: System Environment/Libraries
|
||||
@ -52,6 +52,11 @@ Patch17: 0017-Add-flag-for-protecting-cdrom-devices-during-populate.patch
|
||||
Patch18: 0018-Clean-up-some-errors-evident-in-installer-logs.patch
|
||||
Patch19: 0019-Use-dasd-disklabel-for-vm-disks-backed-by-dasds.patch
|
||||
Patch20: 0020-Fix-reading-LV-attributes-in-LVMVolumeGroupDevice.patch
|
||||
Patch21: 0021-Correctly-handle-non-unicode-iSCSI-initiator-names.patch
|
||||
Patch22: 0022-Do-not-crash-if-dm_get_member_raid_sets-fails.patch
|
||||
Patch23: 0023-Minor-cleanups-to-reduce-log-noise.patch
|
||||
Patch24: 0024-Fix-util.detect_virt-function.patch
|
||||
Patch25: 0025-Check-for-PV-sector-size-when-creating-new-VG.patch
|
||||
|
||||
# Versions of required components (done so we make sure the buildrequires
|
||||
# match the requires versions of things).
|
||||
@ -214,6 +219,26 @@ configuration.
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Nov 19 2019 Vojtech Trefny <vtrefny@redhat.com> - 3.1.0-18
|
||||
- Check for PV sector size when creating new VG
|
||||
Resolves: rhbz#1754446
|
||||
|
||||
* Wed Oct 02 2019 David Lehman <dlehman@redhat.com> - 3.1.0-17
|
||||
- Fix util.detect_virt function
|
||||
Resolves: rhbz#1676935
|
||||
|
||||
* Mon Aug 05 2019 Vojtech Trefny <vtrefny@redhat.com> - 3.1.0-16
|
||||
- Minor cleanups to reduce log noise
|
||||
Related: rhbz#1579375
|
||||
|
||||
* Mon Jul 15 2019 Vojtech Trefny <vtrefny@redhat.com> - 3.1.0-15
|
||||
- Do not crash if 'dm.get_member_raid_sets' fails
|
||||
Resolves: rhbz#1704289
|
||||
|
||||
* Tue Jul 02 2019 Vojtech Trefny <vtrefny@redhat.com> - 3.1.0-14
|
||||
- Correctly handle non-unicode iSCSI initiator names
|
||||
Resolves: rhbz#1632117
|
||||
|
||||
* Tue Jun 18 2019 Vojtech Trefny <vtrefny@redhat.com> - 3.1.0-13
|
||||
- Fix reading LV attributes in LVMVolumeGroupDevice.status
|
||||
Resolves: rhbz#1721381
|
||||
|
Loading…
Reference in New Issue
Block a user