Xen API for pass-through
cover Xen API for pass-through
This series of patches contains fixes for pass-through and Xen API such that xm can now use Xen API to create domains and, attach, detach and list pass-through devices.
PATCH 1/9 xend: pass-through: report attach errors from device model
---
Changes
- Use spaces for indentation
- Removed spurious debug message
tools/python/xen/xend/XendDomainInfo.py +6 -0
@@ -752,6 +752,12 @@ class XendDomainInfo: vslot = xstransact.Read("/local/domain/0/device-model/%i/parameter" % self.getDomid()) + try: + vslot_int = int(vslot, 16) + except ValueError: + raise VmError(("Cannot pass-through PCI function '%s'. " + + "Device model reported an error: %s") % + (bdf_str, vslot)) else: vslot = new_dev['vslot']
PATCH 2/9 xm: xen-api: Install create.dtd in SHAREDIR
In reply to Simon Horman* Install create.dtd in SHAREDIR
* Use SHAREDIR/create.dtd
* import os.path.join into xenapi_create.py,
it already seems to be used many times
Resolves the following error when using XenAPI:
$ xm create hvm.conf Couldn't open resource '/usr/share/xen/create.dtd' at /usr/share/xen/create.dtd:1:0
tools/python/Makefile +3 -2
@@ -22,6 +22,7 @@ genpath: echo "BINDIR=\"$(BINDIR)\"" >> ${xenpath} echo "LIBEXEC=\"$(LIBEXEC)\"" >> ${xenpath} echo "LIBDIR=\"$(LIBDIR)\"" >> ${xenpath} + echo "SHAREDIR=\"$(SHAREDIR)\"" >> ${xenpath} echo "PRIVATE_BINDIR=\"$(PRIVATE_BINDIR)\"" >> ${xenpath} echo "XEN_CONFIG_DIR=\"$(XEN_CONFIG_DIR)\"" >> ${xenpath} echo "XEN_SCRIPT_DIR=\"$(XEN_SCRIPT_DIR)\"" >> ${xenpath}
@@ -70,8 +71,8 @@ install: install-messages install-dtd $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" --force install-dtd: all - $(INSTALL_DIR) $(DESTDIR)$(DOCDIR) - $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(DOCDIR) + $(INSTALL_DIR) $(DESTDIR)$(SHAREDIR) + $(INSTALL_DATA) xen/xm/create.dtd $(DESTDIR)$(SHAREDIR) install-messages: all set -e; if which $(MSGFMT) >/dev/null ; then \
tools/python/xen/xm/xenapi_create.py +3 -1
@@ -26,10 +26,12 @@ from xen.xend.XendAPIConstants import XE XEN_API_ON_CRASH_BEHAVIOUR from xen.xm.opts import OptionError from xen.util import xsconstants +from xen.util.path import SHAREDIR import xen.util.xsm.xsm as security import sys import os +from os.path import join import traceback import re
@@ -75,7 +77,7 @@ class xenapi_create: def __init__(self): self.DEFAULT_STORAGE_REPOSITORY = get_default_SR() - self.dtd = "/usr/share/xen/create.dtd" + self.dtd = join(SHAREDIR, "create.dtd") def create(self, filename=None, document=None, skipdtd=False): """
PATCH 3/9 xm: xen-api, pass-through: Dont pass empty opts
In reply to Simon HormanInternally xend doesn't know how to handle empty opts. This code ensures that opts is only included in the sxpr if its value will be non-empty.
tools/python/xen/xend/XendDomainInfo.py +12 -14
@@ -39,7 +39,7 @@ from xen.util import asserts, auxbin from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype import xen.util.xsm.xsm as security from xen.util import xsconstants -from xen.util.pci import serialise_pci_opts +from xen.util.pci import serialise_pci_opts, pci_opts_list_to_spx from xen.xend import balloon, sxp, uuid, image, arch from xen.xend import XendOptions, XendNode, XendConfig
@@ -3771,23 +3771,21 @@ class XendDomainInfo: opts_dict = xenapi_pci.get('options') for k in opts_dict.keys(): dpci_opts.append([k, opts_dict[k]]) + opts_sxp = pci_opts_list_to_spx(dpci_opts) # Convert xenapi to sxp ppci = XendAPIStore.get(xenapi_pci.get('PPCI'), 'PPCI') - target_pci_sxp = \ - ['pci', - ['dev', - ['domain', '0x%02x' % ppci.get_domain()], - ['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')], - ['opts', dpci_opts], - ['uuid', dpci_uuid] - ], - ['state', 'Initialising'] - ] + dev_sxp = ['dev', + ['domain', '0x%02x' % ppci.get_domain()], + ['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')], + ['uuid', dpci_uuid]] + dev_sxp = sxp.merge(dev_sxp, opts_sxp) + + target_pci_sxp = ['pci', dev_sxp, ['state', 'Initialising'] ] if self._stateGet() != XEN_API_VM_POWER_STATE_RUNNING:
tools/python/xen/util/pci.py +3 -0
@@ -120,6 +120,9 @@ def serialise_pci_opts(opts): def split_pci_opts(opts): return map(lambda x: x.split('='), opts.split(',')) +def pci_opts_list_to_spx(list): + ['dev'] + map(lambda x: ['opts', x], list) + def parse_hex(val): try: if isinstance(val, types.StringTypes):
PATCH 4/9 xend: pass-through: prefix vslot with 0x in device configration
In reply to Simon HormanI don't know of the historical reasons for this, but by convention hex values are stored without a leading '0x' in the backend and with a leading '0x' in the device configuration.
This patch also removes handling of the case where vslot is missing from the backend, should never occur.
tools/python/xen/xend/server/pciif.py +2 -5
@@ -191,11 +191,8 @@ class PciController(DevController): # Per device uuid info dev_dict['uuid'] = self.readBackend(devid, 'uuid-%d' % i) - vslot = self.readBackend(devid, 'vslot-%d' % i) - if vslot != None: - dev_dict['vslot'] = self.readBackend(devid, 'vslot-%d' % i) - else: - dev_dict['vslot'] = AUTO_PHP_SLOT_STR + dev_dict['vslot'] = '0x%s' % \ + self.readBackend(devid, 'vslot-%d' % i) #append opts info opts = self.readBackend(devid, 'opts-%d' % i)
PATCH 5/9 xm, xend: xen-api: DPCI.get_hotplug_slot() returns a decimal
In reply to Simon Hormanxm uses the following code to read pci information using Xen API:
ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
dev = {
"domain": int(ppci_record["domain"]),
"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))
}As the domain, bus, slot and func values are returned as string representations of decimal, it makes sense for get_hotplug_slot() to also return string representations of decimal.
As it is, the int() conversion will break cause xm to fail with an error if the vslot is in the range 0xa-0xf or 0x1a-0x1f.
$ xm pci-list debian Error: Invalid argument.
And the int() conversion will return the wrong value if the vslot is in the range 0x10-0x19.
This patch also alters XendDPCI to store hotplug_vslot as an integer rather than a string. This is consitent with the way other values are stored inside XendDPCI.
get_hotplug_slot() returning a string is not consistent with other calls inside XendDPCI, which return integers.
tools/python/xen/xend/XendDPCI.py +2 -2
@@ -119,7 +119,7 @@ class XendDPCI(XendBase): self.VM = record['VM'] self.PPCI = record['PPCI'] - self.hotplug_slot = record['hotplug_slot'] + self.hotplug_slot = int(record['hotplug_slot'], 16) if 'options' in record.keys(): self.options = record['options']
@@ -153,7 +153,7 @@ class XendDPCI(XendBase): return self.PPCI def get_hotplug_slot(self): - return self.hotplug_slot + return "%d" % self.hotplug_slot def get_options(self): return self.options
PATCH 6/9 xend: xen-api, pass-through: Add create_dpci_from_sxp()
In reply to Simon HormanMove some duplicated code into create_dpci_from_sxp()
tools/python/xen/xend/XendConfig.py +25 -39
@@ -1221,7 +1221,29 @@ class XendConfig(dict): raise XendConfigError('The mac "%s" is already defined' % dev_mac) return None - + + def create_dpci_from_sxp(self, pci_devs): + for pci_dev in pci_devs: + dpci_uuid = pci_dev.get('uuid') + log.debug("create_dpci_from_sxp: %s" % pci_dev) + ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], + pci_dev['bus'], + pci_dev['slot'], + pci_dev['func']) + if ppci_uuid is None: + continue + dpci_record = { + 'VM': self['uuid'], + 'PPCI': ppci_uuid, + 'hotplug_slot': pci_dev.get('vslot', 0) + } + + dpci_opts = pci_dev.get('opts') + if dpci_opts and len(dpci_opts) > 0: + dpci_record['options'] = dpci_opts + + XendDPCI(dpci_uuid, dpci_record) + def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None, target = None): """Add a device configuration in SXP format or XenAPI struct format.
@@ -1276,25 +1298,7 @@ class XendConfig(dict): pci_devs = pci_dict['devs'] # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) target['devices'][pci_devs_uuid] = (dev_type, {'devs': pci_devs,
@@ -1846,25 +1850,7 @@ class XendConfig(dict): XendAPIStore.deregister(dpci_uuid, "DPCI") # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) self['devices'][dev_uuid] = (dev_type, {'devs': pci_devs,
Re: [patch 6/9] xend: xen-api, pass-through: Add create_dpci_from_sxp()
Hi Simon,
Good job!!
This line includes Tab indent.
+ log.debug("create_dpci_from_sxp: %s" % pci_dev)
Best regards,
Kan
Quoted 11 lines · Simon Horman
Move some duplicated code into
create_dpci_from_sxp()Cc Dexuan Cui <[email protected]>Cc Masaki Kanno <[email protected]>Signed-off-by Simon Horman <[email protected]>Index:
xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
---xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py2009-06-03 16:
30:59.000000000 +1000
+++xen-unstable.hg/tools/python/xen/xend/XendConfig.py2009-06-04 08:
27:04
Quoted 94 lines
.000000000 +1000
(quoted diff) +0
-0@@ -1221,7 +1221,29 @@ class XendConfig(dict): raise XendConfigError('The mac "%s" is alreadydefined' %
dev_mac)
return Nonetools/python/xen/xend/XendConfig.py +25
-39- + + def create_dpci_from_sxp(self, pci_devs): + for pci_dev in pci_devs: + dpci_uuid = pci_dev.get('uuid') + log.debug("create_dpci_from_sxp: %s" % pci_dev) + ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], + pci_dev['bus'], + pci_dev['slot'], + pci_dev['func']) + if ppci_uuid is None: + continue + dpci_record = { + 'VM': self['uuid'], + 'PPCI': ppci_uuid, + 'hotplug_slot': pci_dev.get('vslot', 0) + } + + dpci_opts = pci_dev.get('opts') + if dpci_opts and len(dpci_opts) > 0: + dpci_record['options'] = dpci_opts + + XendDPCI(dpci_uuid, dpci_record) + def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None, target = None): """Add a device configuration in SXP format or XenAPI struct format.@@ -1276,25 +1298,7 @@ class XendConfig(dict): pci_devs = pci_dict['devs'] # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) target['devices'][pci_devs_uuid] = (dev_type, {'devs': pci_devs,@@ -1846,25 +1850,7 @@ class XendConfig(dict): XendAPIStore.deregister(dpci_uuid, "DPCI") # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) self['devices'][dev_uuid] = (dev_type, {'devs': pci_devs,Signature · 6 lines
-- _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
Re: [patch 6/9] xend: xen-api, pass-through: Add create_dpci_from_sxp()
tools/python/xen/xend/XendConfig.py class XendConfig(dict): · line 1228
Quoted 7 lines · Masaki Kanno
Hi Simon,
Good job!!
This line includes Tab indent.
tools/python/xen/xend/XendConfig.py +1
-0+ log.debug("create_dpci_from_sxp: %s" % pci_dev)
Thanks, I will remove that line and re-post.
PATCH v2 1/1 xend: xen-api, pass-through: Add create_dpci_from_sxp()
In reply to Masaki KannoMove some duplicated code into create_dpci_from_sxp()
---
* v2: Updated to remove spurious debug message
tools/python/xen/xend/XendConfig.py +24 -39
@@ -1221,7 +1221,28 @@ class XendConfig(dict): raise XendConfigError('The mac "%s" is already defined' % dev_mac) return None - + + def create_dpci_from_sxp(self, pci_devs): + for pci_dev in pci_devs: + dpci_uuid = pci_dev.get('uuid') + ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], + pci_dev['bus'], + pci_dev['slot'], + pci_dev['func']) + if ppci_uuid is None: + continue + dpci_record = { + 'VM': self['uuid'], + 'PPCI': ppci_uuid, + 'hotplug_slot': pci_dev.get('vslot', 0) + } + + dpci_opts = pci_dev.get('opts') + if dpci_opts and len(dpci_opts) > 0: + dpci_record['options'] = dpci_opts + + XendDPCI(dpci_uuid, dpci_record) + def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None, target = None): """Add a device configuration in SXP format or XenAPI struct format.
@@ -1276,25 +1298,7 @@ class XendConfig(dict): pci_devs = pci_dict['devs'] # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) target['devices'][pci_devs_uuid] = (dev_type, {'devs': pci_devs,
@@ -1846,25 +1850,7 @@ class XendConfig(dict): XendAPIStore.deregister(dpci_uuid, "DPCI") # create XenAPI DPCI objects. - for pci_dev in pci_devs: - dpci_uuid = pci_dev.get('uuid') - ppci_uuid = XendPPCI.get_by_sbdf(pci_dev['domain'], - pci_dev['bus'], - pci_dev['slot'], - pci_dev['func']) - if ppci_uuid is None: - continue - dpci_record = { - 'VM': self['uuid'], - 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) - } - - dpci_opts = pci_dev.get('opts') - if dpci_opts and len(dpci_opts) > 0: - dpci_record['options'] = dpci_opts - - XendDPCI(dpci_uuid, dpci_record) + self.create_dpci_from_sxp(pci_devs) self['devices'][dev_uuid] = (dev_type, {'devs': pci_devs,
PATCH 7/9 xm: xen-api, pass-through: create: Use vslot for hotplug_slot
In reply to Simon HormanUsing func for hotplug_slot is not correct, although func is often zero, previously zero meant please pick a vslot and asking xend to pick a vslot was the only method available.
This resolves the following error when using Xen API:
$ xm create hvm.conf ... Internal error: Timed out waiting for device model action.
tools/python/xen/xm/xenapi_create.py +1 -1
@@ -539,7 +539,7 @@ class xenapi_create: "PPCI": target_ref, "hotplug_slot": - int(pci.attributes["func"].value, 16), + int(pci.attributes["vslot"].value, 16), "options": get_child_nodes_as_dict(pci, "pci_opt", "key", "value")
PATCH 8/9 xend: pass-through: Use AUTO_PHP_SLOT as unknown vslot
In reply to Simon HormanThis fixes a few cases where 0 is still used for an known vslot.
tools/python/xen/xend/server/pciif.py +2 -1
@@ -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', 0)) + vslot = parse_hex(pci_config.get('vslot', + '0x' + AUTO_PHP_SLOT_STR)) if pci_config.has_key('opts'): opts = serialise_pci_opts(pci_config['opts'])
tools/python/xen/xend/XendConfig.py +3 -2
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI from xen.xend.XendError import VmError from xen.xend.XendDevices import XendDevices from xen.xend.PrettyPrint import prettyprintstring -from xen.xend.XendConstants import DOM_STATE_HALTED +from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR from xen.xend.xenstore.xstransact import xstransact from xen.xend.server.BlktapController import blktap_disk_types from xen.xend.server.netif import randomMAC
@@ -1235,7 +1235,8 @@ class XendConfig(dict): dpci_record = { 'VM': self['uuid'], 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) + 'hotplug_slot': pci_dev.get('vslot', + '0x' + AUTO_PHP_SLOT_STR) } dpci_opts = pci_dev.get('opts')
Re: [patch 8/9] xend: pass-through: Use AUTO_PHP_SLOT asunknown vslot
Hi Simon,
These line include Tab indent.
pciif.py:
+ '0x' + AUTO_PHP_SLOT_STR))
XendConfig.py:
+ '0x' + AUTO_PHP_SLOT_STR)
Best regards,
Kan
Quoted 11 lines · Simon Horman
This fixes a few cases where 0 is still used for an known vslot.
Cc Dexuan Cui <[email protected]>Cc Masaki Kanno <[email protected]>Signed-off-by Simon Horman <[email protected]>Index:
xen-unstable.hg/tools/python/xen/xend/server/pciif.py
===================================================================
---xen-unstable.hg.orig/tools/python/xen/xend/server/pciif.py2009-06-04
08:28:46.000000000 +1000
+++xen-unstable.hg/tools/python/xen/xend/server/pciif.py2009-06-04 08:
28:
Quoted 11 lines
54.000000000 +1000
tools/python/xen/xend/server/pciif.py +2
-1@@ -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', 0)) + vslot = parse_hex(pci_config.get('vslot', + '0x' + AUTO_PHP_SLOT_STR)) if pci_config.has_key('opts'): opts = serialise_pci_opts(pci_config['opts'])
Quoted 5 lines
Index:
xen-unstable.hg/tools/python/xen/xend/XendConfig.py
===================================================================
---xen-unstable.hg.orig/tools/python/xen/xend/XendConfig.py2009-06-04 08:
28:46.000000000 +1000
+++xen-unstable.hg/tools/python/xen/xend/XendConfig.py2009-06-04 08:
28:54
Quoted 27 lines
.000000000 +1000
(quoted diff) +0
-0@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSIfrom xen.xend.XendError import VmError from xen.xend.XendDevices import XendDevices from xen.xend.PrettyPrint import prettyprintstring
tools/python/xen/xend/XendConfig.py +1
-1-from xen.xend.XendConstants import DOM_STATE_HALTED +from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STRfrom xen.xend.xenstore.xstransact import xstransact from xen.xend.server.BlktapController import
blktap_disk_typesfrom xen.xend.server.netif import randomMACtools/python/xen/xend/XendConfig.py +2
-1@@ -1235,7 +1235,8 @@ class XendConfig(dict): dpci_record = { 'VM': self['uuid'], 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) + 'hotplug_slot': pci_dev.get('vslot', + '0x' + AUTO_PHP_SLOT_STR) } dpci_opts = pci_dev.get('opts')Signature · 6 lines
-- _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
PATCH v2 1/1 xend: pass-through: Use AUTO_PHP_SLOT as unknown vslot
This fixes a few cases where 0 is still used for an known vslot.
---
* Updated to use spaces instead of tabs for indentation
tools/python/xen/xend/server/pciif.py +2 -1
@@ -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', 0)) + vslot = parse_hex(pci_config.get('vslot', + '0x' + AUTO_PHP_SLOT_STR)) if pci_config.has_key('opts'): opts = serialise_pci_opts(pci_config['opts'])
tools/python/xen/xend/XendConfig.py +3 -2
@@ -31,7 +31,7 @@ from xen.xend.XendDSCSI import XendDSCSI from xen.xend.XendError import VmError from xen.xend.XendDevices import XendDevices from xen.xend.PrettyPrint import prettyprintstring -from xen.xend.XendConstants import DOM_STATE_HALTED +from xen.xend.XendConstants import DOM_STATE_HALTED, AUTO_PHP_SLOT_STR from xen.xend.xenstore.xstransact import xstransact from xen.xend.server.BlktapController import blktap_disk_types from xen.xend.server.netif import randomMAC
@@ -1235,7 +1235,8 @@ class XendConfig(dict): dpci_record = { 'VM': self['uuid'], 'PPCI': ppci_uuid, - 'hotplug_slot': pci_dev.get('vslot', 0) + 'hotplug_slot': pci_dev.get('vslot', + '0x' + AUTO_PHP_SLOT_STR) } dpci_opts = pci_dev.get('opts')
Re: [patch 8/9] xend: pass-through: Use AUTO_PHP_SLOT asunknown vslot
In reply to Masaki Kannotools/python/xen/xend/XendConfig.py class XendConfig(dict): · line 1239
Quoted 10 lines · Masaki Kanno
Hi Simon,
These line include Tab indent.
pciif.py:tools/python/xen/xend/server/pciif.py +1
-0+ '0x' + AUTO_PHP_SLOT_STR))
XendConfig.py:tools/python/xen/xend/XendConfig.py +1
-0+ '0x' + AUTO_PHP_SLOT_STR)
Thanks, I have posted a new version without tabs.
PATCH 9/9 xm: pass-through: sort the output of xm pci-list
In reply to Simon HormanOther than being arguably more human readable, this patch reconciles the output differences between using Xen API and xmlrpc to manipulate domains.
tools/python/xen/util/pci.py +4 -0
@@ -114,6 +114,10 @@ PAGE_MASK=~(PAGE_SIZE - 1) def PCI_DEVFN(slot, func): return ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +def PCI_BDF(domain, bus, slot, func): + return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) | + PCI_DEVFN(slot, func)) + def serialise_pci_opts(opts): return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts))
tools/python/xen/xm/main.py +3 -0
@@ -2205,6 +2205,9 @@ def xm_pci_list(args): if len(devs) == 0: return + devs.sort(None, lambda x: x['vslot'] << 32 | PCI_BDF(x['domain'], x['bus'], + x['slot'], x['func'])) + has_vslot = False for x in devs: if x['vslot'] == AUTO_PHP_SLOT: