diff options
author | Janosch Frank <frankja@linux.vnet.ibm.com> | 2016-01-11 16:17:53 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-26 15:58:13 +0100 |
commit | fc9fdeebd5f092d746438ab8eb5f8f8dc5030002 (patch) | |
tree | 2e4a26fdd4d2bef71f87c79d90408510aa8b3588 /scripts | |
parent | e75a36abb42e8ae30bb4ed6fee74699a510ea6e6 (diff) | |
download | qemu-fc9fdeebd5f092d746438ab8eb5f8f8dc5030002.tar.gz qemu-fc9fdeebd5f092d746438ab8eb5f8f8dc5030002.tar.bz2 qemu-fc9fdeebd5f092d746438ab8eb5f8f8dc5030002.zip |
scripts/kvm/kvm_stat: Cleanup of Groups class
Introduced separating newlines for readability and removed special
treatment/variable of the group leader. Renamed fmt to read_format.
The group leader's file descriptor will not be turned into a file
object anymore, instead os.read is used to read from the descriptor.
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-24-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/kvm/kvm_stat | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 203873e913..91054e5efa 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -341,20 +341,20 @@ PATH_DEBUGFS_KVM = '/sys/kernel/debug/kvm' class Group(object): def __init__(self, cpu): self.events = [] - self.group_leader = None self.cpu = cpu + def add_event(self, name, event_set, tracepoint, tracefilter=None): self.events.append(Event(group=self, name=name, event_set=event_set, tracepoint=tracepoint, tracefilter=tracefilter)) - if len(self.events) == 1: - self.file = os.fdopen(self.events[0].fd) + def read(self): length = 8 * (1 + len(self.events)) - fmt = 'xxxxxxxx' + 'q' * len(self.events) + read_format = 'xxxxxxxx' + 'q' * len(self.events) return dict(zip([event.name for event in self.events], - struct.unpack(fmt, self.file.read(length)))) + struct.unpack(read_format, + os.read(self.events[0].fd, length)))) class Event(object): def __init__(self, group, name, event_set, tracepoint, tracefilter=None): |