Commit e0ba3876 authored by Stefan Raspl's avatar Stefan Raspl Committed by Paolo Bonzini

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: default avatarStefan Raspl <raspl@linux.vnet.ibm.com>
Reviewed-by: default avatarMarc Hartmayer <mhartmay@linux.vnet.ibm.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent dadf1e78
...@@ -31,7 +31,6 @@ import resource ...@@ -31,7 +31,6 @@ import resource
import struct import struct
import re import re
from collections import defaultdict from collections import defaultdict
from time import sleep
VMX_EXIT_REASONS = { VMX_EXIT_REASONS = {
'EXCEPTION_NMI': 0, 'EXCEPTION_NMI': 0,
...@@ -657,6 +656,7 @@ class DebugfsProvider(object): ...@@ -657,6 +656,7 @@ class DebugfsProvider(object):
self._fields = self.get_available_fields() self._fields = self.get_available_fields()
self._pid = 0 self._pid = 0
self.do_read = True self.do_read = True
self.paths = []
def get_available_fields(self): def get_available_fields(self):
""""Returns a list of available fields. """"Returns a list of available fields.
...@@ -794,7 +794,6 @@ class Tui(object): ...@@ -794,7 +794,6 @@ class Tui(object):
def __init__(self, stats): def __init__(self, stats):
self.stats = stats self.stats = stats
self.screen = None self.screen = None
self.drilldown = False
self.update_drilldown() self.update_drilldown()
def __enter__(self): def __enter__(self):
...@@ -950,11 +949,10 @@ class Tui(object): ...@@ -950,11 +949,10 @@ class Tui(object):
while True: while True:
self.refresh(sleeptime) self.refresh(sleeptime)
curses.halfdelay(int(sleeptime * 10)) curses.halfdelay(int(sleeptime * 10))
sleeptime = 3 sleeptime = 3.0
try: try:
char = self.screen.getkey() char = self.screen.getkey()
if char == 'x': if char == 'x':
self.drilldown = not self.drilldown
self.update_drilldown() self.update_drilldown()
if char == 'q': if char == 'q':
break break
...@@ -1066,7 +1064,7 @@ Requirements: ...@@ -1066,7 +1064,7 @@ Requirements:
optparser.add_option('-p', '--pid', optparser.add_option('-p', '--pid',
action='store', action='store',
default=0, default=0,
type=int, type='int',
dest='pid', dest='pid',
help='restrict statistics to pid', help='restrict statistics to pid',
) )
...@@ -1099,8 +1097,8 @@ def check_access(options): ...@@ -1099,8 +1097,8 @@ def check_access(options):
"Also ensure, that the kvm modules are loaded.\n") "Also ensure, that the kvm modules are loaded.\n")
sys.exit(1) sys.exit(1)
if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints or
or not options.debugfs): not options.debugfs):
sys.stderr.write("Please enable CONFIG_TRACING in your kernel " sys.stderr.write("Please enable CONFIG_TRACING in your kernel "
"when using the option -t (default).\n" "when using the option -t (default).\n"
"If it is enabled, make {0} readable by the " "If it is enabled, make {0} readable by the "
...@@ -1111,7 +1109,7 @@ def check_access(options): ...@@ -1111,7 +1109,7 @@ def check_access(options):
sys.stderr.write("Falling back to debugfs statistics!\n") sys.stderr.write("Falling back to debugfs statistics!\n")
options.debugfs = True options.debugfs = True
sleep(5) time.sleep(5)
return options return options
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment