python-blivet/0021-Tell-LVM-DBus-to-refresh-its-internal-status-during-reset.patch
2025-07-02 14:47:56 +02:00

66 lines
2.4 KiB
Diff

From ee19e665276fd7cd6477da9bee59641b1de1a916 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 27 Jun 2025 11:28:09 +0200
Subject: [PATCH] Tell LVM DBus to refresh it's internal status during reset
Unfortunately some users run wipefs <disk> thinking it's enough
to remove all devices on top of the disk cleanly.
In cases where the PV is not directly on the disk, LVM DBus
doesn't get a udev event and doesn't remove the VG and LVs from
DBus so we think these still exist.
Resolves: RHEL-93967
---
blivet/devicelibs/lvm.py | 19 +++++++++++++++++++
blivet/populator/populator.py | 3 +++
2 files changed, 22 insertions(+)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index 38e1bc1bc..47cc3e5d7 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -36,6 +36,7 @@
log = logging.getLogger("blivet")
from . import raid
+from .. import safe_dbus
from ..size import Size
from ..i18n import N_
from ..flags import flags
@@ -284,3 +285,21 @@ def recommend_thpool_chunk_size(thpool_size):
def is_valid_cache_md_size(md_size):
return md_size >= LVM_CACHE_MIN_METADATA_SIZE and md_size <= LVM_CACHE_MAX_METADATA_SIZE
+
+
+def lvm_dbusd_refresh():
+ lvm_soname = blockdev.get_plugin_soname(blockdev.Plugin.LVM)
+ if 'dbus' not in lvm_soname:
+ return
+
+ try:
+ rc = safe_dbus.call_sync("com.redhat.lvmdbus1",
+ "/com/redhat/lvmdbus1/Manager",
+ "com.redhat.lvmdbus1.Manager",
+ "Refresh",
+ None)
+ except safe_dbus.DBusCallError as e:
+ log.error("Exception occurred when calling LVM DBusD refresh: %s", str(e))
+ else:
+ if rc[0] != 0:
+ log.error("Failed to call LVM DBusD refresh: %s", rc)
diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py
index 2ddea6618..da3b33cac 100644
--- a/blivet/populator/populator.py
+++ b/blivet/populator/populator.py
@@ -453,6 +453,9 @@ def _populate(self):
disklib.update_volume_info()
self.drop_device_info_cache()
+ # force LVM DBusD to refresh its internal state
+ lvm.lvm_dbusd_refresh()
+
if flags.auto_dev_updates and availability.BLOCKDEV_MPATH_PLUGIN.available:
blockdev.mpath.set_friendly_names(flags.multipath_friendly_names)