Vojtech Trefny e9ae56
From a977e8389a09615615dc76dee8aaaea1cc0ac54b Mon Sep 17 00:00:00 2001
Vojtech Trefny e9ae56
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny e9ae56
Date: Thu, 22 Jul 2021 09:26:54 +0200
Vojtech Trefny e9ae56
Subject: [PATCH 1/2] Tell LVM to ignore the new devices file for now
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
We currently don't support working with the devices file and it's
Vojtech Trefny e9ae56
not possible to use lvm.conf filters together with the devices
Vojtech Trefny e9ae56
file so we need to tell LVM to ignore it until we can support it.
Vojtech Trefny e9ae56
---
Vojtech Trefny e9ae56
 blivet/devicelibs/lvm.py     | 4 ++++
Vojtech Trefny e9ae56
 blivet/tasks/availability.py | 1 +
Vojtech Trefny e9ae56
 2 files changed, 5 insertions(+)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
Vojtech Trefny e9ae56
index d56a76edc..989ecccaf 100644
Vojtech Trefny e9ae56
--- a/blivet/devicelibs/lvm.py
Vojtech Trefny e9ae56
+++ b/blivet/devicelibs/lvm.py
Vojtech Trefny e9ae56
@@ -91,6 +91,10 @@ def _set_global_config():
Vojtech Trefny e9ae56
     if filter_string:
Vojtech Trefny e9ae56
         devices_string += " %s" % filter_string
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
+    # for now ignore the LVM devices file and rely on our filters
Vojtech Trefny e9ae56
+    if availability.LVMDEVICES.available:
Vojtech Trefny e9ae56
+        devices_string += " use_devicesfile=0"
Vojtech Trefny e9ae56
+
Vojtech Trefny e9ae56
     # devices_string can have (inside the brackets) "dir", "scan",
Vojtech Trefny e9ae56
     # "preferred_names", "filter", "cache_dir", "write_cache_state",
Vojtech Trefny e9ae56
     # "types", "sysfs_scan", "md_component_detection".  see man lvm.conf.
Vojtech Trefny e9ae56
diff --git a/blivet/tasks/availability.py b/blivet/tasks/availability.py
Vojtech Trefny e9ae56
index 1fd805901..5d3e295da 100644
Vojtech Trefny e9ae56
--- a/blivet/tasks/availability.py
Vojtech Trefny e9ae56
+++ b/blivet/tasks/availability.py
Vojtech Trefny e9ae56
@@ -451,6 +451,7 @@ def available_resource(name):
Vojtech Trefny e9ae56
 HFORMAT_APP = application("hformat")
Vojtech Trefny e9ae56
 JFSTUNE_APP = application("jfs_tune")
Vojtech Trefny e9ae56
 KPARTX_APP = application("kpartx")
Vojtech Trefny e9ae56
+LVMDEVICES = application("lvmdevices")
Vojtech Trefny e9ae56
 MKDOSFS_APP = application("mkdosfs")
Vojtech Trefny e9ae56
 MKDOSFS_NEW_APP = application_by_version("mkdosfs", DOSFSTOOLS_VERSION)
Vojtech Trefny e9ae56
 MKE2FS_APP = application_by_version("mke2fs", E2FSPROGS_VERSION)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
From 08c137b5c98b24a9ba3df21f04cd20120c61198c Mon Sep 17 00:00:00 2001
Vojtech Trefny e9ae56
From: Vojtech Trefny <vtrefny@redhat.com>
Vojtech Trefny e9ae56
Date: Thu, 22 Jul 2021 11:33:46 +0200
Vojtech Trefny e9ae56
Subject: [PATCH 2/2] Make sure LVM config is updated before running pvcreate
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
Our internal "global" LVM config is set during reset() but we have
Vojtech Trefny e9ae56
test cases that run pvcreate without running reset() first so we
Vojtech Trefny e9ae56
need to make sure to update the global config before running it
Vojtech Trefny e9ae56
because the config string now also controls whether the new LVM
Vojtech Trefny e9ae56
devices file will be used or not.
Vojtech Trefny e9ae56
---
Vojtech Trefny e9ae56
 blivet/formats/lvmpv.py | 2 ++
Vojtech Trefny e9ae56
 1 file changed, 2 insertions(+)
Vojtech Trefny e9ae56
Vojtech Trefny e9ae56
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
Vojtech Trefny e9ae56
index e4182adb2..ea84e9e4b 100644
Vojtech Trefny e9ae56
--- a/blivet/formats/lvmpv.py
Vojtech Trefny e9ae56
+++ b/blivet/formats/lvmpv.py
Vojtech Trefny e9ae56
@@ -125,6 +125,8 @@ def _create(self, **kwargs):
Vojtech Trefny e9ae56
         log_method_call(self, device=self.device,
Vojtech Trefny e9ae56
                         type=self.type, status=self.status)
Vojtech Trefny e9ae56
 
Vojtech Trefny e9ae56
+        lvm._set_global_config()
Vojtech Trefny e9ae56
+
Vojtech Trefny e9ae56
         ea_yes = blockdev.ExtraArg.new("-y", "")
Vojtech Trefny e9ae56
         blockdev.lvm.pvcreate(self.device, data_alignment=self.data_alignment, extra=[ea_yes])
Vojtech Trefny e9ae56