main - lvmlockd: clean up get_local_nodeid
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=da44f2b6fe1e0edbd3e...
Commit: da44f2b6fe1e0edbd3ee875c831f3e467f242bc0
Parent: cd14d3fcc0e03136d0cea1ab1a9edff3b8b9dbeb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 8 11:11:32 2023 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 8 11:11:32 2023 -0600
lvmlockd: clean up get_local_nodeid
Hard to see if fclose calls were correct, and coverity couldn't figure
it out either, so make it clear.
---
daemons/lvmlockd/lvmlockd-dlm.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c
index 248081d0e..ce9d9acf2 100644
--- a/daemons/lvmlockd/lvmlockd-dlm.c
+++ b/daemons/lvmlockd/lvmlockd-dlm.c
@@ -227,8 +227,9 @@ static int get_local_nodeid(void)
struct dirent *de;
DIR *ls_dir;
char ls_comms_path[PATH_MAX];
- FILE *file = NULL;
+ FILE *file;
char line[LOCK_LINE_MAX];
+ char *str1, *str2;
int rv = -1, val;
memset(ls_comms_path, 0, sizeof(ls_comms_path));
@@ -243,30 +244,33 @@ static int get_local_nodeid(void)
memset(ls_comms_path, 0, sizeof(ls_comms_path));
snprintf(ls_comms_path, PATH_MAX, "%s/%s/local",
DLM_COMMS_PATH, de->d_name);
- file = fopen(ls_comms_path, "r");
- if (!file)
+
+ if (!(file = fopen(ls_comms_path, "r")))
continue;
- if (fgets(line, LOCK_LINE_MAX, file)) {
- fclose(file);
+ str1 = fgets(line, LOCK_LINE_MAX, file);
+ fclose(file);
+
+ if (str1) {
rv = sscanf(line, "%d", &val);
if ((rv == 1) && (val == 1 )) {
memset(ls_comms_path, 0, sizeof(ls_comms_path));
snprintf(ls_comms_path, PATH_MAX, "%s/%s/nodeid",
DLM_COMMS_PATH, de->d_name);
- file = fopen(ls_comms_path, "r");
- if (!file)
+
+ if (!(file = fopen(ls_comms_path, "r")))
continue;
- if (fgets(line, LOCK_LINE_MAX, file)) {
+ str2 = fgets(line, LOCK_LINE_MAX, file);
+ fclose(file);
+
+ if (str2) {
rv = sscanf(line, "%d", &val);
if (rv == 1) {
- fclose(file);
closedir(ls_dir);
return val;
}
}
}
}
- fclose(file);
}
if (closedir(ls_dir))
1 year, 1 month
main - toollib: fix segfault if using -S|--select with log/report_command_log=1 setting
by Peter Rajnoha
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cd14d3fcc0e03136d0c...
Commit: cd14d3fcc0e03136d0cea1ab1a9edff3b8b9dbeb
Parent: c8f2125b85afe043af1b2e887a80f882b8d8d7c7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 7 14:45:06 2023 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Mar 7 15:29:54 2023 +0100
toollib: fix segfault if using -S|--select with log/report_command_log=1 setting
When we are using -S|--select for non-reporting tools while using command log
reporting (log/report_command_log=1 setting), we need to create an internal
processing handle to handle the selection itself. In this case, the internal
processing handle to execute the selection (to process the -S|--select) has
a parent handle (that is processing the actual non-reporting command).
When this parent handle exists, we can't destroy the command log report
in destroy_processing_handle as there's still the parent processing to
finish. The parent processing may still generate logs which need to be
reported in the command log report. If the command log report was
destroyed prematurely together with destroying the internal processing
handle for -S|--select, then any subsequent log request from processing
the actual command (and hence an attermpt to access the command log report)
ended up with a segfault.
See also: https://bugzilla.redhat.com/show_bug.cgi?id=2175220
---
WHATS_NEW | 1 +
tools/toollib.c | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8523b5eb7..7c979d69c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
version 2.03.20 -
====================================
+ Fix segfault if using -S|--select with log/report_command_log=1 setting.
Configure now fails when requested lvmlockd dependencies are missing.
Add some configure Gentoo enhancements for static builds.
diff --git a/tools/toollib.c b/tools/toollib.c
index 194088ea6..43e628abf 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2050,7 +2050,20 @@ void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle
log_restore_report_state(cmd->cmd_report.saved_log_report_state);
- if (!cmd->is_interactive) {
+ /*
+ * Do not destroy current cmd->report_group and cmd->log_rh
+ * (the log report) yet if we're running interactively
+ * (== running in lvm shell) or if there's a parent handle
+ * (== we're executing nested processing, like it is when
+ * doing selection for parent's process_each_* processing).
+ *
+ * In both cases, there's still possible further processing
+ * to do outside the processing covered by the handle we are
+ * destroying here and for which we may still need to access
+ * the log report to cover the rest of the processing.
+ *
+ */
+ if (!cmd->is_interactive && !handle->parent) {
if (!dm_report_group_destroy(cmd->cmd_report.report_group))
stack;
cmd->cmd_report.report_group = NULL;
1 year, 1 month
main - lvmdbusd: Add needed env. variables
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c8f2125b85afe043af1...
Commit: c8f2125b85afe043af1b2e887a80f882b8d8d7c7
Parent: df6120e9f715c58327451f650c003d09842f33c7
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Mar 6 10:26:44 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Mar 6 10:26:44 2023 -0600
lvmdbusd: Add needed env. variables
When running lvmdb.py by itself for testing we need these.
---
daemons/lvmdbusd/lvmdb.py.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/daemons/lvmdbusd/lvmdb.py.in b/daemons/lvmdbusd/lvmdb.py.in
index 41fedb80f..e6bec926a 100644
--- a/daemons/lvmdbusd/lvmdb.py.in
+++ b/daemons/lvmdbusd/lvmdb.py.in
@@ -437,6 +437,8 @@ class DataStore(object):
if __name__ == "__main__":
+ os.environ["LC_ALL"] = "C"
+ os.environ["LVM_COMMAND_PROFILE"] = "lvmdbusd"
pp = prettyprint.PrettyPrinter(indent=4)
ds = DataStore()
1 year, 1 month
main - lvmdbusd: Move cfg.lvmdebug data init
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=df6120e9f715c583274...
Commit: df6120e9f715c58327451f650c003d09842f33c7
Parent: 8e27dfd40576f4e2828b169bfe18d8cae9968244
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Mar 6 10:25:22 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Mar 6 10:25:22 2023 -0600
lvmdbusd: Move cfg.lvmdebug data init
Move this to the cfg file itself, so that initialization runs when it
gets processed.
---
daemons/lvmdbusd/cfg.py | 8 +++++---
daemons/lvmdbusd/main.py | 5 -----
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/daemons/lvmdbusd/cfg.py b/daemons/lvmdbusd/cfg.py
index 3ee852855..9da4b1267 100644
--- a/daemons/lvmdbusd/cfg.py
+++ b/daemons/lvmdbusd/cfg.py
@@ -11,6 +11,7 @@ import os
import multiprocessing
import queue
import itertools
+from utils import LvmDebugData
from lvmdbusd import path
@@ -18,6 +19,10 @@ LVM_CMD = os.getenv('LVM_BINARY', path.LVM_BINARY)
LOCK_FILE = os.getenv("LVM_DBUSD_LOCKFILE", "/var/lock/lvm/lvmdbusd")
+# Save off the debug data needed for lvm team to debug issues
+# only used for 'fullreport' at this time.
+lvmdebug = LvmDebugData(os.getenv('LVM_DBUSD_COLLECT_LVM_DEBUG', False))
+
# This is the global object manager
om = None
@@ -114,7 +119,4 @@ def exit_daemon():
loop.quit()
-# Debug data for lvm
-lvmdebug = None
-
systemd = False
diff --git a/daemons/lvmdbusd/main.py b/daemons/lvmdbusd/main.py
index e8bd3ce0e..e07710a5e 100644
--- a/daemons/lvmdbusd/main.py
+++ b/daemons/lvmdbusd/main.py
@@ -148,17 +148,12 @@ def running_under_systemd():
def main():
start = time.time()
use_session = os.getenv('LVM_DBUSD_USE_SESSION', False)
- collect_lvm_debug = os.getenv('LVM_DBUSD_COLLECT_LVM_DEBUG', False)
# Ensure that we get consistent output for parsing stdout/stderr and that we
# are using the lvmdbusd profile.
os.environ["LC_ALL"] = "C"
os.environ["LVM_COMMAND_PROFILE"] = "lvmdbusd"
- # Save off the debug data needed for lvm team to debug issues
- # only used for 'fullreport' at this time.
- cfg.lvmdebug = utils.LvmDebugData(collect_lvm_debug)
-
# Indicator if we are running under systemd
cfg.systemd = running_under_systemd()
1 year, 1 month
main - lvmdbustest: Test duplicate VG rename
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8e27dfd40576f4e2828...
Commit: 8e27dfd40576f4e2828b169bfe18d8cae9968244
Parent: 3e616230f2627d31599d1f4a2c7ff29b5ba86703
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Fri Mar 3 11:17:30 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Mar 3 11:17:30 2023 -0600
lvmdbustest: Test duplicate VG rename
---
daemons/lvmdbusd/cmdhandler.py | 6 ++++--
test/dbus/lvmdbustest.py | 43 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index ea7e300cf..8bc741dc6 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -324,10 +324,12 @@ def vg_rename(vg_uuid, new_name, rename_options):
return call(cmd)
-def vg_remove(vg_name, remove_options):
+def vg_remove(vg_id, remove_options):
cmd = ['vgremove']
cmd.extend(options_to_cli_args(remove_options))
- cmd.extend(['-f', vg_name])
+ cmd.extend(['-f', vg_id])
+ # https://bugzilla.redhat.com/show_bug.cgi?id=2175220 is preventing us from doing the following
+ # cmd.extend(['-f', "--select", "vg_uuid=%s" % vg_id])
return call(cmd)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index ab68e7e5c..b7224df96 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2507,6 +2507,49 @@ class TestDbusService(unittest.TestCase):
else:
time.sleep(0.1)
+ @staticmethod
+ def _is_vg_devices_supported():
+ rc, stdout_txt, stderr_txt = call_lvm(["vgcreate", "--help"])
+ if rc == 0:
+ for line in stdout_txt.split("\n"):
+ if "--devices " in line:
+ return True
+ return False
+
+ @staticmethod
+ def _vg_create_specify_devices(name, device):
+ cmd = [LVM_EXECUTABLE, "vgcreate", "--devices", device, name, device]
+ outcome = Popen(cmd, stdout=PIPE, stderr=PIPE, close_fds=True, env=os.environ)
+ outcome.communicate()
+ if outcome.returncode == 0:
+ return True
+ else:
+ print("Failed to create vg %s, stdout= %s, stderr= %s" % (name, outcome.stdout, outcome.stderr))
+ return False
+
+ def test_duplicate_vg_name(self):
+ # LVM allows duplicate VG names, test handling renames for now
+ if not TestDbusService._is_vg_devices_supported():
+ raise unittest.SkipTest("lvm does not support vgcreate with --device syntax")
+
+ if len(self.objs[PV_INT]) < 2:
+ raise unittest.SkipTest("we need at least 2 PVs to run test")
+
+ vg_name = vg_n()
+ if TestDbusService._vg_create_specify_devices(vg_name, self.objs[PV_INT][0].Pv.Name) and \
+ TestDbusService._vg_create_specify_devices(vg_name, self.objs[PV_INT][1].Pv.Name):
+ objects, _ = get_objects()
+ self.assertEqual(len(objects[VG_INT]), 2)
+
+ if len(objects[VG_INT]) == 2:
+ for vg in objects[VG_INT]:
+ new_name = vg_n()
+ vg.Vg.Rename(dbus.String(new_name), dbus.Int32(g_tmo), EOD)
+ # Ensure we find the renamed VG
+ self.assertNotEqual("/", self._lookup(new_name), "Expecting to find VG='%s'" % new_name)
+ else:
+ self.assertFalse(True, "We failed to create 2 VGs with same name!")
+
class AggregateResults(object):
1 year, 1 month
main - lvmdbustest: Add more info on asserts
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3e616230f2627d31599...
Commit: 3e616230f2627d31599d1f4a2c7ff29b5ba86703
Parent: 95afd315b163143296a1a42d2cad2b1cd762725d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Mar 2 11:44:16 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Mar 2 11:44:16 2023 -0600
lvmdbustest: Add more info on asserts
---
test/dbus/lvmdbustest.py | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 9a3cb175a..ab68e7e5c 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -446,7 +446,7 @@ class TestDbusService(unittest.TestCase):
self.handle_return(vg_proxy.Vg.Remove(dbus.Int32(g_tmo), EOD))
if is_nested_pv(pv_proxy.Pv.Name):
rc = self._pv_remove(pv_proxy)
- self.assertTrue(rc == '/')
+ self.assertTrue(rc == '/', "We expected a '/', but got %s when removing a PV" % str(rc))
def clean_up(self):
self.objs, self.bus = get_objects()
@@ -522,7 +522,8 @@ class TestDbusService(unittest.TestCase):
self._validate_lookup(device, pv_path)
- self.assertTrue(pv_path is not None and len(pv_path) > 0)
+ self.assertTrue(pv_path is not None and len(pv_path) > 0,
+ "When creating a PV we expected the returned path to be valid")
return pv_path
def _manager(self):
@@ -536,7 +537,7 @@ class TestDbusService(unittest.TestCase):
def test_version(self):
rc = self.objs[MANAGER_INT][0].Manager.Version
- self.assertTrue(rc is not None and len(rc) > 0)
+ self.assertTrue(rc is not None and len(rc) > 0, "Manager.Version is invalid")
self._check_consistency()
def _vg_create(self, pv_paths=None, vg_prefix=None, options=None):
@@ -557,7 +558,7 @@ class TestDbusService(unittest.TestCase):
options))
self._validate_lookup(vg_name, vg_path)
- self.assertTrue(vg_path is not None and len(vg_path) > 0)
+ self.assertTrue(vg_path is not None and len(vg_path) > 0, "During VG creation, returned path is empty")
intf = [VG_INT, ]
if self.vdo:
@@ -2427,11 +2428,11 @@ class TestDbusService(unittest.TestCase):
print("Note: Time for udev update = %f" % (time.time() - start))
if present:
rc = self._lookup(block_device)
- self.assertNotEqual(rc, '/')
+ self.assertNotEqual(rc, '/', "Daemon failed to update, missing udev change event?")
return True
else:
rc = self._lookup(block_device)
- self.assertEqual(rc, '/')
+ self.assertEqual(rc, '/', "Daemon failed to update, missing udev change event?")
return True
def test_wipefs(self):
@@ -2500,7 +2501,8 @@ class TestDbusService(unittest.TestCase):
j.update()
if j.Complete:
(ec, error_msg) = j.GetError
- self.assertTrue("insufficient free space" in error_msg, error_msg)
+ self.assertTrue("insufficient free space" in error_msg,
+ "We're expecting 'insufficient free space' in \n\"%s\"\n, stderr missing?" % error_msg)
break
else:
time.sleep(0.1)
1 year, 1 month
main - lvmdbustest: Don't hard code to /tmp
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=95afd315b163143296a...
Commit: 95afd315b163143296a1a42d2cad2b1cd762725d
Parent: 50e6efafb92367beacc0ee85afcb1279163d601d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 1 15:59:14 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Mar 1 15:59:18 2023 -0600
lvmdbustest: Don't hard code to /tmp
During lvm testing they use an alternative tmp directory.
---
test/dbus/lvmdbustest.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 8d70b4477..9a3cb175a 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2301,7 +2301,7 @@ class TestDbusService(unittest.TestCase):
self._vdo_pool_lv(), test_ss=False)
def _log_file_option(self):
- fn = "/tmp/%s" % rs(8, "_lvm.log")
+ fn = os.path.join(tempfile.gettempdir(), rs(8, "_lvm.log"))
try:
options = dbus.Dictionary({}, signature=dbus.Signature('sv'))
option_str = "log { level=7 file=%s syslog=0 }" % fn
1 year, 1 month
main - lvmdbustest: Add more output for test_log_file_option
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=50e6efafb92367beacc...
Commit: 50e6efafb92367beacc0ee85afcb1279163d601d
Parent: 80f6655956273b84ec2301dae7c6454ca62d124c
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 1 15:52:23 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Mar 1 15:52:23 2023 -0600
lvmdbustest: Add more output for test_log_file_option
---
test/dbus/lvmdbustest.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index b98332d65..8d70b4477 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2307,7 +2307,9 @@ class TestDbusService(unittest.TestCase):
option_str = "log { level=7 file=%s syslog=0 }" % fn
options["config"] = dbus.String(option_str)
self._vg_create(None, None, options)
- self.assertTrue(os.path.exists(fn))
+ self.assertTrue(os.path.exists(fn),
+ "We passed the following options %s to lvm while creating a VG and the "
+ "log file we expected to exist (%s) was not found" % (option_str, fn))
finally:
if os.path.exists(fn):
os.unlink(fn)
1 year, 1 month
main - lvmdbustest.py: Increase udev timeout
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=80f6655956273b84ec2...
Commit: 80f6655956273b84ec2301dae7c6454ca62d124c
Parent: 4cbe789f9c273cd03a3b0aff39aa43fc7674099f
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 1 15:25:00 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Mar 1 15:26:37 2023 -0600
lvmdbustest.py: Increase udev timeout
---
test/dbus/lvmdbustest.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index b1c965bb7..b98332d65 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -2410,7 +2410,8 @@ class TestDbusService(unittest.TestCase):
def _block_present_absent(self, block_device, present=False):
start = time.time()
keep_looping = True
- while keep_looping and time.time() < start + 3:
+ max_wait = 10
+ while keep_looping and time.time() < start + max_wait:
if present:
if (self._lookup(block_device) != "/"):
keep_looping = False
@@ -2419,7 +2420,7 @@ class TestDbusService(unittest.TestCase):
keep_looping = False
if keep_looping:
- print("Daemon failed to update")
+ print("Daemon failed to update within %d seconds!" % max_wait)
else:
print("Note: Time for udev update = %f" % (time.time() - start))
if present:
1 year, 1 month
main - lvmdbusd: Remove unused import
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4cbe789f9c273cd03a3...
Commit: 4cbe789f9c273cd03a3b0aff39aa43fc7674099f
Parent: b0e75bd356a070423754676872b7b6948913be2e
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Mon Feb 27 09:57:18 2023 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Mon Feb 27 09:57:18 2023 -0600
lvmdbusd: Remove unused import
---
daemons/lvmdbusd/objectmanager.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemons/lvmdbusd/objectmanager.py b/daemons/lvmdbusd/objectmanager.py
index c5ea14bc3..ed62feb42 100644
--- a/daemons/lvmdbusd/objectmanager.py
+++ b/daemons/lvmdbusd/objectmanager.py
@@ -13,7 +13,7 @@ import dbus
import os
import copy
from . import cfg
-from .utils import log_debug, pv_obj_path_generate, log_error, extract_stack_trace
+from .utils import log_debug, log_error, extract_stack_trace
from .automatedproperties import AutomatedProperties
1 year, 1 month