diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c index e7f6242d..d7c3f31c 100644 --- a/src/plugins/lvm-dbus.c +++ b/src/plugins/lvm-dbus.c @@ -2706,10 +2706,34 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si * * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY */ -gboolean bd_lvm_lvrepair (const gchar *vg_name G_GNUC_UNUSED, const gchar *lv_name G_GNUC_UNUSED, const gchar **pv_list G_GNUC_UNUSED, - const BDExtraArg **extra G_GNUC_UNUSED, GError **error) { - g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_TECH_UNAVAIL, - "lvrepair is not supported by this plugin implementation."); +gboolean bd_lvm_lvrepair (const gchar *vg_name, const gchar *lv_name, const gchar **pv_list, + const BDExtraArg **extra, GError **error) { + GVariantBuilder builder; + GVariant *params = NULL; + gchar *path = NULL; + const gchar **pv = NULL; + GVariant *pvs = NULL; + + /* build the array of PVs (object paths) */ + g_variant_builder_init (&builder, G_VARIANT_TYPE_OBJECT_PATH_ARRAY); + for (pv=pv_list; *pv; pv++) { + path = get_object_path (*pv, error); + if (!path) { + g_variant_builder_clear (&builder); + return FALSE; + } + g_variant_builder_add_value (&builder, g_variant_new ("o", path)); + } + pvs = g_variant_builder_end (&builder); + g_variant_builder_clear (&builder); + + g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE); + g_variant_builder_add_value (&builder, pvs); + params = g_variant_builder_end (&builder); + g_variant_builder_clear (&builder); + + return call_lv_method_sync (vg_name, lv_name, "RepairRaidLv", params, NULL, extra, TRUE, error); + return FALSE; } diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py index d511933c..f1d68a40 100644 --- a/tests/lvm_dbus_tests.py +++ b/tests/lvm_dbus_tests.py @@ -351,6 +351,7 @@ def setUp(self): self.addCleanup(self._clean_up) self.dev_file = create_sparse_tempfile("lvm_test", self._sparse_size) self.dev_file2 = create_sparse_tempfile("lvm_test", self._sparse_size) + self.dev_file3 = create_sparse_tempfile("lvm_test", self._sparse_size) try: self.loop_dev = create_lio_device(self.dev_file) except RuntimeError as e: @@ -359,9 +360,13 @@ def setUp(self): self.loop_dev2 = create_lio_device(self.dev_file2) except RuntimeError as e: raise RuntimeError("Failed to setup loop device for testing: %s" % e) + try: + self.loop_dev3 = create_lio_device(self.dev_file3) + except RuntimeError as e: + raise RuntimeError("Failed to setup loop device for testing: %s" % e) def _clean_up(self): - for dev in (self.loop_dev, self.loop_dev2): + for dev in (self.loop_dev, self.loop_dev2, self.loop_dev3): try: BlockDev.lvm_pvremove(dev) except: @@ -386,6 +391,13 @@ def _clean_up(self): pass os.unlink(self.dev_file2) + try: + delete_lio_device(self.loop_dev3) + except RuntimeError: + # just move on, we can do no better here + pass + os.unlink(self.dev_file3) + @unittest.skipUnless(lvm_dbus_running, "LVM DBus not running") class LvmTestPVcreateRemove(LvmPVonlyTestCase): @tag_test(TestTags.CORE) @@ -1306,7 +1318,10 @@ def test_lvpartial(self): succ = BlockDev.lvm_pvcreate(self.loop_dev2, 0, 0, None) self.assertTrue(succ) - succ = BlockDev.lvm_vgcreate("testVG", [self.loop_dev, self.loop_dev2], 0, None) + succ = BlockDev.lvm_pvcreate(self.loop_dev3, 0, 0, None) + self.assertTrue(succ) + + succ = BlockDev.lvm_vgcreate("testVG", [self.loop_dev, self.loop_dev2, self.loop_dev3], 0, None) self.assertTrue(succ) info = BlockDev.lvm_pvinfo(self.loop_dev2) @@ -1390,6 +1405,16 @@ def assert_raid1_structure(pv1, pv2): # lvs_tree should still report the second stripe to be missing assert_raid1_structure(self.loop_dev, None) + # repair testLV with the third PV + with wait_for_sync("testVG", "testLV"): + succ = BlockDev.lvm_lvrepair("testVG", "testLV", [self.loop_dev3]) + self.assertTrue(succ) + + info = BlockDev.lvm_lvinfo("testVG", "testLV") + self.assertEqual(info.attr[8], "-") + + assert_raid1_structure(self.loop_dev, self.loop_dev3) + @unittest.skipUnless(lvm_dbus_running, "LVM DBus not running") class LvmTestLVsAll(LvmPVVGthpoolTestCase): def test_lvs_all(self): diff --git a/tests/skip.yml b/tests/skip.yml index 67e6a572..cf0a9580 100644 --- a/tests/skip.yml +++ b/tests/skip.yml @@ -55,3 +55,7 @@ - distro: "debian" arch: "i686" reason: "vdo userspace tools are not available on 32bit Debian" + +- test: lvm_dbus_tests.LvmTestPartialLVs + skip_on: + - reason: "LVM DBus doesn't support LV repair yet"