block: Improve readability in HMP 'info blockstats' output
Instead of a long line with key=value pairs for each block device, switch to a tabular form with aligned values. This makes it much easier to find the relevant information in the output. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-ID: <20260512112759.66038-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Kevin Wolf committed
May 12, 2026 at 13:27 UTC
8b663f7d0d96d915d0e0fc5923dc6cc36133f19f
1 file changed
+18
-20
block/monitor/block-hmp-cmds.c
+18
-20
@@ -794,30 +794,28 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
794
continue;
795
}
796
797
- monitor_printf(mon, "%s:", stats->value->device);
798
- monitor_printf(mon, " rd_bytes=%" PRId64
799
- " wr_bytes=%" PRId64
800
- " rd_operations=%" PRId64
801
- " wr_operations=%" PRId64
802
- " flush_operations=%" PRId64
803
- " wr_total_time_ns=%" PRId64
804
- " rd_total_time_ns=%" PRId64
805
- " flush_total_time_ns=%" PRId64
806
- " rd_merged=%" PRId64
807
- " wr_merged=%" PRId64
808
- " idle_time_ns=%" PRId64
809
- "\n",
797
+ monitor_printf(mon, "%s%s: idle_time_ns=%" PRId64 "\n",
798
+ stats != stats_list ? "\n" : "",
799
+ stats->value->device,
800
+ stats->value->stats->idle_time_ns);
801
+ monitor_printf(mon, " %24s %16s %24s %10s\n", "bytes",
802
+ "operations", "total_time_ns", "merged");
803
+ monitor_printf(mon, "Read: %24" PRId64 " %16" PRId64 " %24" PRId64
804
+ " %10" PRId64 "\n",
805
stats->value->stats->rd_bytes,
811
- stats->value->stats->wr_bytes,
806
stats->value->stats->rd_operations,
807
+ stats->value->stats->rd_total_time_ns,
808
+ stats->value->stats->rd_merged);
809
+ monitor_printf(mon, "Write: %24" PRId64 " %16" PRId64 " %24" PRId64
810
+ " %10" PRId64 "\n",
811
+ stats->value->stats->wr_bytes,
812
stats->value->stats->wr_operations,
814
- stats->value->stats->flush_operations,
813
stats->value->stats->wr_total_time_ns,
816
- stats->value->stats->rd_total_time_ns,
817
- stats->value->stats->flush_total_time_ns,
818
- stats->value->stats->rd_merged,
819
- stats->value->stats->wr_merged,
820
- stats->value->stats->idle_time_ns);
814
+ stats->value->stats->wr_merged);
815
+ monitor_printf(mon, "Flush: %24s %16" PRId64 " %24" PRId64 "\n",
816
+ "",
817
+ stats->value->stats->flush_operations,
818
+ stats->value->stats->flush_total_time_ns);
819
}
820
821
qapi_free_BlockStatsList(stats_list);