kvm_stat: Abstract ioctl numbers

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 <mpe@ellerman.id.au>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
master
Michael Ellerman 2014-06-17 17:54:34 +10:00 committed by Paolo Bonzini
parent 4d4103ff32
commit a15d5642a0
1 changed files with 9 additions and 3 deletions

View File

@ -177,6 +177,12 @@ x86_exit_reasons = {
sc_perf_evt_open = None sc_perf_evt_open = None
exit_reasons = None exit_reasons = None
ioctl_numbers = {
'SET_FILTER' : 0x40082406,
'ENABLE' : 0x00002400,
'DISABLE' : 0x00002401,
}
def x86_init(flag): def x86_init(flag):
globals().update({ globals().update({
'sc_perf_evt_open' : 298, 'sc_perf_evt_open' : 298,
@ -301,14 +307,14 @@ class Event(object):
raise Exception('perf_event_open failed') raise Exception('perf_event_open failed')
if filter: if filter:
import fcntl import fcntl
fcntl.ioctl(fd, 0x40082406, filter) fcntl.ioctl(fd, ioctl_numbers['SET_FILTER'], filter)
self.fd = fd self.fd = fd
def enable(self): def enable(self):
import fcntl import fcntl
fcntl.ioctl(self.fd, 0x00002400, 0) fcntl.ioctl(self.fd, ioctl_numbers['ENABLE'], 0)
def disable(self): def disable(self):
import fcntl import fcntl
fcntl.ioctl(self.fd, 0x00002401, 0) fcntl.ioctl(self.fd, ioctl_numbers['DISABLE'], 0)
class TracepointProvider(object): class TracepointProvider(object):
def __init__(self): def __init__(self):