diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2022-08-22 13:59:08 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2022-08-22 14:06:34 +0200 |
commit | 508782a9135acf13b39b47605e675a5678495c58 (patch) | |
tree | b54b22a9b355c496d7317284c0bc26437c2fd999 /tools/lvm.c | |
parent | 8c3cfc75c72696ae8b620555fcc4f815b0c1d6b6 (diff) | |
download | lvm2-508782a9135acf13b39b47605e675a5678495c58.tar.gz |
shell: add pre-cmd log report object type and enable lastlog for it
If we failed or logged anything before we actually execute given command
in lvm shell, we couldn't report the log using lastlog command after.
This patch adds specific 'pre-cmd' log report object type to identify
such log messages and enables lastlog to report even this log.
Diffstat (limited to 'tools/lvm.c')
-rw-r--r-- | tools/lvm.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/lvm.c b/tools/lvm.c index 756328f3f..370dc49e3 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -231,7 +231,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) orig_command_log_selection = dm_pool_strdup(cmd->libmem, find_config_tree_str(cmd, log_command_log_selection_CFG, NULL)); log_set_report_context(LOG_REPORT_CONTEXT_SHELL); - log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_CMD); + log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_PRE_CMD); while (1) { /* @@ -255,6 +255,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) log_error("Failed to reset log report selection."); } + log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_PRE_CMD); log_set_report(cmd->cmd_report.log_rh); log_set_report_object_name_and_id(NULL, NULL); @@ -275,6 +276,8 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) continue; } + log_set_report_object_name_and_id(input, NULL); + add_history(input); for (i = 0; i < MAX_ARGS; i++) @@ -285,8 +288,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) { _discard_log_report_content(cmd); log_error("Too many arguments, sorry."); - dm_report_group_output_and_pop_all(cmd->cmd_report.report_group); - continue; + goto report_log; } if (!argc) { @@ -304,6 +306,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) continue; } + log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_CMD); log_set_report_object_name_and_id(argv[0], NULL); is_lastlog_cmd = !strcmp(argv[0], "lastlog"); @@ -331,7 +334,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline) if (!is_lastlog_cmd) _log_shell_command_status(cmd, ret); - +report_log: log_set_report(NULL); dm_report_group_output_and_pop_all(cmd->cmd_report.report_group); |