From: Stefan Raspl <stefan.raspl@xxxxxxxxxx> Logging mode was broken: Stats were retrieved only once, and then printed over and over again without refreshing. This patch essentially restores how things were for logging mode before, minus renaming 'k' to 'key' for better readability. Fixes: 72664f2937d3 ("tools/kvm_stat: use a more pythonic way to iterate over dictionaries") Signed-off-by: Stefan Raspl <raspl@xxxxxxxxxxxxxxxxxx> Reviewed-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx> --- tools/kvm/kvm_stat/kvm_stat | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index f7ae08dae9cd..c5c8e9295b91 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -1391,16 +1391,17 @@ def batch(stats): def log(stats): """Prints statistics as reiterating key block, multiple value blocks.""" - sorted_stats = sorted(stats.get().items()) + keys = sorted(stats.get().keys()) def banner(): - for key, _ in sorted_stats: + for key in keys: print(key, end=' ') print() def statline(): - for _, values in sorted_stats: - print(' %9d' % values.delta, end=' ') + s = stats.get() + for key in keys: + print(' %9d' % s[key].delta, end=' ') print() line = 0 banner_repeat = 20 -- 2.13.5