1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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.
This commit is contained in:
Peter Rajnoha 2016-05-23 10:16:29 +02:00
parent 213434d426
commit c099f531fb
3 changed files with 14 additions and 0 deletions

View File

@ -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.

View File

@ -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...

View File

@ -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;
};