master - coverity: check for dm_snprintf
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9e3a9eab0ebf06...
Commit: 9e3a9eab0ebf06fb5ed969269e11cb9b31d033fa
Parent: a9634e993a44760e164f0ed12aaeaa6903cc9a6e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 21:03:50 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:17 2016 +0100
coverity: check for dm_snprintf
Check return state like everywhere else.
---
lib/report/report.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index ed6202c..bd7c163 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1446,7 +1446,8 @@ static int _do_get_kernel_cache_settings_list(struct dm_pool *mem,
buf_len = strlen(key) + strlen(value) + 2;
if (!(buf = dm_pool_alloc(mem, buf_len)))
return_0;
- dm_snprintf(buf, buf_len, "%s=%s", key, value);
+ if (dm_snprintf(buf, buf_len, "%s=%s", key, value) < 0)
+ return_0;
if (!str_list_add_no_dup_check(mem, result, buf))
return_0;
}
8 years, 2 months
master - coverity: check cmd pointer exists
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a9634e993a4476...
Commit: a9634e993a44760e164f0ed12aaeaa6903cc9a6e
Parent: 68955a81024d43138ee29b682d08233baf5ee876
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 21:02:36 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: check cmd pointer exists
Since in _report_init() we check few times for cmd != NULL
keep it consistent and Coverity happier.
---
tools/dmsetup.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 4db6004..b61b42f 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -4384,7 +4384,7 @@ static int _report_init(const struct command *cmd, const char *subcommand)
selection, NULL, NULL)))
goto_out;
- if ((_report_type & DR_TREE) && !_build_whole_deptree(cmd)) {
+ if ((_report_type & DR_TREE) && cmd && !_build_whole_deptree(cmd)) {
err("Internal device dependency tree creation failed.");
goto out;
}
8 years, 2 months
master - coverity: ensure non-null pointers are used
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=68955a81024d43...
Commit: 68955a81024d43138ee29b682d08233baf5ee876
Parent: 9b92cb27609ed239814d1e0d36f77d41464b23bd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 20:16:06 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: ensure non-null pointers are used
Here is too complex for Coverity to guess
those pointers cannot be NULL, but it's
very easy to add little checks here.
---
lib/activate/dev_manager.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index a1c9a23..7ad8982 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -352,7 +352,8 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
do {
next = dm_get_next_target(dmt, next, &s, &l,
&target_type, ¶ms);
- if ((s == start) && (l == length)) {
+ if ((s == start) && (l == length) &&
+ target_type && params) {
if (strcmp(target_type, "mirror"))
goto_out;
8 years, 2 months
master - coverity: drop unused assignments
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9b92cb27609ed2...
Commit: 9b92cb27609ed239814d1e0d36f77d41464b23bd
Parent: eaaae185b7870372298502d076defab2c3486ed3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 19:57:56 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: drop unused assignments
---
tools/lvrename.c | 4 ++--
tools/lvresize.c | 6 ++++--
tools/vgrename.c | 3 +--
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/lvrename.c b/tools/lvrename.c
index 1f6e829..e37d8aa 100644
--- a/tools/lvrename.c
+++ b/tools/lvrename.c
@@ -81,7 +81,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
char *lv_name_old, *lv_name_new;
const char *vg_name, *vg_name_new, *vg_name_old;
char *st;
- int ret = ECMD_FAILED;
+ int ret;
if (argc == 3) {
vg_name = skip_dev_dir(cmd, argv[0], NULL);
@@ -169,6 +169,6 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
_lvrename_single);
destroy_processing_handle(cmd, handle);
- return ret;
+ return ret;
}
diff --git a/tools/lvresize.c b/tools/lvresize.c
index af6ce07..2c2df36 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -199,10 +199,12 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle;
struct lvresize_params lp = { 0 };
- int ret = ECMD_FAILED;
+ int ret;
- if (!_lvresize_params(cmd, argc, argv, &lp))
+ if (!_lvresize_params(cmd, argc, argv, &lp)) {
+ stack;
return EINVALID_CMD_LINE;
+ }
if (!(handle = init_processing_handle(cmd))) {
log_error("Failed to initialize processing handle.");
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 633999e..e5af820 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -38,7 +38,6 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct processing_handle *handle)
{
struct vgrename_params *vp = (struct vgrename_params *) handle->custom_handle;
- struct lvmcache_vginfo *vginfo;
char old_path[NAME_LEN];
char new_path[NAME_LEN];
struct id id;
@@ -72,7 +71,7 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
*/
lvmcache_seed_infos_from_lvmetad(cmd);
- if ((vginfo = lvmcache_vginfo_from_vgname(vp->vg_name_new, NULL))) {
+ if (lvmcache_vginfo_from_vgname(vp->vg_name_new, NULL)) {
log_error("New VG name \"%s\" already exists", vp->vg_name_new);
return ECMD_FAILED;
}
8 years, 2 months
master - coverity: check for zero length buffer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eaaae185b78703...
Commit: eaaae185b7870372298502d076defab2c3486ed3
Parent: b08eb91df132e84fa41b4cf06707629b2c5c895e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 19:54:19 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: check for zero length buffer
When get_shared_library_path() would got zero length buffer,
it could have underflow in size calc later.
So just put extra small check for this case.
---
lib/misc/sharedlib.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lib/misc/sharedlib.c b/lib/misc/sharedlib.c
index 28b8aae..db1ba43 100644
--- a/lib/misc/sharedlib.c
+++ b/lib/misc/sharedlib.c
@@ -27,10 +27,13 @@ void get_shared_library_path(struct cmd_context *cmd, const char *libname,
{
struct stat info;
+ if (!path_len)
+ return;
+
/* If libname doesn't begin with '/' then use lib_dir/libname,
* if present */
if (libname[0] == '/' ||
- (!cmd->lib_dir &&
+ (!cmd->lib_dir &&
!(cmd->lib_dir = find_config_tree_str(cmd, global_library_dir_CFG, NULL))) ||
(dm_snprintf(path, path_len, "%s/%s", cmd->lib_dir,
libname) == -1) || stat(path, &info) == -1) {
8 years, 2 months
master - coverity: check for info pointer existance
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b08eb91df132e8...
Commit: b08eb91df132e84fa41b4cf06707629b2c5c895e
Parent: 2e168a52b07bb9dc659bdcda80fc77031edebbd6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 19:48:01 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:16 2016 +0100
coverity: check for info pointer existance
Since we already check in few other places 'info' is not NULL,
do the same for others - however when info would be NULL
it more or less looks like internal error.
---
lib/cache/lvmetad.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index b68e6c9..a483e04 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -1062,14 +1062,16 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
return_0;
}
+ /* TODO: resolve what does it actually mean 'info == NULL'
+ * missing info is likely an INTERNAL_ERROR */
if (!config_make_nodes(pvmeta, pvmeta->root, NULL,
"device = %"PRId64, (int64_t) dev->dev,
"dev_size = %"PRId64, (int64_t) (info ? lvmcache_device_size(info) : 0),
"format = %s", fmt->name,
"label_sector = %"PRId64, (int64_t) label_sector,
"id = %s", uuid,
- "ext_version = %"PRId64, (int64_t) lvmcache_ext_version(info),
- "ext_flags = %"PRId64, (int64_t) lvmcache_ext_flags(info),
+ "ext_version = %"PRId64, (int64_t) (info ? lvmcache_ext_version(info) : 0),
+ "ext_flags = %"PRId64, (int64_t) (info ? lvmcache_ext_flags(info) : 0),
NULL))
{
dm_config_destroy(pvmeta);
8 years, 2 months
master - coverity: drop unneeded header
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2e168a52b07bb9...
Commit: 2e168a52b07bb9dc659bdcda80fc77031edebbd6
Parent: 6d6e063a0fd132c49490f01949dfa5fa28125a33
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 19:47:35 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:40:12 2016 +0100
coverity: drop unneeded header
---
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index ba4044f..25d1063 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -15,7 +15,6 @@
#include "lib.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
-#include "defaults.h"
/* FIXME Reformat to 80 char lines. */
8 years, 2 months
master - libdm: fix string boundary
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d6e063a0fd132...
Commit: 6d6e063a0fd132c49490f01949dfa5fa28125a33
Parent: eccc91f9b0ef7387f46cdd93e3f44ab45e0c1ba3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 23 20:17:41 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 23 21:38:52 2016 +0100
libdm: fix string boundary
The test for string 'end' needs to account for ending \0,
which also needs to fit <SIZE.
---
WHATS_NEW_DM | 1 +
libdm/libdm-report.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3dbbfae..14793b3 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.118 -
=====================================
+ Fix string boundary check in _get_canonical_field_name().
Always initialized hist struct in _stats_parse_histogram().
Version 1.02.117 - 21st February 2016
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 55b5ff0..0163910 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -839,8 +839,9 @@ static int _get_canonical_field_name(const char *field,
diff = 1;
continue;
}
- if (i >= fcanonical_len) {
- log_error("%s: field name too long", field);
+ if ((i + 1) >= fcanonical_len) {
+ canonical_field[0] = '\0';
+ log_error("%s: field name too long.", field);
return 0;
}
canonical_field[i++] = *field;
8 years, 2 months
master - lvmlockd: set default result value
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=eccc91f9b0ef73...
Commit: eccc91f9b0ef7387f46cdd93e3f44ab45e0c1ba3
Parent: 0236a34224d31a6ad7b48e451183672e907b15d3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 23 14:35:40 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 23 14:35:40 2016 -0600
lvmlockd: set default result value
The default error value should be set indicating
an error.
---
lib/locking/lvmlockd.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index a33544c..e78e2cb 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -142,6 +142,8 @@ static int _lockd_result(daemon_reply reply, int *result, uint32_t *lockd_flags)
const char *flags_str = NULL;
const char *lock_type = NULL;
+ *result = -1;
+
if (reply.error) {
log_error("lockd_result reply error %d", reply.error);
return 0;
8 years, 2 months
master - tests: updates for check_lvmlockd
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0236a34224d31a...
Commit: 0236a34224d31a6ad7b48e451183672e907b15d3
Parent: 42da7a6c38ece2a9dca6492af1ba66ebaa9b6231
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 23 13:58:22 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 23 14:00:28 2016 -0600
tests: updates for check_lvmlockd
Move the lvmlockd-related setup functions into aux.
For check_lvmlockd_test, start a new instance of
lvmlockd --test for each shell test.
---
test/Makefile.in | 2 +-
test/lib/aux.sh | 137 +++++++++++++++++++++++++++++
test/lib/inittest.sh | 9 ++
test/shell/aa-lvmlockd-dlm-prepare.sh | 73 +---------------
test/shell/aa-lvmlockd-sanlock-prepare.sh | 45 +---------
test/shell/aa-lvmlockd-test-prepare.sh | 44 ---------
test/shell/dlm-hello-world.sh | 27 ------
test/shell/lvmlockd-hello-world.sh | 25 +++++
test/shell/sanlock-hello-world.sh | 27 ------
test/shell/zz-lvmlockd-test-remove.sh | 23 -----
10 files changed, 176 insertions(+), 236 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index 19a0214..6ed9b9e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -161,7 +161,7 @@ ifeq ("@BUILD_LVMLOCKD@", "yes")
check_lvmlockd_test: .tests-stamp
VERBOSE=$(VERBOSE) ./lib/runner \
--testdir . --outdir results \
- --flavours udev-lvmlockd-test --only shell/aa-lvmlockd-test-prepare.sh,$(T),shell/zz-lvmlockd-test-remove.sh --skip $(S)
+ --flavours udev-lvmlockd-test --only $(T) --skip $(S)
endif
DATADIR = $(datadir)/lvm2-testsuite
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 12316aa..cfd3620 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -21,6 +21,133 @@ expect_failure() {
echo "TEST EXPECT FAILURE"
}
+COROSYNC_CONF="/etc/corosync/corosync.conf"
+COROSYNC_NODE="$(hostname)"
+create_corosync_conf() {
+ if test -a $COROSYNC_CONF; then
+ if ! grep "created by lvm test suite" $COROSYNC_CONF; then
+ rm $COROSYNC_CONF
+ else
+ mv $COROSYNC_CONF $COROSYNC_CONF.prelvmtest
+ fi
+ fi
+
+ sed -e "s/@LOCAL_NODE@/$COROSYNC_NODE/" lib/test-corosync-conf > $COROSYNC_CONF
+ echo "created new $COROSYNC_CONF"
+}
+
+DLM_CONF="/etc/dlm/dlm.conf"
+create_dlm_conf() {
+ if test -a $DLM_CONF; then
+ if ! grep "created by lvm test suite" $DLM_CONF; then
+ rm $DLM_CONF
+ else
+ mv $DLM_CONF $DLM_CONF.prelvmtest
+ fi
+ fi
+
+ cp lib/test-dlm-conf $DLM_CONF
+ echo "created new $DLM_CONF"
+}
+
+prepare_dlm() {
+ if pgrep dlm_controld ; then
+ echo "Cannot run while existing dlm_controld process exists"
+ exit 1
+ fi
+
+ if pgrep corosync; then
+ echo "Cannot run while existing corosync process exists"
+ exit 1
+ fi
+
+ create_corosync_conf
+ create_dlm_conf
+
+ systemctl start corosync
+ sleep 1
+ if ! pgrep corosync; then
+ echo "Failed to start corosync"
+ exit 1
+ fi
+
+ systemctl start dlm
+ sleep 1
+ if ! pgrep dlm_controld; then
+ echo "Failed to start dlm"
+ exit 1
+ fi
+}
+
+SANLOCK_CONF="/etc/sanlock/sanlock.conf"
+create_sanlock_conf() {
+ if test -a $SANLOCK_CONF; then
+ if ! grep "created by lvm test suite" $SANLOCK_CONF; then
+ rm $SANLOCK_CONF
+ else
+ mv $SANLOCK_CONF $SANLOCK_CONF.prelvmtest
+ fi
+ fi
+
+ cp lib/test-sanlock-conf $SANLOCK_CONF
+ echo "created new $SANLOCK_CONF"
+}
+
+prepare_sanlock() {
+ if pgrep sanlock ; then
+ echo "Cannot run while existing sanlock process exists"
+ exit 1
+ fi
+
+ create_sanlock_conf
+
+ systemctl start sanlock
+ if ! pgrep sanlock; then
+ echo "Failed to start sanlock"
+ exit 1
+ fi
+}
+
+# FIXME: add option to allow --test with sanlock
+LVM_TEST_LVMLOCKD_TEST_DLM=1
+
+prepare_lvmlockd() {
+ if pgrep lvmlockd ; then
+ echo "Cannot run while existing lvmlockd process exists"
+ exit 1
+ fi
+
+ if test -n "$LVM_TEST_LOCK_TYPE_SANLOCK"; then
+ # make check_lvmlockd_sanlock
+ echo "starting lvmlockd for sanlock"
+ lvmlockd -o 2
+
+ elif test -n "$LVM_TEST_LOCK_TYPE_DLM"; then
+ # make check_lvmlockd_dlm
+ echo "starting lvmlockd for dlm"
+ lvmlockd
+
+ elif test -n "$LVM_TEST_LVMLOCKD_TEST_DLM"; then
+ # make check_lvmlockd_test
+ echo "starting lvmlockd --test (dlm)"
+ lvmlockd --test -g dlm
+
+ elif test -n "$LVM_TEST_LVMLOCKD_TEST_SANLOCK"; then
+ # FIXME: add option for this combination of --test and sanlock
+ echo "starting lvmlockd --test (sanlock)"
+ lvmlockd --test -g sanlock -o 2
+ else
+ echo "not starting lvmlockd"
+ exit 0
+ fi
+
+ sleep 1
+ if ! pgrep lvmlockd; then
+ echo "Failed to start lvmlockd"
+ exit 1
+ fi
+}
+
prepare_clvmd() {
rm -f debug.log strace.log
test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed
@@ -317,6 +444,16 @@ teardown() {
kill_tagged_processes
+ if test -n "$LVM_TEST_LVMLOCKD_TEST" ; then
+ echo ""
+ echo "stopping lvmlockd in teardown"
+ killall lvmlockd
+ sleep 1
+ killall lvmlockd || true
+ sleep 1
+ killall -9 lvmlockd || true
+ fi
+
kill_sleep_kill_ LOCAL_LVMETAD ${LVM_VALGRIND_LVMETAD:-0}
dm_table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || {
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 4531e66..a2dcf01 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -128,9 +128,18 @@ if test -n "$LVM_TEST_LVMLOCKD" ; then
if test -n "$LVM_TEST_LOCK_TYPE_SANLOCK" ; then
aux lvmconf 'local/host_id = 1'
fi
+
export SHARED="--shared"
fi
+# for check_lvmlockd_test, lvmlockd is restarted for each shell test.
+# for check_lvmlockd_{sanlock,dlm}, lvmlockd is started once by
+# aa-lvmlockd-{sanlock,dlm}-prepare.sh and left running for all shell tests.
+
+if test -n "$LVM_TEST_LVMLOCKD_TEST" ; then
+ aux prepare_lvmlockd
+fi
+
echo "<======== Processing test: \"$TESTNAME\" ========>"
set -vx
diff --git a/test/shell/aa-lvmlockd-dlm-prepare.sh b/test/shell/aa-lvmlockd-dlm-prepare.sh
index e1e1a73..bc30bb7 100644
--- a/test/shell/aa-lvmlockd-dlm-prepare.sh
+++ b/test/shell/aa-lvmlockd-dlm-prepare.sh
@@ -16,75 +16,6 @@ test_description='Set up things to run tests with dlm'
[ -z "$LVM_TEST_LOCK_TYPE_DLM" ] && skip;
-COROSYNC_CONF="/etc/corosync/corosync.conf"
-COROSYNC_NODE="$(hostname)"
-create_corosync_conf() {
- if test -a $COROSYNC_CONF; then
- if ! grep "created by lvm test suite" $COROSYNC_CONF; then
- rm $COROSYNC_CONF
- else
- mv $COROSYNC_CONF $COROSYNC_CONF.prelvmtest
- fi
- fi
-
- sed -e "s/@LOCAL_NODE@/$COROSYNC_NODE/" lib/test-corosync-conf > $COROSYNC_CONF
- echo "created new $COROSYNC_CONF"
-}
-
-DLM_CONF="/etc/dlm/dlm.conf"
-create_dlm_conf() {
- if test -a $DLM_CONF; then
- if ! grep "created by lvm test suite" $DLM_CONF; then
- rm $DLM_CONF
- else
- mv $DLM_CONF $DLM_CONF.prelvmtest
- fi
- fi
-
- cp lib/test-dlm-conf $DLM_CONF
- echo "created new $DLM_CONF"
-}
-
-prepare_lvmlockd_dlm() {
- if pgrep lvmlockd ; then
- echo "Cannot run while existing lvmlockd process exists"
- exit 1
- fi
-
- if pgrep dlm_controld ; then
- echo "Cannot run while existing dlm_controld process exists"
- exit 1
- fi
-
- if pgrep corosync; then
- echo "Cannot run while existing corosync process exists"
- exit 1
- fi
-
- create_corosync_conf
- create_dlm_conf
-
- systemctl start corosync
- sleep 1
- if ! pgrep corosync; then
- echo "Failed to start corosync"
- exit 1
- fi
-
- systemctl start dlm
- sleep 1
- if ! pgrep dlm_controld; then
- echo "Failed to start dlm"
- exit 1
- fi
-
- lvmlockd
- sleep 1
- if ! pgrep lvmlockd ; then
- echo "Failed to start lvmlockd"
- exit 1
- fi
-}
-
-prepare_lvmlockd_dlm
+aux prepare_dlm
+aux prepare_lvmlockd
diff --git a/test/shell/aa-lvmlockd-sanlock-prepare.sh b/test/shell/aa-lvmlockd-sanlock-prepare.sh
index 22127ad..75b94e7 100644
--- a/test/shell/aa-lvmlockd-sanlock-prepare.sh
+++ b/test/shell/aa-lvmlockd-sanlock-prepare.sh
@@ -16,48 +16,6 @@ test_description='Set up things to run tests with sanlock'
[ -z "$LVM_TEST_LOCK_TYPE_SANLOCK" ] && skip;
-SANLOCK_CONF="/etc/sanlock/sanlock.conf"
-create_sanlock_conf() {
- if test -a $SANLOCK_CONF; then
- if ! grep "created by lvm test suite" $SANLOCK_CONF; then
- rm $SANLOCK_CONF
- else
- mv $SANLOCK_CONF $SANLOCK_CONF.prelvmtest
- fi
- fi
-
- cp lib/test-sanlock-conf $SANLOCK_CONF
- echo "created new $SANLOCK_CONF"
-}
-
-prepare_lvmlockd_sanlock() {
- if pgrep lvmlockd ; then
- echo "Cannot run while existing lvmlockd process exists"
- exit 1
- fi
-
- if pgrep sanlock ; then
- echo "Cannot run while existing sanlock process exists"
- exit 1
- fi
-
- create_sanlock_conf
-
- systemctl start sanlock
- if ! pgrep sanlock; then
- echo "Failed to start sanlock"
- exit 1
- fi
-
- # FIXME: use 'systemctl start lvm2-lvmlockd' once we can pass -o 2
- lvmlockd -o 2
- sleep 1
- if ! pgrep lvmlockd; then
- echo "Failed to start lvmlockd"
- exit 1
- fi
-}
-
# Create a device and a VG that are both outside the scope of
# the standard lvm test suite so that they will not be removed
# and will remain in place while all the tests are run.
@@ -77,7 +35,8 @@ dd if=/dev/zero of="$GL_FILE" bs=$((1024*1024)) count=1024 2> /dev/null
GL_LOOP=$(losetup -f "$GL_FILE" --show)
echo "0 `blockdev --getsize $GL_LOOP` linear $GL_LOOP 0" | dmsetup create GL_DEV
-prepare_lvmlockd_sanlock
+aux prepare_sanlock
+aux prepare_lvmlockd
vgcreate --config 'devices { global_filter=["a|GL_DEV|", "r|.*|"] filter=["a|GL_DEV|", "r|.*|"]}' --lock-type sanlock glvg $GL_DEV
diff --git a/test/shell/aa-lvmlockd-test-prepare.sh b/test/shell/aa-lvmlockd-test-prepare.sh
deleted file mode 100644
index 99ec86f..0000000
--- a/test/shell/aa-lvmlockd-test-prepare.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-test_description='Set up things to run tests with lvmlockd'
-
-. lib/utils
-. lib/inittest
-
-[ -z "$LVM_TEST_LVMLOCKD_TEST" ] && skip;
-
-# TODO: allow this to be configured sanlock/dlm
-LVM_TEST_LVMLOCKD_TEST_DLM=1
-
-prepare_lvmlockd_test() {
- if pgrep lvmlockd ; then
- echo "Cannot run while existing lvmlockd process exists"
- exit 1
- fi
-
- if test -n "$LVM_TEST_LVMLOCKD_TEST_SANLOCK"; then
- lvmlockd --test -g sanlock
- fi
-
- if test -n "$LVM_TEST_LVMLOCKD_TEST_DLM"; then
- lvmlockd --test -g dlm
- fi
-
- sleep 1
- if ! pgrep lvmlockd ; then
- echo "Failed to start lvmlockd"
- exit 1
- fi
-}
-
-prepare_lvmlockd_test
-
diff --git a/test/shell/dlm-hello-world.sh b/test/shell/dlm-hello-world.sh
deleted file mode 100644
index 9ee3b14..0000000
--- a/test/shell/dlm-hello-world.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-test_description='Hello world for vgcreate with lvmlockd and dlm'
-
-. lib/inittest
-
-[ -z "$LVM_TEST_LOCK_TYPE_DLM" ] && skip;
-
-aux prepare_devs 1
-
-vgcreate $SHARED $vg "$dev1"
-
-vgs -o+locktype,lockargs $vg
-
-check vg_field $vg vg_locktype dlm
-
-vgremove $vg
-
diff --git a/test/shell/lvmlockd-hello-world.sh b/test/shell/lvmlockd-hello-world.sh
new file mode 100644
index 0000000..01e1c56
--- /dev/null
+++ b/test/shell/lvmlockd-hello-world.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+test_description='Hello world for vgcreate with lvmlockd and sanlock'
+
+. lib/inittest
+
+[ -z "$LVM_TEST_LVMLOCKD" ] && skip;
+
+aux prepare_pvs 1
+
+vgcreate $SHARED $vg "$dev1"
+
+vgs -o+locktype,lockargs $vg
+
+vgremove $vg
+
diff --git a/test/shell/sanlock-hello-world.sh b/test/shell/sanlock-hello-world.sh
deleted file mode 100644
index fb95faa..0000000
--- a/test/shell/sanlock-hello-world.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-test_description='Hello world for vgcreate with lvmlockd and sanlock'
-
-. lib/inittest
-
-[ -z "$LVM_TEST_LOCK_TYPE_SANLOCK" ] && skip;
-
-aux prepare_pvs 1
-
-vgcreate $SHARED $vg "$dev1"
-
-vgs -o+locktype,lockargs $vg
-
-check vg_field $vg vg_locktype sanlock
-
-vgremove $vg
-
diff --git a/test/shell/zz-lvmlockd-test-remove.sh b/test/shell/zz-lvmlockd-test-remove.sh
deleted file mode 100644
index 44749f0..0000000
--- a/test/shell/zz-lvmlockd-test-remove.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-test_description='Remove the dlm test setup'
-
-. lib/inittest
-
-[ -z "$LVM_TEST_LVMLOCKD_TEST" ] && skip;
-
-killall lvmlockd
-sleep 1
-killall lvmlockd || true
-sleep 1
-killall -9 lvmlockd || true
-
8 years, 2 months