Skip to content

Commit a81ea72

Browse files
Merge pull request #1125 from vojtechtrefny/master_lvcreate-empty-pvs-fix
lvm-dbus: Fix calling lvcreate with empty list of PVs
2 parents a21347f + cb219a7 commit a81ea72

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/plugins/lvm/lvm-dbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,7 @@ gboolean bd_lvm_lvcreate (const gchar *vg_name, const gchar *lv_name, guint64 si
23432343
GVariant *extra_params = NULL;
23442344

23452345
/* build the array of PVs (object paths) */
2346-
if (pv_list) {
2346+
if (pv_list && *pv_list) {
23472347
g_variant_builder_init (&builder, G_VARIANT_TYPE_ARRAY);
23482348
for (pv=pv_list; *pv; pv++) {
23492349
path = get_object_path (*pv, error);

tests/_lvm_cases.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,13 @@ def test_lvcreate_lvremove(self):
881881
succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
882882
self.assertTrue(succ)
883883

884+
# no PVs specified
885+
succ = BlockDev.lvm_lvcreate("testVG", "testLV", 512 * 1024**2, None, [], None)
886+
self.assertTrue(succ)
887+
888+
succ = BlockDev.lvm_lvremove("testVG", "testLV", True, None)
889+
self.assertTrue(succ)
890+
884891
# not enough space (only one PV)
885892
with self.assertRaisesRegex(GLib.GError, "Insufficient free space"):
886893
succ = BlockDev.lvm_lvcreate("testVG", "testLV", 1048 * 1024**2, None, [self.loop_dev], None)

0 commit comments

Comments
 (0)