Blame SOURCES/kvm-tools-kvm_stat-full-PEP8-compliance.patch

4a2fec
From 5f41d9716a2f46f18ee4bf02c9875f1ae0ba53ee Mon Sep 17 00:00:00 2001
4a2fec
From: David Hildenbrand <david@redhat.com>
4a2fec
Date: Tue, 17 Oct 2017 19:15:32 +0200
4a2fec
Subject: [PATCH 27/69] tools/kvm_stat: full PEP8 compliance
4a2fec
MIME-Version: 1.0
4a2fec
Content-Type: text/plain; charset=UTF-8
4a2fec
Content-Transfer-Encoding: 8bit
4a2fec
4a2fec
RH-Author: David Hildenbrand <david@redhat.com>
4a2fec
Message-id: <20171017191605.2378-7-david@redhat.com>
4a2fec
Patchwork-id: 77312
4a2fec
O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 06/39] tools/kvm_stat: full PEP8 compliance
4a2fec
Bugzilla: 1497137
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
RH-Acked-by: Thomas Huth <thuth@redhat.com>
4a2fec
4a2fec
Upstream-status: linux.git 692c7f6deb553dde2531102cd10ac17ab61438e4
4a2fec
4a2fec
commit 692c7f6deb553dde2531102cd10ac17ab61438e4
4a2fec
Author: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
Date:   Fri Mar 10 13:40:05 2017 +0100
4a2fec
4a2fec
    tools/kvm_stat: full PEP8 compliance
4a2fec
4a2fec
    Provides all missing empty lines as required for full PEP compliance.
4a2fec
4a2fec
    Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
4a2fec
    Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
4a2fec
    Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
4a2fec
4a2fec
Signed-off-by: David Hildenbrand <david@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 scripts/kvm/kvm_stat | 22 ++++++++++++++++++++++
4a2fec
 1 file changed, 22 insertions(+)
4a2fec
4a2fec
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat
4a2fec
index 6207843..5c4f248 100755
4a2fec
--- a/scripts/kvm/kvm_stat
4a2fec
+++ b/scripts/kvm/kvm_stat
4a2fec
@@ -224,6 +224,7 @@ IOCTL_NUMBERS = {
4a2fec
     'RESET':       0x00002403,
4a2fec
 }
4a2fec
 
4a2fec
+
4a2fec
 class Arch(object):
4a2fec
     """Encapsulates global architecture specific data.
4a2fec
 
4a2fec
@@ -254,12 +255,14 @@ class Arch(object):
4a2fec
                     return ArchX86(SVM_EXIT_REASONS)
4a2fec
                 return
4a2fec
 
4a2fec
+
4a2fec
 class ArchX86(Arch):
4a2fec
     def __init__(self, exit_reasons):
4a2fec
         self.sc_perf_evt_open = 298
4a2fec
         self.ioctl_numbers = IOCTL_NUMBERS
4a2fec
         self.exit_reasons = exit_reasons
4a2fec
 
4a2fec
+
4a2fec
 class ArchPPC(Arch):
4a2fec
     def __init__(self):
4a2fec
         self.sc_perf_evt_open = 319
4a2fec
@@ -274,12 +277,14 @@ class ArchPPC(Arch):
4a2fec
         self.ioctl_numbers['SET_FILTER'] = 0x80002406 | char_ptr_size << 16
4a2fec
         self.exit_reasons = {}
4a2fec
 
4a2fec
+
4a2fec
 class ArchA64(Arch):
4a2fec
     def __init__(self):
4a2fec
         self.sc_perf_evt_open = 241
4a2fec
         self.ioctl_numbers = IOCTL_NUMBERS
4a2fec
         self.exit_reasons = AARCH64_EXIT_REASONS
4a2fec
 
4a2fec
+
4a2fec
 class ArchS390(Arch):
4a2fec
     def __init__(self):
4a2fec
         self.sc_perf_evt_open = 331
4a2fec
@@ -341,6 +346,7 @@ def get_filters():
4a2fec
 libc = ctypes.CDLL('libc.so.6', use_errno=True)
4a2fec
 syscall = libc.syscall
4a2fec
 
4a2fec
+
4a2fec
 class perf_event_attr(ctypes.Structure):
4a2fec
     """Struct that holds the necessary data to set up a trace event.
4a2fec
 
4a2fec
@@ -369,6 +375,7 @@ class perf_event_attr(ctypes.Structure):
4a2fec
         self.size = ctypes.sizeof(self)
4a2fec
         self.read_format = PERF_FORMAT_GROUP
4a2fec
 
4a2fec
+
4a2fec
 def perf_event_open(attr, pid, cpu, group_fd, flags):
4a2fec
     """Wrapper for the sys_perf_evt_open() syscall.
4a2fec
 
4a2fec
@@ -394,6 +401,7 @@ PERF_FORMAT_GROUP = 1 << 3
4a2fec
 PATH_DEBUGFS_TRACING = '/sys/kernel/debug/tracing'
4a2fec
 PATH_DEBUGFS_KVM = '/sys/kernel/debug/kvm'
4a2fec
 
4a2fec
+
4a2fec
 class Group(object):
4a2fec
     """Represents a perf event group."""
4a2fec
 
4a2fec
@@ -426,6 +434,7 @@ class Group(object):
4a2fec
                         struct.unpack(read_format,
4a2fec
                                       os.read(self.events[0].fd, length))))
4a2fec
 
4a2fec
+
4a2fec
 class Event(object):
4a2fec
     """Represents a performance event and manages its life cycle."""
4a2fec
     def __init__(self, name, group, trace_cpu, trace_pid, trace_point,
4a2fec
@@ -509,6 +518,7 @@ class Event(object):
4a2fec
         """Resets the count of the trace event in the kernel."""
4a2fec
         fcntl.ioctl(self.fd, ARCH.ioctl_numbers['RESET'], 0)
4a2fec
 
4a2fec
+
4a2fec
 class TracepointProvider(object):
4a2fec
     """Data provider for the stats class.
4a2fec
 
4a2fec
@@ -650,6 +660,7 @@ class TracepointProvider(object):
4a2fec
                     ret[name] += val
4a2fec
         return ret
4a2fec
 
4a2fec
+
4a2fec
 class DebugfsProvider(object):
4a2fec
     """Provides data from the files that KVM creates in the kvm debugfs
4a2fec
     folder."""
4a2fec
@@ -719,6 +730,7 @@ class DebugfsProvider(object):
4a2fec
         except IOError:
4a2fec
             return 0
4a2fec
 
4a2fec
+
4a2fec
 class Stats(object):
4a2fec
     """Manages the data providers and the data they provide.
4a2fec
 
4a2fec
@@ -790,6 +802,7 @@ class Stats(object):
4a2fec
 LABEL_WIDTH = 40
4a2fec
 NUMBER_WIDTH = 10
4a2fec
 
4a2fec
+
4a2fec
 class Tui(object):
4a2fec
     """Instruments curses to draw a nice text ui."""
4a2fec
     def __init__(self, stats):
4a2fec
@@ -859,6 +872,7 @@ class Tui(object):
4a2fec
                            len('Current'), 'Current')
4a2fec
         row = 3
4a2fec
         stats = self.stats.get()
4a2fec
+
4a2fec
         def sortkey(x):
4a2fec
             if stats[x][1]:
4a2fec
                 return (-stats[x][1], -stats[x][0])
4a2fec
@@ -966,6 +980,7 @@ class Tui(object):
4a2fec
             except curses.error:
4a2fec
                 continue
4a2fec
 
4a2fec
+
4a2fec
 def batch(stats):
4a2fec
     """Prints statistics in a key, value format."""
4a2fec
     try:
4a2fec
@@ -978,13 +993,16 @@ def batch(stats):
4a2fec
     except KeyboardInterrupt:
4a2fec
         pass
4a2fec
 
4a2fec
+
4a2fec
 def log(stats):
4a2fec
     """Prints statistics as reiterating key block, multiple value blocks."""
4a2fec
     keys = sorted(stats.get().iterkeys())
4a2fec
+
4a2fec
     def banner():
4a2fec
         for k in keys:
4a2fec
             print '%s' % k,
4a2fec
         print
4a2fec
+
4a2fec
     def statline():
4a2fec
         s = stats.get()
4a2fec
         for k in keys:
4a2fec
@@ -1002,6 +1020,7 @@ def log(stats):
4a2fec
         except KeyboardInterrupt:
4a2fec
             break
4a2fec
 
4a2fec
+
4a2fec
 def get_options():
4a2fec
     """Returns processed program arguments."""
4a2fec
     description_text = """
4a2fec
@@ -1072,6 +1091,7 @@ Requirements:
4a2fec
     (options, _) = optparser.parse_args(sys.argv)
4a2fec
     return options
4a2fec
 
4a2fec
+
4a2fec
 def get_providers(options):
4a2fec
     """Returns a list of data providers depending on the passed options."""
4a2fec
     providers = []
4a2fec
@@ -1085,6 +1105,7 @@ def get_providers(options):
4a2fec
 
4a2fec
     return providers
4a2fec
 
4a2fec
+
4a2fec
 def check_access(options):
4a2fec
     """Exits if the current user can't access all needed directories."""
4a2fec
     if not os.path.exists('/sys/kernel/debug'):
4a2fec
@@ -1114,6 +1135,7 @@ def check_access(options):
4a2fec
 
4a2fec
     return options
4a2fec
 
4a2fec
+
4a2fec
 def main():
4a2fec
     options = get_options()
4a2fec
     options = check_access(options)
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec