Byte counts and file offsets should use QAPI type 'size' (uint64_t). BlockDeviceStats members @rd_bytes, @wr_bytes and @wr_highest_offset are 'int' (int64_t). bdrv_query_blk_stats() gets them from BlockAcctStats member nr_bytes[] and stat64_get(), implicitly converting from uint64_t.
Change all three to 'size'. query-blockstats now report byte counts and file offsets above 2^63-1 correctly instead of their (negative) two's complement. So does HMP's "info blockstats". Signed-off-by: Markus Armbruster <arm...@redhat.com> --- hmp.c | 4 ++-- qapi/block-core.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hmp.c b/hmp.c index 599e816..ecacb7f 100644 --- a/hmp.c +++ b/hmp.c @@ -577,8 +577,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict) } monitor_printf(mon, "%s:", stats->value->device); - monitor_printf(mon, " rd_bytes=%" PRId64 - " wr_bytes=%" PRId64 + monitor_printf(mon, " rd_bytes=%" PRIu64 + " wr_bytes=%" PRIu64 " rd_operations=%" PRId64 " wr_operations=%" PRId64 " flush_operations=%" PRId64 diff --git a/qapi/block-core.json b/qapi/block-core.json index 2e0d53c..1d68669 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -704,10 +704,10 @@ # Since: 0.14.0 ## { 'struct': 'BlockDeviceStats', - 'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int', + 'data': {'rd_bytes': 'size', 'wr_bytes': 'size', 'rd_operations': 'int', 'wr_operations': 'int', 'flush_operations': 'int', 'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int', - 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int', + 'rd_total_time_ns': 'int', 'wr_highest_offset': 'size', 'rd_merged': 'int', 'wr_merged': 'int', '*idle_time_ns': 'int', 'failed_rd_operations': 'int', 'failed_wr_operations': 'int', 'failed_flush_operations': 'int', 'invalid_rd_operations': 'int', -- 2.7.5