Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3926681imm; Mon, 8 Oct 2018 11:48:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61e6sbcmJpV++0ntrv2pOq+1xkc1AQjFlsNKA1HLPwdTqLy4QqNEHFuyrMeXcpOcdjjop8F X-Received: by 2002:a62:f553:: with SMTP id n80-v6mr26195468pfh.59.1539024530295; Mon, 08 Oct 2018 11:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024530; cv=none; d=google.com; s=arc-20160816; b=xVi20y9j6WyUnF9ie3PWqV2mkFwHTazzymcyjDwT5/jkuD/Nn7AaEDDdaqLMGua4xK 91Ju8GRgO3kE9qSxmUVynZm8E3Dua4lrlwckA6Pt/8UieTSE9tDcXn+cEnAyMqf9hQ+X Iout5hdyrVzqDA/e2XABt+UQhw5qWhxqcZyXMPchwAVVN234C6FklxBIsTXgnyjXIWcp v0ejM3KDYGQBBBM4IZ0O29WfmJF9c02XctAj1l16CSSaNjlKeyUFtmxcbzRgvg8/Zl52 dpcXz7zvhNjpyuYumV4J9kw3BThKJu5YudFpzD2Uyl0ZZ5qlJpjBJLbJzhBR+pBcyDSY APIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xyoJTiYy9mdxRMVlhn2BDcDvVJ4tXVThmli2y87o2Fo=; b=xWsZP/dRstg1paPLCTe0nDL9IeAfQVPI/4x5U2eDDS3W0okdchdowiBOkCYrmePTBJ r9JQhWvAMnFaNzXUuDV+iQ4jdOJ6eeyeGlWfsMb5BW/r706aIH+d5/YQQC7MWMREYwmp vYbpXzrcmKCJ6+QzAy3koZaQ8DTVGofxOBPozQPMGUBRFgwjI9imtJj//i+RXxOGstzi qNUzM8XFQtdUh6JsW9fD8fONKjlf74Jfmtw9fnDMJ3Q9bujVLnerNzbOnM12PDdSQabO 36LWNhHPacDrj5t+UL8Iv0aDZa7yW7/s51p/WwlNdqBt9Rt+97dvP1LHFnidBUTXnGe+ 8jMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Zfz/p3oG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 145-v6si18872711pgd.509.2018.10.08.11.48.35; Mon, 08 Oct 2018 11:48:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Zfz/p3oG"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731684AbeJICBg (ORCPT + 99 others); Mon, 8 Oct 2018 22:01:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:50692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeJICBg (ORCPT ); Mon, 8 Oct 2018 22:01:36 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E0002204FD; Mon, 8 Oct 2018 18:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024509; bh=0I75gtAas8BA1GWrmmwtgT+89OHtL1rzDSrW3M8CdCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zfz/p3oGTIGODXm/7DdYDFQW5I2ECuYDsF5N2RK1f698G2CgAVEdbW3tjSApZbPtQ vsvE6nT6QzkzL5I8XDP5NBHcRnpw0NDybw0KtXvQ4oGjcbK1ZQVHx3FeuS9u4f1ViF sPifkVwbiYpUeCGfOfj5MLfo2Kez9qy6Fs0WFSz0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Raspl , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Sasha Levin Subject: [PATCH 4.18 041/168] tools/kvm_stat: fix handling of invalid paths in debugfs provider Date: Mon, 8 Oct 2018 20:30:21 +0200 Message-Id: <20181008175621.607112948@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stefan Raspl [ Upstream commit 617c66b9f236d20f11cecbb3f45e6d5675b2fae1 ] When filtering by guest, kvm_stat displays garbage when the guest is destroyed - see sample output below. We add code to remove the invalid paths from the providers, so at least no more garbage is displayed. Here's a sample output to illustrate: kvm statistics - pid 13986 (foo) Event Total %Total CurAvg/s diagnose_258 -2 0.0 0 deliver_program_interruption -3 0.0 0 diagnose_308 -4 0.0 0 halt_poll_invalid -91 0.0 -6 deliver_service_signal -244 0.0 -16 halt_successful_poll -250 0.1 -17 exit_pei -285 0.1 -19 exit_external_request -312 0.1 -21 diagnose_9c -328 0.1 -22 userspace_handled -713 0.1 -47 halt_attempted_poll -939 0.2 -62 deliver_emergency_signal -3126 0.6 -208 halt_wakeup -7199 1.5 -481 exit_wait_state -7379 1.5 -493 diagnose_500 -56499 11.5 -3757 exit_null -85491 17.4 -5685 diagnose_44 -133300 27.1 -8874 exit_instruction -195898 39.8 -13037 Total -492063 Signed-off-by: Stefan Raspl Signed-off-by: Radim Krčmář Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/kvm/kvm_stat/kvm_stat | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat @@ -766,6 +766,13 @@ class DebugfsProvider(Provider): self.do_read = True self.reset() + def _verify_paths(self): + """Remove invalid paths""" + for path in self.paths: + if not os.path.exists(os.path.join(PATH_DEBUGFS_KVM, path)): + self.paths.remove(path) + continue + def read(self, reset=0, by_guest=0): """Returns a dict with format:'file name / field -> current value'. @@ -780,6 +787,7 @@ class DebugfsProvider(Provider): # If no debugfs filtering support is available, then don't read. if not self.do_read: return results + self._verify_paths() paths = self.paths if self._pid == 0: