# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1243585986 -3600
# Node ID f6dab6ff90c8e2b30c44683ad3be179f2c788b5d
# Parent 401a793c4b424569c66c906a80a913b1a0ea8d5b
xend: Add serialise_pci_opts() and split_pci_opts()
This centralises some code.
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
---
tools/python/xen/util/pci.py | 6 ++++++
tools/python/xen/xend/XendDomainInfo.py | 8 +++-----
tools/python/xen/xend/server/pciif.py | 11 +++--------
3 files changed, 12 insertions(+), 13 deletions(-)
diff -r 401a793c4b42 -r f6dab6ff90c8 tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py Fri May 29 09:32:40 2009 +0100
+++ b/tools/python/xen/util/pci.py Fri May 29 09:33:06 2009 +0100
@@ -113,6 +113,12 @@ PAGE_MASK=~(PAGE_SIZE - 1)
# Definitions from Linux: include/linux/pci.h
def PCI_DEVFN(slot, func):
return ((((slot) & 0x1f) << 3) | ((func) & 0x07))
+
+def serialise_pci_opts(opts):
+ return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts))
+
+def split_pci_opts(opts):
+ return map(lambda x: x.split('='), opts.split(','))
def parse_hex(val):
try:
diff -r 401a793c4b42 -r f6dab6ff90c8 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Fri May 29 09:32:40 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py Fri May 29 09:33:06 2009 +0100
@@ -39,7 +39,7 @@ from xen.util.blkif import blkdev_uname_
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 assigned_or_requested_vslot
+from xen.util.pci import assigned_or_requested_vslot, serialise_pci_opts
from xen.xend import balloon, sxp, uuid, image, arch
from xen.xend import XendOptions, XendNode, XendConfig
@@ -739,10 +739,8 @@ class XendDomainInfo:
if self.domid is not None:
opts = ''
- if 'opts' in new_dev and len(new_dev['opts']) > 0:
- config_opts = new_dev['opts']
- config_opts = map(lambda (x, y): x+'='+y, config_opts)
- opts = ',' + reduce(lambda x, y: x+','+y, config_opts)
+ if new_dev.has_key('opts'):
+ opts = ',' + serialise_pci_opts(new_dev['opts'])
bdf_str = "%s:%s:%s.%s@%s%s" % (new_dev['domain'],
new_dev['bus'],
diff -r 401a793c4b42 -r f6dab6ff90c8 tools/python/xen/xend/server/pciif.py
--- a/tools/python/xen/xend/server/pciif.py Fri May 29 09:32:40 2009 +0100
+++ b/tools/python/xen/xend/server/pciif.py Fri May 29 09:33:06 2009 +0100
@@ -76,10 +76,8 @@ class PciController(DevController):
func = parse_hex(pci_config.get('func', 0))
vslot = parse_hex(assigned_or_requested_vslot(pci_config))
- opts = pci_config.get('opts', '')
- if len(opts) > 0:
- opts = map(lambda (x, y): x+'='+y, opts)
- opts = reduce(lambda x, y: x+','+y, opts)
+ if pci_config.has_key('opts'):
+ opts = serialise_pci_opts(pci_config['opts'])
back['opts-%i' % pcidevid] = opts
back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
@@ -226,10 +224,7 @@ class PciController(DevController):
dev_sxpr = ['dev']
for dev_key, dev_val in dev.items():
if dev_key == 'opts':
- opts = []
- for opt in dev_val.split(','):
- opts.append(opt.split('='))
- dev_sxpr.append(['opts', opts])
+ dev_sxpr.append(['opts', split_pci_opts(dev_val)])
else:
dev_sxpr.append([dev_key, dev_val])
sxpr.append(dev_sxpr)
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|