From a4b2be204b5034f077c45048e5420c9daf1944b1 Mon Sep 17 00:00:00 2001 From: Janosch Frank Date: Mon, 11 Jan 2016 16:17:41 +0100 Subject: scripts/kvm/kvm_stat: Rename variables that redefine globals Filter, id and byte are builtin python modules which should not be redefined by local variables. Reviewed-by: Jason J. Herne Signed-off-by: Janosch Frank Message-Id: <1452525484-32309-12-git-send-email-frankja@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini --- scripts/kvm/kvm_stat | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index b1e5853b4d..98e1ec74b0 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -333,20 +333,21 @@ class Group(object): self.events = [] self.group_leader = None self.cpu = cpu - def add_event(self, name, event_set, tracepoint, filter=None): + def add_event(self, name, event_set, tracepoint, tracefilter=None): self.events.append(Event(group=self, name=name, event_set=event_set, - tracepoint=tracepoint, filter=filter)) + tracepoint=tracepoint, + tracefilter=tracefilter)) if len(self.events) == 1: self.file = os.fdopen(self.events[0].fd) def read(self): - bytes = 8 * (1 + len(self.events)) + length = 8 * (1 + len(self.events)) fmt = 'xxxxxxxx' + 'q' * len(self.events) return dict(zip([event.name for event in self.events], - struct.unpack(fmt, self.file.read(bytes)))) + struct.unpack(fmt, self.file.read(length)))) class Event(object): - def __init__(self, group, name, event_set, tracepoint, filter=None): + def __init__(self, group, name, event_set, tracepoint, tracefilter=None): self.name = name attr = perf_event_attr() attr.type = PERF_TYPE_TRACEPOINT @@ -364,8 +365,8 @@ class Event(object): if fd == -1: err = get_errno()[0] raise Exception('perf_event_open failed, errno = ' + err.__str__()) - if filter: - fcntl.ioctl(fd, IOCTL_NUMBERS['SET_FILTER'], filter) + if tracefilter: + fcntl.ioctl(fd, IOCTL_NUMBERS['SET_FILTER'], tracefilter) self.fd = fd def enable(self): fcntl.ioctl(self.fd, IOCTL_NUMBERS['ENABLE'], 0) @@ -415,15 +416,15 @@ class TracepointProvider(object): group = Group(cpu) for name in _fields: tracepoint = name - filter = None + tracefilter = None m = re.match(r'(.*)\((.*)\)', name) if m: tracepoint, sub = m.groups() - filter = '%s==%d\0' % (filters[tracepoint][0], - filters[tracepoint][1][sub]) + tracefilter = '%s==%d\0' % (filters[tracepoint][0], + filters[tracepoint][1][sub]) event = group.add_event(name, event_set='kvm', tracepoint=tracepoint, - filter=filter) + tracefilter=tracefilter) self.group_leaders.append(group) def select(self, fields): for group in self.group_leaders: -- cgit v1.2.3-55-g7522