diff options
author | Janosch Frank <frankja@linux.vnet.ibm.com> | 2016-02-03 08:41:31 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-02-09 15:45:26 +0100 |
commit | e3dd68df5287e544a41f77a162a02d08fbcb95ba (patch) | |
tree | 45ef1fa87bc13ea1e85dd5bf4fb3b12260ca87b2 /scripts/kvm | |
parent | 50901218457aebf2eb1c1cac560eb80df3f23b77 (diff) | |
download | qemu-e3dd68df5287e544a41f77a162a02d08fbcb95ba.tar.gz qemu-e3dd68df5287e544a41f77a162a02d08fbcb95ba.tar.bz2 qemu-e3dd68df5287e544a41f77a162a02d08fbcb95ba.zip |
scripts/kvm/kvm_stat: Fix tracefs access checking
On kernels build without CONFIG_TRACING kvm_stat will bail out even
when traces are not used. This is not very helpful, especially if the
user can't install a new kernel. Instead, we should warn the user and
fall back to debugfs statistics.
These changes check if trace statistics were selected without kernel
support, warn with a small timeout, set the debugfs statistics option
to True and the tracefs one to False.
Fixes: 7aa4ee5 ('scripts/kvm/kvm_stat: Improve debugfs access checking')
Signed-off-by: Janosch Frank <frankja@linux.vnet.ibm.com>
Message-Id: <1454485291-43849-2-git-send-email-frankja@linux.vnet.ibm.com>
[Exit if -t is passed explicitly. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'scripts/kvm')
-rwxr-xr-x | scripts/kvm/kvm_stat | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index d43e8f3e85..3cf1181750 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -22,6 +22,7 @@ import resource import struct import re from collections import defaultdict +from time import sleep VMX_EXIT_REASONS = { 'EXCEPTION_NMI': 0, @@ -778,7 +779,7 @@ def get_providers(options): return providers -def check_access(): +def check_access(options): if not os.path.exists('/sys/kernel/debug'): sys.stderr.write('Please enable CONFIG_DEBUG_FS in your kernel.') sys.exit(1) @@ -790,14 +791,24 @@ def check_access(): "Also ensure, that the kvm modules are loaded.\n") sys.exit(1) - if not os.path.exists(PATH_DEBUGFS_TRACING): - sys.stderr.write("Please make {0} readable by the current user.\n" - .format(PATH_DEBUGFS_TRACING)) - sys.exit(1) + if not os.path.exists(PATH_DEBUGFS_TRACING) and (options.tracepoints + or not options.debugfs): + sys.stderr.write("Please enable CONFIG_TRACING in your kernel " + "when using the option -t (default).\n" + "If it is enabled, make {0} readable by the " + "current user.\n") + if options.tracepoints: + sys.exit(1) + + sys.stderr.write("Falling back to debugfs statistics!\n" + options.debugfs = True + sleep(5) + + return options def main(): - check_access() options = get_options() + options = check_access(options) providers = get_providers(options) stats = Stats(providers, fields=options.fields) |