diff options
author | Janosch Frank | 2016-01-11 16:17:45 +0100 |
---|---|---|
committer | Paolo Bonzini | 2016-01-26 15:58:12 +0100 |
commit | 8d3b5ddc4e10eeda435c8f9ceecd15cd9ab284e7 (patch) | |
tree | 53983f858c94db3ea89f951444939e4a85dad6ed | |
parent | scripts/kvm/kvm_stat: Set sensible no. files rlimit (diff) | |
download | qemu-8d3b5ddc4e10eeda435c8f9ceecd15cd9ab284e7.tar.gz qemu-8d3b5ddc4e10eeda435c8f9ceecd15cd9ab284e7.tar.xz qemu-8d3b5ddc4e10eeda435c8f9ceecd15cd9ab284e7.zip |
scripts/kvm/kvm_stat: Cleanup of platform detection
s390 machines can also be detected via uname -m, i.e. python's
os.uname, no need for more complicated checks.
Calling uname once and saving its value for multiple checks is
perfectly sufficient. We don't expect the machine's architecture to
change when the script is running anyway.
On multi-cpu systems x86_init currently will get called multiple
times, returning makes sure we don't waste cicles on that.
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1452525484-32309-16-git-send-email-frankja@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rwxr-xr-x | scripts/kvm/kvm_stat | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 93b5ea7aac..5b6742a6b7 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -254,24 +254,21 @@ def aarch64_init(): EXIT_REASONS = AARCH64_EXIT_REASONS def detect_platform(): - if os.uname()[4].startswith('ppc'): + machine = os.uname()[4] + + if machine.startswith('ppc'): ppc_init() - return - elif os.uname()[4].startswith('aarch64'): + elif machine.startswith('aarch64'): aarch64_init() - return - - for line in file('/proc/cpuinfo').readlines(): - if line.startswith('flags'): - for flag in line.split(): - if flag in X86_EXIT_REASONS: - x86_init(flag) - return - elif line.startswith('vendor_id'): - for flag in line.split(): - if flag == 'IBM/S390': - s390_init() - return + elif machine.startswith('s390'): + s390_init() + else: + for line in file('/proc/cpuinfo').readlines(): + if line.startswith('flags'): + for flag in line.split(): + if flag in X86_EXIT_REASONS: + x86_init(flag) + return def walkdir(path): |