master - toollib: add 'parent' field to processing_handle; init report format only if there's no parent
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f752a953022387...
Commit: f752a953022387cc7e5c4da11d118c12e3716ce4
Parent: c099f531fbb1702ea0aed16e5deec0368e7e7250
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 31 12:24:05 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
toollib: add 'parent' field to processing_handle; init report format only if there's no parent
If there's parent processing handle, we don't need to create completely
new report group and status report - we'll just reuse the one already
initialized for the parent.
Currently, the situation where this matter is when doing internal report
to do the selection for processing commands where we have parent processing
handle for the command itself and processing handle for the selection
part (that is selection for non-reporting tools).
---
tools/lvconvert.c | 2 +-
tools/lvcreate.c | 2 +-
tools/lvrename.c | 2 +-
tools/lvresize.c | 2 +-
tools/polldaemon.c | 4 ++--
tools/pvchange.c | 2 +-
tools/pvcreate.c | 2 +-
tools/pvmove.c | 2 +-
tools/pvremove.c | 2 +-
tools/pvresize.c | 2 +-
tools/pvscan.c | 4 ++--
tools/reporter.c | 4 ++--
tools/toollib.c | 22 +++++++++++++---------
tools/toollib.h | 3 ++-
tools/vgcfgbackup.c | 2 +-
tools/vgcreate.c | 2 +-
tools/vgextend.c | 2 +-
tools/vgreduce.c | 2 +-
tools/vgrename.c | 2 +-
19 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index a4e7023..a711c31 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3499,7 +3499,7 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
.target_attr = ~0,
.idls = DM_LIST_HEAD_INIT(lp.idls),
};
- struct processing_handle *handle = init_processing_handle(cmd);
+ struct processing_handle *handle = init_processing_handle(cmd, NULL);
if (!handle) {
log_error("Failed to initialize processing handle.");
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b1bf1af..fb28dc5 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1557,7 +1557,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
pp.lp = &lp;
pp.lcp = &lcp;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/lvrename.c b/tools/lvrename.c
index e9dd061..4dfcda2 100644
--- a/tools/lvrename.c
+++ b/tools/lvrename.c
@@ -210,7 +210,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
if (!(lp.lv_name_new = dm_pool_strdup(cmd->mem, lv_name_new)))
return ECMD_FAILED;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 7a86178..05e386f 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -216,7 +216,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index f8aa49c..e12a694 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -561,7 +561,7 @@ static int _lvmpoll_daemon(struct cmd_context *cmd, struct poll_operation_id *id
return r ? ECMD_PROCESSED : ECMD_FAILED;
} else {
/* process all in-flight operations */
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
} else {
@@ -614,7 +614,7 @@ static int _poll_daemon(struct cmd_context *cmd, struct poll_operation_id *id,
} else {
if (!parms->interval)
parms->interval = find_config_tree_int(cmd, activation_polling_interval_CFG, NULL);
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
} else {
diff --git a/tools/pvchange.c b/tools/pvchange.c
index e100b80..ed99e7c 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -216,7 +216,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
goto out;
}
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
goto out;
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 77f5969..ae133fa 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -147,7 +147,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
cmd->lockd_gl_disable = 1;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/pvmove.c b/tools/pvmove.c
index b5df45a..f5f5654 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -877,7 +877,7 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
if (is_abort)
cmd->lockd_vg_default_sh = 1;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/pvremove.c b/tools/pvremove.c
index dd9a4e8..e262eb0 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -43,7 +43,7 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
cmd->lockd_gl_disable = 1;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 9931cc6..ddff520 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -86,7 +86,7 @@ int pvresize(struct cmd_context *cmd, int argc, char **argv)
set_pv_notify(cmd);
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
goto out;
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 9b50374..db678d1 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -273,7 +273,7 @@ static int _pvscan_autoactivate(struct cmd_context *cmd, struct pvscan_aa_params
if (!lvmetad_used())
log_warn("WARNING: Autoactivation reading from disk instead of lvmetad.");
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
@@ -633,7 +633,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
ret = ECMD_FAILED;
goto out;
diff --git a/tools/reporter.c b/tools/reporter.c
index d8aac68..7bd5d36 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -581,7 +581,7 @@ int report_for_selection(struct cmd_context *cmd,
&sh->report_type))
return_0;
- if (!(handle = init_processing_handle(cmd)))
+ if (!(handle = init_processing_handle(cmd, parent_handle)))
return_0;
/*
@@ -832,7 +832,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args, struct
int lv_segment_status_needed;
int r = ECMD_FAILED;
- if (!(handle = init_processing_handle(cmd)))
+ if (!(handle = init_processing_handle(cmd, NULL)))
goto_out;
if (!(report_handle = report_init(cmd, single_args->options, single_args->keys, &report_type,
diff --git a/tools/toollib.c b/tools/toollib.c
index e091467..3b2ad6a 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1705,7 +1705,7 @@ static int _get_arg_vgnames(struct cmd_context *cmd,
return ret_max;
}
-struct processing_handle *init_processing_handle(struct cmd_context *cmd)
+struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct processing_handle *parent_handle)
{
struct processing_handle *handle;
@@ -1714,6 +1714,8 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)
return NULL;
}
+ handle->parent = parent_handle;
+
/*
* For any reporting tool, the internal_report_for_select is reset to 0
* automatically because the internal reporting/selection is simply not
@@ -1725,10 +1727,12 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)
handle->internal_report_for_select = arg_is_set(cmd, select_ARG);
handle->include_historical_lvs = cmd->include_historical_lvs;
- if (!report_format_init(cmd, &handle->report_group_type, &handle->report_group,
- &handle->log_rh)) {
- dm_pool_free(cmd->mem, handle);
- return NULL;
+ if (!parent_handle) {
+ if (!report_format_init(cmd, &handle->report_group_type, &handle->report_group,
+ &handle->log_rh)) {
+ dm_pool_free(cmd->mem, handle);
+ return NULL;
+ }
}
return handle;
@@ -2189,7 +2193,7 @@ int process_each_vg(struct cmd_context *cmd,
else
_choose_vgs_to_process(cmd, &arg_vgnames, &vgnameids_on_system, &vgnameids_to_process);
- if (!handle && !(handle = init_processing_handle(cmd))) {
+ if (!handle && !(handle = init_processing_handle(cmd, NULL))) {
ret_max = ECMD_FAILED;
goto_out;
}
@@ -2286,7 +2290,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (arg_lvnames && !dm_list_empty(arg_lvnames))
lvargs_supplied = 1;
- if (!handle && !(handle = init_processing_handle(cmd))) {
+ if (!handle && !(handle = init_processing_handle(cmd, NULL))) {
ret_max = ECMD_FAILED;
goto_out;
}
@@ -2747,7 +2751,7 @@ int process_each_lv(struct cmd_context *cmd,
goto_out;
}
- if (!handle && !(handle = init_processing_handle(cmd))) {
+ if (!handle && !(handle = init_processing_handle(cmd, NULL))) {
ret_max = ECMD_FAILED;
goto_out;
}
@@ -3168,7 +3172,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
int ret_max = ECMD_PROCESSED;
int ret = 0;
- if (!handle && (!(handle = init_processing_handle(cmd)))) {
+ if (!handle && (!(handle = init_processing_handle(cmd, NULL)))) {
ret_max = ECMD_FAILED;
goto_out;
}
diff --git a/tools/toollib.h b/tools/toollib.h
index 622badc..8cd9087 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -69,6 +69,7 @@ int become_daemon(struct cmd_context *cmd, int skip_lvm);
* a part of that reporting for display (dm_report_object).
*/
struct processing_handle {
+ struct processing_handle *parent;
int internal_report_for_select;
int include_historical_lvs;
struct selection_handle *selection_handle;
@@ -144,7 +145,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
int stop_on_error, struct processing_handle *handle,
process_single_lv_fn_t process_single_lv);
-struct processing_handle *init_processing_handle(struct cmd_context *cmd);
+struct processing_handle *init_processing_handle(struct cmd_context *cmd, struct processing_handle *parent_handle);
int init_selection_handle(struct cmd_context *cmd, struct processing_handle *handle,
report_type_t initial_report_type);
void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle *handle);
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index 554317e..c47c1ef 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -85,7 +85,7 @@ int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
char *last_filename = NULL;
struct processing_handle *handle = NULL;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index 3811583..974d7e7 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -92,7 +92,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
*/
unlock_vg(cmd, vp_new.vg_name);
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 24b51cf..8f44672 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -169,7 +169,7 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
cmd->lockd_gl_disable = 1;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 3176a0e..ae86a67 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -222,7 +222,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
return_ECMD_FAILED;
cmd->lockd_gl_disable = 1;
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
diff --git a/tools/vgrename.c b/tools/vgrename.c
index ee6a91f..3dceeab 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -237,7 +237,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
}
}
- if (!(handle = init_processing_handle(cmd))) {
+ if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
7 years, 10 months
master - toollib: add report_group and log_rh to processing_handle and initialize cmd processing log report
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c099f531fbb170...
Commit: c099f531fbb1702ea0aed16e5deec0368e7e7250
Parent: 213434d426622b34f2fd7bc2e74f6e5ca0c6c125
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 23 10:16:29 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
toollib: add report_group and log_rh to processing_handle and initialize cmd processing log report
Wire up report group creation with log report in struct
processing_handle and call report_format_init during processing handle
initialization (init_processing_handle fn) and destroy it while
destroing processing handle (destroy_processing_handle fn).
This way, all the LVM command processing using processing handle
has access to log report via which the current command log
can be reported as items are processed.
---
WHATS_NEW | 1 +
tools/toollib.c | 10 ++++++++++
tools/toollib.h | 3 +++
3 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ebddfd0..349bd30 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Integrate report group handling and cmd log report into cmd processing code.
Add log/report_command_log to lvm.conf to enable or disable cmd log report.
Add log/report_output_format to lvm.conf for default report output format.
Recognize --reportformat {basic|json} option to select report output format.
diff --git a/tools/toollib.c b/tools/toollib.c
index 9353814..e091467 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1725,6 +1725,12 @@ struct processing_handle *init_processing_handle(struct cmd_context *cmd)
handle->internal_report_for_select = arg_is_set(cmd, select_ARG);
handle->include_historical_lvs = cmd->include_historical_lvs;
+ if (!report_format_init(cmd, &handle->report_group_type, &handle->report_group,
+ &handle->log_rh)) {
+ dm_pool_free(cmd->mem, handle);
+ return NULL;
+ }
+
return handle;
}
@@ -1754,6 +1760,10 @@ void destroy_processing_handle(struct cmd_context *cmd, struct processing_handle
if (handle) {
if (handle->selection_handle && handle->selection_handle->selection_rh)
dm_report_free(handle->selection_handle->selection_rh);
+ if (!dm_report_group_destroy(handle->report_group))
+ stack;
+ if (handle->log_rh)
+ dm_report_free(handle->log_rh);
/*
* TODO: think about better alternatives:
* handle mempool, dm_alloc for handle memory...
diff --git a/tools/toollib.h b/tools/toollib.h
index 06d0ef9..622badc 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -72,6 +72,9 @@ struct processing_handle {
int internal_report_for_select;
int include_historical_lvs;
struct selection_handle *selection_handle;
+ dm_report_group_type_t report_group_type;
+ struct dm_report_group *report_group;
+ struct dm_report *log_rh;
void *custom_handle;
};
7 years, 10 months
master - report: separate common report and per-report args
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=213434d426622b...
Commit: 213434d426622b34f2fd7bc2e74f6e5ca0c6c125
Parent: bd0a0ae36b89c3a4ea9f84bfa519e363bc7e407c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed May 25 13:41:42 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
report: separate common report and per-report args
Separating common report and per-report arguments prepares the code for
handling several reports per one command (for example, the command log
report and LVM command report itself).
Each report can have sort keys, options (fields), list of fields to
compact and selection criteria set individually. Hooks for setting these
per report within one command will be a part of subsequent patches, this
patch only separates new struct single_report_args out of existing
struct report_args.
---
tools/reporter.c | 177 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 110 insertions(+), 67 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index a4595f7..d8aac68 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -17,23 +17,36 @@
#include "report.h"
+typedef enum {
+ REPORT_IDX_NULL = -1,
+ REPORT_IDX_SINGLE,
+ REPORT_IDX_LOG,
+ REPORT_IDX_COUNT
+} report_idx_t;
+
+struct single_report_args {
+ report_type_t report_type;
+ int args_are_pvs;
+ const char *keys;
+ const char *options;
+ const char *fields_to_compact;
+ const char *selection;
+};
+
+/* TODO: configure these common report args only once per cmd */
struct report_args {
int argc;
char **argv;
dm_report_group_type_t report_group_type;
report_type_t report_type;
- int args_are_pvs;
int aligned;
int buffered;
int headings;
int field_prefixes;
int quoted;
int columns_as_rows;
- const char *keys;
- const char *options;
- const char *fields_to_compact;
const char *separator;
- const char *selection;
+ struct single_report_args single_args[REPORT_IDX_COUNT];
};
static int _process_each_devtype(struct cmd_context *cmd, int argc,
@@ -625,7 +638,7 @@ int report_for_selection(struct cmd_context *cmd,
return r;
}
-static void _check_pv_list(struct cmd_context *cmd, struct report_args *args)
+static void _check_pv_list(struct cmd_context *cmd, struct report_args *args, struct single_report_args *single_args)
{
unsigned i;
int rescan_done = 0;
@@ -633,11 +646,11 @@ static void _check_pv_list(struct cmd_context *cmd, struct report_args *args)
if (!args->argv)
return;
- args->args_are_pvs = (args->report_type == PVS ||
- args->report_type == LABEL ||
- args->report_type == PVSEGS) ? 1 : 0;
+ single_args->args_are_pvs = (single_args->report_type == PVS ||
+ single_args->report_type == LABEL ||
+ single_args->report_type == PVSEGS) ? 1 : 0;
- if (args->args_are_pvs && args->argc) {
+ if (single_args->args_are_pvs && args->argc) {
for (i = 0; i < args->argc; i++) {
if (!rescan_done && !dev_cache_get(args->argv[i], cmd->full_filter)) {
cmd->filter->wipe(cmd->filter);
@@ -650,8 +663,8 @@ static void _check_pv_list(struct cmd_context *cmd, struct report_args *args)
* Tags are metadata related, not label
* related, change report type accordingly!
*/
- if (args->report_type == LABEL)
- args->report_type = PVS;
+ if (single_args->report_type == LABEL)
+ single_args->report_type = PVS;
/*
* If we changed the report_type and we did rescan,
* no need to iterate over dev list further - nothing
@@ -701,9 +714,10 @@ static void _del_option_from_list(struct dm_list *sll, const char *prefix,
}
static int _get_report_options(struct cmd_context *cmd,
- struct report_args *args)
+ struct report_args *args,
+ struct single_report_args *single_args)
{
- const char *prefix = report_get_field_prefix(args->report_type);
+ const char *prefix = report_get_field_prefix(single_args->report_type);
size_t prefix_len = strlen(prefix);
struct arg_value_group_list *current_group;
struct dm_list *final_opts_list;
@@ -714,12 +728,15 @@ static int _get_report_options(struct cmd_context *cmd,
struct dm_pool *mem;
int r = ECMD_PROCESSED;
+ if (!arg_count(cmd, options_ARG))
+ return ECMD_PROCESSED;
+
if (!(mem = dm_pool_create("report_options", 128))) {
log_error("Failed to create temporary mempool to process report options.");
return ECMD_FAILED;
}
- if (!(final_opts_list = str_to_str_list(mem, args->options, ",", 1))) {
+ if (!(final_opts_list = str_to_str_list(mem, single_args->options, ",", 1))) {
r = ECMD_FAILED;
goto_out;
}
@@ -766,13 +783,13 @@ static int _get_report_options(struct cmd_context *cmd,
}
}
- if (!(args->options = str_list_to_str(cmd->mem, final_opts_list, ","))) {
+ if (!(single_args->options = str_list_to_str(cmd->mem, final_opts_list, ","))) {
r = ECMD_FAILED;
goto_out;
}
if (final_compact_list &&
- !(args->fields_to_compact = str_list_to_str(cmd->mem, final_compact_list, ","))) {
- dm_pool_free(cmd->mem, (char *) args->options);
+ !(single_args->fields_to_compact = str_list_to_str(cmd->mem, final_compact_list, ","))) {
+ dm_pool_free(cmd->mem, (char *) single_args->options);
r = ECMD_FAILED;
goto_out;
}
@@ -782,10 +799,33 @@ out:
return r;
}
-static int _do_report(struct cmd_context *cmd, struct report_args *args)
+static int _get_report_keys(struct cmd_context *cmd,
+ struct report_args *args,
+ struct single_report_args *single_args)
+{
+ int r = ECMD_PROCESSED;
+
+ single_args->keys = arg_str_value(cmd, sort_ARG, single_args->keys);
+
+ return r;
+}
+
+static int _get_report_selection(struct cmd_context *cmd,
+ struct report_args *args,
+ struct single_report_args *single_args)
+{
+ int r = ECMD_PROCESSED;
+
+ if (arg_count(cmd, select_ARG))
+ single_args->selection = arg_str_value(cmd, select_ARG, NULL);
+
+ return r;
+}
+
+static int _do_report(struct cmd_context *cmd, struct report_args *args, struct single_report_args *single_args)
{
struct processing_handle *handle = NULL;
- report_type_t report_type = args->report_type;
+ report_type_t report_type = single_args->report_type;
void *report_handle = NULL;
int lock_global = 0;
int lv_info_needed;
@@ -795,17 +835,17 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
if (!(handle = init_processing_handle(cmd)))
goto_out;
- if (!(report_handle = report_init(cmd, args->options, args->keys, &report_type,
+ if (!(report_handle = report_init(cmd, single_args->options, single_args->keys, &report_type,
args->separator, args->aligned, args->buffered,
args->headings, args->field_prefixes, args->quoted,
- args->columns_as_rows, args->selection)))
+ args->columns_as_rows, single_args->selection)))
goto_out;
handle->internal_report_for_select = 0;
handle->include_historical_lvs = cmd->include_historical_lvs;
handle->custom_handle = report_handle;
- if (!_get_final_report_type(args->args_are_pvs,
+ if (!_get_final_report_type(single_args->args_are_pvs,
report_type, &lv_info_needed,
&lv_segment_status_needed,
&report_type))
@@ -815,7 +855,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
* We lock VG_GLOBAL to enable use of metadata cache.
* This can pause alongide pvscan or vgscan process for a while.
*/
- if (args->args_are_pvs && (report_type == PVS || report_type == PVSEGS) &&
+ if (single_args->args_are_pvs && (report_type == PVS || report_type == PVSEGS) &&
!lvmetad_used()) {
lock_global = 1;
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_READ, NULL)) {
@@ -850,7 +890,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
handle, &_label_single);
break;
case PVS:
- if (args->args_are_pvs)
+ if (single_args->args_are_pvs)
r = process_each_pv(cmd, args->argc, args->argv, NULL,
arg_is_set(cmd, all_ARG), 0,
handle, &_pvs_single);
@@ -866,7 +906,7 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
&_lvsegs_single);
break;
case PVSEGS:
- if (args->args_are_pvs)
+ if (single_args->args_are_pvs)
r = process_each_pv(cmd, args->argc, args->argv, NULL,
arg_is_set(cmd, all_ARG), 0,
handle,
@@ -889,8 +929,8 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
if (find_config_tree_bool(cmd, report_compact_output_CFG, NULL)) {
if (!dm_report_compact_fields(report_handle))
log_error("Failed to compact report output.");
- } else if (args->fields_to_compact) {
- if (!dm_report_compact_given_fields(report_handle, args->fields_to_compact))
+ } else if (single_args->fields_to_compact) {
+ if (!dm_report_compact_given_fields(report_handle, single_args->fields_to_compact))
log_error("Failed to compact given columns in report output.");
}
@@ -906,7 +946,7 @@ out:
return r;
}
-static int _config_report(struct cmd_context *cmd, struct report_args *args)
+static int _config_report(struct cmd_context *cmd, struct report_args *args, struct single_report_args *single_args)
{
args->aligned = find_config_tree_bool(cmd, report_aligned_CFG, NULL);
args->buffered = find_config_tree_bool(cmd, report_buffered_CFG, NULL);
@@ -917,71 +957,73 @@ static int _config_report(struct cmd_context *cmd, struct report_args *args)
args->columns_as_rows = find_config_tree_bool(cmd, report_colums_as_rows_CFG, NULL);
/* Check PV specifics and do extra changes/actions if needed. */
- _check_pv_list(cmd, args);
+ _check_pv_list(cmd, args, single_args);
- switch (args->report_type) {
+ switch (single_args->report_type) {
case DEVTYPES:
- args->keys = find_config_tree_str(cmd, report_devtypes_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_devtypes_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_devtypes_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_devtypes_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_devtypes_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_devtypes_cols_verbose_CFG, NULL);
break;
case LVS:
- args->keys = find_config_tree_str(cmd, report_lvs_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_lvs_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_lvs_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_lvs_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_lvs_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_lvs_cols_verbose_CFG, NULL);
break;
case VGS:
- args->keys = find_config_tree_str(cmd, report_vgs_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_vgs_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_vgs_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_vgs_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_vgs_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_vgs_cols_verbose_CFG, NULL);
break;
case LABEL:
case PVS:
- args->keys = find_config_tree_str(cmd, report_pvs_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_pvs_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_pvs_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_pvs_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_pvs_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_pvs_cols_verbose_CFG, NULL);
break;
case SEGS:
- args->keys = find_config_tree_str(cmd, report_segs_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_segs_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_segs_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_segs_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_segs_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_segs_cols_verbose_CFG, NULL);
break;
case PVSEGS:
- args->keys = find_config_tree_str(cmd, report_pvsegs_sort_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, report_pvsegs_sort_CFG, NULL);
if (!arg_count(cmd, verbose_ARG))
- args->options = find_config_tree_str(cmd, report_pvsegs_cols_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_pvsegs_cols_CFG, NULL);
else
- args->options = find_config_tree_str(cmd, report_pvsegs_cols_verbose_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, report_pvsegs_cols_verbose_CFG, NULL);
break;
case CMDLOG:
- args->keys = find_config_tree_str(cmd, log_command_log_sort_CFG, NULL);
- args->options = find_config_tree_str(cmd, log_command_log_cols_CFG, NULL);
+ single_args->keys = find_config_tree_str(cmd, log_command_log_sort_CFG, NULL);
+ single_args->options = find_config_tree_str(cmd, log_command_log_cols_CFG, NULL);
break;
default:
log_error(INTERNAL_ERROR "_report: unknown report type.");
return 0;
}
+ single_args->fields_to_compact = find_config_tree_str_allow_empty(cmd, report_compact_output_cols_CFG, NULL);
+
/* If -o supplied use it, else use default for report_type */
- if (arg_count(cmd, options_ARG) &&
- (_get_report_options(cmd, args) != ECMD_PROCESSED))
+ if ((_get_report_options(cmd, args, single_args) != ECMD_PROCESSED))
return_0;
- if (!args->fields_to_compact)
- args->fields_to_compact = find_config_tree_str_allow_empty(cmd, report_compact_output_cols_CFG, NULL);
-
/* -O overrides default sort settings */
- args->keys = arg_str_value(cmd, sort_ARG, args->keys);
+ if ((_get_report_keys(cmd, args, single_args) != ECMD_PROCESSED))
+ return_0;
+
+ if ((_get_report_selection(cmd, args, single_args) != ECMD_PROCESSED))
+ return_0;
args->separator = arg_str_value(cmd, separator_ARG, args->separator);
if (arg_count(cmd, separator_ARG))
@@ -1001,15 +1043,13 @@ static int _config_report(struct cmd_context *cmd, struct report_args *args)
if (arg_count(cmd, rows_ARG))
args->columns_as_rows = 1;
- if (arg_count(cmd, select_ARG))
- args->selection = arg_str_value(cmd, select_ARG, NULL);
-
return 1;
}
static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type)
{
struct report_args args = {0};
+ struct single_report_args *single_args = &args.single_args[REPORT_IDX_SINGLE];
/*
* Include foreign VGs that contain active LVs.
@@ -1021,12 +1061,12 @@ static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t
args.argc = argc;
args.argv = argv;
- args.report_type = report_type;
+ single_args->report_type = report_type;
- if (!_config_report(cmd, &args))
+ if (!_config_report(cmd, &args, single_args))
return_ECMD_FAILED;
- return _do_report(cmd, &args);
+ return _do_report(cmd, &args, single_args);
}
int lvs(struct cmd_context *cmd, int argc, char **argv)
@@ -1075,6 +1115,7 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
const char *format_str = arg_str_value(cmd, reportformat_ARG, config_set ? config_format_str : NULL);
int report_command_log = find_config_tree_bool(cmd, log_report_command_log_CFG, NULL);
struct report_args args = {0};
+ struct single_report_args *single_args;
struct dm_report_group *new_report_group;
struct dm_report *tmp_log_rh = NULL;
@@ -1101,14 +1142,16 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
if (report_command_log) {
if (!*log_rh) {
- args.report_type = CMDLOG;
- if (!_config_report(cmd, &args))
+ single_args = &args.single_args[REPORT_IDX_LOG];
+ single_args->report_type = CMDLOG;
+
+ if (!_config_report(cmd, &args, single_args))
goto_bad;
- if (!(tmp_log_rh = report_init(NULL, args.options, args.keys, &args.report_type,
+ if (!(tmp_log_rh = report_init(NULL, single_args->options, single_args->keys, &single_args->report_type,
args.separator, args.aligned, args.buffered, args.headings,
args.field_prefixes, args.quoted, args.columns_as_rows,
- args.selection))) {
+ single_args->selection))) {
log_error("Failed to create log report.");
goto bad;
}
7 years, 10 months
master - conf: add log/report_command_log config setting
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bd0a0ae36b89c3...
Commit: bd0a0ae36b89c3a4ea9f84bfa519e363bc7e407c
Parent: a08e02afbf6c72854d1996c03348a104cbbdaadb
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jun 14 11:58:01 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
conf: add log/report_command_log config setting
---
WHATS_NEW | 1 +
conf/example.conf.in | 7 +++++++
lib/config/config_settings.h | 7 ++++++-
lib/config/defaults.h | 1 +
tools/reporter.c | 33 ++++++++++++++++++++-------------
5 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 23f947f..ebddfd0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Add log/report_command_log to lvm.conf to enable or disable cmd log report.
Add log/report_output_format to lvm.conf for default report output format.
Recognize --reportformat {basic|json} option to select report output format.
Add log/command_log_{sort,cols} to lvm.conf to configure command log report.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 8423442..69bb668 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -478,6 +478,13 @@ allocation {
# How LVM log information is reported.
log {
+ # Configuration option log/report_command_log.
+ # If enabled, LVM will collect log during command processing.
+ # After that the log is reported using current output format
+ # as defined by report/output_format setting.
+ # This configuration option has an automatic default value.
+ # report_command_log = 0
+
# Configuration option log/command_log_sort.
# List of columns to sort by when reporting command log.
# Possible fields are: log_seq_num, log_type, log_context, log_object_type,
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 8332c3f..09c9ab5 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -124,7 +124,7 @@ cfg_section(devices_CFG_SECTION, "devices", root_CFG_SECTION, 0, vsn(1, 0, 0), 0
cfg_section(allocation_CFG_SECTION, "allocation", root_CFG_SECTION, CFG_PROFILABLE, vsn(2, 2, 77), 0, NULL,
"How LVM selects space and applies properties to LVs.\n")
-cfg_section(log_CFG_SECTION, "log", root_CFG_SECTION, 0, vsn(1, 0, 0), 0, NULL,
+cfg_section(log_CFG_SECTION, "log", root_CFG_SECTION, CFG_PROFILABLE, vsn(1, 0, 0), 0, NULL,
"How LVM log information is reported.\n")
cfg_section(backup_CFG_SECTION, "backup", root_CFG_SECTION, 0, vsn(1, 0, 0), 0, NULL,
@@ -547,6 +547,11 @@ cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocat
cfg(allocation_physical_extent_size_CFG, "physical_extent_size", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_EXTENT_SIZE, vsn(2, 2, 112), NULL, 0, NULL,
"Default physical extent size in KiB to use for new VGs.\n")
+cfg(log_report_command_log_CFG, "report_command_log", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_COMMAND_LOG_REPORT, vsn(2, 2, 158), NULL, 0, NULL,
+ "If enabled, LVM will collect log during command processing.\n"
+ "After that the log is reported using current output format\n"
+ "as defined by report/output_format setting.\n")
+
cfg(log_command_log_sort_CFG, "command_log_sort", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMMAND_LOG_SORT, vsn(2, 2, 158), NULL, 0, NULL,
"List of columns to sort by when reporting command log.\n"
"Possible fields are: log_seq_num, log_type, log_context, log_object_type,\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index abb2525..ae8134f 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -160,6 +160,7 @@
# define DEFAULT_LOG_FACILITY LOG_USER
#endif
+#define DEFAULT_COMMAND_LOG_REPORT 0
#define DEFAULT_SYSLOG 1
#define DEFAULT_VERBOSE 0
#define DEFAULT_SILENT 0
diff --git a/tools/reporter.c b/tools/reporter.c
index 6bf00c0..a4595f7 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -1073,14 +1073,14 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
int config_set = find_config_tree_node(cmd, report_output_format_CFG, NULL) != NULL;
const char *config_format_str = find_config_tree_str(cmd, report_output_format_CFG, NULL);
const char *format_str = arg_str_value(cmd, reportformat_ARG, config_set ? config_format_str : NULL);
+ int report_command_log = find_config_tree_bool(cmd, log_report_command_log_CFG, NULL);
struct report_args args = {0};
struct dm_report_group *new_report_group;
struct dm_report *tmp_log_rh = NULL;
- if (!format_str) {
- args.report_group_type = DM_REPORT_GROUP_SINGLE;
- } else if (!strcmp(format_str, REPORT_FORMAT_NAME_BASIC)) {
- args.report_group_type = DM_REPORT_GROUP_BASIC;
+ if (!format_str || !strcmp(format_str, REPORT_FORMAT_NAME_BASIC)) {
+ args.report_group_type = report_command_log ? DM_REPORT_GROUP_BASIC
+ : DM_REPORT_GROUP_SINGLE;
} else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON)) {
args.report_group_type = DM_REPORT_GROUP_JSON;
} else {
@@ -1099,16 +1099,23 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
return 0;
}
- if (!*log_rh) {
- args.report_type = CMDLOG;
- if (!_config_report(cmd, &args))
- goto_bad;
+ if (report_command_log) {
+ if (!*log_rh) {
+ args.report_type = CMDLOG;
+ if (!_config_report(cmd, &args))
+ goto_bad;
+
+ if (!(tmp_log_rh = report_init(NULL, args.options, args.keys, &args.report_type,
+ args.separator, args.aligned, args.buffered, args.headings,
+ args.field_prefixes, args.quoted, args.columns_as_rows,
+ args.selection))) {
+ log_error("Failed to create log report.");
+ goto bad;
+ }
+ }
- if (!(tmp_log_rh = report_init(NULL, args.options, args.keys, &args.report_type,
- args.separator, args.aligned, args.buffered, args.headings,
- args.field_prefixes, args.quoted, args.columns_as_rows,
- args.selection))) {
- log_error("Failed to create log report.");
+ if (!(dm_report_group_push(new_report_group, *log_rh ? : tmp_log_rh, log_report_name))) {
+ log_error("Failed to add log report to report group.");
goto bad;
}
}
7 years, 10 months
master - conf: add report/output_format config setting
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a08e02afbf6c72...
Commit: a08e02afbf6c72854d1996c03348a104cbbdaadb
Parent: 79a74e9aaecee0b02cfd83f544a99870f29e0016
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 24 12:05:42 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
conf: add report/output_format config setting
New report/output_format configuration sets the output format used
for all LVM commands globally. Currently, there are 2 formats
recognized:
- basic (the classical basic output with columns and rows, used by default)
- json (output is in json format)
---
WHATS_NEW | 1 +
conf/example.conf.in | 10 ++++++++++
lib/config/config_settings.h | 8 ++++++++
lib/config/defaults.h | 1 +
tools/reporter.c | 4 +++-
5 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 90ae561..23f947f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Add log/report_output_format to lvm.conf for default report output format.
Recognize --reportformat {basic|json} option to select report output format.
Add log/command_log_{sort,cols} to lvm.conf to configure command log report.
Add log_object_{type,name,id,group,group_id} fields to cmd log.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index f5b4c4a..8423442 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1567,6 +1567,16 @@ activation {
# This configuration section has an automatic default value.
# report {
+ # Configuration option report/output_format.
+ # Format of LVM2 command report output.
+ # Accepted values:
+ # basic
+ # Original format with columns and rows.
+ # json
+ # JSON format.
+ # This configuration option has an automatic default value.
+ # output_format = "basic"
+
# Configuration option report/compact_output.
# Do not print empty values for all report fields.
# If enabled, all fields that don't have a value set for any of the
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 014f9b1..8332c3f 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1474,6 +1474,14 @@ cfg(disk_area_start_sector_CFG, "start_sector", disk_area_CFG_SUBSECTION, CFG_UN
cfg(disk_area_size_CFG, "size", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, 0, vsn(1, 0, 0), NULL, 0, NULL, NULL)
cfg(disk_area_id_CFG, "id", disk_area_CFG_SUBSECTION, CFG_UNSUPPORTED | CFG_DEFAULT_UNDEFINED, CFG_TYPE_STRING, NULL, vsn(1, 0, 0), NULL, 0, NULL, NULL)
+cfg(report_output_format_CFG, "output_format", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_REP_OUTPUT_FORMAT, vsn(2, 2, 158), NULL, 0, NULL,
+ "Format of LVM2 command report output.\n"
+ "Accepted values:\n"
+ " basic\n"
+ " Original format with columns and rows.\n"
+ " json\n"
+ " JSON format.\n")
+
cfg(report_compact_output_CFG, "compact_output", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_REP_COMPACT_OUTPUT, vsn(2, 2, 115), NULL, 0, NULL,
"Do not print empty values for all report fields.\n"
"If enabled, all fields that don't have a value set for any of the\n"
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 82e3716..abb2525 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -207,6 +207,7 @@
#define DEFAULT_REP_LIST_ITEM_SEPARATOR ","
#define DEFAULT_TIME_FORMAT "%Y-%m-%d %T %z"
+#define DEFAULT_REP_OUTPUT_FORMAT "basic"
#define DEFAULT_COMPACT_OUTPUT_COLS ""
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,pool_lv,origin,data_percent,metadata_percent,move_pv,mirror_log,copy_percent,convert_lv"
diff --git a/tools/reporter.c b/tools/reporter.c
index fa66064..6bf00c0 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -1070,7 +1070,9 @@ int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_g
struct dm_report_group **report_group, struct dm_report **log_rh)
{
static char log_report_name[] = "log";
- const char *format_str = arg_str_value(cmd, reportformat_ARG, NULL);
+ int config_set = find_config_tree_node(cmd, report_output_format_CFG, NULL) != NULL;
+ const char *config_format_str = find_config_tree_str(cmd, report_output_format_CFG, NULL);
+ const char *format_str = arg_str_value(cmd, reportformat_ARG, config_set ? config_format_str : NULL);
struct report_args args = {0};
struct dm_report_group *new_report_group;
struct dm_report *tmp_log_rh = NULL;
7 years, 10 months
master - toollib: add report_format_init fn to create report group and to create/add log report handle
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79a74e9aaecee0...
Commit: 79a74e9aaecee0b02cfd83f544a99870f29e0016
Parent: c36d4632a697f6e8f68a214a7c7db9f6fb25c09c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 2 14:22:02 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:41 2016 +0200
toollib: add report_format_init fn to create report group and to create/add log report handle
Add new --reportformat option and new report_format_init function that
checks this option and creates new report group accordingly, also
preparing log report handle and adding it to the report group just
created.
---
WHATS_NEW | 1 +
lib/report/report.h | 3 ++
tools/args.h | 1 +
tools/reporter.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 1e80d82..90ae561 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Recognize --reportformat {basic|json} option to select report output format.
Add log/command_log_{sort,cols} to lvm.conf to configure command log report.
Add log_object_{type,name,id,group,group_id} fields to cmd log.
Add log_{seq_num,type,context,message,errno,ret_code} fields to cmd log.
diff --git a/lib/report/report.h b/lib/report/report.h
index 06ffe70..62c52dc 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -80,6 +80,9 @@ struct processing_handle;
typedef int (*field_report_fn) (struct report_handle * dh, struct field * field,
const void *data);
+int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_group_type,
+ struct dm_report_group **report_group, struct dm_report **log_rh);
+
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,
diff --git a/tools/args.h b/tools/args.h
index ef9dbc9..049ea5a 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -96,6 +96,7 @@ arg(refresh_ARG, '\0', "refresh", NULL, 0)
arg(removemissing_ARG, '\0', "removemissing", NULL, 0)
arg(repair_ARG, '\0', "repair", NULL, 0)
arg(replace_ARG, '\0', "replace", string_arg, ARG_GROUPABLE)
+arg(reportformat_ARG, '\0', "reportformat", string_arg, 0)
arg(restorefile_ARG, '\0', "restorefile", string_arg, 0)
arg(restoremissing_ARG, '\0', "restoremissing", NULL, 0)
arg(resync_ARG, '\0', "resync", NULL, 0)
diff --git a/tools/reporter.c b/tools/reporter.c
index 4714ae1..fa66064 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -20,6 +20,7 @@
struct report_args {
int argc;
char **argv;
+ dm_report_group_type_t report_group_type;
report_type_t report_type;
int args_are_pvs;
int aligned;
@@ -1061,3 +1062,68 @@ int devtypes(struct cmd_context *cmd, int argc, char **argv)
{
return _report(cmd, argc, argv, DEVTYPES);
}
+
+#define REPORT_FORMAT_NAME_BASIC "basic"
+#define REPORT_FORMAT_NAME_JSON "json"
+
+int report_format_init(struct cmd_context *cmd, dm_report_group_type_t *report_group_type,
+ struct dm_report_group **report_group, struct dm_report **log_rh)
+{
+ static char log_report_name[] = "log";
+ const char *format_str = arg_str_value(cmd, reportformat_ARG, NULL);
+ struct report_args args = {0};
+ struct dm_report_group *new_report_group;
+ struct dm_report *tmp_log_rh = NULL;
+
+ if (!format_str) {
+ args.report_group_type = DM_REPORT_GROUP_SINGLE;
+ } else if (!strcmp(format_str, REPORT_FORMAT_NAME_BASIC)) {
+ args.report_group_type = DM_REPORT_GROUP_BASIC;
+ } else if (!strcmp(format_str, REPORT_FORMAT_NAME_JSON)) {
+ args.report_group_type = DM_REPORT_GROUP_JSON;
+ } else {
+ log_error("%s: unknown report format.", format_str);
+ log_error("Supported report formats: %s, %s.",
+ REPORT_FORMAT_NAME_BASIC,
+ REPORT_FORMAT_NAME_JSON);
+ return 0;
+ }
+
+ if (report_group_type)
+ *report_group_type = args.report_group_type;
+
+ if (!(new_report_group = dm_report_group_create(args.report_group_type, NULL))) {
+ log_error("Failed to create report group.");
+ return 0;
+ }
+
+ if (!*log_rh) {
+ args.report_type = CMDLOG;
+ if (!_config_report(cmd, &args))
+ goto_bad;
+
+ if (!(tmp_log_rh = report_init(NULL, args.options, args.keys, &args.report_type,
+ args.separator, args.aligned, args.buffered, args.headings,
+ args.field_prefixes, args.quoted, args.columns_as_rows,
+ args.selection))) {
+ log_error("Failed to create log report.");
+ goto bad;
+ }
+ }
+
+ if (!(dm_report_group_push(new_report_group, tmp_log_rh ? : *log_rh, log_report_name))) {
+ log_error("Failed to add log report to report group.");
+ goto bad;
+ }
+
+ *report_group = new_report_group;
+ if (tmp_log_rh)
+ *log_rh = tmp_log_rh;
+ return 1;
+bad:
+ if (!dm_report_group_destroy(new_report_group))
+ stack;
+ if (tmp_log_rh)
+ dm_report_free(tmp_log_rh);
+ return 0;
+}
7 years, 10 months
master - conf: add log/command_log_{sort,cols} config settings
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c36d4632a697f6...
Commit: c36d4632a697f6e8f68a214a7c7db9f6fb25c09c
Parent: 99c2a2b960d24d4826e3e66b4879de4bad13fbab
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jun 14 13:10:29 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:40 2016 +0200
conf: add log/command_log_{sort,cols} config settings
---
WHATS_NEW | 1 +
conf/example.conf.in | 16 ++++++++++++++++
lib/config/config_settings.h | 12 ++++++++++++
tools/reporter.c | 4 ++--
4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2c360cb..1e80d82 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Add log/command_log_{sort,cols} to lvm.conf to configure command log report.
Add log_object_{type,name,id,group,group_id} fields to cmd log.
Add log_{seq_num,type,context,message,errno,ret_code} fields to cmd log.
Add CMDLOG report type - a separate report type for command logging.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index c34481e..f5b4c4a 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -478,6 +478,22 @@ allocation {
# How LVM log information is reported.
log {
+ # Configuration option log/command_log_sort.
+ # List of columns to sort by when reporting command log.
+ # Possible fields are: log_seq_num, log_type, log_context, log_object_type,
+ # log_object_name, log_object_id, log_object_group, log_object_group_id,
+ # log_message, log_errno, log_ret_code.
+ # This configuration option has an automatic default value.
+ # command_log_sort = "log_seq_num"
+
+ # Configuration option log/command_log_cols.
+ # List of columns to report when reporting command log.
+ # Possible fields are: log_seq_num, log_type, log_context, log_object_type,
+ # log_object_name, log_object_id, log_object_group, log_object_group_id,
+ # log_message, log_errno, log_ret_code.
+ # This configuration option has an automatic default value.
+ # command_log_cols = "log_seq_num,log_type,log_context,log_object_type,log_object_name,log_object_id,log_object_group,log_object_group_id,log_message,log_errno,log_ret_code"
+
# Configuration option log/verbose.
# Controls the messages sent to stdout or stderr.
verbose = 0
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 0955d0a..014f9b1 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -547,6 +547,18 @@ cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocat
cfg(allocation_physical_extent_size_CFG, "physical_extent_size", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_EXTENT_SIZE, vsn(2, 2, 112), NULL, 0, NULL,
"Default physical extent size in KiB to use for new VGs.\n")
+cfg(log_command_log_sort_CFG, "command_log_sort", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMMAND_LOG_SORT, vsn(2, 2, 158), NULL, 0, NULL,
+ "List of columns to sort by when reporting command log.\n"
+ "Possible fields are: log_seq_num, log_type, log_context, log_object_type,\n"
+ "log_object_name, log_object_id, log_object_group, log_object_group_id,\n"
+ "log_message, log_errno, log_ret_code.\n")
+
+cfg(log_command_log_cols_CFG, "command_log_cols", log_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_COMMAND_LOG_COLS, vsn(2, 2, 158), NULL, 0, NULL,
+ "List of columns to report when reporting command log.\n"
+ "Possible fields are: log_seq_num, log_type, log_context, log_object_type,\n"
+ "log_object_name, log_object_id, log_object_group, log_object_group_id,\n"
+ "log_message, log_errno, log_ret_code.\n")
+
cfg(log_verbose_CFG, "verbose", log_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_VERBOSE, vsn(1, 0, 0), NULL, 0, NULL,
"Controls the messages sent to stdout or stderr.\n")
diff --git a/tools/reporter.c b/tools/reporter.c
index 6ba1b5b..4714ae1 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -963,8 +963,8 @@ static int _config_report(struct cmd_context *cmd, struct report_args *args)
args->options = find_config_tree_str(cmd, report_pvsegs_cols_verbose_CFG, NULL);
break;
case CMDLOG:
- args->keys = DEFAULT_COMMAND_LOG_SORT;
- args->options = DEFAULT_COMMAND_LOG_COLS;
+ args->keys = find_config_tree_str(cmd, log_command_log_sort_CFG, NULL);
+ args->options = find_config_tree_str(cmd, log_command_log_cols_CFG, NULL);
break;
default:
log_error(INTERNAL_ERROR "_report: unknown report type.");
7 years, 10 months
master - report: add CMDLOG report type
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=99c2a2b960d24d...
Commit: 99c2a2b960d24d4826e3e66b4879de4bad13fbab
Parent: 094fce37765964a9c3b32d1473e75c7d121eace1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue May 10 15:15:48 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 11:33:08 2016 +0200
report: add CMDLOG report type
This is a preparation for new CMDLOG report type which is going to be
used for reporting LVM command log.
The new report type introduces several new fields (log_seq_num, log_type,
log_context, log_object_type, log_object_group, log_object_id, object_name,
log_message, log_errno, log_ret_code) as well as new configuration settings
to set this report type (report/command_log_sort and report/command_log_cols
lvm.conf settings).
This patch also introduces internal report_cmdlog helper function
which is a wrapper over dm_report_object to report command log via
CMDLOG report type and which is going to be used throughout the code
to report the log items.
---
WHATS_NEW | 3 ++
lib/config/defaults.h | 2 +
lib/report/columns-cmdlog.h | 40 ++++++++++++++++++++++++++++++++++
lib/report/report.c | 50 ++++++++++++++++++++++++++++++++++++++++--
lib/report/report.h | 40 +++++++++++++++++++++++++--------
tools/reporter.c | 7 ++++++
6 files changed, 129 insertions(+), 13 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c91e28d..2c360cb 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,8 @@
Version 2.02.158 -
=================================
+ Add log_object_{type,name,id,group,group_id} fields to cmd log.
+ Add log_{seq_num,type,context,message,errno,ret_code} fields to cmd log.
+ Add CMDLOG report type - a separate report type for command logging.
Version 2.02.157 - 17th June 2016
=================================
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 07ca5de..82e3716 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -215,6 +215,7 @@
#define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
#define DEFAULT_PVSEGS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pvseg_start,pvseg_size"
#define DEFAULT_DEVTYPES_COLS "devtype_name,devtype_max_partitions,devtype_description"
+#define DEFAULT_COMMAND_LOG_COLS "log_seq_num,log_type,log_context,log_object_type,log_object_name,log_object_id,log_object_group,log_object_group_id,log_message,log_errno,log_ret_code"
#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_major,lv_minor,lv_kernel_major,lv_kernel_minor,pool_lv,origin,data_percent,metadata_percent,move_pv,copy_percent,mirror_log,convert_lv,lv_uuid,lv_profile"
#define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid,vg_profile"
@@ -229,6 +230,7 @@
#define DEFAULT_SEGS_SORT "vg_name,lv_name,seg_start"
#define DEFAULT_PVSEGS_SORT "pv_name,pvseg_start"
#define DEFAULT_DEVTYPES_SORT "devtype_name"
+#define DEFAULT_COMMAND_LOG_SORT "log_seq_num"
#define DEFAULT_MIRROR_DEVICE_FAULT_POLICY "remove"
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
diff --git a/lib/report/columns-cmdlog.h b/lib/report/columns-cmdlog.h
new file mode 100644
index 0000000..3dd7df5
--- /dev/null
+++ b/lib/report/columns-cmdlog.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * This file defines the fields (columns) for the command log reporting.
+ *
+ * The preferred order of the field descriptions in the help text
+ * determines the order the entries appear in this file.
+ *
+ * When adding new entries take care to use the existing style.
+ * Displayed fields names normally have a type prefix and use underscores.
+ * Field-specific internal functions names normally match the displayed
+ * field names but without underscores.
+ * Help text ends with a full stop.
+ */
+
+/* *INDENT-OFF* */
+FIELD(CMDLOG, cmd_log_item, NUM, "Seq", seq_num, 3, uint32, log_seq_num, "Log sequence number.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "LogType", type, 7, string, log_type, "Log type.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "Context", context, 7, string, log_context, "Current context.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "ObjType", object_type_name, 7, string, log_object_type, "Current object type.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "ObjName", object_name, 7, string, log_object_name, "Current object name.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "ObjID", object_id, 7, string, log_object_id, "Current object ID.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "ObjGrp", object_group, 7, string, log_object_group, "Current object group.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "ObjGrpID", object_group_id, 8, string, log_object_group_id, "Current object group ID.", 0)
+FIELD(CMDLOG, cmd_log_item, STR, "Msg", msg, 7, string, log_message, "Log message.", 0)
+FIELD(CMDLOG, cmd_log_item, SNUM, "Errno", current_errno, 5, int32, log_errno, "Errno.", 0)
+FIELD(CMDLOG, cmd_log_item, SNUM, "RetCode", ret_code, 7, int32, log_ret_code, "Return code.", 0)
+/* *INDENT-ON* */
diff --git a/lib/report/report.c b/lib/report/report.c
index 8e08c75..eec9756 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -3622,6 +3622,16 @@ static void *_obj_get_devtypes(void *obj)
return obj;
}
+static void *_obj_get_cmdlog(void *obj)
+{
+ return obj;
+}
+
+static const struct dm_report_object_type _log_report_types[] = {
+ { CMDLOG, "Command Log", "log_", _obj_get_cmdlog },
+ { 0, "", "", NULL },
+};
+
static const struct dm_report_object_type _report_types[] = {
{ VGS, "Volume Group", "vg_", _obj_get_vg },
{ LVS, "Logical Volume", "lv_", _obj_get_lv },
@@ -3656,6 +3666,8 @@ static const struct dm_report_object_type _devtypes_report_types[] = {
{type, sorttype, offsetof(type_ ## strct, field), width ? : sizeof(head) - 1, \
#id, head, &_ ## func ## _disp, desc},
+typedef struct cmd_log_item type_cmd_log_item;
+
typedef struct physical_volume type_pv;
typedef struct logical_volume type_lv;
typedef struct volume_group type_vg;
@@ -3675,6 +3687,11 @@ static const struct dm_report_field_type _devtypes_fields[] = {
{0, 0, 0, 0, "", "", NULL, NULL},
};
+static const struct dm_report_field_type _log_fields[] = {
+#include "columns-cmdlog.h"
+{0, 0, 0, 0, "", "", NULL, NULL},
+};
+
#undef STR
#undef NUM
#undef BIN
@@ -3712,7 +3729,11 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
if (columns_as_rows)
report_flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
- if (*report_type & DEVTYPES) {
+ if (*report_type & CMDLOG) {
+ types = _log_report_types;
+ fields = _log_fields;
+ reserved_values = NULL;
+ } else if (*report_type & DEVTYPES) {
types = _devtypes_report_types;
fields = _devtypes_fields;
reserved_values = NULL;
@@ -3748,8 +3769,12 @@ const char *report_get_field_prefix(report_type_t report_type_id)
{
const struct dm_report_object_type *report_types, *report_type;
- report_types = report_type_id & DEVTYPES ? _devtypes_report_types
- : _report_types;
+ if (report_type_id & CMDLOG)
+ report_types = _log_report_types;
+ else if (report_type_id & DEVTYPES)
+ report_types = _devtypes_report_types;
+ else
+ report_types = _report_types;
for (report_type = report_types; report_type->id; report_type++) {
if (report_type_id & report_type->id)
@@ -3825,3 +3850,22 @@ int report_devtypes(void *handle)
return 1;
}
+
+int report_cmdlog(void *handle, const char *type, const char *context,
+ const char *object_type_name, const char *object_name,
+ const char *object_id, const char *object_group,
+ const char *object_group_id, const char *msg,
+ int current_errno, int ret_code)
+{
+ static uint32_t seq_num = 1;
+
+ struct cmd_log_item log_item = {seq_num++, type, context, object_type_name,
+ object_name ? : "", object_id ? : "",
+ object_group ? : "", object_group_id ? : "",
+ msg ? : "", current_errno, ret_code};
+
+ if (handle)
+ return dm_report_object(handle, &log_item);
+
+ return 1;
+}
diff --git a/lib/report/report.h b/lib/report/report.h
index 8db84e0..06ffe70 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -21,16 +21,17 @@
#include "activate.h"
typedef enum {
- LVS = 1,
- LVSINFO = 2,
- LVSSTATUS = 4,
- LVSINFOSTATUS = 8,
- PVS = 16,
- VGS = 32,
- SEGS = 64,
- PVSEGS = 128,
- LABEL = 256,
- DEVTYPES = 512
+ CMDLOG = 1,
+ LVS = 2,
+ LVSINFO = 4,
+ LVSSTATUS = 8,
+ LVSINFOSTATUS = 16,
+ PVS = 32,
+ VGS = 64,
+ SEGS = 128,
+ PVSEGS = 256,
+ LABEL = 512,
+ DEVTYPES = 1024
} report_type_t;
/*
@@ -58,6 +59,20 @@ struct selection_handle {
int selected;
};
+struct cmd_log_item {
+ uint32_t seq_num;
+ const char *type;
+ const char *context;
+ const char *object_type_name;
+ const char *object_name;
+ const char *object_id;
+ const char *object_group;
+ const char *object_group_id;
+ const char *msg;
+ int current_errno;
+ int ret_code;
+};
+
struct field;
struct report_handle;
struct processing_handle;
@@ -84,6 +99,11 @@ int report_object(void *handle, int selection_only, const struct volume_group *v
const struct lv_with_info_and_seg_status *lvdm,
const struct label *label);
int report_devtypes(void *handle);
+int report_cmdlog(void *handle, const char *type, const char *context,
+ const char *object_type_name, const char *object_name,
+ const char *object_id, const char *object_group,
+ const char *object_group_id, const char *msg,
+ int current_errno, int ret_code);
int report_output(void *handle);
#endif
diff --git a/tools/reporter.c b/tools/reporter.c
index f572d31..6ba1b5b 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -877,6 +877,9 @@ static int _do_report(struct cmd_context *cmd, struct report_args *args)
r = process_each_vg(cmd, args->argc, args->argv, NULL, NULL,
0, handle, &_pvsegs_in_vg);
break;
+ case CMDLOG:
+ /* Log is reported throughout the code via report_cmdlog calls. */
+ break;
default:
log_error(INTERNAL_ERROR "_do_report: unknown report type.");
return 0;
@@ -959,6 +962,10 @@ static int _config_report(struct cmd_context *cmd, struct report_args *args)
else
args->options = find_config_tree_str(cmd, report_pvsegs_cols_verbose_CFG, NULL);
break;
+ case CMDLOG:
+ args->keys = DEFAULT_COMMAND_LOG_SORT;
+ args->options = DEFAULT_COMMAND_LOG_COLS;
+ break;
default:
log_error(INTERNAL_ERROR "_report: unknown report type.");
return 0;
7 years, 10 months
master - libdm: report: implement DM_REPORT_GROUP_JSON for JSON report output
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=094fce37765964...
Commit: 094fce37765964a9c3b32d1473e75c7d121eace1
Parent: 230b7ff0f6c844bde2185baa9db63961baefb3d0
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 2 14:21:40 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 10:42:26 2016 +0200
libdm: report: implement DM_REPORT_GROUP_JSON for JSON report output
This patch introduces DM_REPORT_GROUP_JSON report group type. When using
this group type and when pushing a report to such a group, these flags
are automatically unset:
DM_REPORT_OUTPUT_ALIGNED
DM_REPORT_OUTPUT_HEADINGS
DM_REPORT_OUTPUT_COLUMNS_AS_ROWS
...and this flag is set:
DM_REPORT_OUTPUT_BUFFERED
The whole group is encapsulated in { } for the outermost JSON object
and then each report is reported on output as array of objects where
each object is the row from report:
{
"report_name1": [
{field1="value", field2="value",...},
{field1="value", field2="value",...}
...
],
"report_name2": [
{field1="value", field2="value",...},
{field1="value", field2="value",...}
...
]
...
}
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 3 +-
libdm/libdm-report.c | 241 +++++++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 233 insertions(+), 12 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 9e1985a..da36f49 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.128 -
=================================
+ Introduce DM_REPORT_GROUP_JSON for report group with JSON output format.
Introduce DM_REPORT_GROUP_BASIC for report group with basic report output.
Introduce DM_REPORT_GROUP_SINGLE for report group having single report only.
Add dm_report_group_{create,push,pop,destroy} to support report grouping.
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index fbe4322..cad79dd 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2710,7 +2710,8 @@ struct dm_report_group;
typedef enum {
DM_REPORT_GROUP_SINGLE,
- DM_REPORT_GROUP_BASIC
+ DM_REPORT_GROUP_BASIC,
+ DM_REPORT_GROUP_JSON
} dm_report_group_type_t;
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index d73598f..485bbdf 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4203,6 +4203,16 @@ static int _sort_rows(struct dm_report *rh)
#define STANDARD_QUOTE "\'"
#define STANDARD_PAIR "="
+#define JSON_INDENT_UNIT 4
+#define JSON_SPACE " "
+#define JSON_QUOTE "\""
+#define JSON_PAIR ":"
+#define JSON_SEPARATOR ","
+#define JSON_OBJECT_START "{"
+#define JSON_OBJECT_END "}"
+#define JSON_ARRAY_START "["
+#define JSON_ARRAY_END "]"
+
#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
static int _is_basic_report(struct dm_report *rh)
@@ -4211,6 +4221,12 @@ static int _is_basic_report(struct dm_report *rh)
(rh->group_item->group->type == DM_REPORT_GROUP_BASIC);
}
+static int _is_json_report(struct dm_report *rh)
+{
+ return rh->group_item &&
+ (rh->group_item->group->type == DM_REPORT_GROUP_JSON);
+}
+
/*
* Produce report output
*/
@@ -4225,7 +4241,16 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
char *buf = NULL;
size_t buf_size = 0;
- if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
+ if (_is_json_report(rh)) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, fields[field->props->field_num].id, 0) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_PAIR, 1) ||
+ !dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
+ log_error("dm_report: Unable to extend output line");
+ return 0;
+ }
+ } else if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
if (!(field_id = dm_strdup(fields[field->props->field_num].id))) {
log_error("dm_report: Failed to copy field name");
return 0;
@@ -4300,12 +4325,19 @@ static int _output_field(struct dm_report *rh, struct dm_report_field *field)
}
}
- if ((rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) &&
- !(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED))
- if (!dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
+ if (rh->flags & DM_REPORT_OUTPUT_FIELD_NAME_PREFIX) {
+ if (!(rh->flags & DM_REPORT_OUTPUT_FIELD_UNQUOTED)) {
+ if (!dm_pool_grow_object(rh->mem, STANDARD_QUOTE, 1)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ }
+ } else if (_is_json_report(rh)) {
+ if (!dm_pool_grow_object(rh->mem, JSON_QUOTE, 1)) {
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
goto bad;
}
+ }
dm_free(buf);
return 1;
@@ -4407,39 +4439,78 @@ static int _output_as_columns(struct dm_report *rh)
struct dm_list *fh, *rowh, *ftmp, *rtmp;
struct row *row = NULL;
struct dm_report_field *field;
+ struct dm_list *last_row;
+ int do_field_delim;
+ char *line;
/* If headings not printed yet, calculate field widths and print them */
if (!(rh->flags & RH_HEADINGS_PRINTED))
_report_headings(rh);
/* Print and clear buffer */
+ last_row = dm_list_last(&rh->rows);
dm_list_iterate_safe(rowh, rtmp, &rh->rows) {
if (!dm_pool_begin_object(rh->mem, 512)) {
log_error("dm_report: Unable to allocate output line");
return 0;
}
+
+ if (_is_json_report(rh)) {
+ if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_START, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ }
+
row = dm_list_item(rowh, struct row);
+ do_field_delim = 0;
+
dm_list_iterate_safe(fh, ftmp, &row->fields) {
field = dm_list_item(fh, struct dm_report_field);
if (field->props->flags & FLD_HIDDEN)
continue;
+ if (do_field_delim) {
+ if (_is_json_report(rh)) {
+ if (!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0) ||
+ !dm_pool_grow_object(rh->mem, JSON_SPACE, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ } else {
+ if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ }
+ } else
+ do_field_delim = 1;
+
if (!_output_field(rh, field))
goto bad;
- if (!dm_list_end(&row->fields, fh))
- if (!dm_pool_grow_object(rh->mem, rh->separator, 0)) {
- log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
- goto bad;
- }
-
dm_list_del(&field->list);
}
+
+ if (_is_json_report(rh)) {
+ if (!dm_pool_grow_object(rh->mem, JSON_OBJECT_END, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ if (rowh != last_row &&
+ !dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+ }
+
if (!dm_pool_grow_object(rh->mem, "\0", 1)) {
log_error("dm_report: Unable to terminate output line");
goto bad;
}
- log_print("%s", (char *) dm_pool_end_object(rh->mem));
+
+ line = (char *) dm_pool_end_object(rh->mem);
+ log_print("%*s", rh->group_item ? rh->group_item->group->indent + (int) strlen(line) : 0, line);
dm_list_del(&row->list);
}
@@ -4469,6 +4540,70 @@ static struct report_group_item *_get_topmost_report_group_item(struct dm_report
return item;
}
+static int _json_output_array_start(struct dm_pool *mem, struct report_group_item *item)
+{
+ const char *name = (const char *) item->data;
+ char *output;
+
+ if (!dm_pool_begin_object(mem, 32)) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ return 0;
+ }
+
+ if (!dm_pool_grow_object(mem, JSON_QUOTE, 1) ||
+ !dm_pool_grow_object(mem, name, 0) ||
+ !dm_pool_grow_object(mem, JSON_QUOTE JSON_PAIR JSON_SPACE JSON_ARRAY_START, 0) ||
+ !dm_pool_grow_object(mem, "\0", 1) ||
+ !(output = dm_pool_end_object(mem))) {
+ log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
+ goto bad;
+ }
+
+ if (item->parent->store.finished_count > 0)
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR);
+
+ if (item->parent->parent && item->parent->data) {
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START);
+ item->group->indent += JSON_INDENT_UNIT;
+ }
+
+ log_print("%*s", item->group->indent + (int) strlen(output), output);
+ item->group->indent += JSON_INDENT_UNIT;
+
+ dm_pool_free(mem, output);
+ return 1;
+bad:
+ dm_pool_abandon_object(mem);
+ return 0;
+}
+
+static int _prepare_json_report_output(struct dm_report *rh)
+{
+ if (rh->group_item->output_done && dm_list_empty(&rh->rows))
+ return 1;
+
+ /*
+ * If this report is in JSON group, it must be at the
+ * top of the stack of reports so the output from
+ * different reports do not interleave with each other.
+ */
+ if (_get_topmost_report_group_item(rh->group_item->group) != rh->group_item) {
+ log_error("dm_report: dm_report_output: interleaved reports detected for JSON output");
+ return 0;
+ }
+
+ if (rh->group_item->needs_closing) {
+ log_error("dm_report: dm_report_output: unfinished JSON output detected");
+ return 0;
+ }
+
+ if (!_json_output_array_start(rh->mem, rh->group_item))
+ return_0;
+
+ rh->group_item->needs_closing = 1;
+ return 1;
+}
+
static int _print_basic_report_header(struct dm_report *rh)
{
const char *report_name = (const char *) rh->group_item->data;
@@ -4493,6 +4628,10 @@ int dm_report_output(struct dm_report *rh)
{
int r = 0;
+ if (_is_json_report(rh) &&
+ !_prepare_json_report_output(rh))
+ return_0;
+
if (dm_list_empty(&rh->rows)) {
r = 1;
goto out;
@@ -4524,6 +4663,13 @@ static int _report_group_create_basic(struct dm_report_group *group)
return 1;
}
+static int _report_group_create_json(struct dm_report_group *group)
+{
+ log_print(JSON_OBJECT_START);
+ group->indent += JSON_INDENT_UNIT;
+ return 1;
+}
+
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data)
{
struct dm_report_group *group;
@@ -4560,6 +4706,10 @@ struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void
if (!_report_group_create_basic(group))
goto_bad;
break;
+ case DM_REPORT_GROUP_JSON:
+ if (!_report_group_create_json(group))
+ goto_bad;
+ break;
default:
goto_bad;
}
@@ -4597,6 +4747,40 @@ static int _report_group_push_basic(struct report_group_item *item, const char *
return 1;
}
+static int _report_group_push_json(struct report_group_item *item, const char *name)
+{
+ if (name && !(item->data = dm_pool_strdup(item->group->mem, name))) {
+ log_error("dm_report: failed to duplicate json item name");
+ return 0;
+ }
+
+ if (item->report) {
+ item->report->flags &= ~(DM_REPORT_OUTPUT_ALIGNED |
+ DM_REPORT_OUTPUT_HEADINGS |
+ DM_REPORT_OUTPUT_COLUMNS_AS_ROWS);
+ item->report->flags |= DM_REPORT_OUTPUT_BUFFERED;
+ } else {
+ if (name) {
+ if (!_json_output_array_start(item->group->mem, item))
+ return_0;
+ } else {
+ if (!item->parent->parent) {
+ log_error("dm_report: can't use unnamed object at top level of JSON output");
+ return 0;
+ }
+ if (item->parent->store.finished_count > 0)
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_SEPARATOR) - 1, JSON_SEPARATOR);
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_START) - 1, JSON_OBJECT_START);
+ item->group->indent += JSON_INDENT_UNIT;
+ }
+
+ item->output_done = 1;
+ item->needs_closing = 1;
+ }
+
+ return 1;
+}
+
int dm_report_group_push(struct dm_report_group *group, struct dm_report *report, void *data)
{
struct report_group_item *item, *tmp_item;
@@ -4634,6 +4818,10 @@ int dm_report_group_push(struct dm_report_group *group, struct dm_report *report
if (!_report_group_push_basic(item, data))
goto_bad;
break;
+ case DM_REPORT_GROUP_JSON:
+ if (!_report_group_push_json(item, data))
+ goto_bad;
+ break;
default:
goto_bad;
}
@@ -4655,6 +4843,23 @@ static int _report_group_pop_basic(struct report_group_item *item)
return 1;
}
+static int _report_group_pop_json(struct report_group_item *item)
+{
+ if (item->output_done && item->needs_closing) {
+ if (item->data) {
+ item->group->indent -= JSON_INDENT_UNIT;
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_ARRAY_END) - 1, JSON_ARRAY_END);
+ }
+ if (item->parent->data && item->parent->parent) {
+ item->group->indent -= JSON_INDENT_UNIT;
+ log_print("%*s", item->group->indent + (int) sizeof(JSON_OBJECT_END) - 1, JSON_OBJECT_END);
+ }
+ item->needs_closing = 0;
+ }
+
+ return 1;
+}
+
int dm_report_group_pop(struct dm_report_group *group)
{
struct report_group_item *item;
@@ -4676,6 +4881,10 @@ int dm_report_group_pop(struct dm_report_group *group)
if (!_report_group_pop_basic(item))
return_0;
break;
+ case DM_REPORT_GROUP_JSON:
+ if (!_report_group_pop_json(item))
+ return_0;
+ break;
default:
return 0;
}
@@ -4704,6 +4913,12 @@ static int _report_group_destroy_basic(void)
return 1;
}
+static int _report_group_destroy_json(void)
+{
+ log_print(JSON_OBJECT_END);
+ return 1;
+}
+
int dm_report_group_destroy(struct dm_report_group *group)
{
struct report_group_item *item, *tmp_item;
@@ -4728,6 +4943,10 @@ int dm_report_group_destroy(struct dm_report_group *group)
if (!_report_group_destroy_basic())
goto_out;
break;
+ case DM_REPORT_GROUP_JSON:
+ if (!_report_group_destroy_json())
+ goto_out;
+ break;
default:
goto_out;
}
7 years, 10 months
master - libdm: report: implement DM_REPORT_GROUP_BASIC for extended report output
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=230b7ff0f6c844...
Commit: 230b7ff0f6c844bde2185baa9db63961baefb3d0
Parent: a9fe57db1c285ef7052a1054891f5eb7dbbb01b2
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon May 23 10:47:03 2016 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jun 20 10:42:26 2016 +0200
libdm: report: implement DM_REPORT_GROUP_BASIC for extended report output
This patch introduces DM_REPORT_GROUP_BASIC report group type. This
type has exactly the classical output format as we know from before
introduction of report groups. However, in addition to that, it allows
to put several reports into a group - this is the very basic grouping
scheme that doesn't change the output format itself:
Report: report1_name
Header1 Header2 ...
value value ...
value value ...
... ... ...
Report: report2_name
Header1 Header2 ...
value value ...
value value ...
... ... ...
---
WHATS_NEW_DM | 1 +
libdm/libdevmapper.h | 1 +
libdm/libdm-report.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 71 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index fdae74b..9e1985a 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.128 -
=================================
+ Introduce DM_REPORT_GROUP_BASIC for report group with basic report output.
Introduce DM_REPORT_GROUP_SINGLE for report group having single report only.
Add dm_report_group_{create,push,pop,destroy} to support report grouping.
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index c99ebe8..fbe4322 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -2710,6 +2710,7 @@ struct dm_report_group;
typedef enum {
DM_REPORT_GROUP_SINGLE,
+ DM_REPORT_GROUP_BASIC
} dm_report_group_type_t;
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data);
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 7ea5ebf..d73598f 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -4205,6 +4205,12 @@ static int _sort_rows(struct dm_report *rh)
#define UNABLE_TO_EXTEND_OUTPUT_LINE_MSG "dm_report: Unable to extend output line"
+static int _is_basic_report(struct dm_report *rh)
+{
+ return rh->group_item &&
+ (rh->group_item->group->type == DM_REPORT_GROUP_BASIC);
+}
+
/*
* Produce report output
*/
@@ -4463,9 +4469,29 @@ static struct report_group_item *_get_topmost_report_group_item(struct dm_report
return item;
}
+static int _print_basic_report_header(struct dm_report *rh)
+{
+ const char *report_name = (const char *) rh->group_item->data;
+ size_t len = strlen(report_name);
+ char *underline;
+
+ if (!(underline = dm_pool_zalloc(rh->mem, len + 1)))
+ return_0;
+
+ memset(underline, '=', len);
+
+ if (rh->group_item->parent->store.finished_count > 0)
+ log_print("%s", "");
+ log_print("%s", report_name);
+ log_print("%s", underline);
+
+ dm_pool_free(rh->mem, underline);
+ return 1;
+}
+
int dm_report_output(struct dm_report *rh)
{
- int r;
+ int r = 0;
if (dm_list_empty(&rh->rows)) {
r = 1;
@@ -4475,6 +4501,9 @@ int dm_report_output(struct dm_report *rh)
if ((rh->flags & RH_SORT_REQUIRED))
_sort_rows(rh);
+ if (_is_basic_report(rh) && !_print_basic_report_header(rh))
+ goto_out;
+
if ((rh->flags & DM_REPORT_OUTPUT_COLUMNS_AS_ROWS))
r = _output_as_rows(rh);
else
@@ -4490,6 +4519,11 @@ static int _report_group_create_single(struct dm_report_group *group)
return 1;
}
+static int _report_group_create_basic(struct dm_report_group *group)
+{
+ return 1;
+}
+
struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void *data)
{
struct dm_report_group *group;
@@ -4522,6 +4556,10 @@ struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void
if (!_report_group_create_single(group))
goto_bad;
break;
+ case DM_REPORT_GROUP_BASIC:
+ if (!_report_group_create_basic(group))
+ goto_bad;
+ break;
default:
goto_bad;
}
@@ -4551,6 +4589,14 @@ static int _report_group_push_single(struct report_group_item *item, void *data)
return 1;
}
+static int _report_group_push_basic(struct report_group_item *item, const char *name)
+{
+ if (!item->report && !name && item->parent->store.finished_count > 0)
+ log_print("%s", "");
+
+ return 1;
+}
+
int dm_report_group_push(struct dm_report_group *group, struct dm_report *report, void *data)
{
struct report_group_item *item, *tmp_item;
@@ -4584,6 +4630,10 @@ int dm_report_group_push(struct dm_report_group *group, struct dm_report *report
if (!_report_group_push_single(item, data))
goto_bad;
break;
+ case DM_REPORT_GROUP_BASIC:
+ if (!_report_group_push_basic(item, data))
+ goto_bad;
+ break;
default:
goto_bad;
}
@@ -4600,6 +4650,11 @@ static int _report_group_pop_single(struct report_group_item *item)
return 1;
}
+static int _report_group_pop_basic(struct report_group_item *item)
+{
+ return 1;
+}
+
int dm_report_group_pop(struct dm_report_group *group)
{
struct report_group_item *item;
@@ -4617,6 +4672,10 @@ int dm_report_group_pop(struct dm_report_group *group)
if (!_report_group_pop_single(item))
return_0;
break;
+ case DM_REPORT_GROUP_BASIC:
+ if (!_report_group_pop_basic(item))
+ return_0;
+ break;
default:
return 0;
}
@@ -4640,6 +4699,11 @@ static int _report_group_destroy_single(void)
return 1;
}
+static int _report_group_destroy_basic(void)
+{
+ return 1;
+}
+
int dm_report_group_destroy(struct dm_report_group *group)
{
struct report_group_item *item, *tmp_item;
@@ -4660,6 +4724,10 @@ int dm_report_group_destroy(struct dm_report_group *group)
if (!_report_group_destroy_single())
goto_out;
break;
+ case DM_REPORT_GROUP_BASIC:
+ if (!_report_group_destroy_basic())
+ goto_out;
+ break;
default:
goto_out;
}
7 years, 10 months