lvm-dbus: Fix calling lvcreate with empty list of PVs

Resolves: RHEL-113928
This commit is contained in:
Vojtech Trefny 2025-10-06 09:19:34 +02:00
parent 2ae3b40251
commit 4ad6357ad1
2 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 21ff65eb84f4d1d498726712a8dbf703ac97f649 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 4 Sep 2025 15:51:35 +0200
Subject: [PATCH] lvm-dbus: Fix calling lvcreate with empty list of PVs
GLib really dislikes us calling 'g_variant_builder_end' on the
empty array in this case.
Resolves: RHEL-113928
---
src/plugins/lvm-dbus.c | 2 +-
tests/lvm_dbus_tests.py | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index a129d884..b5317b0d 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -2061,7 +2061,7 @@ gboolean bd_lvm_lvcreate (const gchar *vg_name, const gchar *lv_name, guint64 si
GVariant *extra_params = NULL;
/* build the array of PVs (object paths) */
- if (pv_list) {
+ if (pv_list && *pv_list) {
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
for (pv=pv_list; *pv; pv++) {
path = get_object_path (*pv, error);
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
index bc8b3052..0a91f224 100644
--- a/tests/lvm_dbus_tests.py
+++ b/tests/lvm_dbus_tests.py
@@ -725,6 +725,13 @@ class LvmTestLVcreateRemove(LvmPVVGLVTestCase):
succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
self.assertTrue(succ)
+ # no PVs specified
+ succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, None, [], None)
+ self.assertTrue(succ)
+
+ succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
+ self.assertTrue(succ)
+
# not enough space (only one PV)
with six.assertRaisesRegex(self, GLib.GError, "Insufficient free space"):
succ = BlockDev.lvm_lvcreate("testVG", "testLV", 1048 * 1024**2, None, [self.loop_dev], None)
--
2.50.1

View File

@ -129,7 +129,7 @@
Name: libblockdev
Version: 2.28
Release: 14%{?dist}
Release: 15%{?dist}
Summary: A library for low-level manipulation with block devices
License: LGPLv2+
URL: https://github.com/storaged-project/libblockdev
@ -151,6 +151,7 @@ Patch13: 0013-tests-Remove_unreliable_nvme_attribute_checks.patch
Patch14: 0014-nvme-Add-bd_nvme_is_tech_avail-to-the-API-file.patch
Patch15: 0015-crypto-Add-a-function-to-set-persistent-flags-for-LU.patch
Patch16: 0016-Don-t-allow-suid-and-dev-set-on-fs-resize.patch
Patch17: 0017-lvm-dbus-Fix-calling-lvcreate-with-empty-list-of-PVs.patch
BuildRequires: make
BuildRequires: glib2-devel
@ -1049,6 +1050,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* Mon Oct 06 2025 Vojtech Trefny <vtrefny@redhat.com> - 2.28-15
- lvm-dbus: Fix calling lvcreate with empty list of PVs
Resolves: RHEL-113928
* Mon Jun 23 2025 Vojtech Trefny <vtrefny@redhat.com> - 2.28-14
- Don't allow suid and dev set on fs resize
Resolves: RHEL-96039