xend: pass-through: rename vslot to vdevfn and vslots to vdevfns

This is a noisy patch that makes not functional changes.
It renames vslot to vdevfn and vslots to vdevfns.

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:
Keir Fraser committed 2009-06-27 10:00:24 +01:00
1 parent 82334d45f3
commit e22b1a81b3
8 files changed
+78 -74

No files matched your search

+12 -12
View File
@@ -180,10 +180,10 @@ def pci_convert_sxp_to_dict(dev_sxp):
# extendend like this:
#
# [device, [pci, [dev, [domain, 0], [bus, 0], [slot, 1], [func, 2],
# [vslot, 0]],
# [vdevfn, 0]],
# [state, 'Initialising']]]
#
# 'vslot' shows the virtual hotplug slot number which the PCI device
# 'vdevfn' shows the virtual hotplug slot number which the PCI device
# is inserted in. This is only effective for HVM domains.
#
# state 'Initialising' indicates that the device is being attached,
@@ -191,7 +191,7 @@ def pci_convert_sxp_to_dict(dev_sxp):
#
# The Dict looks like this:
#
# { devs: [{domain: 0, bus: 0, slot: 1, func: 2, vslot: 0}],
# { devs: [{domain: 0, bus: 0, slot: 1, func: 2, vdevfn: 0}],
# states: ['Initialising'] }
dev_config = {}
@@ -260,7 +260,7 @@ def parse_pci_name_extended(pci_dev_str):
r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" +
r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" +
r"(?P<func>(\*|[0-7]([,-][0-7])*))" +
r"(@(?P<vslot>[01]?[0-9a-fA-F]))?" +
r"(@(?P<vdevfn>[01]?[0-9a-fA-F]))?" +
r"(,(?P<opts>.*))?$", pci_dev_str)
if pci_match == None:
@@ -299,11 +299,11 @@ def parse_pci_name_extended(pci_dev_str):
# For multi-function virtual devices,
# identity map the func to vfunc
vfunc = func
if pci_dev_info['vslot'] == '':
vslot = AUTO_PHP_SLOT | vfunc
if pci_dev_info['vdevfn'] == '':
vdevfn = AUTO_PHP_SLOT | vfunc
else:
vslot = PCI_DEVFN(int(pci_dev_info['vslot'], 16), vfunc)
pci_dev['vslot'] = "0x%02x" % vslot
vdevfn = PCI_DEVFN(int(pci_dev_info['vdevfn'], 16), vfunc)
pci_dev['vdevfn'] = "0x%02x" % vdevfn
pci.append(pci_dev)
@@ -314,7 +314,7 @@ def parse_pci_name_extended(pci_dev_str):
# By arranging things so that virtual function 0 is first,
# attachemnt can use the returned list as is. And detachment
# can just reverse the list.
pci.sort(None, lambda x: int(x['vslot'], 16), 1)
pci.sort(None, lambda x: int(x['vdevfn'], 16), 1)
return pci
def parse_pci_name(pci_name_string):
@@ -326,11 +326,11 @@ def parse_pci_name(pci_name_string):
pci_name_string)
pci = dev[0]
if not int(pci['vslot'], 16) & AUTO_PHP_SLOT:
if not int(pci['vdevfn'], 16) & AUTO_PHP_SLOT:
raise PciDeviceParseError(("Failed to parse pci device: %s: " +
"vslot provided where prohibited: 0x%02x") %
"vdevfn provided where prohibited: 0x%02x") %
(pci_name_string,
PCI_SLOT(int(pci['vslot'], 16))))
PCI_SLOT(int(pci['vdevfn'], 16))))
if 'opts' in pci:
raise PciDeviceParseError(("Failed to parse pci device: %s: " +
"options provided where prohibited: %s") %
+3 -3
View File
@@ -1249,7 +1249,7 @@ 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('vdevfn', '0x%02x' % AUTO_PHP_SLOT),
'key': pci_dev['key']
}
@@ -2065,8 +2065,8 @@ class XendConfig(dict):
bus = sxp.child_value(dev, 'bus')
slot = sxp.child_value(dev, 'slot')
func = sxp.child_value(dev, 'func')
vslot = sxp.child_value(dev, 'vslot')
vdevfn = sxp.child_value(dev, 'vdevfn')
opts = pci_opts_list_from_sxp(dev)
pci.append([domain, bus, slot, func, vslot, opts])
pci.append([domain, bus, slot, func, vdevfn, opts])
self['platform']['pci'] = pci
+28 -26
View File
@@ -637,7 +637,7 @@ class XendDomainInfo:
if len(dev) == 0:
continue
if int(head_dev['vslot'], 16) & AUTO_PHP_SLOT:
if int(head_dev['vdevfn'], 16) & AUTO_PHP_SLOT:
new_dev_info = self._getDeviceInfo_pci(devid)
if new_dev_info is None:
continue
@@ -648,14 +648,15 @@ class XendDomainInfo:
new_head_dev = filter(lambda x: pci_dict_cmp(x, head_dev),
new_pci_devs)[0]
if int(new_head_dev['vslot'], 16) & AUTO_PHP_SLOT:
if int(new_head_dev['vdevfn'], 16) & AUTO_PHP_SLOT:
continue
vslot = PCI_SLOT(int(new_head_dev['vslot'], 16))
vdevfn = PCI_SLOT(int(new_head_dev['vdevfn'], 16))
new_dev = []
for i in dev:
i['vslot'] = '0x%02x' % \
PCI_DEVFN(vslot, PCI_FUNC(int(i['vslot'], 16)))
i['vdevfn'] = '0x%02x' % \
PCI_DEVFN(vdevfn,
PCI_FUNC(int(i['vdevfn'], 16)))
new_dev.append(i)
dev = new_dev
@@ -683,9 +684,10 @@ class XendDomainInfo:
pci_conf = self.info['devices'][dev_uuid][1]
pci_devs = pci_conf['devs']
for x in pci_devs:
if (int(x['vslot'], 16) == int(new_dev['vslot'], 16) and
not int(x['vslot'], 16) & AUTO_PHP_SLOT):
raise VmError("vslot %s already have a device." % (new_dev['vslot']))
if (int(x['vdevfn'], 16) == int(new_dev['vdevfn'], 16) and
not int(x['vdevfn'], 16) & AUTO_PHP_SLOT):
raise VmError("vdevfn %s already have a device." %
(new_dev['vdevfn']))
if (pci_dict_cmp(x, new_dev)):
raise VmError("device is already inserted")
@@ -769,22 +771,22 @@ class XendDomainInfo:
opts = ',' + serialise_pci_opts(new_dev['opts'])
bdf_str = "%s@%02x%s" % (pci_dict_to_bdf_str(new_dev),
int(new_dev['vslot'], 16), opts)
int(new_dev['vdevfn'], 16), opts)
log.debug("XendDomainInfo.hvm_pci_device_insert_dev: %s" % bdf_str)
self.image.signalDeviceModel('pci-ins', 'pci-inserted', bdf_str)
vslot = xstransact.Read("/local/domain/0/device-model/%i/parameter"
vdevfn = xstransact.Read("/local/domain/0/device-model/%i/parameter"
% self.getDomid())
try:
vslot_int = int(vslot, 16)
vdevfn_int = int(vdevfn, 16)
except ValueError:
raise VmError(("Cannot pass-through PCI function '%s'. " +
"Device model reported an error: %s") %
(bdf_str, vslot))
(bdf_str, vdevfn))
else:
vslot = new_dev['vslot']
vdevfn = new_dev['vdevfn']
return vslot
return vdevfn
def device_create(self, dev_config):
@@ -865,14 +867,14 @@ class XendDomainInfo:
if pci_state == 'Initialising':
# HVM PCI device attachment
if pci_sub_state == 'Booting':
vslot = self.hvm_pci_device_insert(dev_config)
vdevfn = self.hvm_pci_device_insert(dev_config)
else:
vslot = self.hvm_pci_device_create(dev_config)
# Update vslot
dev['vslot'] = vslot
vdevfn = self.hvm_pci_device_create(dev_config)
# Update vdevfn
dev['vdevfn'] = vdevfn
for n in sxp.children(pci_dev):
if(n[0] == 'vslot'):
n[1] = vslot
if(n[0] == 'vdevfn'):
n[1] = vdevfn
else:
# HVM PCI device detachment
existing_dev_uuid = sxp.child_value(existing_dev_info, 'uuid')
@@ -891,13 +893,13 @@ class XendDomainInfo:
# hot-plugged. Telling qemu-dm to unplug function 0
# also tells it to unplug all other functions in the
# same vslot.
if (PCI_FUNC(int(new_dev['vslot'], 16)) == 0):
if (PCI_FUNC(int(new_dev['vdevfn'], 16)) == 0):
self.hvm_destroyPCIDevice(new_dev)
# Update vslot
dev['vslot'] = new_dev['vslot']
# Update vdevfn
dev['vdevfn'] = new_dev['vdevfn']
for n in sxp.children(pci_dev):
if(n[0] == 'vslot'):
n[1] = new_dev['vslot']
if(n[0] == 'vdevfn'):
n[1] = new_dev['vdevfn']
# If pci platform does not exist, create and exit.
if existing_dev_info is None:
@@ -3772,7 +3774,7 @@ class XendDomainInfo:
['bus', '0x%02x' % ppci.get_bus()],
['slot', '0x%02x' % ppci.get_slot()],
['func', '0x%1x' % ppci.get_func()],
['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
['vdevfn', '0x%02x' % xenapi_pci.get('hotplug_slot')],
['key', xenapi_pci['key']],
['uuid', dpci_uuid]]
dev_sxp = sxp.merge(dev_sxp, opts_sxp)
+10 -8
View File
@@ -74,7 +74,8 @@ class PciController(DevController):
bus = parse_hex(pci_config.get('bus', 0))
slot = parse_hex(pci_config.get('slot', 0))
func = parse_hex(pci_config.get('func', 0))
vslot = parse_hex(pci_config.get('vslot', '0x%02x' % AUTO_PHP_SLOT))
vdevfn = parse_hex(pci_config.get('vdevfn', \
'0x%02x' % AUTO_PHP_SLOT))
if pci_config.has_key('opts'):
opts = serialise_pci_opts(pci_config['opts'])
@@ -84,7 +85,7 @@ class PciController(DevController):
(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
back['vdevfn-%i' % pcidevid] = "%02x" % vdevfn
pcidevid += 1
back['num_devs']=str(pcidevid)
@@ -140,9 +141,9 @@ class PciController(DevController):
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):
self.writeBackend(devid, 'vslot-%i' % devno,
back['vslot-%i' % i])
if back.has_key('vdevfn-%i' % i):
self.writeBackend(devid, 'vdevfn-%i' % devno,
back['vdevfn-%i' % i])
# If a device is being attached then num_devs will grow
if attaching:
@@ -177,7 +178,8 @@ 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)
pci_dev['vdevfn'] = '0x%s' % self.readBackend(devid,
'vdevfn-%d' % i)
#append opts info
opts = self.readBackend(devid, 'opts-%d' % i)
@@ -504,7 +506,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', 'key']
list = ['dev', 'vdev', 'state', 'uuid', 'vdevfn', 'key']
if self.readBackend(devid, 'opts-%i' % i) is not None:
list.append('opts')
for key in list:
@@ -514,7 +516,7 @@ class PciController(DevController):
if new_num_devs == i + 1:
continue
list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vslot', 'key']
list = ['dev', 'vdev', 'state', 'uuid', 'opts', 'vdevfn', 'key']
for key in list:
tmp = self.readBackend(devid, '%s-%i' % (key, i))
if tmp is None:
+1 -1
View File
@@ -90,7 +90,7 @@
slot CDATA #REQUIRED
func CDATA #REQUIRED
opts_str CDATA #IMPLIED
vslot CDATA #IMPLIED
vdevfn CDATA #IMPLIED
key CDATA #IMPLIED>
<!ELEMENT vscsi EMPTY>
+3 -3
View File
@@ -1074,14 +1074,14 @@ 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['key'])
dev['vdevfn'], dev.get('opts', []), dev['key'])
def pci_tuple_to_dict((domain, bus, slot, func, vslot, opts, key)):
def pci_tuple_to_dict((domain, bus, slot, func, vdevfn, opts, key)):
pci_dev = { 'domain': domain,
'bus': bus,
'slot': slot,
'func': func,
'vslot': vslot,
'vdevfn': vdevfn,
'key': key}
if len(opts) > 0:
pci_dev['opts'] = opts
+18 -18
View File
@@ -2186,7 +2186,7 @@ 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)),
'vdevfn': int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref)),
'key': server.xenapi.DPCI.get_key(dpci_ref)
}
devs.append(dev)
@@ -2198,7 +2198,7 @@ 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),
'vdevfn': int(x['vdevfn'], 16),
'key': x['key']
}
devs.append(dev)
@@ -2212,7 +2212,7 @@ def pci_dict_bin_to_str(pci_dev):
new_dev['bus'] = '0x%02x' % pci_dev['bus']
new_dev['slot'] = '0x%02x' % pci_dev['slot']
new_dev['func'] = '0x%x' % pci_dev['func']
new_dev['vslot'] = '0x%02x' % pci_dev['vslot']
new_dev['vdevfn'] = '0x%02x' % pci_dev['vdevfn']
return new_dev
@@ -2227,22 +2227,22 @@ def xm_pci_list(args):
return
devs.sort(None,
lambda x: (x['vslot'] - PCI_FUNC(x['vslot'])) << 32 |
lambda x: (x['vdevfn'] - PCI_FUNC(x['vdevfn'])) << 32 |
PCI_BDF(x['domain'], x['bus'], x['slot'], x['func']))
has_vslot = False
has_vdevfn = False
for x in devs:
if x['vslot'] & AUTO_PHP_SLOT:
if x['vdevfn'] & AUTO_PHP_SLOT:
x['show_vslot'] = '-'
x['show_vfunc'] = '-'
else:
x['show_vslot'] = "0x%02x" % PCI_SLOT(x['vslot'])
x['show_vfunc'] = "0x%x" % PCI_FUNC(x['vslot'])
has_vslot = True
x['show_vslot'] = "0x%02x" % PCI_SLOT(x['vdevfn'])
x['show_vfunc'] = "0x%x" % PCI_FUNC(x['vdevfn'])
has_vdevfn = True
hdr_str = 'domain bus slot func'
fmt_str = '0x%(domain)04x 0x%(bus)02x 0x%(slot)02x 0x%(func)x'
if has_vslot:
if has_vdevfn:
hdr_str = 'VSlt VFn ' + hdr_str
fmt_str = '%(show_vslot)-4s %(show_vfunc)-3s ' + fmt_str
@@ -2572,7 +2572,7 @@ def xm_pci_attach_one(dom, pci_dev):
dpci_record = {
"VM": get_single_vm(dom),
"PPCI": target_ref,
"hotplug_slot": int(pci_dev['vslot'], 16),
"hotplug_slot": int(pci_dev['vdevfn'], 16),
"options": dict(pci_dev.get('opts', [])),
"key": pci_dev['key']
}
@@ -2735,7 +2735,7 @@ def find_attached(attached, key):
def find_attached_devfn(attached, key):
pci_dev = find_attached(attached, key)
return pci_dev['vslot']
return pci_dev['vdevfn']
def xm_pci_detach(args):
arg_check(args, 'pci-detach', 2)
@@ -2746,18 +2746,18 @@ def xm_pci_detach(args):
attached_dev = map(lambda x: find_attached(attached, x), dev)
def f(pci_dev):
vdevfn = int(pci_dev['vslot'], 16)
vdevfn = int(pci_dev['vdevfn'], 16)
return PCI_SLOT(vdevfn) | (vdevfn & AUTO_PHP_SLOT)
vslots = map(f, attached_dev)
if len(set(vslots)) > 1:
vdevfns = map(f, attached_dev)
if len(set(vdevfns)) > 1:
err_str = map(lambda x: "\t%s is in slot 0x%02x\n" %
(pci_dict_to_bdf_str(x),
PCI_SLOT(int(x['vslot'], 16))), dev)
PCI_SLOT(int(x['vdevfn'], 16))), dev)
raise OptionError("More than one slot used by specified devices\n"
+ ''.join(err_str))
attached_to_slot = filter(lambda x:
f(x) == vslots[0] and
f(x) == vdevfns[0] and
attached_dev[0]["key"] ==
x["key"], attached_dev)
@@ -2769,7 +2769,7 @@ def xm_pci_detach(args):
attached_to_slot)
err_str += "Present:\n" + ''.join(err_str_)
raise OptionError(("Not all functions in slot 0x%02x have had "
"detachment requested.\n" % vslots[0]) + err_str)
"detachment requested.\n" % vdevfns[0]) + err_str)
for i in dev:
xm_pci_detach_one(dom, i)
+3 -3
View File
@@ -540,7 +540,7 @@ class xenapi_create:
"PPCI":
target_ref,
"hotplug_slot":
int(pci.attributes["vslot"].value, 16),
int(pci.attributes["vdevfn"].value, 16),
"options":
get_child_nodes_as_dict(pci,
"pci_opt", "key", "value"),
@@ -946,8 +946,8 @@ class sxp2xml:
= get_child_by_name(dev_sxp, "slot", "0")
pci.attributes["func"] \
= get_child_by_name(dev_sxp, "func", "0")
pci.attributes["vslot"] \
= get_child_by_name(dev_sxp, "vslot", "0")
pci.attributes["vdevfn"] \
= get_child_by_name(dev_sxp, "vdevfn", "0")
pci.attributes["key"] \
= get_child_by_name(dev_sxp, "key", "0")
for opt in pci_opts_list_from_sxp(dev_sxp):
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.