From patchwork Tue Jun 17 07:54:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 360428 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 1EAE214007D for ; Tue, 17 Jun 2014 19:50:17 +1000 (EST) Received: from localhost ([::1]:48565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wwq1u-0007Bl-R5 for incoming@patchwork.ozlabs.org; Tue, 17 Jun 2014 05:50:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwoEV-0002Pa-LV for qemu-devel@nongnu.org; Tue, 17 Jun 2014 03:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwoEG-0002AM-HO for qemu-devel@nongnu.org; Tue, 17 Jun 2014 03:55:07 -0400 Received: from ozlabs.org ([103.22.144.67]:37716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwoEG-0002AA-68 for qemu-devel@nongnu.org; Tue, 17 Jun 2014 03:54:52 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id E66861400D3; Tue, 17 Jun 2014 17:54:49 +1000 (EST) From: Michael Ellerman To: qemu-devel@nongnu.org Date: Tue, 17 Jun 2014 17:54:34 +1000 Message-Id: <1402991675-24905-5-git-send-email-mpe@ellerman.id.au> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1402991675-24905-1-git-send-email-mpe@ellerman.id.au> References: <1402991675-24905-1-git-send-email-mpe@ellerman.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 103.22.144.67 X-Mailman-Approved-At: Tue, 17 Jun 2014 05:47:18 -0400 Cc: kvm@vger.kernel.org, aik@ozlabs.ru, jan.kiszka@siemens.com, agraf@suse.de, jfrei@linux.vnet.ibm.com, alfs@linux.vnet.ibm.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 5/6] kvm_stat: Abstract ioctl numbers 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 Unfortunately ioctl numbers are platform specific, so abstract them out of the code so they can be overridden. As it happens x86 and s390 share the same values, so nothing needs to change yet. Signed-off-by: Michael Ellerman --- scripts/kvm/kvm_stat | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 2468a22..2e0f5ed 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -180,6 +180,12 @@ filters = { 'kvm_userspace_exit': ('reason', generic_exit_reasons) } +ioctl_numbers = { + 'SET_FILTER' : 0x40082406, + 'ENABLE' : 0x00002400, + 'DISABLE' : 0x00002401, +} + def x86_init(flag): globals().update({ 'sc_perf_evt_open' : 298, @@ -304,14 +310,14 @@ class Event(object): raise Exception('perf_event_open failed') if filter: import fcntl - fcntl.ioctl(fd, 0x40082406, filter) + fcntl.ioctl(fd, ioctl_numbers['SET_FILTER'], filter) self.fd = fd def enable(self): import fcntl - fcntl.ioctl(self.fd, 0x00002400, 0) + fcntl.ioctl(self.fd, ioctl_numbers['ENABLE'], 0) def disable(self): import fcntl - fcntl.ioctl(self.fd, 0x00002401, 0) + fcntl.ioctl(self.fd, ioctl_numbers['DISABLE'], 0) class TracepointProvider(object): def __init__(self):