Import from AlmaLinux stable repository
This commit is contained in:
parent
5ff90eea81
commit
4a6eb9c2c5
@ -0,0 +1,219 @@
|
|||||||
|
From 08d0ab8b93907ed3e2c7588dcaecb76bc4b26055 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Mon, 27 Feb 2023 11:29:29 +0100
|
||||||
|
Subject: [PATCH 1/2] Include LVM cli in the LVM DBus plugin dependencies
|
||||||
|
|
||||||
|
Strictly speaking the lvm command is not needed by the plugin, but
|
||||||
|
the LVM DBus daemon uses it so it must be present on the system
|
||||||
|
and we are already calling "lvm segtypes" from the plugin so if
|
||||||
|
the command is not available for us (for example not in $PATH) the
|
||||||
|
plugin wouldn't load anyway so an extra check isn't going to
|
||||||
|
change anything.
|
||||||
|
---
|
||||||
|
src/plugins/lvm-dbus.c | 15 ++++++++++++---
|
||||||
|
1 file changed, 12 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
||||||
|
index d4b542e2..8496a697 100644
|
||||||
|
--- a/src/plugins/lvm-dbus.c
|
||||||
|
+++ b/src/plugins/lvm-dbus.c
|
||||||
|
@@ -249,11 +249,14 @@ static volatile guint avail_features = 0;
|
||||||
|
static volatile guint avail_module_deps = 0;
|
||||||
|
static GMutex deps_check_lock;
|
||||||
|
|
||||||
|
-#define DEPS_LVMDEVICES 0
|
||||||
|
+#define DEPS_LVM 0
|
||||||
|
+#define DEPS_LVM_MASK (1 << DEPS_LVM)
|
||||||
|
+#define DEPS_LVMDEVICES 1
|
||||||
|
#define DEPS_LVMDEVICES_MASK (1 << DEPS_LVMDEVICES)
|
||||||
|
-#define DEPS_LAST 1
|
||||||
|
+#define DEPS_LAST 2
|
||||||
|
|
||||||
|
static const UtilDep deps[DEPS_LAST] = {
|
||||||
|
+ {"lvm", LVM_MIN_VERSION, "version", "LVM version:\\s+([\\d\\.]+)"},
|
||||||
|
{"lvmdevices", NULL, NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -2121,6 +2124,7 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
GVariantBuilder builder;
|
||||||
|
GVariantType *type = NULL;
|
||||||
|
GVariant *params = NULL;
|
||||||
|
+ GVariant *extra_params = NULL;
|
||||||
|
|
||||||
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
|
||||||
|
g_variant_builder_add_value (&builder, g_variant_new ("t", size));
|
||||||
|
@@ -2130,7 +2134,12 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
params = g_variant_builder_end (&builder);
|
||||||
|
g_variant_builder_clear (&builder);
|
||||||
|
|
||||||
|
- call_lv_method_sync (vg_name, lv_name, "Resize", params, NULL, extra, TRUE, error);
|
||||||
|
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
+ g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore"));
|
||||||
|
+ extra_params = g_variant_builder_end (&builder);
|
||||||
|
+ g_variant_builder_clear (&builder);
|
||||||
|
+
|
||||||
|
+ call_lv_method_sync (vg_name, lv_name, "Resize", params, extra_params, extra, TRUE, error);
|
||||||
|
return (*error == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
|
|
||||||
|
|
||||||
|
From cfb23f424c2f318efea7d9fd60ec1bcdb365ee35 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Mon, 27 Feb 2023 14:00:21 +0100
|
||||||
|
Subject: [PATCH 2/2] Allow resizing of inactive LVs with latest LVM
|
||||||
|
|
||||||
|
Latest LVM doesn't allow resizing of inactive LVs without the
|
||||||
|
"--fs ignore" option to protect users from corrupting their
|
||||||
|
filesystems. As a low level API we don't really want to offer this
|
||||||
|
kind of protection and we should allow to resize an inactive LV.
|
||||||
|
---
|
||||||
|
src/plugins/lvm-dbus.c | 28 ++++++++++++++++++++++++----
|
||||||
|
src/plugins/lvm.c | 31 ++++++++++++++++++++++++++++---
|
||||||
|
tests/lvm_dbus_tests.py | 4 ++++
|
||||||
|
tests/lvm_test.py | 4 ++++
|
||||||
|
4 files changed, 60 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
||||||
|
index 8496a697..28f3bb25 100644
|
||||||
|
--- a/src/plugins/lvm-dbus.c
|
||||||
|
+++ b/src/plugins/lvm-dbus.c
|
||||||
|
@@ -32,6 +32,8 @@
|
||||||
|
#define SECTOR_SIZE 512
|
||||||
|
#define VDO_POOL_SUFFIX "vpool"
|
||||||
|
|
||||||
|
+#define LVM_VERSION_FSRESIZE "2.03.19"
|
||||||
|
+
|
||||||
|
static GMutex global_config_lock;
|
||||||
|
static gchar *global_config_str = NULL;
|
||||||
|
|
||||||
|
@@ -2125,6 +2127,14 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
GVariantType *type = NULL;
|
||||||
|
GVariant *params = NULL;
|
||||||
|
GVariant *extra_params = NULL;
|
||||||
|
+ gboolean success = FALSE;
|
||||||
|
+ BDLVMLVdata *lvinfo = NULL;
|
||||||
|
+ GError *l_error = NULL;
|
||||||
|
+
|
||||||
|
+ lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error);
|
||||||
|
+ if (!lvinfo)
|
||||||
|
+ /* error is already populated */
|
||||||
|
+ return FALSE;
|
||||||
|
|
||||||
|
g_variant_builder_init (&builder, G_VARIANT_TYPE_TUPLE);
|
||||||
|
g_variant_builder_add_value (&builder, g_variant_new ("t", size));
|
||||||
|
@@ -2134,10 +2144,20 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
params = g_variant_builder_end (&builder);
|
||||||
|
g_variant_builder_clear (&builder);
|
||||||
|
|
||||||
|
- g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
- g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore"));
|
||||||
|
- extra_params = g_variant_builder_end (&builder);
|
||||||
|
- g_variant_builder_clear (&builder);
|
||||||
|
+ if (lvinfo->attr[4] != 'a') {
|
||||||
|
+ /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */
|
||||||
|
+ success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE,
|
||||||
|
+ deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, &l_error);
|
||||||
|
+ if (success) {
|
||||||
|
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
+ g_variant_builder_add (&builder, "{sv}", "--fs", g_variant_new ("s", "ignore"));
|
||||||
|
+ extra_params = g_variant_builder_end (&builder);
|
||||||
|
+ g_variant_builder_clear (&builder);
|
||||||
|
+ } else
|
||||||
|
+ g_clear_error (&l_error);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ bd_lvm_lvdata_free (lvinfo);
|
||||||
|
|
||||||
|
call_lv_method_sync (vg_name, lv_name, "Resize", params, extra_params, extra, TRUE, error);
|
||||||
|
return (*error == NULL);
|
||||||
|
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
|
||||||
|
index 03211f8a..f1e2941b 100644
|
||||||
|
--- a/src/plugins/lvm.c
|
||||||
|
+++ b/src/plugins/lvm.c
|
||||||
|
@@ -31,6 +31,8 @@
|
||||||
|
#define SECTOR_SIZE 512
|
||||||
|
#define VDO_POOL_SUFFIX "vpool"
|
||||||
|
|
||||||
|
+#define LVM_VERSION_FSRESIZE "2.03.19"
|
||||||
|
+
|
||||||
|
static GMutex global_config_lock;
|
||||||
|
static gchar *global_config_str = NULL;
|
||||||
|
|
||||||
|
@@ -1606,15 +1608,38 @@ gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gcha
|
||||||
|
* Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
*/
|
||||||
|
gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error) {
|
||||||
|
- const gchar *args[6] = {"lvresize", "--force", "-L", NULL, NULL, NULL};
|
||||||
|
+ const gchar *args[8] = {"lvresize", "--force", "-L", NULL, NULL, NULL, NULL, NULL};
|
||||||
|
gboolean success = FALSE;
|
||||||
|
+ guint8 next_arg = 4;
|
||||||
|
+ g_autofree gchar *lvspec = NULL;
|
||||||
|
+ BDLVMLVdata *lvinfo = NULL;
|
||||||
|
+ GError *l_error = NULL;
|
||||||
|
+
|
||||||
|
+ lvinfo = bd_lvm_lvinfo (vg_name, lv_name, error);
|
||||||
|
+ if (!lvinfo)
|
||||||
|
+ /* error is already populated */
|
||||||
|
+ return FALSE;
|
||||||
|
|
||||||
|
args[3] = g_strdup_printf ("%"G_GUINT64_FORMAT"K", size/1024);
|
||||||
|
- args[4] = g_strdup_printf ("%s/%s", vg_name, lv_name);
|
||||||
|
+
|
||||||
|
+ if (lvinfo->attr[4] != 'a') {
|
||||||
|
+ /* starting with 2.03.19 we need to add extra option to allow resizing of inactive LVs */
|
||||||
|
+ success = bd_utils_check_util_version (deps[DEPS_LVM].name, LVM_VERSION_FSRESIZE,
|
||||||
|
+ deps[DEPS_LVM].ver_arg, deps[DEPS_LVM].ver_regexp, &l_error);
|
||||||
|
+ if (success) {
|
||||||
|
+ args[next_arg++] = "--fs";
|
||||||
|
+ args[next_arg++] = "ignore";
|
||||||
|
+ } else
|
||||||
|
+ g_clear_error (&l_error);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ bd_lvm_lvdata_free (lvinfo);
|
||||||
|
+
|
||||||
|
+ lvspec = g_strdup_printf ("%s/%s", vg_name, lv_name);
|
||||||
|
+ args[next_arg++] = lvspec;
|
||||||
|
|
||||||
|
success = call_lvm_and_report_error (args, extra, TRUE, error);
|
||||||
|
g_free ((gchar *) args[3]);
|
||||||
|
- g_free ((gchar *) args[4]);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
||||||
|
index 61c898c1..fc12b55d 100644
|
||||||
|
--- a/tests/lvm_dbus_tests.py
|
||||||
|
+++ b/tests/lvm_dbus_tests.py
|
||||||
|
@@ -944,6 +944,10 @@ class LvmTestLVresize(LvmPVVGLVTestCase):
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
+ # try to resize when deactivated
|
||||||
|
+ succ = BlockDev.lvm_lvresize("testVG", "testLV", 768 * 1024**2, None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
|
||||||
|
class LvmTestLVrename(LvmPVVGLVTestCase):
|
||||||
|
def test_lvrename(self):
|
||||||
|
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
||||||
|
index 36ff10ec..7ede4b59 100644
|
||||||
|
--- a/tests/lvm_test.py
|
||||||
|
+++ b/tests/lvm_test.py
|
||||||
|
@@ -877,6 +877,10 @@ class LvmTestLVresize(LvmPVVGLVTestCase):
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
+ # try to resize when deactivated
|
||||||
|
+ succ = BlockDev.lvm_lvresize("testVG", "testLV", 768 * 1024**2, None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
class LvmTestLVrename(LvmPVVGLVTestCase):
|
||||||
|
def test_lvrename(self):
|
||||||
|
"""Verify that it's possible to rename an LV"""
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
|
|
@ -0,0 +1,41 @@
|
|||||||
|
From 2c59bc22d30ebfc16d5d06b1f31c4d7bbede68e9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Mon, 31 Oct 2022 12:43:17 +0100
|
||||||
|
Subject: [PATCH] tests: Fix test_swapon_pagesize on systems with 64k pages
|
||||||
|
|
||||||
|
---
|
||||||
|
tests/swap_test.py | 12 ++++++++++--
|
||||||
|
1 file changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/swap_test.py b/tests/swap_test.py
|
||||||
|
index 0a0f333d..e350f8e8 100644
|
||||||
|
--- a/tests/swap_test.py
|
||||||
|
+++ b/tests/swap_test.py
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
import unittest
|
||||||
|
import os
|
||||||
|
+import resource
|
||||||
|
import overrides_hack
|
||||||
|
|
||||||
|
from utils import create_sparse_tempfile, create_lio_device, delete_lio_device, fake_utils, fake_path, run_command, run, TestTags, tag_test
|
||||||
|
@@ -102,8 +103,15 @@ class SwapTestCase(SwapTest):
|
||||||
|
def test_swapon_pagesize(self):
|
||||||
|
"""Verify that activating swap with different pagesize fails"""
|
||||||
|
|
||||||
|
- # create swap with 64k pagesize
|
||||||
|
- ret, out, err = run_command("mkswap --pagesize 65536 %s" % self.loop_dev)
|
||||||
|
+ # pick some wrong page size: 8k on 64k and 64k everywhere else
|
||||||
|
+ pagesize = resource.getpagesize()
|
||||||
|
+ if pagesize == 65536:
|
||||||
|
+ wrong_pagesize = 8192
|
||||||
|
+ else:
|
||||||
|
+ wrong_pagesize = 65536
|
||||||
|
+
|
||||||
|
+ # create swap with "wrong" pagesize
|
||||||
|
+ ret, out, err = run_command("mkswap --pagesize %s %s" % (wrong_pagesize, self.loop_dev))
|
||||||
|
if ret != 0:
|
||||||
|
self.fail("Failed to prepare swap for pagesize test: %s %s" % (out, err))
|
||||||
|
|
||||||
|
--
|
||||||
|
2.39.2
|
||||||
|
|
@ -0,0 +1,32 @@
|
|||||||
|
From 9c96e621e9abb0649118d2e1731a09b1fa139579 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Wed, 19 Apr 2023 09:50:38 +0200
|
||||||
|
Subject: [PATCH] part: Fix segfault when adding a partition too big for MSDOS
|
||||||
|
|
||||||
|
Resolves: rhbz#2185564
|
||||||
|
---
|
||||||
|
src/plugins/part.c | 8 ++++++++
|
||||||
|
1 file changed, 8 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/plugins/part.c b/src/plugins/part.c
|
||||||
|
index 8b2285f5..28e20c28 100644
|
||||||
|
--- a/src/plugins/part.c
|
||||||
|
+++ b/src/plugins/part.c
|
||||||
|
@@ -841,6 +841,14 @@ static gboolean resize_part (PedPartition *part, PedDevice *dev, PedDisk *disk,
|
||||||
|
constr = ped_constraint_any (dev);
|
||||||
|
|
||||||
|
geom = ped_disk_get_max_partition_geometry (disk, part, constr);
|
||||||
|
+ if (!geom) {
|
||||||
|
+ set_parted_error (error, BD_PART_ERROR_FAIL);
|
||||||
|
+ g_prefix_error (error, "Failed to create geometry for partition on device '%s'", dev->path);
|
||||||
|
+ ped_constraint_destroy (constr);
|
||||||
|
+ finish_alignment_constraint (disk, orig_flag_state);
|
||||||
|
+ return FALSE;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (!ped_geometry_set_start (geom, start)) {
|
||||||
|
set_parted_error (error, BD_PART_ERROR_FAIL);
|
||||||
|
g_prefix_error (error, "Failed to set partition start on device '%s'", dev->path);
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
From bc8c4fa2b3ba76647de9742c28bae751757dc2dd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Thu, 18 May 2023 14:45:42 +0200
|
||||||
|
Subject: [PATCH 1/2] tests: Use longer passphrase for LUKS in dm_test
|
||||||
|
|
||||||
|
The short passphrase doesn't work when running in FIPS mode.
|
||||||
|
---
|
||||||
|
tests/dm_test.py | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/dm_test.py b/tests/dm_test.py
|
||||||
|
index 936e3055..3b491d89 100644
|
||||||
|
--- a/tests/dm_test.py
|
||||||
|
+++ b/tests/dm_test.py
|
||||||
|
@@ -59,8 +59,8 @@ class DevMapperGetSubsystemFromName(DevMapperTestCase):
|
||||||
|
def test_get_subsystem_from_name_crypt(self):
|
||||||
|
"""Verify that it is possible to get luks device subsystem from its name"""
|
||||||
|
self.addCleanup(self._destroy_crypt)
|
||||||
|
- run("echo \"key\" | cryptsetup luksFormat %s -" %self.loop_dev)
|
||||||
|
- run("echo \"key\" | cryptsetup open %s libbd_dm_tests-subsystem_crypt --key-file=-" %self.loop_dev)
|
||||||
|
+ run("echo \"supersecretkey\" | cryptsetup luksFormat %s -" %self.loop_dev)
|
||||||
|
+ run("echo \"supersecretkey\" | cryptsetup open %s libbd_dm_tests-subsystem_crypt --key-file=-" %self.loop_dev)
|
||||||
|
subsystem = BlockDev.dm_get_subsystem_from_name("libbd_dm_tests-subsystem_crypt")
|
||||||
|
self.assertEqual(subsystem, "CRYPT")
|
||||||
|
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
||||||
|
|
||||||
|
From b1f6d1484a980885b9870d27d2b113c98400851b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Thu, 18 May 2023 14:56:32 +0200
|
||||||
|
Subject: [PATCH 2/2] tests: Skip crypto tests with argon2 in FIPS mode
|
||||||
|
|
||||||
|
argon is not available when running in FIPS mode.
|
||||||
|
---
|
||||||
|
tests/crypto_test.py | 17 +++++++++++++++++
|
||||||
|
1 file changed, 17 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/tests/crypto_test.py b/tests/crypto_test.py
|
||||||
|
index 94b89131..91ea1f35 100644
|
||||||
|
--- a/tests/crypto_test.py
|
||||||
|
+++ b/tests/crypto_test.py
|
||||||
|
@@ -175,6 +175,23 @@ class CryptoTestFormat(CryptoTestCase):
|
||||||
|
self.fail("Failed to get pbkdf information from:\n%s %s" % (out, err))
|
||||||
|
self.assertEqual(m.group(1), "pbkdf2")
|
||||||
|
|
||||||
|
+ def _is_fips_enabled(self):
|
||||||
|
+ if not os.path.exists("/proc/sys/crypto/fips_enabled"):
|
||||||
|
+ # if the file doesn't exist, we are definitely not in FIPS mode
|
||||||
|
+ return False
|
||||||
|
+
|
||||||
|
+ with open("/proc/sys/crypto/fips_enabled", "r") as f:
|
||||||
|
+ enabled = f.read()
|
||||||
|
+ return enabled.strip() == "1"
|
||||||
|
+
|
||||||
|
+ @tag_test(TestTags.SLOW, TestTags.CORE)
|
||||||
|
+ @unittest.skipUnless(HAVE_LUKS2, "LUKS 2 not supported")
|
||||||
|
+ def test_luks2_format_pbkdf_options(self):
|
||||||
|
+ """Verify that formatting device as LUKS 2 works"""
|
||||||
|
+
|
||||||
|
+ if self._is_fips_enabled():
|
||||||
|
+ self.skipTest("FIPS mode is enabled, cannot use argon2, skipping")
|
||||||
|
+
|
||||||
|
# different options for argon2 -- all parameters set
|
||||||
|
pbkdf = BlockDev.CryptoLUKSPBKDF(type="argon2id", max_memory_kb=100*1024, iterations=10, parallel_threads=1)
|
||||||
|
extra = BlockDev.CryptoLUKSExtra(pbkdf=pbkdf)
|
||||||
|
--
|
||||||
|
2.40.1
|
||||||
|
|
@ -0,0 +1,300 @@
|
|||||||
|
From 6bdbafc79e5bcdf2087148c6caa88a6c50c1e94a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Mon, 24 Apr 2023 11:57:18 +0200
|
||||||
|
Subject: [PATCH] lvm: Add a function to activate LVs in shared mode
|
||||||
|
|
||||||
|
Needed by the new blivet feature to support shared LVM setups.
|
||||||
|
---
|
||||||
|
src/lib/plugin_apis/lvm.api | 16 +++++++++
|
||||||
|
src/plugins/lvm-dbus.c | 51 ++++++++++++++++++++-------
|
||||||
|
src/plugins/lvm.c | 53 ++++++++++++++++++++++-------
|
||||||
|
src/plugins/lvm.h | 1 +
|
||||||
|
src/python/gi/overrides/BlockDev.py | 5 ++-
|
||||||
|
tests/lvm_dbus_tests.py | 18 +++++++---
|
||||||
|
tests/lvm_test.py | 18 +++++++---
|
||||||
|
7 files changed, 124 insertions(+), 38 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
||||||
|
index b8cde70b..640eee49 100644
|
||||||
|
--- a/src/lib/plugin_apis/lvm.api
|
||||||
|
+++ b/src/lib/plugin_apis/lvm.api
|
||||||
|
@@ -1057,6 +1057,22 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
*/
|
||||||
|
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error);
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_lvactivate_shared:
|
||||||
|
+ * @vg_name: name of the VG containing the to-be-activated LV
|
||||||
|
+ * @lv_name: name of the to-be-activated LV
|
||||||
|
+ * @ignore_skip: whether to ignore the skip flag or not
|
||||||
|
+ * @shared: whether to activate the LV in shared mode
|
||||||
|
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error);
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_lvdeactivate:
|
||||||
|
* @vg_name: name of the VG containing the to-be-deactivated LV
|
||||||
|
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
||||||
|
index 28f3bb25..46e09833 100644
|
||||||
|
--- a/src/plugins/lvm-dbus.c
|
||||||
|
+++ b/src/plugins/lvm-dbus.c
|
||||||
|
@@ -2163,6 +2163,27 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
return (*error == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static gboolean _lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ GVariant *params = NULL;
|
||||||
|
+ GVariantBuilder builder;
|
||||||
|
+ GVariant *extra_params = NULL;
|
||||||
|
+
|
||||||
|
+ if (shared)
|
||||||
|
+ params = g_variant_new ("(t)", (guint64) 1 << 6);
|
||||||
|
+ else
|
||||||
|
+ params = g_variant_new ("(t)", (guint64) 0);
|
||||||
|
+
|
||||||
|
+ if (ignore_skip) {
|
||||||
|
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
+ g_variant_builder_add (&builder, "{sv}", "-K", g_variant_new ("s", ""));
|
||||||
|
+ extra_params = g_variant_builder_end (&builder);
|
||||||
|
+ g_variant_builder_clear (&builder);
|
||||||
|
+ }
|
||||||
|
+ call_lv_method_sync (vg_name, lv_name, "Activate", params, extra_params, extra, TRUE, error);
|
||||||
|
+
|
||||||
|
+ return (*error == NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_lvactivate:
|
||||||
|
* @vg_name: name of the VG containing the to-be-activated LV
|
||||||
|
@@ -2177,19 +2198,25 @@ 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_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error) {
|
||||||
|
- GVariant *params = g_variant_new ("(t)", (guint64) 0);
|
||||||
|
- GVariantBuilder builder;
|
||||||
|
- GVariant *extra_params = NULL;
|
||||||
|
-
|
||||||
|
- if (ignore_skip) {
|
||||||
|
- g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
- g_variant_builder_add (&builder, "{sv}", "-K", g_variant_new ("s", ""));
|
||||||
|
- extra_params = g_variant_builder_end (&builder);
|
||||||
|
- g_variant_builder_clear (&builder);
|
||||||
|
- }
|
||||||
|
- call_lv_method_sync (vg_name, lv_name, "Activate", params, extra_params, extra, TRUE, error);
|
||||||
|
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, FALSE, extra, error);
|
||||||
|
+}
|
||||||
|
|
||||||
|
- return (*error == NULL);
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_lvactivate_shared:
|
||||||
|
+ * @vg_name: name of the VG containing the to-be-activated LV
|
||||||
|
+ * @lv_name: name of the to-be-activated LV
|
||||||
|
+ * @ignore_skip: whether to ignore the skip flag or not
|
||||||
|
+ * @shared: whether to activate the LV in shared mode
|
||||||
|
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, shared, extra, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
|
||||||
|
index f1e2941b..0db3bf4a 100644
|
||||||
|
--- a/src/plugins/lvm.c
|
||||||
|
+++ b/src/plugins/lvm.c
|
||||||
|
@@ -1644,6 +1644,28 @@ gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 si
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static gboolean _lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ const gchar *args[5] = {"lvchange", NULL, NULL, NULL, NULL};
|
||||||
|
+ guint8 next_arg = 2;
|
||||||
|
+ gboolean success = FALSE;
|
||||||
|
+
|
||||||
|
+ if (shared)
|
||||||
|
+ args[1] = "-asy";
|
||||||
|
+ else
|
||||||
|
+ args[1] = "-ay";
|
||||||
|
+
|
||||||
|
+ if (ignore_skip) {
|
||||||
|
+ args[next_arg] = "-K";
|
||||||
|
+ next_arg++;
|
||||||
|
+ }
|
||||||
|
+ args[next_arg] = g_strdup_printf ("%s/%s", vg_name, lv_name);
|
||||||
|
+
|
||||||
|
+ success = call_lvm_and_report_error (args, extra, TRUE, error);
|
||||||
|
+ g_free ((gchar *) args[next_arg]);
|
||||||
|
+
|
||||||
|
+ return success;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_lvactivate:
|
||||||
|
* @vg_name: name of the VG containing the to-be-activated LV
|
||||||
|
@@ -1658,20 +1680,25 @@ 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_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error) {
|
||||||
|
- const gchar *args[5] = {"lvchange", "-ay", NULL, NULL, NULL};
|
||||||
|
- guint8 next_arg = 2;
|
||||||
|
- gboolean success = FALSE;
|
||||||
|
-
|
||||||
|
- if (ignore_skip) {
|
||||||
|
- args[next_arg] = "-K";
|
||||||
|
- next_arg++;
|
||||||
|
- }
|
||||||
|
- args[next_arg] = g_strdup_printf ("%s/%s", vg_name, lv_name);
|
||||||
|
-
|
||||||
|
- success = call_lvm_and_report_error (args, extra, TRUE, error);
|
||||||
|
- g_free ((gchar *) args[next_arg]);
|
||||||
|
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, FALSE, extra, error);
|
||||||
|
+}
|
||||||
|
|
||||||
|
- return success;
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_lvactivate_shared:
|
||||||
|
+ * @vg_name: name of the VG containing the to-be-activated LV
|
||||||
|
+ * @lv_name: name of the to-be-activated LV
|
||||||
|
+ * @ignore_skip: whether to ignore the skip flag or not
|
||||||
|
+ * @shared: whether to activate the LV in shared mode
|
||||||
|
+ * @extra: (allow-none) (array zero-terminated=1): extra options for the LV activation
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the @vg_name/@lv_name LV was successfully activated or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _lvm_lvactivate (vg_name, lv_name, ignore_skip, shared, extra, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
|
||||||
|
index fabf091f..c85c043d 100644
|
||||||
|
--- a/src/plugins/lvm.h
|
||||||
|
+++ b/src/plugins/lvm.h
|
||||||
|
@@ -277,6 +277,7 @@ gboolean bd_lvm_lvremove (const gchar *vg_name, const gchar *lv_name, gboolean f
|
||||||
|
gboolean bd_lvm_lvrename (const gchar *vg_name, const gchar *lv_name, const gchar *new_name, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_lvresize (const gchar *vg_name, const gchar *lv_name, guint64 size, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_lvactivate (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, const BDExtraArg **extra, GError **error);
|
||||||
|
+gboolean bd_lvm_lvactivate_shared (const gchar *vg_name, const gchar *lv_name, gboolean ignore_skip, gboolean shared, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_lvdeactivate (const gchar *vg_name, const gchar *lv_name, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_lvsnapshotcreate (const gchar *vg_name, const gchar *origin_name, const gchar *snapshot_name, guint64 size, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_lvsnapshotmerge (const gchar *vg_name, const gchar *snapshot_name, const BDExtraArg **extra, GError **error);
|
||||||
|
diff --git a/src/python/gi/overrides/BlockDev.py b/src/python/gi/overrides/BlockDev.py
|
||||||
|
index 795e0de4..3e074260 100644
|
||||||
|
--- a/src/python/gi/overrides/BlockDev.py
|
||||||
|
+++ b/src/python/gi/overrides/BlockDev.py
|
||||||
|
@@ -605,11 +605,10 @@ def lvm_lvresize(vg_name, lv_name, size, extra=None, **kwargs):
|
||||||
|
return _lvm_lvresize(vg_name, lv_name, size, extra)
|
||||||
|
__all__.append("lvm_lvresize")
|
||||||
|
|
||||||
|
-_lvm_lvactivate = BlockDev.lvm_lvactivate
|
||||||
|
@override(BlockDev.lvm_lvactivate)
|
||||||
|
-def lvm_lvactivate(vg_name, lv_name, ignore_skip=False, extra=None, **kwargs):
|
||||||
|
+def lvm_lvactivate(vg_name, lv_name, ignore_skip=False, shared=False, extra=None, **kwargs):
|
||||||
|
extra = _get_extra(extra, kwargs)
|
||||||
|
- return _lvm_lvactivate(vg_name, lv_name, ignore_skip, extra)
|
||||||
|
+ return BlockDev.lvm_lvactivate_shared(vg_name, lv_name, ignore_skip, shared, extra)
|
||||||
|
__all__.append("lvm_lvactivate")
|
||||||
|
|
||||||
|
_lvm_lvdeactivate = BlockDev.lvm_lvdeactivate
|
||||||
|
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
||||||
|
index fc12b55d..a821636e 100644
|
||||||
|
--- a/tests/lvm_dbus_tests.py
|
||||||
|
+++ b/tests/lvm_dbus_tests.py
|
||||||
|
@@ -873,15 +873,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True)
|
||||||
|
|
||||||
|
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
@@ -896,7 +896,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ # try activating in shared mode, unfortunately no way to check whether it really
|
||||||
|
+ # works or not
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, True)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
||||||
|
index 7ede4b59..63f43afb 100644
|
||||||
|
--- a/tests/lvm_test.py
|
||||||
|
+++ b/tests/lvm_test.py
|
||||||
|
@@ -807,15 +807,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("nonexistingVG", "testLV", True)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("testVG", "nonexistingLV", True)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
- BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True, None)
|
||||||
|
+ BlockDev.lvm_lvactivate("nonexistingVG", "nonexistingLV", True)
|
||||||
|
|
||||||
|
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
with self.assertRaises(GLib.GError):
|
||||||
|
@@ -830,7 +830,15 @@ class LvmTestLVactivateDeactivate(LvmPVVGLVTestCase):
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
- succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, None)
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ # try activating in shared mode, unfortunately no way to check whether it really
|
||||||
|
+ # works or not
|
||||||
|
+ succ = BlockDev.lvm_lvactivate("testVG", "testLV", True, True)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
succ = BlockDev.lvm_lvdeactivate("testVG", "testLV", None)
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
1395
SOURCES/0011-nvme_libblockdev-3.0.4_backport.patch
Normal file
1395
SOURCES/0011-nvme_libblockdev-3.0.4_backport.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,299 @@
|
|||||||
|
From f72ba6aded6093d34d5e8a1666a844ec2b0ee5eb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Vojtech Trefny <vtrefny@redhat.com>
|
||||||
|
Date: Tue, 18 Apr 2023 12:05:35 +0200
|
||||||
|
Subject: [PATCH] lvm: Add support for starting and stopping VG locking
|
||||||
|
|
||||||
|
---
|
||||||
|
docs/libblockdev-sections.txt | 2 ++
|
||||||
|
src/lib/plugin_apis/lvm.api | 27 +++++++++++++++++++
|
||||||
|
src/plugins/lvm-dbus.c | 49 ++++++++++++++++++++++++++++++++++-
|
||||||
|
src/plugins/lvm.c | 41 +++++++++++++++++++++++++++++
|
||||||
|
src/plugins/lvm.h | 3 +++
|
||||||
|
tests/lvm_dbus_tests.py | 33 +++++++++++++++++++++++
|
||||||
|
tests/lvm_test.py | 32 +++++++++++++++++++++++
|
||||||
|
7 files changed, 186 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/docs/libblockdev-sections.txt b/docs/libblockdev-sections.txt
|
||||||
|
index 540e2b96..08ea309c 100644
|
||||||
|
--- a/docs/libblockdev-sections.txt
|
||||||
|
+++ b/docs/libblockdev-sections.txt
|
||||||
|
@@ -286,6 +286,8 @@ bd_lvm_vgactivate
|
||||||
|
bd_lvm_vgdeactivate
|
||||||
|
bd_lvm_vgextend
|
||||||
|
bd_lvm_vgreduce
|
||||||
|
+bd_lvm_vglock_start
|
||||||
|
+bd_lvm_vglock_stop
|
||||||
|
bd_lvm_vginfo
|
||||||
|
bd_lvm_vgs
|
||||||
|
bd_lvm_lvorigin
|
||||||
|
diff --git a/src/lib/plugin_apis/lvm.api b/src/lib/plugin_apis/lvm.api
|
||||||
|
index 640eee49..1343fbdb 100644
|
||||||
|
--- a/src/lib/plugin_apis/lvm.api
|
||||||
|
+++ b/src/lib/plugin_apis/lvm.api
|
||||||
|
@@ -603,6 +603,7 @@ typedef enum {
|
||||||
|
BD_LVM_TECH_GLOB_CONF,
|
||||||
|
BD_LVM_TECH_VDO,
|
||||||
|
BD_LVM_TECH_DEVICES,
|
||||||
|
+ BD_LVM_TECH_SHARED,
|
||||||
|
} BDLVMTech;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
@@ -943,6 +944,32 @@ gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExt
|
||||||
|
*/
|
||||||
|
gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_start:
|
||||||
|
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully started for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error);
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_stop:
|
||||||
|
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully stopped for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error);
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_vginfo:
|
||||||
|
* @vg_name: a VG to get information about
|
||||||
|
diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
|
||||||
|
index 46e09833..a129d884 100644
|
||||||
|
--- a/src/plugins/lvm-dbus.c
|
||||||
|
+++ b/src/plugins/lvm-dbus.c
|
||||||
|
@@ -1872,10 +1872,57 @@ gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExt
|
||||||
|
return ((*error) == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
+gboolean _vglock_start_stop (const gchar *vg_name, gboolean start, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ GVariantBuilder builder;
|
||||||
|
+ GVariant *params = NULL;
|
||||||
|
+
|
||||||
|
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_DICTIONARY);
|
||||||
|
+ if (start)
|
||||||
|
+ g_variant_builder_add (&builder, "{sv}", "--lockstart", g_variant_new ("s", ""));
|
||||||
|
+ else
|
||||||
|
+ g_variant_builder_add (&builder, "{sv}", "--lockstop", g_variant_new ("s", ""));
|
||||||
|
+ params = g_variant_builder_end (&builder);
|
||||||
|
+ g_variant_builder_clear (&builder);
|
||||||
|
+
|
||||||
|
+ call_lvm_obj_method_sync (vg_name, VG_INTF, "Change", NULL, params, extra, TRUE, error);
|
||||||
|
+
|
||||||
|
+ return ((*error) == NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_start:
|
||||||
|
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully started for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _vglock_start_stop (vg_name, TRUE, extra, error);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_stop:
|
||||||
|
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully stopped for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_BASIC-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _vglock_start_stop (vg_name, FALSE, extra, error);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_vginfo:
|
||||||
|
* @vg_name: a VG to get information about
|
||||||
|
- * @error: (out): place to store error (if any)
|
||||||
|
+ * @error: (out) (optional): place to store error (if any)
|
||||||
|
*
|
||||||
|
* Returns: (transfer full): information about the @vg_name VG or %NULL in case
|
||||||
|
* of error (the @error) gets populated in those cases)
|
||||||
|
diff --git a/src/plugins/lvm.c b/src/plugins/lvm.c
|
||||||
|
index 0db3bf4a..b0a71224 100644
|
||||||
|
--- a/src/plugins/lvm.c
|
||||||
|
+++ b/src/plugins/lvm.c
|
||||||
|
@@ -1341,6 +1341,47 @@ gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExt
|
||||||
|
return call_lvm_and_report_error (args, extra, TRUE, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
+gboolean _vglock_start_stop (const gchar *vg_name, gboolean start, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ const gchar *args[4] = {"vgchange", NULL, vg_name, NULL};
|
||||||
|
+
|
||||||
|
+ if (start)
|
||||||
|
+ args[1] = "--lockstart";
|
||||||
|
+ else
|
||||||
|
+ args[1] = "--lockstop";
|
||||||
|
+
|
||||||
|
+ return call_lvm_and_report_error (args, extra, TRUE, error);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_start:
|
||||||
|
+ * @vg_name: a shared VG to start the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully started for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _vglock_start_stop (vg_name, TRUE, extra, error);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * bd_lvm_vglock_stop:
|
||||||
|
+ * @vg_name: a shared VG to stop the lockspace in lvmlockd
|
||||||
|
+ * @extra: (nullable) (array zero-terminated=1): extra options for the vgchange command
|
||||||
|
+ * (just passed to LVM as is)
|
||||||
|
+ * @error: (out): place to store error (if any)
|
||||||
|
+ *
|
||||||
|
+ * Returns: whether the lock was successfully stopped for @vg_name or not
|
||||||
|
+ *
|
||||||
|
+ * Tech category: %BD_LVM_TECH_SHARED-%BD_LVM_TECH_MODE_MODIFY
|
||||||
|
+ */
|
||||||
|
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error) {
|
||||||
|
+ return _vglock_start_stop (vg_name, FALSE, extra, error);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* bd_lvm_vginfo:
|
||||||
|
* @vg_name: a VG to get information about
|
||||||
|
diff --git a/src/plugins/lvm.h b/src/plugins/lvm.h
|
||||||
|
index c85c043d..2e47b06f 100644
|
||||||
|
--- a/src/plugins/lvm.h
|
||||||
|
+++ b/src/plugins/lvm.h
|
||||||
|
@@ -218,6 +218,7 @@ typedef enum {
|
||||||
|
BD_LVM_TECH_GLOB_CONF,
|
||||||
|
BD_LVM_TECH_VDO,
|
||||||
|
BD_LVM_TECH_DEVICES,
|
||||||
|
+ BD_LVM_TECH_SHARED,
|
||||||
|
} BDLVMTech;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
@@ -268,6 +269,8 @@ gboolean bd_lvm_vgactivate (const gchar *vg_name, const BDExtraArg **extra, GErr
|
||||||
|
gboolean bd_lvm_vgdeactivate (const gchar *vg_name, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_vgextend (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
|
||||||
|
gboolean bd_lvm_vgreduce (const gchar *vg_name, const gchar *device, const BDExtraArg **extra, GError **error);
|
||||||
|
+gboolean bd_lvm_vglock_start (const gchar *vg_name, const BDExtraArg **extra, GError **error);
|
||||||
|
+gboolean bd_lvm_vglock_stop (const gchar *vg_name, const BDExtraArg **extra, GError **error);
|
||||||
|
BDLVMVGdata* bd_lvm_vginfo (const gchar *vg_name, GError **error);
|
||||||
|
BDLVMVGdata** bd_lvm_vgs (GError **error);
|
||||||
|
|
||||||
|
diff --git a/tests/lvm_dbus_tests.py b/tests/lvm_dbus_tests.py
|
||||||
|
index a821636e..bc8b3052 100644
|
||||||
|
--- a/tests/lvm_dbus_tests.py
|
||||||
|
+++ b/tests/lvm_dbus_tests.py
|
||||||
|
@@ -655,6 +655,39 @@ class LvmTestVGs(LvmPVVGTestCase):
|
||||||
|
succ = BlockDev.lvm_pvremove(self.loop_dev, None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
+@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
|
||||||
|
+class LvmTestVGLocking(LvmPVVGTestCase):
|
||||||
|
+ @tag_test(TestTags.UNSAFE)
|
||||||
|
+ def test_vglock_stop_start(self):
|
||||||
|
+ """Verify that it is possible to start and stop locking on a VG"""
|
||||||
|
+
|
||||||
|
+ # better not do anything if lvmlockd is running, shared VGs have
|
||||||
|
+ # a tendency to wreak havoc on your system if you look at them wrong
|
||||||
|
+ ret, _out, _err = run_command("systemctl is-active lvmlockd")
|
||||||
|
+ if ret == 0:
|
||||||
|
+ self.skipTest("lvmlockd is running, skipping")
|
||||||
|
+
|
||||||
|
+ _ret, out, _err = run_command("lvm config 'global/use_lvmlockd'")
|
||||||
|
+ if "use_lvmlockd=0" not in out:
|
||||||
|
+ self.skipTest("lvmlockd is enabled, skipping")
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ 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)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ # this actually doesn't "test" anything, the commands will just say lvmlockd is not
|
||||||
|
+ # running and return 0, but that's good enough for us
|
||||||
|
+ succ = BlockDev.lvm_vglock_start("testVG")
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_vglock_stop("testVG")
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
@unittest.skipUnless(lvm_dbus_running, "LVM DBus not running")
|
||||||
|
class LvmPVVGLVTestCase(LvmPVVGTestCase):
|
||||||
|
def _clean_up(self):
|
||||||
|
diff --git a/tests/lvm_test.py b/tests/lvm_test.py
|
||||||
|
index 63f43afb..d517001b 100644
|
||||||
|
--- a/tests/lvm_test.py
|
||||||
|
+++ b/tests/lvm_test.py
|
||||||
|
@@ -632,6 +632,38 @@ class LvmTestVGs(LvmPVVGTestCase):
|
||||||
|
succ = BlockDev.lvm_pvremove(self.loop_dev, None)
|
||||||
|
self.assertTrue(succ)
|
||||||
|
|
||||||
|
+class LvmTestVGLocking(LvmPVVGTestCase):
|
||||||
|
+ @tag_test(TestTags.UNSAFE)
|
||||||
|
+ def test_vglock_stop_start(self):
|
||||||
|
+ """Verify that it is possible to start and stop locking on a VG"""
|
||||||
|
+
|
||||||
|
+ # better not do anything if lvmlockd is running, shared VGs have
|
||||||
|
+ # a tendency to wreak havoc on your system if you look at them wrong
|
||||||
|
+ ret, _out, _err = run_command("systemctl is-active lvmlockd")
|
||||||
|
+ if ret == 0:
|
||||||
|
+ self.skipTest("lvmlockd is running, skipping")
|
||||||
|
+
|
||||||
|
+ _ret, out, _err = run_command("lvm config 'global/use_lvmlockd'")
|
||||||
|
+ if "use_lvmlockd=0" not in out:
|
||||||
|
+ self.skipTest("lvmlockd is enabled, skipping")
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_pvcreate(self.loop_dev, 0, 0, None)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ 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)
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ # this actually doesn't "test" anything, the commands will just say lvmlockd is not
|
||||||
|
+ # running and return 0, but that's good enough for us
|
||||||
|
+ succ = BlockDev.lvm_vglock_start("testVG")
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
+ succ = BlockDev.lvm_vglock_stop("testVG")
|
||||||
|
+ self.assertTrue(succ)
|
||||||
|
+
|
||||||
|
class LvmPVVGLVTestCase(LvmPVVGTestCase):
|
||||||
|
def _clean_up(self):
|
||||||
|
try:
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -129,7 +129,7 @@
|
|||||||
|
|
||||||
Name: libblockdev
|
Name: libblockdev
|
||||||
Version: 2.28
|
Version: 2.28
|
||||||
Release: 4%{?dist}
|
Release: 10%{?dist}
|
||||||
Summary: A library for low-level manipulation with block devices
|
Summary: A library for low-level manipulation with block devices
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: https://github.com/storaged-project/libblockdev
|
URL: https://github.com/storaged-project/libblockdev
|
||||||
@ -140,6 +140,13 @@ Patch2: 0002-Add-support-for-creating-and-activating-integrity-de.patch
|
|||||||
Patch3: 0003-NVMe-plugin-backport.patch
|
Patch3: 0003-NVMe-plugin-backport.patch
|
||||||
Patch4: 0004-Fix-double-free-in-write_escrow_data_file.patch
|
Patch4: 0004-Fix-double-free-in-write_escrow_data_file.patch
|
||||||
Patch5: 0005-nvme-Fix-namespace-identifiers.patch
|
Patch5: 0005-nvme-Fix-namespace-identifiers.patch
|
||||||
|
Patch6: 0006-Allow-resizing-of-inactive-LVs-with-latest-LVM.patch
|
||||||
|
Patch7: 0007-tests-Fix-test_swapon_pagesize-on-systems-with-64k-p.patch
|
||||||
|
Patch8: 0008-part-Fix-segfault-when-adding-a-partition-too-big-fo.patch
|
||||||
|
Patch9: 0009-Fix-issues-in-tests-when-running-in-FIPS-mode.patch
|
||||||
|
Patch10: 0010-lvm-Add-a-function-to-activate-LVs-in-shared-mode.patch
|
||||||
|
Patch11: 0011-nvme_libblockdev-3.0.4_backport.patch
|
||||||
|
Patch12: 0012-lvm-Add-support-for-starting-and-stopping-VG-locking.patch
|
||||||
|
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
BuildRequires: glib2-devel
|
BuildRequires: glib2-devel
|
||||||
@ -719,13 +726,7 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
|
|||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}
|
%autosetup -n %{name}-%{version} -p1
|
||||||
%patch0 -p1
|
|
||||||
%patch1 -p1
|
|
||||||
%patch2 -p1
|
|
||||||
%patch3 -p1
|
|
||||||
%patch4 -p1
|
|
||||||
%patch5 -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
autoreconf -ivf
|
autoreconf -ivf
|
||||||
@ -1044,6 +1045,36 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
|
|||||||
%files plugins-all
|
%files plugins-all
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Nov 08 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-10
|
||||||
|
- lvm: Add support for starting and stopping VG locking
|
||||||
|
Resolves: RHEL-15921
|
||||||
|
|
||||||
|
* Wed Nov 01 2023 Tomas Bzatek <tbzatek@redhat.com> - 2.28-9
|
||||||
|
- nvme: HostID fixes for TP4126
|
||||||
|
Resolves: RHEL-1375
|
||||||
|
- nvme: Stack smashing fixes
|
||||||
|
Resolves: RHEL-13127
|
||||||
|
Resolves: RHEL-8037
|
||||||
|
|
||||||
|
* Tue Oct 17 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-8
|
||||||
|
- lvm: Add a function to activate LVs in shared mode
|
||||||
|
Resolves: RHEL-14018
|
||||||
|
|
||||||
|
* Wed May 24 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-7
|
||||||
|
- Fix issues in tests when running in FIPS mode
|
||||||
|
Resolves: rhbz#2188749
|
||||||
|
Resolves: rhbz#2188603
|
||||||
|
|
||||||
|
* Tue May 16 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-6
|
||||||
|
- Fix segfault when adding a partition too big for MSDOS
|
||||||
|
Resolves: rhbz#2185564
|
||||||
|
|
||||||
|
* Mon Apr 03 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-5
|
||||||
|
- Allow resizing of inactive LVs with latest LVM
|
||||||
|
Resolves: rhbz#2161181
|
||||||
|
- Fix test_swapon_pagesize on systems with 64k pages
|
||||||
|
Resolves: rhbz#2168220
|
||||||
|
|
||||||
* Thu Jan 05 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-4
|
* Thu Jan 05 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-4
|
||||||
- nvme: Fix namespace identifiers
|
- nvme: Fix namespace identifiers
|
||||||
Resolves: rhbz#2151535
|
Resolves: rhbz#2151535
|
||||||
|
Loading…
Reference in New Issue
Block a user