[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [rfc 8/9] 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. This breaks compatibility with qemu-xen and a companion patch for that code will be posted separately. Cc: Dexuan Cui <dexuan.cui@xxxxxxxxx> Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx> Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx> --- Co-Dependent on "qemu-xen: pass-through: rename vslot to vdevfn and vslots to vdevfns" Changes Wed, 13 May 2009 11:33:37 +1000 * Rediff for "[patch] passthrough: Fix PCI hot-plug option parsing" Fri, 22 May 2009 17:35:07 +1000 * Rediff for recent changes to previous patches * sxp_to_bdf6(): stringify opts Index: xen-unstable.hg/tools/python/xen/util/pci.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-15 11:25:04.000000000 +1000 @@ -187,10 +187,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, @@ -198,7 +198,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 = {} @@ -267,7 +267,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: @@ -306,11 +306,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) @@ -321,7 +321,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): @@ -333,11 +333,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") % Index: xen-unstable.hg/tools/python/xen/xend/server/pciif.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/server/pciif.py 2009-06-15 11:25:04.000000000 +1000 @@ -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: Index: xen-unstable.hg/tools/python/xen/xm/main.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xm/main.py 2009-06-15 11:25:03.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-15 11:25:04.000000000 +1000 @@ -2182,7 +2182,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) @@ -2194,7 +2194,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) @@ -2208,7 +2208,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 @@ -2223,22 +2223,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 @@ -2543,13 +2543,13 @@ def xm_pci_attach(args): # If the slot wasn't spefified in the args then use the slot # assigned to the head by qemu-xen for the rest of the functions - if int(head_dev['vslot'], 16) & AUTO_PHP_SLOT: + if int(head_dev['vdevfn'], 16) & AUTO_PHP_SLOT: vdevfn = int(find_attached_devfn(attached_pci_dict(dom), head_dev), 16) if not vdevfn & AUTO_PHP_SLOT: vslot = PCI_SLOT(vdevfn) for i in dev: - i['vslot'] = '0x%02x' % \ - PCI_DEVFN(vslot, PCI_FUNC(int(i['vslot'], 16))) + i['vdevfn'] = '0x%02x' % \ + PCI_DEVFN(vslot, PCI_FUNC(int(i['vdevfn'], 16))) for i in dev: xm_pci_attach_one(dom, i) @@ -2568,7 +2568,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'] } @@ -2731,7 +2731,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) @@ -2742,18 +2742,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) @@ -2765,7 +2765,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) Index: xen-unstable.hg/tools/python/xen/xend/XendConfig.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/XendConfig.py 2009-06-15 11:25:04.000000000 +1000 @@ -1237,7 +1237,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'] } @@ -2038,8 +2038,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 Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py 2009-06-15 11:25:03.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-06-15 11:25:04.000000000 +1000 @@ -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) Index: xen-unstable.hg/tools/python/xen/xm/create.dtd =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xm/create.dtd 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xm/create.dtd 2009-06-15 11:25:04.000000000 +1000 @@ -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> Index: xen-unstable.hg/tools/python/xen/xm/create.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xm/create.py 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xm/create.py 2009-06-15 11:25:04.000000000 +1000 @@ -1044,14 +1044,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 Index: xen-unstable.hg/tools/python/xen/xm/xenapi_create.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xm/xenapi_create.py 2009-06-15 11:25:00.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xm/xenapi_create.py 2009-06-15 11:25:04.000000000 +1000 @@ -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): -- _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |