ia64/xen-unstable

view tools/python/xen/xend/server/irqif.py @ 13642:ba3ec84c9423

[XEND] Add missing ConsoleController.py

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Fri Jan 26 02:44:35 2007 +0000 (2007-01-26)
parents 5bed7bc05c8a
children b377a102f0eb
line source
1 #============================================================================
2 # This library is free software; you can redistribute it and/or
3 # modify it under the terms of version 2.1 of the GNU Lesser General Public
4 # License as published by the Free Software Foundation.
5 #
6 # This library is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 # Lesser General Public License for more details.
10 #
11 # You should have received a copy of the GNU Lesser General Public
12 # License along with this library; if not, write to the Free Software
13 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14 #============================================================================
15 # Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
16 # Copyright (C) 2005 XenSource Ltd
17 # Copyright (C) 2005 Jody Belka
18 #============================================================================
19 # This code based on tools/python/xen/xend/server/iopif.py and modified
20 # to handle interrupts
21 #============================================================================
24 import types
26 import xen.lowlevel.xc
28 from xen.xend import sxp
29 from xen.xend.XendError import VmError
31 from xen.xend.server.DevController import DevController
34 xc = xen.lowlevel.xc.xc()
37 class IRQController(DevController):
39 def __init__(self, vm):
40 DevController.__init__(self, vm)
43 def getDeviceDetails(self, config):
44 """@see DevController.getDeviceDetails"""
46 def get_param(field):
47 try:
48 val = config.get(field)
50 if not val:
51 raise VmError('irq: Missing %s config setting' % field)
53 if isinstance(val, types.StringType):
54 return int(val,10)
55 radix = 10
56 else:
57 return val
58 except:
59 raise VmError('irq: Invalid config setting %s: %s' %
60 (field, val))
62 pirq = get_param('irq')
64 rc = xc.domain_irq_permission(dom = self.getDomid(),
65 pirq = pirq,
66 allow_access = True)
68 if rc < 0:
69 #todo non-fatal
70 raise VmError(
71 'irq: Failed to configure irq: %d' % (pirq))
73 return (None, {}, {})