From 05032bf08c3ab2df4bdaf2d0471e87b5c9a1851d Mon Sep 17 00:00:00 2001 From: Vojtech Trefny 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. --- 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 e3901539..4e900ff0 100644 --- a/src/plugins/lvm-dbus.c +++ b/src/plugins/lvm-dbus.c @@ -1992,7 +1992,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 ef174793..2b7cacc1 100644 --- a/tests/lvm_dbus_tests.py +++ b/tests/lvm_dbus_tests.py @@ -675,6 +675,13 @@ def test_lvcreate_lvremove(self): 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)