mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
xend: pass-through: Add key to pci device dictionary
This will be used to identify the functions belonging to a multi-function device. Cc: Dexuan Cui <dexuan.cui@intel.com> Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
This commit is contained in:
1 parent
88b7aa5e4c
commit
437cbbf3fb
9 files changed
+36
-13
No files matched your search
@@ -277,7 +277,7 @@ def parse_pci_name_extended(pci_dev_str):
|
||||
template['domain'] = "0x%04x" % domain
|
||||
template['bus'] = "0x%02x" % int(pci_dev_info['bus'], 16)
|
||||
template['slot'] = "0x%02x" % int(pci_dev_info['slot'], 16)
|
||||
template['func'] = "0x%x" % int(pci_dev_info['func'], 16)
|
||||
template['key'] = pci_dev_str
|
||||
if pci_dev_info['opts'] != '':
|
||||
template['opts'] = split_pci_opts(pci_dev_info['opts'])
|
||||
check_pci_opts(template['opts'])
|
||||
@@ -290,6 +290,7 @@ def parse_pci_name_extended(pci_dev_str):
|
||||
pci_dev_info['func'])
|
||||
for func in func_list:
|
||||
pci_dev = template.copy()
|
||||
pci_dev['func'] = "0x%x" % func
|
||||
|
||||
if len(func_list) == 1:
|
||||
# For single-function devices vfunc must be 0
|
||||
|
||||
@@ -1249,7 +1249,8 @@ class XendConfig(dict):
|
||||
dpci_record = {
|
||||
'VM': self['uuid'],
|
||||
'PPCI': ppci_uuid,
|
||||
'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT)
|
||||
'hotplug_slot': pci_dev.get('vslot', '0x%02x' % AUTO_PHP_SLOT),
|
||||
'key': pci_dev['key']
|
||||
}
|
||||
|
||||
dpci_opts = pci_dev.get('opts')
|
||||
|
||||
@@ -42,6 +42,7 @@ class XendDPCI(XendBase):
|
||||
'VM',
|
||||
'PPCI',
|
||||
'hotplug_slot',
|
||||
'key',
|
||||
'options']
|
||||
return XendBase.getAttrRO() + attrRO
|
||||
|
||||
@@ -52,7 +53,8 @@ class XendDPCI(XendBase):
|
||||
def getAttrInst(self):
|
||||
attrInst = ['VM',
|
||||
'PPCI',
|
||||
'hotplug_slot']
|
||||
'hotplug_slot',
|
||||
'key']
|
||||
return XendBase.getAttrInst() + attrInst
|
||||
|
||||
def getMethods(self):
|
||||
@@ -120,6 +122,7 @@ class XendDPCI(XendBase):
|
||||
self.VM = record['VM']
|
||||
self.PPCI = record['PPCI']
|
||||
self.hotplug_slot = int(record['hotplug_slot'], 16)
|
||||
self.key = record['key']
|
||||
if 'options' in record.keys():
|
||||
self.options = record['options']
|
||||
|
||||
@@ -155,5 +158,8 @@ class XendDPCI(XendBase):
|
||||
def get_hotplug_slot(self):
|
||||
return "%d" % self.hotplug_slot
|
||||
|
||||
def get_key(self):
|
||||
return self.key
|
||||
|
||||
def get_options(self):
|
||||
return self.options
|
||||
@@ -3733,6 +3733,7 @@ class XendDomainInfo:
|
||||
['slot', '0x%02x' % ppci.get_slot()],
|
||||
['func', '0x%1x' % ppci.get_func()],
|
||||
['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
|
||||
['key', xenapi_pci['key']],
|
||||
['uuid', dpci_uuid]]
|
||||
dev_sxp = sxp.merge(dev_sxp, opts_sxp)
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ class PciController(DevController):
|
||||
back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
|
||||
(domain, bus, slot, func)
|
||||
back['uuid-%i' % pcidevid] = pci_config.get('uuid', '')
|
||||
back['key-%i' % pcidevid] = pci_config.get('key', '')
|
||||
back['vslot-%i' % pcidevid] = "%02x" % vslot
|
||||
pcidevid += 1
|
||||
|
||||
@@ -113,6 +114,7 @@ class PciController(DevController):
|
||||
dev = back['dev-%i' % i]
|
||||
state = states[i]
|
||||
uuid = back['uuid-%i' %i]
|
||||
key = back['key-%i' %i]
|
||||
opts = ''
|
||||
if 'opts-%i' % i in back:
|
||||
opts = back['opts-%i' % i]
|
||||
@@ -135,6 +137,7 @@ class PciController(DevController):
|
||||
self.writeBackend(devid, 'state-%i' % devno,
|
||||
str(xenbusState['Initialising']))
|
||||
self.writeBackend(devid, 'uuid-%i' % devno, uuid)
|
||||
self.writeBackend(devid, 'key-%i' % devno, key)
|
||||
if len(opts) > 0:
|
||||
self.writeBackend(devid, 'opts-%i' % devno, opts)
|
||||
if back.has_key('vslot-%i' % i):
|
||||
@@ -173,6 +176,7 @@ class PciController(DevController):
|
||||
|
||||
# Per device uuid info
|
||||
pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
|
||||
pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
|
||||
pci_dev['vslot'] = '0x%s' % self.readBackend(devid, 'vslot-%d' % i)
|
||||
|
||||
#append opts info
|
||||
@@ -500,7 +504,7 @@ class PciController(DevController):
|
||||
# In HVM case, I/O resources are disabled in ioemu.
|
||||
self.cleanupOneDevice(pci_dev)
|
||||
# Remove xenstore nodes.
|
||||
list = ['dev', 'vdev', 'state', 'uuid', 'vslot']
|
||||
list = ['dev', 'vdev', 'state', 'uuid', 'vslot', 'key']
|
||||
if self.readBackend(devid, 'opts-%i' % i) is not None:
|
||||
list.append('opts')
|
||||
for key in list:
|
||||
@@ -510,7 +514,7 @@ class PciController(DevController):
|
||||
if new_num_devs == i + 1:
|
||||
continue
|
||||
|
||||
list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot']
|
||||
list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key']
|
||||
for key in list:
|
||||
tmp = self.readBackend(devid, '%s-%i' % (key, i))
|
||||
if tmp is None:
|
||||
|
||||
@@ -90,7 +90,8 @@
|
||||
slot CDATA #REQUIRED
|
||||
func CDATA #REQUIRED
|
||||
opts_str CDATA #IMPLIED
|
||||
vslot CDATA #IMPLIED>
|
||||
vslot CDATA #IMPLIED
|
||||
key CDATA #IMPLIED>
|
||||
|
||||
<!ELEMENT vscsi EMPTY>
|
||||
<!ATTLIST vscsi p-dev CDATA #REQUIRED
|
||||
|
||||
@@ -1074,14 +1074,15 @@ def preprocess_cpuid(vals, attr_name):
|
||||
|
||||
def pci_dict_to_tuple(dev):
|
||||
return (dev['domain'], dev['bus'], dev['slot'], dev['func'],
|
||||
dev['vslot'], dev.get('opts', []))
|
||||
dev['vslot'], dev.get('opts', []), dev['key'])
|
||||
|
||||
def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts)):
|
||||
def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts, key)):
|
||||
pci_dev = { 'domain': domain,
|
||||
'bus': bus,
|
||||
'slot': slot,
|
||||
'func': func,
|
||||
'vslot': vslot}
|
||||
'vslot': vslot,
|
||||
'key': key}
|
||||
if len(opts) > 0:
|
||||
pci_dev['opts'] = opts
|
||||
return pci_dev
|
||||
|
||||
@@ -2186,7 +2186,8 @@ def attached_pci_dict_bin(dom):
|
||||
'bus': int(ppci_record['bus']),
|
||||
'slot': int(ppci_record['slot']),
|
||||
'func': int(ppci_record['func']),
|
||||
'vslot': int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
|
||||
'vslot': int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)),
|
||||
'key': server.xenapi.DPCI.get_key(dpci_ref)
|
||||
}
|
||||
devs.append(dev)
|
||||
|
||||
@@ -2197,7 +2198,8 @@ def attached_pci_dict_bin(dom):
|
||||
'bus': int(x['bus'], 16),
|
||||
'slot': int(x['slot'], 16),
|
||||
'func': int(x['func'], 16),
|
||||
'vslot': int(x['vslot'], 16)
|
||||
'vslot': int(x['vslot'], 16),
|
||||
'key': x['key']
|
||||
}
|
||||
devs.append(dev)
|
||||
|
||||
@@ -2543,6 +2545,7 @@ def xm_pci_attach(args):
|
||||
slot = int(sxp.child_value(pci_dev, 'slot'), 16)
|
||||
func = int(sxp.child_value(pci_dev, 'func'), 16)
|
||||
vslot = int(sxp.child_value(pci_dev, 'vslot'), 16)
|
||||
key = sxp.child_value(pci_dev, 'key')
|
||||
name = "%04x:%02x:%02x.%01x" % (domain, bus, slot, func)
|
||||
|
||||
target_ref = None
|
||||
@@ -2557,7 +2560,8 @@ def xm_pci_attach(args):
|
||||
"VM": get_single_vm(dom),
|
||||
"PPCI": target_ref,
|
||||
"hotplug_slot": vslot,
|
||||
"options": dict(config_pci_opts)
|
||||
"options": dict(config_pci_opts),
|
||||
"key": key
|
||||
}
|
||||
server.xenapi.DPCI.create(dpci_record)
|
||||
|
||||
|
||||
@@ -543,7 +543,9 @@ class xenapi_create:
|
||||
int(pci.attributes["vslot"].value, 16),
|
||||
"options":
|
||||
get_child_nodes_as_dict(pci,
|
||||
"pci_opt", "key", "value")
|
||||
"pci_opt", "key", "value"),
|
||||
"key":
|
||||
pci.attributes["key"].value
|
||||
}
|
||||
|
||||
return server.xenapi.DPCI.create(dpci_record)
|
||||
@@ -946,6 +948,8 @@ class sxp2xml:
|
||||
= get_child_by_name(dev_sxp, "func", "0")
|
||||
pci.attributes["vslot"] \
|
||||
= get_child_by_name(dev_sxp, "vslot", "0")
|
||||
pci.attributes["key"] \
|
||||
= get_child_by_name(dev_sxp, "key", "0")
|
||||
for opt in pci_opts_list_from_sxp(dev_sxp):
|
||||
pci_opt = document.createElement("pci_opt")
|
||||
pci_opt.attributes["key"] = opt[0]
|
||||
|
||||