master - report: add report_init_for_selection fn and modify report_object to support reporting for selection only
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a64b39aef80d79...
Commit: a64b39aef80d790dd4afe4ce8fdaa0ed1b0e2c48
Parent: 51d96a170314b7ce75f233d42501262805384770
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Dec 2 13:14:12 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 10 16:05:25 2015 +0100
report: add report_init_for_selection fn and modify report_object to support reporting for selection only
The new "report_init_for_selection" is just a wrapper over
dm_report_init_with_selection that initializes reporting for selection
only. This means we're not going to do the actual reporting to output
for display and as such we intialize reporting as if no fields are reported
or sorted. The only fields "reported" are taken from the selection criteria
string and all such fields are marked as hidden automatically (FLD_HIDDEN flag).
These fields are used solely for selection criteria matching.
Also, modify existing report_object function that was used for reporting to
output for display. Now, it can either cause reporting to output or reporting
for selection only. The selection result is stored in struct selection_handle's
"selected" variable which can be handled further by any report_object caller.
---
lib/report/report.c | 18 ++++++++++++++++--
lib/report/report.h | 4 +++-
tools/reporter.c | 35 ++++++++++++++++++++++++-----------
3 files changed, 43 insertions(+), 14 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 53de714..cf3d9b6 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2009,15 +2009,28 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
return rh;
}
+void *report_init_for_selection(struct cmd_context *cmd,
+ report_type_t *report_type,
+ const char *selection_criteria)
+{
+ return dm_report_init_with_selection(report_type, _report_types, _fields,
+ "", DEFAULT_REP_SEPARATOR,
+ DM_REPORT_OUTPUT_FIELD_UNQUOTED,
+ "", selection_criteria,
+ _report_reserved_values,
+ cmd);
+}
+
/*
* Create a row of data for an object
*/
-int report_object(void *handle, const struct volume_group *vg,
+int report_object(void *handle, int selection_only, const struct volume_group *vg,
const struct logical_volume *lv, const struct physical_volume *pv,
const struct lv_segment *seg, const struct pv_segment *pvseg,
const struct lv_with_info_and_seg_status *lvdm,
const struct label *label)
{
+ struct selection_handle *sh = selection_only ? (struct selection_handle *) handle : NULL;
struct device dummy_device = { .dev = 0 };
struct label dummy_label = { .dev = &dummy_device };
struct lvm_report_object obj = {
@@ -2051,7 +2064,8 @@ int report_object(void *handle, const struct volume_group *vg,
if (!obj.vg && pv)
_dummy_fid.fmt = pv->fmt;
- return dm_report_object(handle, &obj);
+ return sh ? dm_report_object_is_selected(sh->selection_rh, &obj, 0, &sh->selected)
+ : dm_report_object(handle, &obj);
}
static int _report_devtype_single(void *handle, const dev_known_type_t *devtype)
diff --git a/lib/report/report.h b/lib/report/report.h
index aef6d72..80a75fd 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -69,8 +69,10 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
report_type_t *report_type, const char *separator,
int aligned, int buffered, int headings, int field_prefixes,
int quoted, int columns_as_rows, const char *selection);
+void *report_init_for_selection(struct cmd_context *cmd, report_type_t *report_type,
+ const char *selection);
void report_free(void *handle);
-int report_object(void *handle, const struct volume_group *vg,
+int report_object(void *handle, int selection_only, const struct volume_group *vg,
const struct logical_volume *lv, const struct physical_volume *pv,
const struct lv_segment *seg, const struct pv_segment *pvseg,
const struct lv_with_info_and_seg_status *lvdm,
diff --git a/tools/reporter.c b/tools/reporter.c
index 3d7e5dd..3cba020 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -32,7 +32,10 @@ static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name, struct volume_group *vg,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, vg, NULL, NULL, NULL, NULL, NULL, NULL))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, NULL, NULL, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
check_current_backup(vg);
@@ -88,6 +91,7 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
@@ -96,8 +100,8 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, lv->vg, lv,
- NULL, NULL, NULL, &status, NULL))
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ lv->vg, lv, NULL, NULL, NULL, &status, NULL))
goto out;
r = ECMD_PROCESSED;
@@ -137,6 +141,7 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
int do_info, int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
};
@@ -145,9 +150,9 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
- &status, NULL))
- goto_out;
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ seg->lv->vg, seg->lv, NULL, seg, NULL, &status, NULL))
+ goto_out;
r = ECMD_PROCESSED;
out:
@@ -224,6 +229,7 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
int do_status,
struct processing_handle *handle)
{
+ struct selection_handle *sh = handle->selection_handle;
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
@@ -268,9 +274,10 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
if (seg && !_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle->custom_handle, vg, seg ? seg->lv : &_free_logical_volume,
- pvseg->pv, seg ? : &_free_lv_segment, pvseg, &status,
- pv_label(pvseg->pv))) {
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, seg ? seg->lv : &_free_logical_volume,
+ pvseg->pv, seg ? : &_free_lv_segment, pvseg,
+ &status, pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
}
@@ -350,7 +357,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, vg, NULL, pv, NULL, NULL, NULL, NULL))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ vg, NULL, pv, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -359,7 +369,10 @@ static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
static int _label_single(struct cmd_context *cmd, struct label *label,
struct processing_handle *handle)
{
- if (!report_object(handle->custom_handle, NULL, NULL, NULL, NULL, NULL, NULL, label))
+ struct selection_handle *sh = handle->selection_handle;
+
+ if (!report_object(sh ? : handle->custom_handle, sh != NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, label))
return_ECMD_FAILED;
return ECMD_PROCESSED;
9 years, 3 months
master - toollib: replace void *handle with struct processing_handle for use in processing functions (process_each_*/process_single_* and related)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51d96a170314b7...
Commit: 51d96a170314b7ce75f233d42501262805384770
Parent: 2a19866a74c5101d262586ad0e08317e9a514977
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Nov 27 15:02:13 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 10 16:05:24 2015 +0100
toollib: replace void *handle with struct processing_handle for use in processing functions (process_each_*/process_single_* and related)
This patch replaces "void *handle" with "struct processing_handle *handle"
in process_each_*, process_single_* and related functions.
The struct processing_handle consists of two handles inside now:
- the "struct selection_handle *selection_handle" used for
applying selection criteria while processing process_each_*,
process_single_* and related functions (patches using this
logic will follow)
- the "void* custom_handle" (this is actually the original handle
used before this patch - a pointer to custom data passed into
process_each_*, process_single_* and related functions).
---
lib/report/report.h | 25 ++++++++++++
tools/lvchange.c | 2 +-
tools/lvconvert.c | 10 +++-
tools/lvdisplay.c | 4 +-
tools/lvscan.c | 2 +-
tools/polldaemon.c | 10 +++-
tools/pvdisplay.c | 5 +-
tools/pvresize.c | 9 +++-
tools/reporter.c | 102 +++++++++++++++++++++++++++------------------------
tools/toollib.c | 33 +++++++++-------
tools/toollib.h | 88 ++++++++++++++++++++++++++++++++++++-------
tools/vgcfgbackup.c | 9 +++-
tools/vgchange.c | 2 +-
tools/vgck.c | 2 +-
tools/vgconvert.c | 2 +-
tools/vgdisplay.c | 2 +-
tools/vgexport.c | 2 +-
tools/vgimport.c | 2 +-
tools/vgmknodes.c | 2 +-
tools/vgreduce.c | 2 +-
tools/vgremove.c | 2 +-
tools/vgscan.c | 2 +-
22 files changed, 214 insertions(+), 105 deletions(-)
diff --git a/lib/report/report.h b/lib/report/report.h
index 563f684e18..aef6d72 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -34,6 +34,31 @@ typedef enum {
DEVTYPES = 1024
} report_type_t;
+/*
+ * The "struct selection_handle" is used only for selection
+ * of items that should be processed further (not for display!).
+ *
+ * It consists of selection reporting handle "selection_rh"
+ * used for the selection itself (not for display on output!).
+ * The items are reported directly in memory to a buffer and
+ * then compared against selection criteria. Once we know the
+ * result of the selection, the buffer is dropped!
+ *
+ * The "orig_report_type" is the original requested report type.
+ * The "report_type" is the reporting type actually used which
+ * also counts with report types of the fields used in selection
+ * criteria.
+ *
+ * The "selected" variable is used for propagating the result
+ * of the selection.
+ */
+struct selection_handle {
+ struct dm_report *selection_rh;
+ report_type_t orig_report_type;
+ report_type_t report_type;
+ int selected;
+};
+
struct field;
struct report_handle;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 8a175e0..17e977f 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -848,7 +848,7 @@ static int lvchange_activation_skip(struct logical_volume *lv)
static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
int doit = 0, docmds = 0;
struct logical_volume *origin;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 20f017a..f9f666d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3486,9 +3486,9 @@ out:
}
static int _lvconvert_merge_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
- struct lvconvert_params *lp = handle;
+ struct lvconvert_params *lp = (struct lvconvert_params *) handle->custom_handle;
const char *vg_name;
struct logical_volume *refreshed_lv;
int ret;
@@ -3542,13 +3542,17 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
.target_attr = ~0,
};
+ struct processing_handle handle = { .internal_report_for_select = 1,
+ .selection_handle = NULL,
+ .custom_handle = &lp };
+
if (!_read_params(cmd, argc, argv, &lp)) {
stack;
return EINVALID_CMD_LINE;
}
if (lp.merge)
- return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, &lp,
+ return process_each_lv(cmd, argc, argv, READ_FOR_UPDATE, &handle,
&_lvconvert_merge_single);
return lvconvert_single(cmd, &lp);
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index fb3420a..6b1540f 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -16,7 +16,7 @@
#include "tools.h"
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle __attribute__ ((unused)))
{
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -24,7 +24,7 @@ static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, colon_ARG))
lvdisplay_colons(lv);
else {
- lvdisplay_full(cmd, lv, handle);
+ lvdisplay_full(cmd, lv, NULL);
if (arg_count(cmd, maps_ARG))
lvdisplay_segments(lv);
}
diff --git a/tools/lvscan.c b/tools/lvscan.c
index 2d7be07..fa9d976 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -48,7 +48,7 @@ static int _lvscan_single_lvmetad(struct cmd_context *cmd, struct logical_volume
}
static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
struct lvinfo info;
int inkernel, snap_active = 1;
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index 8d5c6ba..3eb9b17 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -189,9 +189,9 @@ static int _wait_for_single_lv(struct cmd_context *cmd, const char *name, const
}
static int _poll_vg(struct cmd_context *cmd, const char *vgname,
- struct volume_group *vg, void *handle)
+ struct volume_group *vg, struct processing_handle *handle)
{
- struct daemon_parms *parms = (struct daemon_parms *) handle;
+ struct daemon_parms *parms = (struct daemon_parms *) handle->custom_handle;
struct lv_list *lvl;
struct logical_volume *lv;
const char *name;
@@ -229,9 +229,13 @@ static int _poll_vg(struct cmd_context *cmd, const char *vgname,
static void _poll_for_all_vgs(struct cmd_context *cmd,
struct daemon_parms *parms)
{
+ struct processing_handle handle = { .internal_report_for_select = 1,
+ .selection_handle = NULL,
+ .custom_handle = parms };
+
while (1) {
parms->outstanding_count = 0;
- process_each_vg(cmd, 0, NULL, READ_FOR_UPDATE, parms, _poll_vg);
+ process_each_vg(cmd, 0, NULL, READ_FOR_UPDATE, &handle, _poll_vg);
if (!parms->outstanding_count)
break;
sleep(parms->interval);
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index 50522d9..94a3bbf 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -17,7 +17,8 @@
static int _pvdisplay_single(struct cmd_context *cmd,
struct volume_group *vg,
- struct physical_volume *pv, void *handle)
+ struct physical_volume *pv,
+ struct processing_handle *handle __attribute__((unused)))
{
const char *pv_name = pv_dev_name(pv);
int ret = ECMD_PROCESSED;
@@ -48,7 +49,7 @@ static int _pvdisplay_single(struct cmd_context *cmd,
goto out;
}
- pvdisplay_full(cmd, pv, handle);
+ pvdisplay_full(cmd, pv, NULL);
if (arg_count(cmd, maps_ARG))
pvdisplay_segments(pv);
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 631e63e..a2f6b8b 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -26,9 +26,9 @@ struct pvresize_params {
static int _pvresize_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ struct processing_handle *handle)
{
- struct pvresize_params *params = (struct pvresize_params *) handle;
+ struct pvresize_params *params = (struct pvresize_params *) handle->custom_handle;
if (!params) {
log_error(INTERNAL_ERROR "Invalid resize params.");
@@ -47,6 +47,9 @@ static int _pvresize_single(struct cmd_context *cmd,
int pvresize(struct cmd_context *cmd, int argc, char **argv)
{
struct pvresize_params params;
+ struct processing_handle handle = { .internal_report_for_select = 1,
+ .selection_handle = NULL,
+ .custom_handle = ¶ms };
int ret;
if (!argc) {
@@ -65,7 +68,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
params.done = 0;
params.total = 0;
- ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, ¶ms,
+ ret = process_each_pv(cmd, argc, argv, NULL, READ_FOR_UPDATE, &handle,
_pvresize_single);
log_print_unless_silent("%d physical volume(s) resized / %d physical volume(s) "
diff --git a/tools/reporter.c b/tools/reporter.c
index 7517ac5..3d7e5dd 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -16,12 +16,13 @@
#include "tools.h"
#include "report.h"
-static int _process_each_devtype(struct cmd_context *cmd, int argc, void *handle)
+static int _process_each_devtype(struct cmd_context *cmd, int argc,
+ struct processing_handle *handle)
{
if (argc)
log_warn("WARNING: devtypes currently ignores command line arguments.");
- if (!report_devtypes(handle))
+ if (!report_devtypes(handle->custom_handle))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -29,9 +30,9 @@ static int _process_each_devtype(struct cmd_context *cmd, int argc, void *handle
static int _vgs_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name, struct volume_group *vg,
- void *handle)
+ struct processing_handle *handle)
{
- if (!report_object(handle, vg, NULL, NULL, NULL, NULL, NULL, NULL))
+ if (!report_object(handle->custom_handle, vg, NULL, NULL, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
check_current_backup(vg);
@@ -85,7 +86,7 @@ static int _do_info_and_status(struct cmd_context *cmd,
static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
const struct logical_volume *lv,
int do_info, int do_status,
- void *handle)
+ struct processing_handle *handle)
{
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
@@ -95,9 +96,9 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status))
goto_out;
- if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL,
- &status, NULL))
- goto_out;
+ if (!report_object(handle->custom_handle, lv->vg, lv,
+ NULL, NULL, NULL, &status, NULL))
+ goto out;
r = ECMD_PROCESSED;
out:
@@ -108,25 +109,25 @@ out:
}
static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
return _do_lvs_with_info_and_status_single(cmd, lv, 0, 0, handle);
}
static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
return _do_lvs_with_info_and_status_single(cmd, lv, 1, 0, handle);
}
static int _lvs_with_status_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
return _do_lvs_with_info_and_status_single(cmd, lv, 0, 1, handle);
}
static int _lvs_with_info_and_status_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
return _do_lvs_with_info_and_status_single(cmd, lv, 1, 1, handle);
}
@@ -134,7 +135,7 @@ static int _lvs_with_info_and_status_single(struct cmd_context *cmd, struct logi
static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
const struct lv_segment *seg,
int do_info, int do_status,
- void *handle)
+ struct processing_handle *handle)
{
struct lv_with_info_and_seg_status status = {
.seg_status.type = SEG_STATUS_NONE
@@ -144,7 +145,7 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
+ if (!report_object(handle->custom_handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
&status, NULL))
goto_out;
@@ -157,31 +158,31 @@ out:
}
static int _segs_single(struct cmd_context *cmd, struct lv_segment *seg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_segs_with_info_and_status_single(cmd, seg, 0, 0, handle);
}
static int _segs_with_info_single(struct cmd_context *cmd, struct lv_segment *seg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_segs_with_info_and_status_single(cmd, seg, 1, 0, handle);
}
static int _segs_with_status_single(struct cmd_context *cmd, struct lv_segment *seg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_segs_with_info_and_status_single(cmd, seg, 0, 1, handle);
}
static int _segs_with_info_and_status_single(struct cmd_context *cmd, struct lv_segment *seg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_segs_with_info_and_status_single(cmd, seg, 1, 1, handle);
}
static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -190,7 +191,7 @@ static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
}
static int _lvsegs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -199,7 +200,7 @@ static int _lvsegs_with_info_single(struct cmd_context *cmd, struct logical_volu
}
static int _lvsegs_with_status_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -208,7 +209,7 @@ static int _lvsegs_with_status_single(struct cmd_context *cmd, struct logical_vo
}
static int _lvsegs_with_info_and_status_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle)
+ struct processing_handle *handle)
{
if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
return ECMD_PROCESSED;
@@ -221,7 +222,7 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
struct pv_segment *pvseg,
int do_info,
int do_status,
- void *handle)
+ struct processing_handle *handle)
{
int ret = ECMD_PROCESSED;
struct lv_segment *seg = pvseg->lvseg;
@@ -267,8 +268,8 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
if (seg && !_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
goto_out;
- if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
- seg ? : &_free_lv_segment, pvseg, &status,
+ if (!report_object(handle->custom_handle, vg, seg ? seg->lv : &_free_logical_volume,
+ pvseg->pv, seg ? : &_free_lv_segment, pvseg, &status,
pv_label(pvseg->pv))) {
ret = ECMD_FAILED;
goto_out;
@@ -284,7 +285,7 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
static int _pvsegs_sub_single(struct cmd_context *cmd,
struct volume_group *vg,
struct pv_segment *pvseg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_pvsegs_sub_single(cmd, vg, pvseg, 0, 0, handle);
}
@@ -292,7 +293,7 @@ static int _pvsegs_sub_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_info_sub_single(struct cmd_context *cmd,
struct volume_group *vg,
struct pv_segment *pvseg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_pvsegs_sub_single(cmd, vg, pvseg, 1, 0, handle);
}
@@ -300,7 +301,7 @@ static int _pvsegs_with_lv_info_sub_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_status_sub_single(struct cmd_context *cmd,
struct volume_group *vg,
struct pv_segment *pvseg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_pvsegs_sub_single(cmd, vg, pvseg, 0, 1, handle);
}
@@ -308,7 +309,7 @@ static int _pvsegs_with_lv_status_sub_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_info_and_status_sub_single(struct cmd_context *cmd,
struct volume_group *vg,
struct pv_segment *pvseg,
- void *handle)
+ struct processing_handle *handle)
{
return _do_pvsegs_sub_single(cmd, vg, pvseg, 1, 1, handle);
}
@@ -316,7 +317,7 @@ static int _pvsegs_with_lv_info_and_status_sub_single(struct cmd_context *cmd,
static int _pvsegs_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ struct processing_handle *handle)
{
return process_each_segment_in_pv(cmd, vg, pv, handle, _pvsegs_sub_single);
}
@@ -324,7 +325,7 @@ static int _pvsegs_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_info_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ struct processing_handle *handle)
{
return process_each_segment_in_pv(cmd, vg, pv, handle, _pvsegs_with_lv_info_sub_single);
}
@@ -332,7 +333,7 @@ static int _pvsegs_with_lv_info_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_status_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ struct processing_handle *handle)
{
return process_each_segment_in_pv(cmd, vg, pv, handle, _pvsegs_with_lv_status_sub_single);
}
@@ -340,24 +341,25 @@ static int _pvsegs_with_lv_status_single(struct cmd_context *cmd,
static int _pvsegs_with_lv_info_and_status_single(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle)
+ struct processing_handle *handle)
{
return process_each_segment_in_pv(cmd, vg, pv, handle, _pvsegs_with_lv_info_and_status_sub_single);
}
static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
- struct physical_volume *pv, void *handle)
+ struct physical_volume *pv,
+ struct processing_handle *handle)
{
- if (!report_object(handle, vg, NULL, pv, NULL, NULL, NULL, NULL))
+ if (!report_object(handle->custom_handle, vg, NULL, pv, NULL, NULL, NULL, NULL))
return_ECMD_FAILED;
return ECMD_PROCESSED;
}
static int _label_single(struct cmd_context *cmd, struct label *label,
- void *handle)
+ struct processing_handle *handle)
{
- if (!report_object(handle, NULL, NULL, NULL, NULL, NULL, NULL, label))
+ if (!report_object(handle->custom_handle, NULL, NULL, NULL, NULL, NULL, NULL, label))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -365,7 +367,7 @@ static int _label_single(struct cmd_context *cmd, struct label *label,
static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle)
+ struct processing_handle *handle)
{
int skip;
@@ -380,7 +382,7 @@ static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name,
static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle)
+ struct processing_handle *handle)
{
int skip;
@@ -397,6 +399,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type_t report_type)
{
void *report_handle;
+ struct processing_handle handle = {0};
const char *opts;
char *str;
const char *keys = NULL, *options = NULL, *selection = NULL, *separator;
@@ -565,9 +568,12 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
}
}
+ handle.internal_report_for_select = 0;
+ handle.custom_handle = report_handle;
+
switch (report_type) {
case DEVTYPES:
- r = _process_each_devtype(cmd, argc, report_handle);
+ r = _process_each_devtype(cmd, argc, &handle);
break;
case LVSINFO:
/* fall through */
@@ -576,7 +582,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
case LVSINFOSTATUS:
/* fall through */
case LVS:
- r = process_each_lv(cmd, argc, argv, 0, report_handle,
+ r = process_each_lv(cmd, argc, argv, 0, &handle,
lv_info_needed && !lv_segment_status_needed ? &_lvs_with_info_single :
!lv_info_needed && lv_segment_status_needed ? &_lvs_with_status_single :
lv_info_needed && lv_segment_status_needed ? &_lvs_with_info_and_status_single :
@@ -584,24 +590,24 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
case VGS:
r = process_each_vg(cmd, argc, argv, 0,
- report_handle, &_vgs_single);
+ &handle, &_vgs_single);
break;
case LABEL:
r = process_each_label(cmd, argc, argv,
- report_handle, &_label_single);
+ &handle, &_label_single);
break;
case PVS:
if (args_are_pvs)
r = process_each_pv(cmd, argc, argv, NULL, 0,
- report_handle, &_pvs_single);
+ &handle, &_pvs_single);
else
r = process_each_vg(cmd, argc, argv, 0,
- report_handle, &_pvs_in_vg);
+ &handle, &_pvs_in_vg);
break;
case SEGSSTATUS:
/* fall through */
case SEGS:
- r = process_each_lv(cmd, argc, argv, 0, report_handle,
+ r = process_each_lv(cmd, argc, argv, 0, &handle,
lv_info_needed && !lv_segment_status_needed ? &_lvsegs_with_info_single :
!lv_info_needed && lv_segment_status_needed ? &_lvsegs_with_status_single :
lv_info_needed && lv_segment_status_needed ? &_lvsegs_with_info_and_status_single :
@@ -610,14 +616,14 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
case PVSEGS:
if (args_are_pvs)
r = process_each_pv(cmd, argc, argv, NULL, 0,
- report_handle,
+ &handle,
lv_info_needed && !lv_segment_status_needed ? &_pvsegs_with_lv_info_single :
!lv_info_needed && lv_segment_status_needed ? &_pvsegs_with_lv_status_single :
lv_info_needed && lv_segment_status_needed ? &_pvsegs_with_lv_info_and_status_single :
&_pvsegs_single);
else
r = process_each_vg(cmd, argc, argv, 0,
- report_handle, &_pvsegs_in_vg);
+ &handle, &_pvsegs_in_vg);
break;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index c634b17..759769e 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -203,7 +203,7 @@ int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsiste
int process_each_segment_in_pv(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle,
+ struct processing_handle *handle,
process_single_pvseg_fn_t process_single_pvseg)
{
struct pv_segment *pvseg;
@@ -235,7 +235,7 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
int process_each_segment_in_lv(struct cmd_context *cmd,
struct logical_volume *lv,
- void *handle,
+ struct processing_handle *handle,
process_single_seg_fn_t process_single_seg)
{
struct lv_segment *seg;
@@ -1236,7 +1236,8 @@ int change_tag(struct cmd_context *cmd, struct volume_group *vg,
return 1;
}
-int process_each_label(struct cmd_context *cmd, int argc, char **argv, void *handle,
+int process_each_label(struct cmd_context *cmd, int argc, char **argv,
+ struct processing_handle *handle,
process_single_label_fn_t process_single_label)
{
struct label *label;
@@ -1564,7 +1565,8 @@ int select_match_pv(struct cmd_context *cmd, struct volume_group *vg,
static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
struct dm_list *vgnameids_to_process,
struct dm_list *arg_vgnames,
- struct dm_list *arg_tags, void *handle,
+ struct dm_list *arg_tags,
+ struct processing_handle *handle,
process_single_vg_fn_t process_single_vg)
{
struct volume_group *vg;
@@ -1657,7 +1659,7 @@ static int _copy_str_to_vgnameid_list(struct cmd_context *cmd, struct dm_list *s
* Call process_single_vg() for each VG selected by the command line arguments.
*/
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
- uint32_t flags, void *handle,
+ uint32_t flags, struct processing_handle *handle,
process_single_vg_fn_t process_single_vg)
{
struct dm_list arg_tags; /* str_list */
@@ -1716,7 +1718,8 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *arg_lvnames, const struct dm_list *tags_in,
int stop_on_error,
- void *handle, process_single_lv_fn_t process_single_lv)
+ struct processing_handle *handle,
+ process_single_lv_fn_t process_single_lv)
{
int ret_max = ECMD_PROCESSED;
int ret = 0;
@@ -1939,7 +1942,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
struct dm_list *arg_vgnames,
struct dm_list *arg_lvnames,
struct dm_list *arg_tags,
- void *handle,
+ struct processing_handle *handle,
process_single_lv_fn_t process_single_lv)
{
struct volume_group *vg;
@@ -2023,7 +2026,7 @@ static int _process_lv_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
* Call process_single_lv() for each LV selected by the command line arguments.
*/
int process_each_lv(struct cmd_context *cmd, int argc, char **argv, uint32_t flags,
- void *handle, process_single_lv_fn_t process_single_lv)
+ struct processing_handle *handle, process_single_lv_fn_t process_single_lv)
{
struct dm_list arg_tags; /* str_list */
struct dm_list arg_vgnames; /* str_list */
@@ -2219,7 +2222,8 @@ static struct device_id_list *_device_list_find_pvid(struct dm_list *devices, st
}
static int _process_device_list(struct cmd_context *cmd, struct dm_list *all_devices,
- void *handle, process_single_pv_fn_t process_single_pv)
+ struct processing_handle *handle,
+ process_single_pv_fn_t process_single_pv)
{
struct physical_volume pv_dummy;
struct physical_volume *pv;
@@ -2260,7 +2264,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
int process_all_pvs,
int process_all_devices,
int skip,
- void *handle,
+ struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
struct physical_volume *pv;
@@ -2423,7 +2427,7 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t flags,
struct dm_list *arg_tags,
int process_all_pvs,
int process_all_devices,
- void *handle,
+ struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
struct volume_group *vg;
@@ -2480,7 +2484,7 @@ int process_each_pv(struct cmd_context *cmd,
int argc, char **argv,
const char *only_this_vgname,
uint32_t flags,
- void *handle,
+ struct processing_handle *handle,
process_single_pv_fn_t process_single_pv)
{
struct dm_list arg_tags; /* str_list */
@@ -2570,7 +2574,8 @@ out:
}
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- void *handle, process_single_pv_fn_t process_single_pv)
+ struct processing_handle *handle,
+ process_single_pv_fn_t process_single_pv)
{
int ret_max = ECMD_PROCESSED;
int ret;
@@ -2591,7 +2596,7 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
}
int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
/*
* Single force is equivalent to single --yes
diff --git a/tools/toollib.h b/tools/toollib.h
index 56259fb..cc86227 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -17,66 +17,124 @@
#define _LVM_TOOLLIB_H
#include "metadata-exported.h"
+#include "report.h"
int become_daemon(struct cmd_context *cmd, int skip_lvm);
int ignore_vg(struct volume_group *vg, const char *vg_name, int allow_inconsistent, int *skip);
+/*
+ * The "struct processing_handle" is used as a handle for processing
+ * functions (process_each_* and related).
+ *
+ * The "custom_handle" is any handle used to pass custom data into
+ * process_each_* and related functions.
+ *
+ * The "internal_report_for_select=0" makes processing function to
+ * skip checking the report/selection criteria (if given on cmd line)
+ * before executing the action on the item.
+ *
+ * The "selection_handle" is only used if "internal_report_for_select=1".
+ *
+ * Some important notes about selection:
+ * =====================================
+ * In case we're processing for display, the selection is directly
+ * a part of reporting for the display on output so we don't need to
+ * report the item in memory to get the selection result, then dropping
+ * the report and then reporting the same thing again for it to be
+ * displayed on output.
+ * For example, compare these code paths:
+ *
+ * - when reporting for display on output:
+ * _report -> process_each_* -> ... -> dm_report_object
+ * (Here the dm_report_object does both selection and
+ * reporting for display on output.)
+ *
+ * - for any other processing and reporting for selection:
+ * process_each_* -> _select_match_* -> ... -> dm_report_object_is_selected
+ * |
+ * --> (selection result) --> ...
+ * (Here the dm_report_object_is_selected just gets
+ * the selection result and it drops reporting buffer
+ * immediately. Then based on the selection result,
+ * the process_each_* action on the item is executed
+ * or not...)
+ *
+ * Simply, we want to avoid this double reporting when reporting
+ * for display on output:
+ * _report -> process_each_* -> _select_match_* -> ... -> dm_report_object_is_selected
+ * |
+ * --> (selection result) -> dm_report_object
+ *
+ * So whenever the processing action is "to display item on output", use
+ * "internal_report_for_select=0" as report/selection is already
+ * a part of that reporting for display (dm_report_object).
+ */
+struct processing_handle {
+ int internal_report_for_select;
+ struct selection_handle *selection_handle;
+ void *custom_handle;
+};
+
typedef int (*process_single_vg_fn_t) (struct cmd_context * cmd,
const char *vg_name,
struct volume_group * vg,
- void *handle);
+ struct processing_handle *handle);
typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle);
+ struct processing_handle *handle);
typedef int (*process_single_label_fn_t) (struct cmd_context *cmd,
struct label *label,
- void *handle);
+ struct processing_handle *handle);
typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
struct logical_volume *lv,
- void *handle);
+ struct processing_handle *handle);
typedef int (*process_single_seg_fn_t) (struct cmd_context * cmd,
struct lv_segment * seg,
- void *handle);
+ struct processing_handle *handle);
typedef int (*process_single_pvseg_fn_t) (struct cmd_context * cmd,
struct volume_group * vg,
struct pv_segment * pvseg,
- void *handle);
+ struct processing_handle *handle);
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
- uint32_t flags, void *handle,
+ uint32_t flags, struct processing_handle *handle,
process_single_vg_fn_t process_single_vg);
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
const char *vg_name, uint32_t lock_type,
- void *handle, process_single_pv_fn_t process_single_pv);
+ struct processing_handle *handle,
+ process_single_pv_fn_t process_single_pv);
int process_each_label(struct cmd_context *cmd, int argc, char **argv,
- void *handle, process_single_label_fn_t process_single_label);
+ struct processing_handle *handle,
+ process_single_label_fn_t process_single_label);
int process_each_segment_in_pv(struct cmd_context *cmd,
struct volume_group *vg,
struct physical_volume *pv,
- void *handle,
+ struct processing_handle *handle,
process_single_pvseg_fn_t process_single_pvseg);
int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
- uint32_t flags, void *handle,
+ uint32_t flags, struct processing_handle *handle,
process_single_lv_fn_t process_single_lv);
int process_each_segment_in_lv(struct cmd_context *cmd,
- struct logical_volume *lv, void *handle,
+ struct logical_volume *lv,
+ struct processing_handle *handle,
process_single_seg_fn_t process_single_seg);
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- void *handle, process_single_pv_fn_t process_single_pv);
+ struct processing_handle *handle,
+ process_single_pv_fn_t process_single_pv);
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
struct dm_list *arg_lvnames, const struct dm_list *tagsl,
- int stop_on_error, void *handle,
+ int stop_on_error, struct processing_handle *handle,
process_single_lv_fn_t process_single_lv);
int select_match_vg(struct cmd_context *cmd, struct volume_group *vg,
@@ -145,6 +203,6 @@ int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_na
const char **lv_name);
int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)));
+ struct processing_handle *handle __attribute__((unused)));
#endif
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index 7cf19bc..ee65f18 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -49,9 +49,9 @@ static char *_expand_filename(const char *template, const char *vg_name,
static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle)
+ struct processing_handle *handle)
{
- char **last_filename = (char **)handle;
+ char **last_filename = (char **)handle->custom_handle;
char *filename;
if (arg_count(cmd, file_ARG)) {
@@ -83,11 +83,14 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
char *last_filename = NULL;
+ struct processing_handle handle = { .internal_report_for_select = 1,
+ .selection_handle = NULL,
+ .custom_handle = &last_filename };
init_pvmove(1);
ret = process_each_vg(cmd, argc, argv, READ_ALLOW_INCONSISTENT,
- &last_filename, &vg_backup_single);
+ &handle, &vg_backup_single);
dm_free(last_filename);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index e5d700d..e3f852b 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -473,7 +473,7 @@ static int _vgchange_profile(struct cmd_context *cmd,
static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
int ret = ECMD_PROCESSED;
unsigned i;
diff --git a/tools/vgck.c b/tools/vgck.c
index b9d05ae..1631289 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -18,7 +18,7 @@
static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
if (!vg_check_status(vg, EXPORTED_VG))
return_ECMD_FAILED;
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 1089344..50b3e44 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -17,7 +17,7 @@
static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
struct physical_volume *pv, *existing_pv;
struct pvcreate_restorable_params rp;
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index 59d741a..3c34727 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -17,7 +17,7 @@
static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
if (arg_count(cmd, activevolumegroups_ARG) && !lvs_in_vg_activated(vg))
return ECMD_PROCESSED;
diff --git a/tools/vgexport.c b/tools/vgexport.c
index d9f8efa..aeff612 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -18,7 +18,7 @@
static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
struct pv_list *pvl;
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 7cb9337..857f4a9 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -18,7 +18,7 @@
static int vgimport_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
struct pv_list *pvl;
struct physical_volume *pv;
diff --git a/tools/vgmknodes.c b/tools/vgmknodes.c
index 9ba0677..92eb2d0 100644
--- a/tools/vgmknodes.c
+++ b/tools/vgmknodes.c
@@ -16,7 +16,7 @@
#include "tools.h"
static int _vgmknodes_single(struct cmd_context *cmd, struct logical_volume *lv,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
if (arg_count(cmd, refresh_ARG) && lv_is_visible(lv))
if (!lv_refresh(cmd, lv))
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 7af5a76..0adf1bb 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -123,7 +123,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
/* Or take pv_name instead? */
static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
int r;
diff --git a/tools/vgremove.c b/tools/vgremove.c
index 1dce41f..315e1dc 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -17,7 +17,7 @@
static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
/*
* Single force is equivalent to sinle --yes
diff --git a/tools/vgscan.c b/tools/vgscan.c
index bca98cc..b3af9bc 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -17,7 +17,7 @@
static int vgscan_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg,
- void *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
log_print_unless_silent("Found %svolume group \"%s\" using metadata type %s",
vg_is_exported(vg) ? "exported " : "", vg_name,
9 years, 3 months
master - cleanup: make report type condition consistent with the rest of the code
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2a19866a74c510...
Commit: 2a19866a74c5101d262586ad0e08317e9a514977
Parent: 455ef6f2f58e5af11a75eb4b369c1a48780b068d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 25 14:13:04 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 10 16:05:23 2015 +0100
cleanup: make report type condition consistent with the rest of the code
It's just more readable this way (each condition resulting in a certain
report type is always on one line), just like it's used elsewhere in the
code.
---
tools/reporter.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 20fa4ab..7517ac5 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -543,9 +543,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
if ((report_type & PVSEGS) ||
((report_type & (PVS | LABEL)) && (report_type & (LVS | LVSINFO | LVSSTATUS | LVSINFOSTATUS))))
report_type = PVSEGS;
- else if ((report_type & LABEL) && (report_type & VGS))
- report_type = PVS;
- else if (report_type & PVS)
+ else if ((report_type & PVS) ||
+ ((report_type & LABEL) && (report_type & VGS)))
report_type = PVS;
else if (report_type & (SEGS | SEGSSTATUS))
report_type = SEGS;
9 years, 3 months
master - toollib: prepare select_match_{pv, vg, lv} hooks
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=455ef6f2f58e5a...
Commit: 455ef6f2f58e5af11a75eb4b369c1a48780b068d
Parent: 123a3383a021df737852892ff400f047b5ff609e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Nov 24 11:08:41 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 10 16:04:41 2015 +0100
toollib: prepare select_match_{pv,vg,lv} hooks
These hooks will check currently processed PV/VG/LV with current selection
criteria and the processing continues only if there's a match.
---
tools/toollib.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++-----
tools/toollib.h | 7 ++++++
2 files changed, 59 insertions(+), 6 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 17a9c71..c634b17 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1541,6 +1541,26 @@ static int _get_vgnameids_on_system(struct cmd_context *cmd,
return ECMD_PROCESSED;
}
+int select_match_vg(struct cmd_context *cmd, struct volume_group *vg, int *selected)
+{
+ *selected = 1;
+ return 1;
+}
+
+int select_match_lv(struct cmd_context *cmd, struct volume_group *vg,
+ struct logical_volume *lv, int *selected)
+{
+ *selected = 1;
+ return 1;
+}
+
+int select_match_pv(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, int *selected)
+{
+ *selected = 1;
+ return 1;
+}
+
static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
struct dm_list *vgnameids_to_process,
struct dm_list *arg_vgnames,
@@ -1551,6 +1571,7 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
struct vgnameid_list *vgnl;
const char *vg_name;
const char *vg_uuid;
+ int selected;
int ret_max = ECMD_PROCESSED;
int ret;
int skip;
@@ -1583,9 +1604,10 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t flags,
}
/* Process this VG? */
- if (process_all ||
+ if ((process_all ||
(!dm_list_empty(arg_vgnames) && str_list_match_item(arg_vgnames, vg_name)) ||
- (!dm_list_empty(arg_tags) && str_list_match_list(arg_tags, &vg->tags, NULL))) {
+ (!dm_list_empty(arg_tags) && str_list_match_list(arg_tags, &vg->tags, NULL))) &&
+ select_match_vg(cmd, vg, &selected) && selected) {
ret = process_single_vg(cmd, vg_name, vg, handle);
if (ret != ECMD_PROCESSED)
stack;
@@ -1698,6 +1720,8 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
{
int ret_max = ECMD_PROCESSED;
int ret = 0;
+ int selected;
+ unsigned process_lv;
unsigned process_all = 0;
unsigned tags_supplied = 0;
unsigned lvargs_supplied = 0;
@@ -1751,12 +1775,31 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!lvargs_supplied && !lv_is_visible(lvl->lv) && !arg_count(cmd, all_ARG))
continue;
- /* Only process the LV if the name matches or process_all is set or if an LV tag matches */
- if (lvargs_supplied && str_list_match_item(arg_lvnames, lvl->lv->name))
+ /*
+ * process the LV if one of the following:
+ * - process_all is set
+ * - LV name matches a supplied LV name
+ * - LV tag matches a supplied LV tag
+ * - LV matches the selection
+ */
+
+ process_lv = process_all;
+
+ if (lvargs_supplied && str_list_match_item(arg_lvnames, lvl->lv->name)) {
/* Remove LV from list of unprocessed LV names */
str_list_del(arg_lvnames, lvl->lv->name);
- else if (!process_all &&
- (!tags_supplied || !str_list_match_list(tags_in, &lvl->lv->tags, NULL)))
+ process_lv = 1;
+ }
+
+ if (!process_lv && tags_supplied && str_list_match_list(tags_in, &lvl->lv->tags, NULL))
+ process_lv = 1;
+
+ process_lv = process_lv && select_match_lv(cmd, vg, lvl->lv, &selected) && selected;
+
+ if (sigint_caught())
+ return_ECMD_FAILED;
+
+ if (!process_lv)
continue;
log_very_verbose("Processing LV %s in VG %s.", lvl->lv->name, vg->name);
@@ -2225,6 +2268,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
struct device_id_list *dil;
struct device *dev_orig;
const char *pv_name;
+ int selected;
int process_pv;
int dev_found;
int ret_max = ECMD_PROCESSED;
@@ -2259,6 +2303,8 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
str_list_match_list(arg_tags, &pv->tags, NULL))
process_pv = 1;
+ process_pv = process_pv && select_match_pv(cmd, vg, pv, &selected) && selected;
+
if (process_pv) {
if (skip)
log_verbose("Skipping PV %s in VG %s.", pv_name, vg->name);
diff --git a/tools/toollib.h b/tools/toollib.h
index 715f65e..56259fb 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -79,6 +79,13 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
int stop_on_error, void *handle,
process_single_lv_fn_t process_single_lv);
+int select_match_vg(struct cmd_context *cmd, struct volume_group *vg,
+ int *selected);
+int select_match_lv(struct cmd_context *cmd, struct volume_group *vg,
+ struct logical_volume *lv, int *selected);
+int select_match_pv(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, int *selected);
+
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
unsigned *dev_dir_found);
9 years, 3 months
master - libdm: report: add dm_report_object_is_selected
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=123a3383a021df...
Commit: 123a3383a021df737852892ff400f047b5ff609e
Parent: 2ee3bcb877b081dd6281644d4c9c366dd08ad1c1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Nov 24 11:07:39 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 10 16:04:38 2015 +0100
libdm: report: add dm_report_object_is_selected
The new dm_report_object_is_selected fn makes it possible to opt whether the
object reported should be displayed on output or not. Also, in addition to
that, it makes it possible to save the result of selection (either 0 or 1).
So dm_report_object_is_selected is simply more general form of object
reporting fn - combinations now allow for:
dm_report_object_is_selected(rh, object, 1, NULL):
This is exactly the original dm_report_object fn and it's fully equal
to it.
dm_report_object_is_selected(rh, object, 0, selected):
Do not display the result on output, but save info whether the object
is selected or not in 'selected' variable.
dm_report_object_is_selected(rh, object, 1, selected):
Display the result on output (if it passes selection criteria) and save
whether the object is selected or not in 'selected' variable.
dm_report_object(rh, object, 0, NULL):
This combination is not allowed - it will end up with internal error.
We're either interested in selection status or we want to display the
result on output or both, but never nothing of the two.
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 10 +++++++++
libdm/libdm-report.c | 53 +++++++++++++++++++++++++++++++++----------------
3 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 3fb69cb..183ef15 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.94 -
===================================
+ Add dm_report_object_is_selected for generalized interface for report/select.
Version 1.02.93 - 21st January 2015
===================================
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index b164b51..309e63f 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1761,7 +1761,17 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
const char *selection,
const struct dm_report_reserved_value reserved_values[],
void *private_data);
+/*
+ * Report an object, pass it through the selection criteria if they
+ * are present and display the result on output if it passes the criteria.
+ */
int dm_report_object(struct dm_report *rh, void *object);
+/*
+ * The same as dm_report_object, but display the result on output only if
+ * 'do_output' arg is set. Also, save the result of selection in 'selected'
+ * arg if it's not NULL (either 1 if the object passes, otherwise 0).
+ */
+int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_output, int *selected);
/*
* Compact report output so that if field value is empty for all rows in
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 2612f74..6f528f1 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1575,7 +1575,7 @@ static int _check_report_selection(struct dm_report *rh, struct dm_list *fields)
return _check_selection(rh, rh->selection->selection_root, fields);
}
-int dm_report_object(struct dm_report *rh, void *object)
+static int _do_report_object(struct dm_report *rh, void *object, int do_output, int *selected)
{
const struct dm_report_field_type *fields;
struct field_properties *fp;
@@ -1586,7 +1586,13 @@ int dm_report_object(struct dm_report *rh, void *object)
int r = 0;
if (!rh) {
- log_error(INTERNAL_ERROR "dm_report handler is NULL.");
+ log_error(INTERNAL_ERROR "_do_report_object: dm_report handler is NULL.");
+ return 0;
+ }
+
+ if (!do_output && !selected) {
+ log_error(INTERNAL_ERROR "_do_report_object: output not requested and "
+ "selected output variable is NULL too.");
return 0;
}
@@ -1594,7 +1600,7 @@ int dm_report_object(struct dm_report *rh, void *object)
return 1;
if (!(row = dm_pool_zalloc(rh->mem, sizeof(*row)))) {
- log_error("dm_report_object: struct row allocation failed");
+ log_error("_do_report_object: struct row allocation failed");
return 0;
}
@@ -1604,7 +1610,7 @@ int dm_report_object(struct dm_report *rh, void *object)
!(row->sort_fields =
dm_pool_zalloc(rh->mem, sizeof(struct dm_report_field *) *
rh->keys_count))) {
- log_error("dm_report_object: "
+ log_error("_do_report_object: "
"row sort value structure allocation failed");
goto out;
}
@@ -1615,7 +1621,7 @@ int dm_report_object(struct dm_report *rh, void *object)
/* For each field to be displayed, call its report_fn */
dm_list_iterate_items(fp, &rh->field_props) {
if (!(field = dm_pool_zalloc(rh->mem, sizeof(*field)))) {
- log_error("dm_report_object: "
+ log_error("_do_report_object: "
"struct dm_report_field allocation failed");
goto out;
}
@@ -1632,7 +1638,7 @@ int dm_report_object(struct dm_report *rh, void *object)
data = fp->implicit ? _report_get_implicit_field_data(rh, fp, row)
: _report_get_field_data(rh, fp, object);
if (!data) {
- log_error("dm_report_object: "
+ log_error("_do_report_object: "
"no data assigned to field %s",
fields[fp->field_num].id);
goto out;
@@ -1641,7 +1647,7 @@ int dm_report_object(struct dm_report *rh, void *object)
if (!fields[fp->field_num].report_fn(rh, rh->mem,
field, data,
rh->private)) {
- log_error("dm_report_object: "
+ log_error("_do_report_object: "
"report function failed for field %s",
fields[fp->field_num].id);
goto out;
@@ -1650,11 +1656,14 @@ int dm_report_object(struct dm_report *rh, void *object)
dm_list_add(&row->fields, &field->list);
}
+ r = 1;
+
if (!_check_report_selection(rh, &row->fields)) {
- if (!field_sel_status) {
- r = 1;
+ row->selected = 0;
+
+ if (!field_sel_status)
goto out;
- }
+
/*
* If field with id "selected" is reported,
* report the row although it does not pass
@@ -1662,7 +1671,6 @@ int dm_report_object(struct dm_report *rh, void *object)
* The "selected" field reports the result
* of the selection.
*/
- row->selected = 0;
_implicit_report_fields[field_sel_status->props->field_num].report_fn(rh,
rh->mem, field_sel_status, row, rh->private);
/*
@@ -1670,12 +1678,13 @@ int dm_report_object(struct dm_report *rh, void *object)
* because it is part of the sort field list,
* skip the display of the row as usual.
*/
- if (field_sel_status->props->flags & FLD_HIDDEN) {
- r = 1;
+ if (field_sel_status->props->flags & FLD_HIDDEN)
goto out;
- }
}
+ if (!do_output)
+ goto out;
+
dm_list_add(&rh->rows, &row->list);
dm_list_iterate_items(field, &row->fields) {
@@ -1691,10 +1700,10 @@ int dm_report_object(struct dm_report *rh, void *object)
if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED))
return dm_report_output(rh);
-
- r = 1;
out:
- if (!r)
+ if (selected)
+ *selected = row->selected;
+ if (!do_output || !r)
dm_pool_free(rh->mem, row);
return r;
}
@@ -1751,6 +1760,16 @@ int dm_report_compact_fields(struct dm_report *rh)
return 1;
}
+int dm_report_object(struct dm_report *rh, void *object)
+{
+ return _do_report_object(rh, object, 1, NULL);
+}
+
+int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_output, int *selected)
+{
+ return _do_report_object(rh, object, do_output, selected);
+}
+
/*
* Selection parsing
*/
9 years, 3 months
master - test: Fix a typo in shell/pvmove-restart.sh.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2ee3bcb877b081...
Commit: 2ee3bcb877b081dd6281644d4c9c366dd08ad1c1
Parent: b6f558adcc3b08cb627aca0a0cddbe65bdd19052
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Tue Feb 10 12:42:05 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Tue Feb 10 12:42:05 2015 +0100
test: Fix a typo in shell/pvmove-restart.sh.
---
test/shell/pvmove-restart.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index b4a2893..3c4947d 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -40,7 +40,7 @@ wait
# Simulate reboot - forcibly remove related devices
dmsetup table
-dmsetup ls --exec echo | egrep '$vg-$lv1|$vg-pvmove0' | xargs -r -n 1 dmsetup remove
+dmsetup ls --exec echo | egrep "$vg-$lv1|$vg-pvmove0" | xargs -r -n 1 dmsetup remove
# Check we really have pvmove volume
check lv_attr_bit type $vg/pvmove0 "p"
9 years, 3 months
master - lvm: recognize LVM_COMMAND_PROFILE env var for default command profile to use in LVM commands
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b6f558adcc3b08...
Commit: b6f558adcc3b08cb627aca0a0cddbe65bdd19052
Parent: 4e4ea46cfee9afcfc9a48eb60925177890c5ec31
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 9 14:16:24 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 9 14:16:30 2015 +0100
lvm: recognize LVM_COMMAND_PROFILE env var for default command profile to use in LVM commands
Once LVM_COMMAND_PROFILE environment variable is specified, the profile
referenced is used just like it was specified using "<lvm command> --commandprofile".
If both --commandprofile cmd line option and LVM_COMMAND_PROFILE env
var is used, the --commandprofile cmd line option gets preference.
---
WHATS_NEW | 1 +
man/lvm.8.in | 8 ++++++-
tools/lvmcmdline.c | 53 ++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 53 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cd4abfe..6488f44 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
+ Add LVM_COMMAND_PROFILE env var to set default command profile name to use.
set CLOEXEC flag on file descriptors originating in libdaemon
Version 2.02.116 - 30th January 2015
diff --git a/man/lvm.8.in b/man/lvm.8.in
index 5347e94..f87729e 100644
--- a/man/lvm.8.in
+++ b/man/lvm.8.in
@@ -291,7 +291,9 @@ placing two stripes on the same Physical Volume.
.IR \fB\-\-commandprofile " " \fIProfileName
Selects the command configuration profile to use when processing an LVM command.
See also \fBlvm.conf\fP(5) for more information about \fBcommand profile config\fP and
-the way it fits with other LVM configuration methods.
+the way it fits with other LVM configuration methods. Using \fB\-\-commandprofile\fP
+option overrides any command profile specified via \fBLVM_COMMAND_PROFILE\fP
+environment variable.
.TP
.IR \fB\-\-metadataprofile " " \fIProfileName
Selects the metadata configuration profile to use when processing an LVM command.
@@ -480,6 +482,10 @@ All tools return a status code of zero on success or non-zero on failure.
Directory containing \fI.lvm_history\fP if the internal readline
shell is invoked.
.TP
+.B LVM_COMMAND_PROFILE
+Name of default command profile to use for LVM commands. This profile
+is overriden by direct use of \fB\-\-commandprofile\fP command line option.
+.TP
.B LVM_SYSTEM_DIR
Directory containing \fBlvm.conf\fP(5) and other LVM system files.
Defaults to "#DEFAULT_SYS_DIR#".
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 6149dbc..1cdc293 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1232,17 +1232,39 @@ static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **
static int _prepare_profiles(struct cmd_context *cmd)
{
+ static const char COMMAND_PROFILE_ENV_VAR_NAME[] = "LVM_COMMAND_PROFILE";
+ static const char _cmd_profile_arg_preferred_over_env_var_msg[] = "Giving "
+ "preference to command profile specified on command "
+ "line over the one specified via environment variable.";
static const char _failed_to_add_profile_msg[] = "Failed to add %s %s.";
static const char _failed_to_apply_profile_msg[] = "Failed to apply %s %s.";
static const char _command_profile_source_name[] = "command profile";
static const char _metadata_profile_source_name[] = "metadata profile";
static const char _setting_global_profile_msg[] = "Setting global %s \"%s\".";
+ const char *env_cmd_profile_name = NULL;
const char *name;
struct profile *profile;
config_source_t source;
const char *source_name;
+ /* Check whether default global command profile is set via env. var. */
+ if ((env_cmd_profile_name = getenv(COMMAND_PROFILE_ENV_VAR_NAME))) {
+ if (!*env_cmd_profile_name)
+ env_cmd_profile_name = NULL;
+ else
+ log_debug("Command profile '%s' requested via "
+ "environment variable.",
+ env_cmd_profile_name);
+ }
+
+ if (!arg_count(cmd, profile_ARG) &&
+ !arg_count(cmd, commandprofile_ARG) &&
+ !arg_count(cmd, metadataprofile_ARG) &&
+ !env_cmd_profile_name)
+ /* nothing to do */
+ return 1;
+
if (arg_count(cmd, profile_ARG)) {
/*
* If --profile is used with dumpconfig, it's used
@@ -1274,6 +1296,15 @@ static int _prepare_profiles(struct cmd_context *cmd)
"--commandprofile allowed.");
return 0;
}
+ /*
+ * Prefer command profile specified on command
+ * line over the profile specified via
+ * COMMAND_PROFILE_ENV_VAR_NAME env. var.
+ */
+ if (env_cmd_profile_name) {
+ log_debug(_cmd_profile_arg_preferred_over_env_var_msg);
+ env_cmd_profile_name = NULL;
+ }
source = CONFIG_PROFILE_COMMAND;
source_name = _command_profile_source_name;
}
@@ -1301,8 +1332,18 @@ static int _prepare_profiles(struct cmd_context *cmd)
}
- if (arg_count(cmd, commandprofile_ARG)) {
- name = arg_str_value(cmd, commandprofile_ARG, NULL);
+ if (arg_count(cmd, commandprofile_ARG) || env_cmd_profile_name) {
+ if (arg_count(cmd, commandprofile_ARG)) {
+ /*
+ * Prefer command profile specified on command
+ * line over the profile specified via
+ * COMMAND_PROFILE_ENV_VAR_NAME env. var.
+ */
+ if (env_cmd_profile_name)
+ log_debug(_cmd_profile_arg_preferred_over_env_var_msg);
+ name = arg_str_value(cmd, commandprofile_ARG, NULL);
+ } else
+ name = env_cmd_profile_name;
source_name = _command_profile_source_name;
if (!(profile = add_profile(cmd, name, CONFIG_PROFILE_COMMAND))) {
@@ -1394,12 +1435,8 @@ int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
}
}
- if (arg_count(cmd, profile_ARG) ||
- arg_count(cmd, commandprofile_ARG) ||
- arg_count(cmd, metadataprofile_ARG)) {
- if (!_prepare_profiles(cmd))
- return_ECMD_FAILED;
- }
+ if (!_prepare_profiles(cmd))
+ return_ECMD_FAILED;
if (arg_count(cmd, readonly_ARG))
cmd->metadata_read_only = 1;
9 years, 3 months
master - reporter: properly check for _do_info_and_status return value and free the mempool if created within the fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4e4ea46cfee9af...
Commit: 4e4ea46cfee9afcfc9a48eb60925177890c5ec31
Parent: 4065741a672d97f1c6b158ad781bc486c38e7c0a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 9 11:48:21 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 9 11:48:21 2015 +0100
reporter: properly check for _do_info_and_status return value and free the mempool if created within the fn
---
tools/reporter.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 7c481be..20fa4ab 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -92,10 +92,8 @@ static int _do_lvs_with_info_and_status_single(struct cmd_context *cmd,
};
int r = ECMD_FAILED;
- if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status)) {
- stack;
- return r;
- }
+ if (!_do_info_and_status(cmd, lv, NULL, &status, do_info, do_status))
+ goto_out;
if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL,
&status, NULL))
@@ -143,10 +141,8 @@ static int _do_segs_with_info_and_status_single(struct cmd_context *cmd,
};
int r = ECMD_FAILED;
- if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status)) {
- stack;
- return r;
- }
+ if (!_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
+ goto_out;
if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL,
&status, NULL))
@@ -268,8 +264,8 @@ static int _do_pvsegs_sub_single(struct cmd_context *cmd,
.lv = &_free_logical_volume
};
- if (seg)
- _do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status);
+ if (seg && !_do_info_and_status(cmd, seg->lv, seg, &status, do_info, do_status))
+ goto_out;
if (!report_object(handle, vg, seg ? seg->lv : &_free_logical_volume, pvseg->pv,
seg ? : &_free_lv_segment, pvseg, &status,
9 years, 3 months
master - configure: Fix a warning about test/Makefile.in.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4065741a672d97...
Commit: 4065741a672d97f1c6b158ad781bc486c38e7c0a
Parent: 43d6b44a9fac5809bf73a88a7a6a106e302b4fe4
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Feb 5 16:30:50 2015 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 16:30:50 2015 +0100
configure: Fix a warning about test/Makefile.in.
---
test/Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.in b/test/Makefile.in
index e0652e1..9e8e484 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -23,6 +23,7 @@ abs_srcdir = @abs_srcdir@
abs_builddir = @abs_builddir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
+datarootdir = @datarootdir@
LVM_TEST_RESULTS ?= results
export LVM_TEST_THIN_CHECK_CMD?=@THIN_CHECK_CMD@
9 years, 3 months
master - NIX: Request {fedora, centos}-release packages explicitly.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=43d6b44a9fac58...
Commit: 43d6b44a9fac5809bf73a88a7a6a106e302b4fe4
Parent: b9a017d94cb5ad432c51df861242f42cc4f01ba3
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Thu Feb 5 14:21:31 2015 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 14:21:31 2015 +0100
NIX: Request {fedora,centos}-release packages explicitly.
---
nix/default.nix | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index f9f025f..0a45bab 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -207,8 +207,7 @@ let
};
urlPrefix = centos_url version arch;
archs = ["noarch" arch] ++ (if eqStrings arch "i386" then ["i586" "i686"] else []);
- packages = filter (n: !(eqStrings n "fedora-release")) pkgs.vmTools.commonFedoraPackages ++
- [ "centos-release" ];
+ packages = [ "centos-release" ] ++ pkgs.vmTools.commonFedoraPackages;
};
fedora = { version, sha, arch }: rec {
name = "fedora-${version}-${arch}";
@@ -219,7 +218,7 @@ let
};
urlPrefix = fedora_url version arch;
archs = ["noarch" arch] ++ (if eqStrings arch "i386" then ["i586" "i686"] else []);
- packages = pkgs.vmTools.commonFedoraPackages;
+ packages = [ "fedora-release" ] ++ pkgs.vmTools.commonFedoraPackages;
unifiedSystemDir = true;
};
rawhide = version: arch: repodata: import (pkgs.runCommand "rawhide-${version}-${arch}.nix" {} ''
9 years, 3 months