|
|
9bac43 |
From 7bc419ee18fb59acbd0bf2fc5d31b25b32bc28ea Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Date: Tue, 17 Oct 2017 19:15:45 +0200
|
|
|
9bac43 |
Subject: [PATCH 40/69] tools/kvm_stat: fix event counts display for
|
|
|
9bac43 |
interrupted intervals
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Message-id: <20171017191605.2378-20-david@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 77330
|
|
|
9bac43 |
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 19/39] tools/kvm_stat: fix event counts display for interrupted intervals
|
|
|
9bac43 |
Bugzilla: 1497137
|
|
|
9bac43 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Upstream-status: linux.git 124c2fc9fdf5fb1d9cea4707d7e5471e317ba3bf
|
|
|
9bac43 |
|
|
|
9bac43 |
commit 124c2fc9fdf5fb1d9cea4707d7e5471e317ba3bf
|
|
|
9bac43 |
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
|
|
|
9bac43 |
Date: Wed Jun 7 21:08:26 2017 +0200
|
|
|
9bac43 |
|
|
|
9bac43 |
tools/kvm_stat: fix event counts display for interrupted intervals
|
|
|
9bac43 |
|
|
|
9bac43 |
When an update interval is interrupted via key press (e.g. space), the
|
|
|
9bac43 |
'Current' column value is calculated using the full interval length
|
|
|
9bac43 |
instead of the elapsed time, which leads to lower than actual numbers.
|
|
|
9bac43 |
Furthermore, the value should be rounded, not truncated.
|
|
|
9bac43 |
This is fixed by using the actual elapsed time for the calculation.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
|
|
|
9bac43 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: David Hildenbrand <david@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9bac43 |
---
|
|
|
9bac43 |
scripts/kvm/kvm_stat | 7 +++++--
|
|
|
9bac43 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
|
|
|
9bac43 |
index 904eb62..b571584 100755
|
|
|
9bac43 |
--- a/scripts/kvm/kvm_stat
|
|
|
9bac43 |
+++ b/scripts/kvm/kvm_stat
|
|
|
9bac43 |
@@ -1009,7 +1009,8 @@ class Tui(object):
|
|
|
9bac43 |
self.screen.addstr(row, col, '%7.1f' % (values[0] * 100 / total,))
|
|
|
9bac43 |
col += 7
|
|
|
9bac43 |
if values[1] is not None:
|
|
|
9bac43 |
- self.screen.addstr(row, col, '%8d' % (values[1] / sleeptime,))
|
|
|
9bac43 |
+ self.screen.addstr(row, col, '%8d' %
|
|
|
9bac43 |
+ round(values[1] / sleeptime))
|
|
|
9bac43 |
row += 1
|
|
|
9bac43 |
self.screen.refresh()
|
|
|
9bac43 |
|
|
|
9bac43 |
@@ -1130,9 +1131,11 @@ class Tui(object):
|
|
|
9bac43 |
"""Refreshes the screen and processes user input."""
|
|
|
9bac43 |
sleeptime = DELAY_INITIAL
|
|
|
9bac43 |
self.refresh_header()
|
|
|
9bac43 |
+ start = 0.0 # result based on init value never appears on screen
|
|
|
9bac43 |
while True:
|
|
|
9bac43 |
- self.refresh_body(sleeptime)
|
|
|
9bac43 |
+ self.refresh_body(time.time() - start)
|
|
|
9bac43 |
curses.halfdelay(int(sleeptime * 10))
|
|
|
9bac43 |
+ start = time.time()
|
|
|
9bac43 |
sleeptime = DELAY_REGULAR
|
|
|
9bac43 |
try:
|
|
|
9bac43 |
char = self.screen.getkey()
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|