diff --git a/WHATS_NEW b/WHATS_NEW index 6f6e9e843..25494cb82 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.158 - ================================= + Use 'orphan' object type in cmd log for groups to collect PVs not yet in VGs. Add lvm lastlog command for query and display of last cmd's log in lvm shell. Report per-object return codes via cmd log while processing multiple objects. Annotate processing code with log report hooks for per-object command log. diff --git a/lib/log/log.c b/lib/log/log.c index 0bd2de963..e8793c6a5 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -298,6 +298,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) { static const char *log_object_type_names[LOG_REPORT_OBJECT_TYPE_COUNT] = {[LOG_REPORT_OBJECT_TYPE_NULL] = "", + [LOG_REPORT_OBJECT_TYPE_ORPHAN] = "orphan", [LOG_REPORT_OBJECT_TYPE_PV] = "pv", [LOG_REPORT_OBJECT_TYPE_VG] = "vg", [LOG_REPORT_OBJECT_TYPE_LV] = "lv"}; diff --git a/lib/log/lvm-logging.h b/lib/log/lvm-logging.h index 5789c0bf8..e5b8b63b6 100644 --- a/lib/log/lvm-logging.h +++ b/lib/log/lvm-logging.h @@ -74,6 +74,7 @@ typedef enum { typedef enum { LOG_REPORT_OBJECT_TYPE_NULL, + LOG_REPORT_OBJECT_TYPE_ORPHAN, LOG_REPORT_OBJECT_TYPE_PV, LOG_REPORT_OBJECT_TYPE_VG, LOG_REPORT_OBJECT_TYPE_LV, diff --git a/tools/toollib.c b/tools/toollib.c index 41ef5499c..0eb28877a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1894,11 +1894,14 @@ static int _process_vgnameid_list(struct cmd_context *cmd, uint32_t read_flags, notfound = 0; uuid[0] = '\0'; - if (vg_uuid && !is_orphan_vg(vg_name) && - !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid))) - stack; - - log_set_report_object_name_and_id(vg_name, uuid); + if (is_orphan_vg(vg_name)) { + log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_ORPHAN); + log_set_report_object_name_and_id(vg_name + sizeof(VG_ORPHANS), uuid); + } else { + if (vg_uuid && !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid))) + stack; + log_set_report_object_name_and_id(vg_name, uuid); + } if (sigint_caught()) { ret_max = ECMD_FAILED; @@ -3306,7 +3309,8 @@ static int _process_pvs_in_vg(struct cmd_context *cmd, goto_out; } - log_set_report_object_group_and_group_id(vg->name, vg_uuid); + if (!is_orphan_vg(vg->name)) + log_set_report_object_group_and_group_id(vg->name, vg_uuid); dm_list_iterate_items(pvl, &vg->pvs) { pv = pvl->pv; @@ -3430,11 +3434,14 @@ static int _process_pvs_in_vgs(struct cmd_context *cmd, uint32_t read_flags, notfound = 0; uuid[0] = '\0'; - if (vg_uuid && !is_orphan_vg(vg_name) && - !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid))) - stack; - - log_set_report_object_name_and_id(vg_name, uuid); + if (is_orphan_vg(vg_name)) { + log_set_report_object_type(LOG_REPORT_OBJECT_TYPE_ORPHAN); + log_set_report_object_name_and_id(vg_name + sizeof(VG_ORPHANS), uuid); + } else { + if (vg_uuid && !id_write_format((const struct id*)vg_uuid, uuid, sizeof(uuid))) + stack; + log_set_report_object_name_and_id(vg_name, uuid); + } if (sigint_caught()) { ret_max = ECMD_FAILED; @@ -3750,7 +3757,8 @@ int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg, if (!id_write_format(&vg->id, vg_uuid, sizeof(vg_uuid))) stack; - log_set_report_object_group_and_group_id(vg->name, vg_uuid); + if (!is_orphan_vg(vg->name)) + log_set_report_object_group_and_group_id(vg->name, vg_uuid); dm_list_iterate_items(pvl, &vg->pvs) { pv_uuid[0] = '\0';