From 8654f68785c5ddddfd92b8fd2b0e550481e3099c Mon Sep 17 00:00:00 2001
From: David Hildenbrand <david@redhat.com>
Date: Tue, 17 Oct 2017 19:15:30 +0200
Subject: [PATCH 25/69] tools/kvm_stat: fix misc glitches
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: David Hildenbrand <david@redhat.com>
Message-id: <20171017191605.2378-5-david@redhat.com>
Patchwork-id: 77313
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 04/39] tools/kvm_stat: fix misc glitches
Bugzilla: 1497137
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Thomas Huth <thuth@redhat.com>
Upstream-status: linux.git e0ba38765c1d1d670246d6f6c518594aa8e62587
commit e0ba38765c1d1d670246d6f6c518594aa8e62587
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
Date: Fri Mar 10 13:40:03 2017 +0100
tools/kvm_stat: fix misc glitches
Addresses
- eliminate extra import
- missing variable initialization
- type redefinition from int to float
- passing of int type argument instead of string
- a couple of PEP8-reported indentation/formatting glitches
- remove unused variable drilldown in class Tui
Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
scripts/kvm/kvm_stat | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
index 14536c0..231186a 100755
--- a/scripts/kvm/kvm_stat
+++ b/scripts/kvm/kvm_stat
@@ -31,7 +31,6 @@ import resource
import struct
import re
from collections import defaultdict
-from time import sleep
VMX_EXIT_REASONS = {
'EXCEPTION_NMI': 0,
@@ -657,6 +656,7 @@ class DebugfsProvider(object):
self._fields = self.get_available_fields()
self._pid = 0
self.do_read = True
+ self.paths = []
def get_available_fields(self):
""""Returns a list of available fields.
@@ -794,7 +794,6 @@ class Tui(object):
def __init__(self, stats):
self.stats = stats
self.screen = None
- self.drilldown = False
self.update_drilldown()
def __enter__(self):
@@ -950,11 +949,10 @@ class Tui(object):
while True:
self.refresh(sleeptime)
curses.halfdelay(int(sleeptime * 10))
- sleeptime = 3
+ sleeptime = 3.0
try:
char = self.screen.getkey()
if char == 'x':
- self.drilldown = not self.drilldown
self.update_drilldown()
if char == 'q':
break
@@ -1064,12 +1062,12 @@ Requirements:
help='fields to display (regex)',
)
optparser.add_option('-p', '--pid',
- action='store',
- default=0,
- type=int,
- dest='pid',
- help='restrict statistics to pid',
- )
+ action='store',
+ default=0,
+ type='int',
+ dest='pid',
+ help='restrict statistics to pid',
+ )
(options, _) = optparser.parse_args(sys.argv)
return options
@@ -1099,8 +1097,8 @@ def check_access(options):
"Also ensure, that the kvm modules are loaded.\n")
sys.exit(1)
- if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints
- or not options.debugfs):
+ if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints or
+ not options.debugfs):
sys.stderr.write("Please enable CONFIG_TRACING in your kernel "
"when using the option -t (default).\n"
"If it is enabled, make {0} readable by the "
@@ -1111,7 +1109,7 @@ def check_access(options):
sys.stderr.write("Falling back to debugfs statistics!\n")
options.debugfs = True
- sleep(5)
+ time.sleep(5)
return options
--
1.8.3.1