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

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.
This commit is contained in:
Peter Rajnoha 2022-08-22 13:59:08 +02:00
parent 8c3cfc75c7
commit 508782a913
4 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.03.17 - Version 2.03.17 -
=============================== ===============================
Fix lvm shell's lastlog command to report previous pre-command failures.
Extend VDO and VDOPOOL without flushing and locking fs. Extend VDO and VDOPOOL without flushing and locking fs.
Add --valuesonly option to lvmconfig to print only values without keys. Add --valuesonly option to lvmconfig to print only values without keys.
Updates configure with recent autoconf tooling. Updates configure with recent autoconf tooling.

View File

@ -446,6 +446,7 @@ const char *log_get_report_context_name(log_report_context_t context)
const char *log_get_report_object_type_name(log_report_object_type_t object_type) const char *log_get_report_object_type_name(log_report_object_type_t object_type)
{ {
static const char *log_object_type_names[LOG_REPORT_OBJECT_TYPE_COUNT] = {[LOG_REPORT_OBJECT_TYPE_NULL] = "", static const char *log_object_type_names[LOG_REPORT_OBJECT_TYPE_COUNT] = {[LOG_REPORT_OBJECT_TYPE_NULL] = "",
[LOG_REPORT_OBJECT_TYPE_PRE_CMD] = "pre-cmd",
[LOG_REPORT_OBJECT_TYPE_CMD] = "cmd", [LOG_REPORT_OBJECT_TYPE_CMD] = "cmd",
[LOG_REPORT_OBJECT_TYPE_ORPHAN] = "orphan", [LOG_REPORT_OBJECT_TYPE_ORPHAN] = "orphan",
[LOG_REPORT_OBJECT_TYPE_PV] = "pv", [LOG_REPORT_OBJECT_TYPE_PV] = "pv",

View File

@ -91,6 +91,7 @@ typedef enum {
typedef enum { typedef enum {
LOG_REPORT_OBJECT_TYPE_NULL, LOG_REPORT_OBJECT_TYPE_NULL,
LOG_REPORT_OBJECT_TYPE_PRE_CMD,
LOG_REPORT_OBJECT_TYPE_CMD, LOG_REPORT_OBJECT_TYPE_CMD,
LOG_REPORT_OBJECT_TYPE_ORPHAN, LOG_REPORT_OBJECT_TYPE_ORPHAN,
LOG_REPORT_OBJECT_TYPE_PV, LOG_REPORT_OBJECT_TYPE_PV,

View File

@ -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)); 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_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) { 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_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(cmd->cmd_report.log_rh);
log_set_report_object_name_and_id(NULL, NULL); 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; continue;
} }
log_set_report_object_name_and_id(input, NULL);
add_history(input); add_history(input);
for (i = 0; i < MAX_ARGS; i++) 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) { if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
_discard_log_report_content(cmd); _discard_log_report_content(cmd);
log_error("Too many arguments, sorry."); log_error("Too many arguments, sorry.");
dm_report_group_output_and_pop_all(cmd->cmd_report.report_group); goto report_log;
continue;
} }
if (!argc) { if (!argc) {
@ -304,6 +306,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
continue; continue;
} }
log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_CMD);
log_set_report_object_name_and_id(argv[0], NULL); log_set_report_object_name_and_id(argv[0], NULL);
is_lastlog_cmd = !strcmp(argv[0], "lastlog"); 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) if (!is_lastlog_cmd)
_log_shell_command_status(cmd, ret); _log_shell_command_status(cmd, ret);
report_log:
log_set_report(NULL); log_set_report(NULL);
dm_report_group_output_and_pop_all(cmd->cmd_report.report_group); dm_report_group_output_and_pop_all(cmd->cmd_report.report_group);