master - tests: minimize teardown when uneeded
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=244ca7ee775b55...
Commit: 244ca7ee775b554eb12d1897a8f90bf2d9640138
Parent: c5b4327f3d34f823ae01511ea8b7635c3637fe87
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 29 13:37:13 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 29 15:09:58 2015 +0200
tests: minimize teardown when uneeded
If test has not yet initilized any device,
make teardown a bit faster.
---
test/lib/aux.sh | 25 +++++++++++++------------
test/lib/inittest.sh | 10 +++-------
2 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 961dfcf..373909a 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -140,6 +140,8 @@ teardown_devs_prefixed() {
local IFS=$IFS_NL
local dm
+ rm -rf "$TESTDIR/dev/$prefix"*
+
# Resume suspended devices first
for dm in $(dm_info suspended,name | grep "^Suspended:.*$prefix"); do
echo "dmsetup resume \"${dm#Suspended:}\""
@@ -180,16 +182,16 @@ teardown_devs_prefixed() {
num_remaining_devs=$num_devs
done
fi
+
+ udev_wait
}
teardown_devs() {
# Delete any remaining dm/udev semaphores
teardown_udev_cookies
- test -z "$PREFIX" || {
- rm -rf "$TESTDIR/dev/$PREFIX"*
- teardown_devs_prefixed "$PREFIX"
- }
+ test ! -f MD_DEV || cleanup_md_dev
+ test ! -f DEVICES || teardown_devs_prefixed "$PREFIX"
# NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because
# prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop()
@@ -199,22 +201,21 @@ teardown_devs() {
test ! -f LOOP || losetup -d $(< LOOP) || true
test ! -f LOOPFILE || rm -f $(< LOOPFILE)
fi
- rm -f DEVICES # devs is set in prepare_devs()
+
not diff LOOP BACKING_DEV >/dev/null 2>&1 || rm -f BACKING_DEV
- rm -f LOOP
+ rm -f DEVICES LOOP
# Attempt to remove any loop devices that failed to get torn down if earlier tests aborted
test "${LVM_TEST_PARALLEL:-0}" -eq 1 -o -z "$COMMON_PREFIX" || {
- teardown_devs_prefixed "$COMMON_PREFIX" 1
local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) )
test ${#stray_loops[@]} -eq 0 || {
+ teardown_devs_prefixed "$COMMON_PREFIX" 1
echo "Removing stray loop devices containing $COMMON_PREFIX: ${stray_loops[@]}"
for i in "${stray_loops[@]}" ; do losetup -d $i ; done
+ # Leave test when udev processed all removed devices
+ udev_wait
}
}
-
- # Leave test when udev processed all removed devices
- udev_wait
}
kill_sleep_kill_() {
@@ -248,9 +249,8 @@ kill_listed_processes() {
}
teardown() {
- test -f MD_DEV && cleanup_md_dev
-
echo -n "## teardown..."
+ unset LVM_LOG_FILE_EPOCH
if test -f TESTNAME ; then
@@ -461,6 +461,7 @@ prepare_devs() {
local pvname=${3:-pv}
local shift=0
+ touch DEVICES
prepare_backing_dev $(($n*$devsize))
# shift start of PV devices on /dev/loopXX by 1M
not diff LOOP BACKING_DEV >/dev/null 2>&1 || shift=2048
diff --git a/test/lib/inittest.sh b/test/lib/inittest.sh
index 0efbf0d..96dfff2 100644
--- a/test/lib/inittest.sh
+++ b/test/lib/inittest.sh
@@ -32,7 +32,7 @@ PREFIX="${COMMON_PREFIX}$$"
if test -z "$LVM_TEST_DIR"; then LVM_TEST_DIR=$TMPDIR; fi
TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-/tmp}" "$PREFIX.XXXXXXXXXX") || \
die "failed to create temporary directory in ${LVM_TEST_DIR:-$TESTOLDPWD}"
-RUNNING_DMEVENTD=$(pgrep dmeventd) || true
+RUNNING_DMEVENTD=$(pgrep dmeventd || true)
export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD
export LVM_LOG_FILE_EPOCH=DEBUG
@@ -62,7 +62,7 @@ mkdir "$LVM_SYSTEM_DIR" "$DM_DEV_DIR"
if test -n "$LVM_TEST_DEVDIR" ; then
DM_DEV_DIR=$LVM_TEST_DEVDIR
else
- mknod "$DM_DEV_DIR/testnull" c 1 3 || die "mknod failed";
+ mknod "$DM_DEV_DIR/testnull" c 1 3 || die "mknod failed"
echo >"$DM_DEV_DIR/testnull" || \
die "Filesystem does support devices in $DM_DEV_DIR (mounted with nodev?)"
mkdir "$DM_DEV_DIR/mapper"
@@ -77,11 +77,7 @@ echo "$TESTNAME" >TESTNAME
echo "Kernel is $(uname -a)"
# Report SELinux mode
-if which getenforce &>/dev/null ; then
- echo "Selinux mode is \"$(getenforce 2>/dev/null)\"."
-else
- echo "Selinux mode is not installed."
-fi
+echo "Selinux mode is $(getenforce 2>/dev/null || echo not installed)."
# Set vars from utils now that we have TESTDIR/PREFIX/...
prepare_test_vars
8 years, 11 months
master - tests: bash-fu for lvmconf
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c5b4327f3d34f8...
Commit: c5b4327f3d34f823ae01511ea8b7635c3637fe87
Parent: 923902013c6d47f02abe2d6171bdeed9f16f413c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 29 12:26:12 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 29 15:09:58 2015 +0200
tests: bash-fu for lvmconf
Sqeeze about 0.1s out of every created conf and use internal
bash associative arrays instead of lot of command forking
---
test/lib/aux.sh | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 24be323..961dfcf 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -785,16 +785,29 @@ EOF
echo "$v"
done >> "$config_values"
- local s
- for s in $(cut -f1 -d/ "$config_values" | sort | uniq); do
- echo "$s {"
- local k
- for k in $(grep ^"$s"/ "$config_values" | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do
- grep "^$k" "$config_values" | tail -n 1 | sed -e "s,^$s/, ,"
- done
- echo "}"
- echo
- done | tee "$config" | sed -e "s,^,## LVMCONF: ,"
+ declare -A CONF
+ local sec
+ local last_sec
+
+ # read sequential list and put into associative array
+ while IFS=$IFS_NL read -r v; do
+ # trim white-space-chars via echo when inserting
+ CONF[$(echo ${v%%=*})]=${v##*=}
+ done < "$config_values"
+
+ # sort by section and iterate through them
+ printf "%s\n" ${!CONF[@]} | sort | while read -r v ; do
+ sec=${v%%/*} # split on section'/'param_name
+ test "$sec" = "$last_sec" || {
+ test -z "$last_sec" || echo "}"
+ echo "$sec {"
+ last_sec=$sec
+ }
+ echo " ${v#*/} =${CONF[$v]}"
+ done > "$config"
+ echo "}" >> "$config"
+
+ sed -e "s,^,## LVMCONF: ," "$config"
}
lvmconf() {
8 years, 11 months
master - lvmetad: drop unused vars
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=923902013c6d47...
Commit: 923902013c6d47f02abe2d6171bdeed9f16f413c
Parent: 5d8b31ffad4fb6e3f1e9a4f20387cd7f1e141085
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 29 15:00:33 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 29 15:09:58 2015 +0200
lvmetad: drop unused vars
Squash some unused vars introduced in some previous commit.s
---
daemons/lvmetad/lvmetad-core.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index e3394ab..398ef38 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -809,8 +809,7 @@ static response pv_gone(lvmetad_state *s, request r)
int64_t device = daemon_request_int(r, "device", 0);
int64_t alt_device = 0;
struct dm_config_tree *pvmeta;
- struct dm_config_node *pvmeta_tmp;
- char *pvid_old, *vgid;
+ char *vgid;
DEBUGLOG(s, "pv_gone: %s / %" PRIu64, pvid, device);
@@ -825,7 +824,6 @@ static response pv_gone(lvmetad_state *s, request r)
DEBUGLOG(s, "pv_gone (updated): %s / %" PRIu64, pvid, device);
pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
- pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
vgid = dm_hash_lookup(s->pvid_to_vgid, pvid);
dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
8 years, 11 months
master - python: python 3 compat patch for lvm2
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5d8b31ffad4fb6...
Commit: 5d8b31ffad4fb6e3f1e9a4f20387cd7f1e141085
Parent: 4946c64092a04d6a5a7a09a31f7c74c193d3484f
Author: bkabrda(a)redhat.com <bkabrda(a)redhat.com>
AuthorDate: Tue Sep 2 15:42:01 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 29 15:09:56 2015 +0200
python: python 3 compat patch for lvm2
As provided by rhbz: 1136366
---
WHATS_NEW | 1 +
python/example.py | 18 ++++----
python/liblvm.c | 103 +++++++++++++++++++++++++++++++------------
test/api/python_lvm_unit.py | 18 ++-----
4 files changed, 89 insertions(+), 51 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7873d37..1437825 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.119 -
==================================
+ Make python bindings usable with python3 (and compatible with 2.6 & 2.7).
Add lvmconfig -l|--list as shortcut for lvmconfig --type list --withsummary.
Add lvmconfig --type list to display plain list of configuration settings.
Introduce lvmconfig as the preferred form of 'lvm dumpconfig'.
diff --git a/python/example.py b/python/example.py
index 5c14ee1..07ebbf2 100644
--- a/python/example.py
+++ b/python/example.py
@@ -27,7 +27,7 @@ import lvm
#Dump information about PV
def print_pv(pv):
- print 'PV name: ', pv.getName(), ' ID: ', pv.getUuid(), 'Size: ', pv.getSize()
+ print('PV name: ', pv.getName(), ' ID: ', pv.getUuid(), 'Size: ', pv.getSize())
#Dump some information about a specific volume group
@@ -35,7 +35,7 @@ def print_vg(vg_name):
#Open read only
vg = lvm.vgOpen(vg_name, 'r')
- print 'Volume group:', vg_name, 'Size: ', vg.getSize()
+ print('Volume group:', vg_name, 'Size: ', vg.getSize())
#Retrieve a list of Physical volumes for this volume group
pv_list = vg.listPVs()
@@ -48,9 +48,9 @@ def print_vg(vg_name):
lv_list = vg.listLVs()
if len(lv_list):
for l in lv_list:
- print 'LV name: ', l.getName(), ' ID: ', l.getUuid()
+ print('LV name: ', l.getName(), ' ID: ', l.getUuid())
else:
- print 'No logical volumes present!'
+ print('No logical volumes present!')
vg.close()
@@ -75,14 +75,14 @@ def find_vg_with_free_space():
def create_delete_logical_volume():
vg_name = find_vg_with_free_space()
- print 'Using volume group ', vg_name, ' for example'
+ print('Using volume group ', vg_name, ' for example')
if vg_name:
vg = lvm.vgOpen(vg_name, 'w')
lv = vg.createLvLinear('python_lvm_ok_to_delete', vg.getFreeSize())
if lv:
- print 'New lv, id= ', lv.getUuid()
+ print('New lv, id= ', lv.getUuid())
#Create a tag
lv.addTag('Demo_tag')
@@ -97,16 +97,16 @@ def create_delete_logical_volume():
#Try to rename
lv.rename("python_lvm_renamed")
- print 'LV name= ', lv.getName()
+ print('LV name= ', lv.getName())
lv.remove()
vg.close()
else:
- print 'No free space available to create demo lv!'
+ print('No free space available to create demo lv!')
if __name__ == '__main__':
#What version
- print 'lvm version=', lvm.getVersion()
+ print('lvm version=', lvm.getVersion())
#Get a list of volume group names
vg_names = lvm.listVgNames()
diff --git a/python/liblvm.c b/python/liblvm.c
index 1c9b5c4..6151745 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -25,6 +25,23 @@
#include "lvm2app.h"
#include "defaults.h"
+#if PY_MAJOR_VERSION >= 3
+#define IS_PY3K
+#define PYINTTYPE_CHECK PyLong_Check
+#define PYINTTYPE_ASLONG PyLong_AsLong
+#define PYINTTYPE_FROMLONG PyLong_FromLong
+#define PYSTRYPE_CHECK PyUnicode_Check
+#define PYSTRTYPE_ASSTRING PyUnicode_AsUTF8
+#define PYSTRTYPE_FROMSTRING PyUnicode_FromString
+#else
+#define PYINTTYPE_CHECK PyInt_Check
+#define PYINTTYPE_ASLONG PyInt_AsLong
+#define PYINTTYPE_FROMLONG PyInt_FromLong
+#define PYSTRYPE_CHECK PyString_Check
+#define PYSTRTYPE_ASSTRING PyString_AsString
+#define PYSTRTYPE_FROMSTRING PyString_FromString
+#endif
+
static lvm_t _libh;
@@ -148,10 +165,10 @@ static PyObject *_liblvm_get_last_error(void)
if (!(info = PyTuple_New(2)))
return NULL;
- PyTuple_SetItem(info, 0, PyInt_FromLong((long) lvm_errno(_libh)));
+ PyTuple_SetItem(info, 0, PYINTTYPE_FROMLONG((long) lvm_errno(_libh)));
msg = lvm_errmsg(_libh);
- PyTuple_SetItem(info, 1, ((msg) ? PyString_FromString(msg) :
- PyString_FromString("Memory error while retrieving error message")));
+ PyTuple_SetItem(info, 1, ((msg) ? PYSTRTYPE_FROMSTRING(msg) :
+ PYSTRTYPE_FROMSTRING("Memory error while retrieving error message")));
return info;
}
@@ -199,7 +216,7 @@ static PyObject *_liblvm_lvm_list_vg_names(void)
return NULL;
dm_list_iterate_items(strl, vgnames) {
- PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
+ PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
i++;
}
@@ -224,7 +241,7 @@ static PyObject *_liblvm_lvm_list_vg_uuids(void)
return NULL;
dm_list_iterate_items(strl, uuids) {
- PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
+ PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
i++;
}
@@ -856,7 +873,7 @@ static PyObject *get_property(struct lvm_property_value *prop)
if (prop->is_integer)
PyTuple_SET_ITEM(pytuple, 0, Py_BuildValue("K", prop->value.integer));
else
- PyTuple_SET_ITEM(pytuple, 0, PyString_FromString(prop->value.string));
+ PyTuple_SET_ITEM(pytuple, 0, PYSTRTYPE_FROMSTRING(prop->value.string));
if (prop->is_settable)
setable = Py_True;
@@ -904,14 +921,14 @@ static PyObject *_liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
if (!lvm_property.is_valid)
goto lvmerror;
- if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyString_Type)) {
+ if (PYSTRYPE_CHECK(variant_type_arg)) {
if (!lvm_property.is_string) {
PyErr_Format(PyExc_ValueError, "Property requires string value");
goto bail;
}
- if (!(string_value = PyString_AsString(variant_type_arg))) {
+ if (!(string_value = PYSTRTYPE_ASSTRING(variant_type_arg))) {
PyErr_NoMemory();
goto bail;
}
@@ -924,8 +941,8 @@ static PyObject *_liblvm_lvm_vg_set_property(vgobject *self, PyObject *args)
goto bail;
}
- if (PyObject_IsInstance(variant_type_arg, (PyObject*)&PyInt_Type)) {
- temp_py_int = PyInt_AsLong(variant_type_arg);
+ if (PYINTTYPE_CHECK(variant_type_arg)) {
+ temp_py_int = PYINTTYPE_ASLONG(variant_type_arg);
/* -1 could be valid, need to see if an exception was gen. */
if (temp_py_int == -1 && PyErr_Occurred())
@@ -1056,7 +1073,7 @@ static PyObject *_liblvm_lvm_vg_get_tags(vgobject *self)
return NULL;
dm_list_iterate_items(strl, tagsl) {
- PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
+ PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
i++;
}
@@ -1499,7 +1516,7 @@ static PyObject *_liblvm_lvm_lv_get_tags(lvobject *self)
return NULL;
dm_list_iterate_items(strl, tagsl) {
- PyTuple_SET_ITEM(pytuple, i, PyString_FromString(strl->str));
+ PyTuple_SET_ITEM(pytuple, i, PYSTRTYPE_FROMSTRING(strl->str));
i++;
}
@@ -1923,7 +1940,7 @@ static PyMethodDef _liblvm_pvseg_methods[] = {
};
static PyTypeObject _LibLVMvgType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_vg",
.tp_basicsize = sizeof(vgobject),
.tp_new = PyType_GenericNew,
@@ -1934,7 +1951,7 @@ static PyTypeObject _LibLVMvgType = {
};
static PyTypeObject _LibLVMlvType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_lv",
.tp_basicsize = sizeof(lvobject),
.tp_new = PyType_GenericNew,
@@ -1945,7 +1962,7 @@ static PyTypeObject _LibLVMlvType = {
};
static PyTypeObject _LibLVMpvlistType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_pvlist",
.tp_basicsize = sizeof(pvslistobject),
.tp_new = PyType_GenericNew,
@@ -1956,7 +1973,7 @@ static PyTypeObject _LibLVMpvlistType = {
};
static PyTypeObject _LibLVMpvType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_pv",
.tp_basicsize = sizeof(pvobject),
.tp_new = PyType_GenericNew,
@@ -1967,7 +1984,7 @@ static PyTypeObject _LibLVMpvType = {
};
static PyTypeObject _LibLVMlvsegType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_lvseg",
.tp_basicsize = sizeof(lvsegobject),
.tp_new = PyType_GenericNew,
@@ -1978,7 +1995,7 @@ static PyTypeObject _LibLVMlvsegType = {
};
static PyTypeObject _LibLVMpvsegType = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
.tp_name = "lvm.Liblvm_pvseg",
.tp_basicsize = sizeof(pvsegobject),
.tp_new = PyType_GenericNew,
@@ -1996,40 +2013,65 @@ static void _liblvm_cleanup(void)
}
}
+#ifdef IS_PY3K
+static struct PyModuleDef moduledef = {
+ PyModuleDef_HEAD_INIT,
+ "lvm",
+ "Liblvm module",
+ -1,
+ _Liblvm_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+#define MODINITERROR return NULL
+PyObject *
+PyInit_lvm(void)
+
+#else
+#define MODINITERROR return
PyMODINIT_FUNC initlvm(void);
PyMODINIT_FUNC initlvm(void)
+#endif
{
PyObject *m;
_libh = lvm_init(NULL);
if (PyType_Ready(&_LibLVMvgType) < 0)
- return;
+ MODINITERROR;
if (PyType_Ready(&_LibLVMlvType) < 0)
- return;
+ MODINITERROR;
if (PyType_Ready(&_LibLVMpvType) < 0)
- return;
+ MODINITERROR;
if (PyType_Ready(&_LibLVMlvsegType) < 0)
- return;
+ MODINITERROR;
if (PyType_Ready(&_LibLVMpvsegType) < 0)
- return;
+ MODINITERROR;
if (PyType_Ready(&_LibLVMpvlistType) < 0)
- return;
+ MODINITERROR;
- if (!(m = Py_InitModule3("lvm", _Liblvm_methods, "Liblvm module")))
- return;
+#ifdef IS_PY3K
+ m = PyModule_Create(&moduledef);
+#else
+ m = Py_InitModule3("lvm", _Liblvm_methods, "Liblvm module");
+#endif
+ if (m == NULL)
+ MODINITERROR;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_IGNORE",
LVM_THIN_DISCARDS_IGNORE) < 0)
- return;
+ MODINITERROR;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_NO_PASSDOWN",
LVM_THIN_DISCARDS_NO_PASSDOWN) < 0)
- return;
+ MODINITERROR;
if (PyModule_AddIntConstant(m, "THIN_DISCARDS_PASSDOWN",
LVM_THIN_DISCARDS_PASSDOWN) < 0)
- return;
+ MODINITERROR;
if ((_LibLVMError = PyErr_NewException((char*)"lvm.LibLVMError", NULL, NULL))) {
/* Each call to PyModule_AddObject decrefs it; compensate: */
@@ -2040,4 +2082,7 @@ PyMODINIT_FUNC initlvm(void)
}
Py_AtExit(_liblvm_cleanup);
+#ifdef IS_PY3K
+ return m;
+#endif
}
diff --git a/test/api/python_lvm_unit.py b/test/api/python_lvm_unit.py
index 455c9e8..e66ebda 100755
--- a/test/api/python_lvm_unit.py
+++ b/test/api/python_lvm_unit.py
@@ -18,6 +18,10 @@ import string
import lvm
import os
import itertools
+import sys
+
+if sys.version_info[0] > 2:
+ long = int
# Set of basic unit tests for the python bindings.
#
@@ -56,18 +60,6 @@ def _get_allowed_devices():
return rc
-def compare_pv(right, left):
- r_name = right.getName()
- l_name = left.getName()
-
- if r_name > l_name:
- return 1
- elif r_name == l_name:
- return 0
- else:
- return -1
-
-
class AllowedPVS(object):
"""
We are only allowed to muck with certain PV, filter to only
@@ -92,7 +84,7 @@ class AllowedPVS(object):
rc.append(p)
#Sort them consistently
- rc.sort(compare_pv)
+ rc.sort(key=lambda x: x.getName())
return rc
def __exit__(self, t_type, value, traceback):
8 years, 11 months
master - lvmetad: Avoid duplicate entries in the list of alternate devices.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4946c64092a04d...
Commit: 4946c64092a04d6a5a7a09a31f7c74c193d3484f
Parent: 3be3eb2995f83ab73a2a1419b1db5f1098fcb5a8
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Apr 23 01:39:39 2015 +0200
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Apr 29 13:23:23 2015 +0200
lvmetad: Avoid duplicate entries in the list of alternate devices.
---
daemons/lvmetad/lvmetad-core.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 1a2ce44..e3394ab 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -936,12 +936,29 @@ static response pv_found(lvmetad_state *s, request r)
altdev = dm_config_clone_node(cft, altdev, 0);
chain_node(altdev, cft->root, 0);
} else
- altdev = make_config_node(cft, "devices_alternate", cft->root, 0);
- if (!altdev || !(altdev_v = dm_config_create_value(cft)))
- goto out_of_mem;
- altdev_v->next = altdev->v;
- altdev->v = altdev_v;
- altdev->v->v.i = device_old_pvid;
+ if (!(altdev = make_config_node(cft, "devices_alternate", cft->root, 0)))
+ goto out_of_mem;
+ altdev_v = altdev->v;
+ while (1) {
+ if (altdev_v && altdev_v->v.i == device_old_pvid)
+ break;
+ if (altdev_v)
+ altdev_v = altdev_v->next;
+ if (!altdev_v) {
+ if (!(altdev_v = dm_config_create_value(cft)))
+ goto out_of_mem;
+ altdev_v->next = altdev->v;
+ altdev->v = altdev_v;
+ altdev->v->v.i = device_old_pvid;
+ break;
+ }
+ };
+ altdev_v = altdev->v;
+ while (altdev_v) {
+ if (altdev_v->next && altdev_v->next->v.i == device)
+ altdev_v->next = altdev_v->next->next;
+ altdev_v = altdev_v->next;
+ }
changed |= 1;
}
8 years, 11 months
master - lvmconfig: add --type list and -l|--list
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3be3eb2995f83a...
Commit: 3be3eb2995f83ab73a2a1419b1db5f1098fcb5a8
Parent: 0ba332e82a308415d715bf8a24ebf5d649f1c071
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Apr 29 11:11:58 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Apr 29 11:58:14 2015 +0200
lvmconfig: add --type list and -l|--list
lvmconfig --type list displays plain list of configuration settings.
Some of the existing decorations can be used (--withsummary and
--withversions) as well as existing options/switches (--ignoreadvanced,
--ignoreunsupported, --ignorelocal, --atversion).
For example (displaying only "config" section so the list is not long):
$lvmconfig --type list config
config/checks
config/abort_on_errors
config/profile_dir
$ lvmconfig --type list --withsummary config
config/checks - If enabled, any LVM configuration mismatch is reported.
config/abort_on_errors - Abort the LVM process if a configuration mismatch is found.
config/profile_dir - Directory where LVM looks for configuration profiles.
$ lvmconfig -l config
config/checks - If enabled, any LVM configuration mismatch is reported.
config/abort_on_errors - Abort the LVM process if a configuration mismatch is found.
config/profile_dir - Directory where LVM looks for configuration profiles.
$ lvmconfig --type list --withsummary --withversions config
config/checks - If enabled, any LVM configuration mismatch is reported. [2.2.99]
config/abort_on_errors - Abort the LVM process if a configuration mismatch is found. [2.2.99]
config/profile_dir - Directory where LVM looks for configuration profiles. [2.2.99]
Example with --atversion (displaying global section):
$ lvmconfig --type list global
global/umask
global/test
global/units
global/si_unit_consistency
global/suffix
global/activation
global/fallback_to_lvm1
global/format
global/format_libraries
global/segment_libraries
global/proc
global/etc
global/locking_type
global/wait_for_locks
global/fallback_to_clustered_locking
global/fallback_to_local_locking
global/locking_dir
global/prioritise_write_locks
global/library_dir
global/locking_library
global/abort_on_internal_errors
global/detect_internal_vg_cache_corruption
global/metadata_read_only
global/mirror_segtype_default
global/raid10_segtype_default
global/sparse_segtype_default
global/lvdisplay_shows_full_device_path
global/use_lvmetad
global/thin_check_executable
global/thin_dump_executable
global/thin_repair_executable
global/thin_check_options
global/thin_repair_options
global/thin_disabled_features
global/cache_check_executable
global/cache_dump_executable
global/cache_repair_executable
global/cache_check_options
global/cache_repair_options
global/system_id_source
global/system_id_file
$ lvmconfig --type list global --atversion 2.2.50
global/umask
global/test
global/units
global/suffix
global/activation
global/fallback_to_lvm1
global/format
global/format_libraries
global/segment_libraries
global/proc
global/locking_type
global/wait_for_locks
global/fallback_to_clustered_locking
global/fallback_to_local_locking
global/locking_dir
global/library_dir
global/locking_library
---
WHATS_NEW | 2 +
lib/config/config.c | 53 ++++++++++++++++++++++++++++++++++++++++++++------
lib/config/config.h | 1 +
man/lvmconfig.8.in | 8 +++++++
tools/commands.h | 15 ++++++++-----
tools/dumpconfig.c | 25 ++++++++++++++++++-----
6 files changed, 85 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ad1573e..7873d37 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.119 -
==================================
+ Add lvmconfig -l|--list as shortcut for lvmconfig --type list --withsummary.
+ Add lvmconfig --type list to display plain list of configuration settings.
Introduce lvmconfig as the preferred form of 'lvm dumpconfig'.
Add lv_ancestors and lv_descendants reporting fields.
Add --ignorelocal option to dumpconfig to ignore the local section.
diff --git a/lib/config/config.c b/lib/config/config.c
index 79e9de4..45a1d36 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1519,6 +1519,19 @@ static int _copy_one_line(const char *comment, char *line, int *pos, int len)
return i;
}
+static int _get_config_node_version(char *version, struct cfg_def_item *cfg_def)
+{
+ if (dm_snprintf(version, 9, "%u.%u.%u",
+ (cfg_def->since_version & 0xE000) >> 13,
+ (cfg_def->since_version & 0x1E00) >> 9,
+ (cfg_def->since_version & 0x1FF)) == -1) {
+ log_error("_get_config_node_version: couldn't create version string");
+ return 0;
+ }
+
+ return 1;
+}
+
static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, void *baton)
{
struct out_baton *out = baton;
@@ -1536,6 +1549,9 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
return 0;
}
+ if (out->tree_spec->type == CFG_DEF_TREE_LIST)
+ return 1;
+
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
return 1;
@@ -1571,13 +1587,8 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
}
if (out->tree_spec->withversions) {
- if (dm_snprintf(version, 9, "%u.%u.%u",
- (cfg_def->since_version & 0xE000) >> 13,
- (cfg_def->since_version & 0x1E00) >> 9,
- (cfg_def->since_version & 0x1FF)) == -1) {
- log_error("_out_prefix_fn: couldn't create version string");
- return 0;
- }
+ if (!_get_config_node_version(version, cfg_def))
+ return_0;
fprintf(out->fp, "%s# Since version %s.\n", line, version);
}
@@ -1588,14 +1599,42 @@ static int _out_line_fn(const struct dm_config_node *cn, const char *line, void
{
struct out_baton *out = baton;
struct cfg_def_item *cfg_def = cfg_def_get_item_p(cn->id);
+ char config_path[CFG_PATH_MAX_LEN];
+ char summary[MAX_COMMENT_LINE+1];
+ char version[9];
+ int pos = 0;
if ((out->tree_spec->type == CFG_DEF_TREE_DIFF) &&
(!(out->tree_spec->check_status[cn->id] & CFG_DIFF)))
return 1;
+ if (out->tree_spec->type == CFG_DEF_TREE_LIST) {
+ /* List view with node paths and summary. */
+ if (cfg_def->type & CFG_TYPE_SECTION)
+ return 1;
+ if (!_cfg_def_make_path(config_path, CFG_PATH_MAX_LEN, cfg_def->id, cfg_def, 1))
+ return_0;
+ if (out->tree_spec->withsummary) {
+ summary[0] = '\0';
+ if (cfg_def->comment)
+ _copy_one_line(cfg_def->comment, summary, &pos, strlen(cfg_def->comment));
+ if (out->tree_spec->withversions && !_get_config_node_version(version, cfg_def))
+ return_0;
+ fprintf(out->fp, "%s - %s%s%s%s\n", config_path, summary,
+ out->tree_spec->withversions ? " [" : "",
+ out->tree_spec->withversions ? version : "",
+ out->tree_spec->withversions ? "]" : "");
+ } else
+ fprintf(out->fp, "%s\n", config_path);
+
+ return 1;
+ }
+
+ /* Usual tree view with nodes and their values. */
fprintf(out->fp, "%s%s\n", (out->tree_spec->type != CFG_DEF_TREE_CURRENT) &&
(out->tree_spec->type != CFG_DEF_TREE_DIFF) &&
(cfg_def->flags & CFG_DEFAULT_UNDEFINED) ? "#" : "", line);
+
return 1;
}
diff --git a/lib/config/config.h b/lib/config/config.h
index a316cd0..1e9f0f8 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -142,6 +142,7 @@ typedef enum {
CFG_DEF_TREE_PROFILABLE_CMD, /* tree of all nodes that are customizable by command profiles (subset of PROFILABLE) */
CFG_DEF_TREE_PROFILABLE_MDA, /* tree of all nodes that are customizable by metadata profiles (subset of PROFILABLE) */
CFG_DEF_TREE_DIFF, /* tree of all nodes that differ from defaults */
+ CFG_DEF_TREE_LIST, /* list all nodes */
} cfg_def_tree_t;
/* configuration definition tree specification */
diff --git a/man/lvmconfig.8.in b/man/lvmconfig.8.in
index ce59d52..798e2bb 100644
--- a/man/lvmconfig.8.in
+++ b/man/lvmconfig.8.in
@@ -12,6 +12,7 @@ lvmconfig, lvm dumpconfig, lvm config \(em Display LVM configuration
.RB [ \-\-ignoreadvanced ]
.RB [ \-\-ignoreunsupported ]
.RB [ \-\-ignorelocal ]
+.RB [ \-l | \-\-list ]
.RB [ \-\-config
.IR ConfigurationString ]
.RB [ \-\-commandprofile
@@ -38,6 +39,11 @@ The command was added in release 2.02.119 and has an identical longer form
Send output to a file named 'filename'.
.TP
+.BR \-l ", " \-\-list
+List configuration settings with summarizing comment. This is the same as using
+\fBlvmconfig --type list --withsummary\fP.
+
+.TP
.IR \fB\-\-type " {" current | default | diff | missing | new | profilable }
Select the type of configuration to display. The configuration settings
displayed have either default values or currently-used values assigned based on
@@ -58,6 +64,8 @@ Display all configuration settings for which the values used differ from default
The value assigned for each configuration setting is the value currently used.
This is actually minimal LVM configuration which can be used without
a change to current configured behaviour.
+.IP list 3
+Display plain list of configuration settings.
.IP missing 3
Display all configuration settings with default values assigned which are
missing in the configuration currently used and for which LVM automatically
diff --git a/tools/commands.h b/tools/commands.h
index ea70cc2..f7b6e98 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -33,11 +33,12 @@ xx(config,
PERMITTED_READ_ONLY,
"config\n"
"\t[-f|--file filename]\n"
- "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--type {current|default|diff|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
"\t[--atversion version]]\n"
"\t[--ignoreadvanced]\n"
"\t[--ignoreunsupported]\n"
"\t[--ignorelocal]\n"
+ "\t[-l|--list]\n"
"\t[--config ConfigurationString]\n"
"\t[--commandprofile ProfileName]\n"
"\t[--profile ProfileName]\n"
@@ -50,7 +51,7 @@ xx(config,
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
- ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
+ ignoreunsupported_ARG, ignorelocal_ARG, list_ARG, mergedconfig_ARG, metadataprofile_ARG,
validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(devtypes,
@@ -84,11 +85,12 @@ xx(dumpconfig,
PERMITTED_READ_ONLY,
"dumpconfig\n"
"\t[-f|--file filename]\n"
- "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--type {current|default|diff|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
"\t[--atversion version]]\n"
"\t[--ignoreadvanced]\n"
"\t[--ignoreunsupported]\n"
"\t[--ignorelocal]\n"
+ "\t[-l|--list]\n"
"\t[--config ConfigurationString]\n"
"\t[--commandprofile ProfileName]\n"
"\t[--profile ProfileName]\n"
@@ -101,7 +103,7 @@ xx(dumpconfig,
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
- ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
+ ignoreunsupported_ARG, ignorelocal_ARG, list_ARG, mergedconfig_ARG, metadataprofile_ARG,
validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(formats,
@@ -484,11 +486,12 @@ xx(lvmconfig,
PERMITTED_READ_ONLY,
"lvmconfig\n"
"\t[-f|--file filename]\n"
- "\t[--type {current|default|diff|missing|new|profilable|profilable-command|profilable-metadata}\n"
+ "\t[--type {current|default|diff|list|missing|new|profilable|profilable-command|profilable-metadata}\n"
"\t[--atversion version]]\n"
"\t[--ignoreadvanced]\n"
"\t[--ignoreunsupported]\n"
"\t[--ignorelocal]\n"
+ "\t[-l|--list]\n"
"\t[--config ConfigurationString]\n"
"\t[--commandprofile ProfileName]\n"
"\t[--profile ProfileName]\n"
@@ -501,7 +504,7 @@ xx(lvmconfig,
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
- ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
+ ignoreunsupported_ARG, ignorelocal_ARG, list_ARG, mergedconfig_ARG, metadataprofile_ARG,
validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(lvmdiskscan,
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 04d5df6..50057a1 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -88,7 +88,7 @@ static int _config_validate(struct cmd_context *cmd, struct dm_config_tree *cft)
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
- const char *type = arg_str_value(cmd, configtype_ARG, "current");
+ const char *type = arg_str_value(cmd, configtype_ARG, arg_count(cmd, list_ARG) ? "list" : "current");
struct config_def_tree_spec tree_spec = {0};
struct dm_config_tree *cft = NULL;
struct cft_check_handle *cft_check_handle = NULL;
@@ -102,8 +102,14 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, atversion_ARG) && !arg_count(cmd, configtype_ARG)) {
- log_error("--atversion requires --type");
+ if (arg_count(cmd, configtype_ARG) && arg_count(cmd, list_ARG)) {
+ log_error("Only one of --type and --list permitted.");
+ return EINVALID_CMD_LINE;
+ }
+
+ if (arg_count(cmd, atversion_ARG) && !arg_count(cmd, configtype_ARG) &&
+ !arg_count(cmd, list_ARG)) {
+ log_error("--atversion requires --type or --list");
return EINVALID_CMD_LINE;
}
@@ -171,7 +177,14 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
}
}
- if (!strcmp(type, "current")) {
+ if (!strcmp(type, "list") || arg_count(cmd, list_ARG)) {
+ tree_spec.type = CFG_DEF_TREE_LIST;
+ if (arg_count(cmd, withcomments_ARG)) {
+ log_error("--withcomments has no effect with --type list");
+ return EINVALID_CMD_LINE;
+ }
+ /* list type does not require status check */
+ } else if (!strcmp(type, "current")) {
tree_spec.type = CFG_DEF_TREE_CURRENT;
if (!_do_def_check(&tree_spec, cft, &cft_check_handle)) {
r = ECMD_FAILED;
@@ -214,13 +227,13 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
}
else {
log_error("Incorrect type of configuration specified. "
- "Expected one of: current, default, missing, new, "
+ "Expected one of: current, default, list, missing, new, "
"profilable, profilable-command, profilable-metadata.");
r = EINVALID_CMD_LINE;
goto out;
}
- if (arg_count(cmd, withsummary_ARG))
+ if (arg_count(cmd, withsummary_ARG) || arg_count(cmd, list_ARG))
tree_spec.withsummary = 1;
if (arg_count(cmd, withcomments_ARG))
tree_spec.withcomments = 1;
8 years, 11 months
master - refactor: dumpconfig: keep --withcomments to display full comment and use --withsummary for one line summary
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0ba332e82a3084...
Commit: 0ba332e82a308415d715bf8a24ebf5d649f1c071
Parent: 15a563c376d5288f6ec61c20422c27352363f6e1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Apr 29 10:53:25 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Apr 29 11:14:18 2015 +0200
refactor: dumpconfig: keep --withcomments to display full comment and use --withsummary for one line summary
---
WHATS_NEW | 2 +-
conf/Makefile.in | 4 ++--
lib/config/config.c | 6 +++---
lib/config/config.h | 10 +++++-----
man/lvm.conf.5.in | 4 ++--
man/lvmconfig.8.in | 6 +++---
tools/args.h | 2 +-
tools/commands.h | 12 ++++++------
tools/dumpconfig.c | 4 ++--
9 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f0c248c..ad1573e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -8,7 +8,7 @@ Version 2.02.119 -
Split pvmove update metadata fn in an initial one and a subsequent one.
Refactor shared pvmove and lvconvert code into new _poll files.
Add --unconfigured option to dumpconfig to print strings unconfigured.
- Add --withfullcomments option to dumpconfig to print full comment.
+ Add --withsummary option to dumpconfig to print first line - summary comment.
Check for lvm binary in blkdeactivate and skip LVM processing if not present.
Add --enable-halvm and --disable-halvm options to lvmconf script.
Add --services, --mirrorservice and --startstopservices option to lvmconf.
diff --git a/conf/Makefile.in b/conf/Makefile.in
index c427a2e..c98be88 100644
--- a/conf/Makefile.in
+++ b/conf/Makefile.in
@@ -27,8 +27,8 @@ include $(top_builddir)/make.tmpl
.PHONY: install_conf install_localconf install_profiles
generate:
- (cat $(top_srcdir)/conf/example.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments --ignorelocal) > example.conf.in
- (cat $(top_srcdir)/conf/lvmlocal.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withfullcomments local) > lvmlocal.conf.in
+ (cat $(top_srcdir)/conf/example.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withcomments --ignorelocal) > example.conf.in
+ (cat $(top_srcdir)/conf/lvmlocal.conf.base && LD_LIBRARY_PATH=$(top_builddir)/libdm:$(LD_LIBRARY_PATH) $(top_builddir)/tools/lvm dumpconfig --type default --unconfigured --withcomments local) > lvmlocal.conf.in
install_conf: $(CONFSRC)
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \
diff --git a/lib/config/config.c b/lib/config/config.c
index fbe7cb9..79e9de4 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1542,7 +1542,7 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
cfg_def = cfg_def_get_item_p(cn->id);
- if (out->tree_spec->withcomments || out->tree_spec->withfullcomments) {
+ if (out->tree_spec->withsummary || out->tree_spec->withcomments) {
_cfg_def_make_path(path, sizeof(path), cfg_def->id, cfg_def, 1);
fprintf(out->fp, "\n");
fprintf(out->fp, "%s# Configuration %s %s.\n", line, node_type_name, path);
@@ -1551,8 +1551,8 @@ static int _out_prefix_fn(const struct dm_config_node *cn, const char *line, voi
int pos = 0;
while (_copy_one_line(cfg_def->comment, commentline, &pos, strlen(cfg_def->comment))) {
fprintf(out->fp, "%s# %s\n", line, commentline);
- /* withcomments prints only the first comment line. */
- if (!out->tree_spec->withfullcomments)
+ /* withsummary prints only the first comment line. */
+ if (!out->tree_spec->withcomments)
break;
}
}
diff --git a/lib/config/config.h b/lib/config/config.h
index 193f4e3..a316cd0 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -149,13 +149,13 @@ struct config_def_tree_spec {
struct cmd_context *cmd; /* command context (for run-time defaults */
cfg_def_tree_t type; /* tree type */
uint16_t version; /* tree at this LVM2 version */
- unsigned ignoreadvanced:1; /* do not include advanced configs */
+ unsigned ignoreadvanced:1; /* do not include advanced configs */
unsigned ignoreunsupported:1; /* do not include unsupported configs */
unsigned ignorelocal:1; /* do not include the local section */
- unsigned withcomments:1; /* include first line of comment */
- unsigned withfullcomments:1; /* include all comment lines */
- unsigned withversions:1; /* include versions */
- unsigned unconfigured:1; /* use unconfigured path strings */
+ unsigned withsummary:1; /* include first line of comments - a summary */
+ unsigned withcomments:1; /* include all comment lines */
+ unsigned withversions:1; /* include versions */
+ unsigned unconfigured:1; /* use unconfigured path strings */
uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */
};
diff --git a/man/lvm.conf.5.in b/man/lvm.conf.5.in
index 2c4effc..517c0f9 100644
--- a/man/lvm.conf.5.in
+++ b/man/lvm.conf.5.in
@@ -171,7 +171,7 @@ default values:
Command to print a list of all possible config settings, with their
default values, and a full description of each as a comment:
.br
-.B lvmconfig \-\-type default --withfullcomments
+.B lvmconfig \-\-type default --withcomments
Command to print a list of all possible config settings, with their
current values (configured, non-default values are shown):
@@ -189,7 +189,7 @@ and a full description, where "Section" refers to the config section,
e.g. global, and "Setting" refers to the name of the specific setting,
e.g. umask:
.br
-.B lvmconfig \-\-type default --withfullcomments Section/Setting
+.B lvmconfig \-\-type default --withcomments Section/Setting
.SH FILES
diff --git a/man/lvmconfig.8.in b/man/lvmconfig.8.in
index 76f8ffe..ce59d52 100644
--- a/man/lvmconfig.8.in
+++ b/man/lvmconfig.8.in
@@ -22,8 +22,8 @@ lvmconfig, lvm dumpconfig, lvm config \(em Display LVM configuration
.IR ProfileName ]
.RB [ \-\-mergedconfig ]
.RB [ \-\-validate ]
+.RB [ \-\-withsummary ]
.RB [ \-\-withcomments ]
-.RB [ \-\-withfullcomments ]
.RB [ \-\-withversions ]
.RB [ ConfigurationNode... ]
@@ -148,11 +148,11 @@ The validation is done even if \fBconfig/checks\fP \fBlvm.conf\fP(5)
option is disabled.
.TP
-.B \-\-withcomments
+.B \-\-withsummary
Display a one line comment for each configuration node.
.TP
-.B \-\-withfullcomments
+.B \-\-withcomments
Display a full comment for each configuration node.
.TP
diff --git a/tools/args.h b/tools/args.h
index 9497223..465100d 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -118,8 +118,8 @@ arg(validate_ARG, '\0', "validate", NULL, 0)
arg(version_ARG, '\0', "version", NULL, 0)
arg(vgmetadatacopies_ARG, '\0', "vgmetadatacopies", metadatacopies_arg, 0)
arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
+arg(withsummary_ARG, '\0', "withsummary", NULL, 0)
arg(withcomments_ARG, '\0', "withcomments", NULL, 0)
-arg(withfullcomments_ARG, '\0', "withfullcomments", NULL, 0)
arg(withversions_ARG, '\0', "withversions", NULL, 0)
arg(writebehind_ARG, '\0', "writebehind", int_arg, 0)
arg(writemostly_ARG, '\0', "writemostly", string_arg, ARG_GROUPABLE)
diff --git a/tools/commands.h b/tools/commands.h
index df69c2a..ea70cc2 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -44,14 +44,14 @@ xx(config,
"\t[--metadataprofile ProfileName]\n"
"\t[--mergedconfig]\n"
"\t[--validate]\n"
+ "\t[--withsummary]\n"
"\t[--withcomments]\n"
- "\t[--withfullcomments]\n"
"\t[--unconfigured]\n"
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
- validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
+ validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(devtypes,
"Display recognised built-in block device types",
@@ -95,14 +95,14 @@ xx(dumpconfig,
"\t[--metadataprofile ProfileName]\n"
"\t[--mergedconfig]\n"
"\t[--validate]\n"
+ "\t[--withsummary]\n"
"\t[--withcomments]\n"
- "\t[--withfullcomments]\n"
"\t[--unconfigured]\n"
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
- validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
+ validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(formats,
"List available metadata formats",
@@ -495,14 +495,14 @@ xx(lvmconfig,
"\t[--metadataprofile ProfileName]\n"
"\t[--mergedconfig]\n"
"\t[--validate]\n"
+ "\t[--withsummary]\n"
"\t[--withcomments]\n"
- "\t[--withfullcomments]\n"
"\t[--unconfigured]\n"
"\t[--withversions]\n"
"\t[ConfigurationNode...]\n",
atversion_ARG, configtype_ARG, file_ARG, ignoreadvanced_ARG,
ignoreunsupported_ARG, ignorelocal_ARG, mergedconfig_ARG, metadataprofile_ARG,
- validate_ARG, withcomments_ARG, withfullcomments_ARG, unconfigured_ARG, withversions_ARG)
+ validate_ARG, withsummary_ARG, withcomments_ARG, unconfigured_ARG, withversions_ARG)
xx(lvmdiskscan,
"List devices that may be used as physical volumes",
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 341bffa..04d5df6 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -220,10 +220,10 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
+ if (arg_count(cmd, withsummary_ARG))
+ tree_spec.withsummary = 1;
if (arg_count(cmd, withcomments_ARG))
tree_spec.withcomments = 1;
- if (arg_count(cmd, withfullcomments_ARG))
- tree_spec.withfullcomments = 1;
if (arg_count(cmd, unconfigured_ARG))
tree_spec.unconfigured = 1;
8 years, 11 months
master - polldaemon: remove redundant log messages
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15a563c376d528...
Commit: 15a563c376d5288f6ec61c20422c27352363f6e1
Parent: ea5c1b0a7310ffb9528a4c3451d347360b021303
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Tue Apr 14 14:43:16 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Apr 28 23:19:20 2015 +0200
polldaemon: remove redundant log messages
also alter comments describing the change in _poll_vg
wrt correct handling of multiple LVs
---
tools/polldaemon.c | 20 +++++---------------
1 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 1b6e1b4..2684f63 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -207,13 +207,9 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
if (!(sls = str_list_create(cmd->mem)))
return ECMD_FAILED;
- log_verbose("Looking for pvmove LVs in VG: %s.", vg->name);
-
/*
- * _check_lv_status must not be called from within any
- * dm_list_iterate_ routine with vg->lvs as list head.
- * It may remove more than one LV in the process thus
- * even "*_safe" variant won't help.
+ * first iterate all LVs in a VG and collect LVs suitable
+ * for polling (or an abort) which takes place below
*/
dm_list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
@@ -240,19 +236,13 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
log_error("Failed to clone pvname");
goto err;
}
-
- log_verbose("Found LV: %s/%s. It belongs to pvmove task on PV %s.", lv->vg->name, lv->name, name);
}
+ /* perform the poll operation on LVs collected in previous cycle */
dm_list_iterate_items(sl, sls) {
lv = parms->poll_fns->get_copy_lv(cmd, vg, sl->str, NULL, parms->lv_type);
- if (lv) {
- log_verbose("About to call _check_lv_status on LV: %s/%s, name: %s",
- lv->vg->name, lv->name, sl->str);
- if (_check_lv_status(cmd, vg, lv, sl->str, parms, &finished) &&
- !finished)
- parms->outstanding_count++;
- }
+ if (lv && _check_lv_status(cmd, vg, lv, sl->str, parms, &finished) && !finished)
+ parms->outstanding_count++;
}
err:
8 years, 11 months
master - pvmove: make log messages more comprehensible
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ea5c1b0a7310ff...
Commit: ea5c1b0a7310ffb9528a4c3451d347360b021303
Parent: a1474b98f90de0ed272935debc6773f08cdfbace
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Thu Apr 16 17:40:53 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Apr 28 22:45:54 2015 +0200
pvmove: make log messages more comprehensible
clarify messages printed during pvmove set up (in
_update_metadata fn) and subsequent metadata updates
during a segment progression
---
tools/pvmove.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 6acac42..90cf5fe 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -516,7 +516,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
{
int r = 0;
- log_verbose("Updating volume group metadata for the first time.");
+ log_verbose("Setting up pvmove in on-disk volume group metadata.");
if (!vg_write(vg)) {
log_error("ABORTING: Volume group metadata update failed.");
return 0;
@@ -530,7 +530,7 @@ static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
/* Commit on-disk metadata */
if (!vg_commit(vg)) {
- log_error("ABORTING: First volume group metadata update failed.");
+ log_error("ABORTING: Volume group metadata update failed.");
if (!resume_lvs(cmd, lvs_changed))
log_error("Unable to resume logical volumes.");
return 0;
8 years, 11 months
master - update copyright info in various files
by okozina
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a1474b98f90de0...
Commit: a1474b98f90de0ed272935debc6773f08cdfbace
Parent: 90cbc5576fa8511c7045700fa7de0bc3b01e2225
Author: Ondrej Kozina <okozina(a)redhat.com>
AuthorDate: Thu Apr 16 17:31:07 2015 +0200
Committer: Ondrej Kozina <okozina(a)redhat.com>
CommitterDate: Tue Apr 28 22:45:19 2015 +0200
update copyright info in various files
basically transfer former date ranges from files where
the code originated from (pvmove.c and lvconvert.c)
---
tools/lvconvert_poll.c | 2 +-
tools/pvmove_poll.c | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/lvconvert_poll.c b/tools/lvconvert_poll.c
index 012911e..4745d06 100644
--- a/tools/lvconvert_poll.c
+++ b/tools/lvconvert_poll.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index 0e9d639..cd32476 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
8 years, 11 months