From patchwork Mon Feb 8 17:03:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 580392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DC36E140BE7 for ; Tue, 9 Feb 2016 04:06:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=ZfBVvMW4; dkim-atps=neutral Received: from localhost ([::1]:46864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpGd-000897-V7 for incoming@patchwork.ozlabs.org; Mon, 08 Feb 2016 12:06:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpDv-0003L9-NL for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aSpDu-0006kc-G8 for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:39 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:34710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aSpDu-0006ju-AD for qemu-devel@nongnu.org; Mon, 08 Feb 2016 12:03:38 -0500 Received: by mail-wm0-x231.google.com with SMTP id 128so163725726wmz.1 for ; Mon, 08 Feb 2016 09:03:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0PqHSL+IcALHpdJO5n4YtRwG+hFsGEK68zOpug/bgAw=; b=ZfBVvMW48o0c2KCc9oZb1nz/HGsmJkcJeBQeOE93Wj2VQ+KIgKhwR5K2/7dswwCdpB XzPz1JO5AUY/T/w2ITCNannqm/LesdUsf744YMoIxG9S/gmOWzRyClR4wP+wlc4+O9qy 0dOR5tSAY3zzrDaMOuXh4oGnk54oUXi+T6MtCrL7W7YxHZxNGQEOtxUMJj/HACpYGvo6 ENUwml2Jl5BDlJ4uUKDylGSmYsiVL/DJMTgAKYNyGLJ0R3tME9Ww/Dvhie1o5UkydYqO OJHuhbvkN6NRels4UV8ICwaF5t0O1ZLIaEyjDFIo55FtW5oziI+YLVvqGppcGwdrNz4R iekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0PqHSL+IcALHpdJO5n4YtRwG+hFsGEK68zOpug/bgAw=; b=AZTZ74V56TsX+urmJfof0hY36RXPnQBc2xXhMLVb5ENoAxrOyg1/C9D3J76DLk4Bj/ og74jgAjwQsGlsF6nxZ0X5S3K2U8o2UGsNa6iHkf5uqb/KEabXjpFU3YroMXtrBuqGYI NO3iGsyzcUjssw34WKiLGcu5nxPDurp3YZNKR7akkd2HciPxs+ItImJKZo3YZMazgpmw MhMX4uhg6yaT0k/LCdI0rs5WHjFetAR7MpoFfEb4ZvDCGvrt/aRMIFnfEIhpljRJtyPH Gs+onhSVrpIysXT6K9GMqoE8RSjerHUfHNNJ2ECtd9Nn+6AugX57UQ6E4cy0VQjs94qz fMJg== X-Gm-Message-State: AG10YORPxsCAiZXmzYUwdwUYeB0eySf/lVjWkxnaUSD/2LJ5MjhuudgTcN9E2rYIt/Zahg== X-Received: by 10.28.0.86 with SMTP id 83mr6145372wma.63.1454951017666; Mon, 08 Feb 2016 09:03:37 -0800 (PST) Received: from 640k.lan (94-39-141-130.adsl-ull.clienti.tiscali.it. [94.39.141.130]) by smtp.gmail.com with ESMTPSA id b1sm30651442wjy.0.2016.02.08.09.03.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 09:03:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 8 Feb 2016 18:03:03 +0100 Message-Id: <1454950999-64128-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> References: <1454950999-64128-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::231 Cc: Janosch Frank Subject: [Qemu-devel] [PULL 12/28] scripts/kvm/kvm_stat: Fix tracefs access checking X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Janosch Frank 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 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 --- scripts/kvm/kvm_stat | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index d43e8f3..3cf1181 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)