From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFyr-0006xR-Tu for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:27:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XkFym-00081K-S5 for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:27:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52607) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XkFym-00081A-Es for qemu-devel@nongnu.org; Fri, 31 Oct 2014 13:27:16 -0400 From: Paolo Bonzini Date: Fri, 31 Oct 2014 18:26:05 +0100 Message-Id: <1414776373-9704-28-git-send-email-pbonzini@redhat.com> In-Reply-To: <1414776373-9704-1-git-send-email-pbonzini@redhat.com> References: <1414776373-9704-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 27/35] kvm_stat: Abstract ioctl numbers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Michael Ellerman From: Michael Ellerman 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 Signed-off-by: Paolo Bonzini --- 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 00d4c5d..a65d0a3 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -177,6 +177,12 @@ x86_exit_reasons = { sc_perf_evt_open = None exit_reasons = None +ioctl_numbers = { + 'SET_FILTER' : 0x40082406, + 'ENABLE' : 0x00002400, + 'DISABLE' : 0x00002401, +} + def x86_init(flag): globals().update({ 'sc_perf_evt_open' : 298, @@ -301,14 +307,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): -- 1.8.3.1