From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWFzr-0000hC-1d for qemu-devel@nongnu.org; Sun, 30 Aug 2015 23:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWFzm-0002F1-7e for qemu-devel@nongnu.org; Sun, 30 Aug 2015 23:43:02 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:46341) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWFzl-0002EN-Kv for qemu-devel@nongnu.org; Sun, 30 Aug 2015 23:42:58 -0400 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Aug 2015 09:12:52 +0530 From: Hemant Kumar Date: Mon, 31 Aug 2015 09:12:34 +0530 Message-Id: <1440992554-5200-1-git-send-email-hemant@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH][RESEND] qemu/kvm_stat: Fix I/O error from kvm_stat List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: wei@redhat.com, Hemant Kumar , qemu-ppc@nongnu.org, agraf@suse.de Running kvm_stat on a powerpc macine where the kernel is compiled with KVM_BOOK3S_HV_EXIT_TIMING config option, generates the following error : # kvm_stat Traceback (most recent call last): File "/usr/bin/kvm_stat", line 644, in curses.wrapper(tui, stats) File "/usr/lib64/python2.7/curses/wrapper.py", line 43, in wrapper return func(stdscr, *args, **kwds) File "/usr/bin/kvm_stat", line 550, in tui refresh(sleeptime) File "/usr/bin/kvm_stat", line 526, in refresh s = stats.get() File "/usr/bin/kvm_stat", line 486, in get new = d.read() File "/usr/bin/kvm_stat", line 29, in read return dict([(key, val(key)) for key in self._fields]) File "/usr/bin/kvm_stat", line 28, in val return int(file(self.base + '/' + key).read()) IOError: [Errno 21] Is a directory: '/sys/kernel/debug/kvm/vm12840' The error says that its trying to read the contents of a directory as if it were a file. The kernel here creates directories inside "/sys/kernel/debug/kvm/" for the individual VMs running on the machine. These directories contain timing information (for rm_entry, rm_intr, rm_exit, guest, cede) related to each vcpu of each VM. All of this is enabled with KVM_BOOK3S_HV_EXIT_TIMING config option for the kernel. kvm_stat script isn't supposed to parse/read these directories and isn't even expecting any directories inside "/sys/kernel/debug/kvm/". This patch fixes the problem by avoiding lookup for these directories. Reported-by: Krishnaja Balachandran Signed-off-by: Hemant Kumar --- scripts/kvm/kvm_stat | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 7e5d256..1da7a53 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -18,7 +18,11 @@ from ctypes import * class DebugfsProvider(object): def __init__(self): self.base = '/sys/kernel/debug/kvm' - self._fields = os.listdir(self.base) + files = os.listdir(self.base) + self._fields = [] + for f in files: + if os.path.isfile(self.base + '/' + f): + self._fields.append(f) def fields(self): return self._fields def select(self, fields): -- 1.9.3