debuggers.hg

view tools/python/xen/xend/XendPPCI.py @ 17989:e65fe28b5288

XenAPI: Add Physical PCI Device (PPCI) Support

Signed-off-by: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jul 03 10:26:16 2008 +0100 (2008-07-03)
parents
children dec845b4d9c3
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) 2008 NEC Corporation
16 # Yosuke Iwamatsu <y-iwamatsu at ab jp nec com>
17 #============================================================================
19 from xen.xend.XendBase import XendBase
20 from xen.xend.XendBase import XendAPIStore
21 from xen.xend import uuid as genuuid
23 class XendPPCI(XendBase):
24 """Representation of a physical PCI device."""
26 def getClass(self):
27 return "PPCI"
29 def getAttrRO(self):
30 attrRO = ['host',
31 'domain',
32 'bus',
33 'slot',
34 'func',
35 'name',
36 'vendor_id',
37 'vendor_name',
38 'device_id',
39 'device_name',
40 'revision_id',
41 'class_code',
42 'class_name',
43 'subsystem_vendor_id',
44 'subsystem_vendor_name',
45 'subsystem_id',
46 'subsystem_name',
47 'driver']
48 return XendBase.getAttrRO() + attrRO
50 def getAttrRW(self):
51 attrRW = []
52 return XendBase.getAttrRW() + attrRW
54 def getAttrInst(self):
55 attrInst = []
56 return XendBase.getAttrInst() + attrInst
58 def getMethods(self):
59 methods = []
60 return XendBase.getMethods() + methods
62 def getFuncs(self):
63 funcs = []
64 return XendBase.getFuncs() + funcs
66 getClass = classmethod(getClass)
67 getAttrRO = classmethod(getAttrRO)
68 getAttrRW = classmethod(getAttrRW)
69 getAttrInst = classmethod(getAttrInst)
70 getMethods = classmethod(getMethods)
71 getFuncs = classmethod(getFuncs)
73 def get_by_sbdf(self, domain, bus, slot, func):
74 for ppci in XendAPIStore.get_all("PPCI"):
75 if ppci.get_domain() == int(domain, 16) and \
76 ppci.get_bus() == int(bus, 16) and \
77 ppci.get_slot() == int(slot, 16) and \
78 ppci.get_func() == int(func, 16):
79 return ppci.get_uuid()
80 return None
82 get_by_sbdf = classmethod(get_by_sbdf)
84 def __init__(self, uuid, record):
85 self.domain = record['domain']
86 self.bus = record['bus']
87 self.slot = record['slot']
88 self.func = record['func']
89 self.vendor_id = record['vendor_id']
90 self.vendor_name = record['vendor_name']
91 self.device_id = record['device_id']
92 self.device_name = record['device_name']
93 self.revision_id = record['revision_id']
94 self.class_code = record['class_code']
95 self.class_name = record['class_name']
96 self.subsystem_vendor_id = record['subsystem_vendor_id']
97 self.subsystem_vendor_name = record['subsystem_vendor_name']
98 self.subsystem_id = record['subsystem_id']
99 self.subsystem_name = record['subsystem_name']
100 self.driver = record['driver']
101 XendBase.__init__(self, uuid, record)
103 def get_host(self):
104 from xen.xend import XendNode
105 return XendNode.instance().get_uuid()
107 def get_domain(self):
108 return self.domain
110 def get_bus(self):
111 return self.bus
113 def get_slot(self):
114 return self.slot
116 def get_func(self):
117 return self.func
119 def get_name(self):
120 return "%04x:%02x:%02x.%01x" % (self.domain, self.bus, self.slot,
121 self.func)
123 def get_vendor_id(self):
124 return self.vendor_id
126 def get_vendor_name(self):
127 return self.vendor_name
129 def get_device_id(self):
130 return self.device_id
132 def get_device_name(self):
133 return self.device_name
135 def get_class_code(self):
136 return self.class_code
138 def get_class_name(self):
139 return self.class_name
141 def get_revision_id(self):
142 return self.revision_id
144 def get_subsystem_vendor_id(self):
145 return self.subsystem_vendor_id
147 def get_subsystem_vendor_name(self):
148 return self.subsystem_vendor_name
150 def get_subsystem_id(self):
151 return self.subsystem_id
153 def get_subsystem_name(self):
154 return self.subsystem_name
156 def get_driver(self):
157 return self.driver