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 | #============================================================================ |
---|
22 | |
---|
23 | |
---|
24 | import types |
---|
25 | |
---|
26 | import xen.lowlevel.xc |
---|
27 | |
---|
28 | from xen.xend import sxp |
---|
29 | from xen.xend.XendError import VmError |
---|
30 | |
---|
31 | from xen.xend.server.DevController import DevController |
---|
32 | |
---|
33 | |
---|
34 | xc = xen.lowlevel.xc.xc() |
---|
35 | |
---|
36 | |
---|
37 | class IRQController(DevController): |
---|
38 | |
---|
39 | def __init__(self, vm): |
---|
40 | DevController.__init__(self, vm) |
---|
41 | |
---|
42 | |
---|
43 | def getDeviceDetails(self, config): |
---|
44 | """@see DevController.getDeviceDetails""" |
---|
45 | |
---|
46 | def get_param(field): |
---|
47 | try: |
---|
48 | val = config.get(field) |
---|
49 | |
---|
50 | if not val: |
---|
51 | raise VmError('irq: Missing %s config setting' % field) |
---|
52 | |
---|
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)) |
---|
61 | |
---|
62 | pirq = get_param('irq') |
---|
63 | |
---|
64 | rc = xc.domain_irq_permission(dom = self.getDomid(), |
---|
65 | pirq = pirq, |
---|
66 | allow_access = True) |
---|
67 | |
---|
68 | if rc < 0: |
---|
69 | #todo non-fatal |
---|
70 | raise VmError( |
---|
71 | 'irq: Failed to configure irq: %d' % (pirq)) |
---|
72 | |
---|
73 | return (None, {}, {}) |
---|