aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-01-08 11:39:06 +0000
committerKeir Fraser <keir.fraser@citrix.com>2010-01-08 11:39:06 +0000
commitdbaa1e36038b28d9dd8497dd7d03f263aa15bef4 (patch)
treea49e0e8b8bfac2211eb568ba35cdfaf4affcd2a5
parent17fed54483fbeac4792adaac7c17983853052281 (diff)
downloadxen-dbaa1e36038b28d9dd8497dd7d03f263aa15bef4.tar.gz
xen-dbaa1e36038b28d9dd8497dd7d03f263aa15bef4.tar.bz2
xen-dbaa1e36038b28d9dd8497dd7d03f263aa15bef4.zip
xend: fix options for assigned pci
pci global options and per-device options for HVM device model have been broken for some time, the patch tries to fix the problem. It: * maintains global options in xend, and merge it into per-device option when creating the backend * merge the global options also into the parameter of pci-ins dm-command The second one is there because the backend is effectively skipped in ioemu at present, ioemu solely relies on the parameter string to create the device. Cc: Simon Horman <horms@verge.net.au> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Signed-off-by: Qing He <qing.he@intel.com>
-rw-r--r--tools/python/xen/util/pci.py6
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py15
-rw-r--r--tools/python/xen/xend/server/pciif.py19
3 files changed, 33 insertions, 7 deletions
diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py
index c5f70eee73..35c804495c 100644
--- a/tools/python/xen/util/pci.py
+++ b/tools/python/xen/util/pci.py
@@ -158,6 +158,10 @@ def split_pci_opts(opts):
return map(lambda x: x.split('='),
filter(lambda x: x != '', opts.split(',')))
+def append_default_pci_opts(opts, defopts):
+ optsdict = dict(opts)
+ return opts + filter(lambda (k, v): not optsdict.has_key(k), defopts)
+
def pci_opts_list_to_sxp(list):
return dev_dict_to_sxp({'opts': list})
@@ -328,7 +332,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['key'] = pci_dev_str
+ template['key'] = pci_dev_str.split(',')[0]
if pci_dev_info['opts'] != '':
template['opts'] = split_pci_opts(pci_dev_info['opts'])
check_pci_opts(template['opts'])
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 3cc3417c74..1a5ead0d33 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -42,6 +42,7 @@ import xen.util.xsm.xsm as security
from xen.util import xsconstants
from xen.util import mkdir
from xen.util.pci import serialise_pci_opts, pci_opts_list_to_sxp, \
+ append_default_pci_opts, \
pci_dict_to_bdf_str, pci_dict_to_xc_str, \
pci_convert_sxp_to_dict, pci_convert_dict_to_sxp, \
pci_dict_cmp, PCI_DEVFN, PCI_SLOT, PCI_FUNC, parse_hex
@@ -784,8 +785,20 @@ class XendDomainInfo:
if self.domid is not None:
opts = ''
+ optslist = []
+ pci_defopts = []
+ if 'pci_msitranslate' in self.info['platform']:
+ pci_defopts.append(['msitranslate',
+ str(self.info['platform']['pci_msitranslate'])])
+ if 'pci_power_mgmt' in self.info['platform']:
+ pci_defopts.append(['power_mgmt',
+ str(self.info['platform']['pci_power_mgmt'])])
if new_dev.has_key('opts'):
- opts = ',' + serialise_pci_opts(new_dev['opts'])
+ optslist += new_dev['opts']
+
+ if optslist or pci_defopts:
+ opts = ',' + serialise_pci_opts(
+ append_default_pci_opts(optslist, pci_defopts))
bdf_str = "%s@%02x%s" % (pci_dict_to_bdf_str(new_dev),
int(new_dev['vdevfn'], 16), opts)
diff --git a/tools/python/xen/xend/server/pciif.py b/tools/python/xen/xend/server/pciif.py
index ea5ac0aee3..43d0c80c2a 100644
--- a/tools/python/xen/xend/server/pciif.py
+++ b/tools/python/xen/xend/server/pciif.py
@@ -97,6 +97,15 @@ class PciController(DevController):
"""@see DevController.getDeviceDetails"""
back = {}
pcidevid = 0
+ pci_defopts = []
+
+ if 'pci_msitranslate' in self.vm.info['platform']:
+ pci_defopts.append(['msitranslate',
+ str(self.vm.info['platform']['pci_msitranslate'])])
+ if 'pci_power_mgmt' in self.vm.info['platform']:
+ pci_defopts.append(['power_mgmt',
+ str(self.vm.info['platform']['pci_power_mgmt'])])
+
for pci_config in config.get('devs', []):
domain = parse_hex(pci_config.get('domain', 0))
bus = parse_hex(pci_config.get('bus', 0))
@@ -105,8 +114,12 @@ class PciController(DevController):
vdevfn = parse_hex(pci_config.get('vdevfn', \
'0x%02x' % AUTO_PHP_SLOT))
+ optslist = []
if pci_config.has_key('opts'):
- opts = serialise_pci_opts(pci_config['opts'])
+ optslist += pci_config['opts']
+ if optslist or pci_defopts:
+ opts = serialise_pci_opts(
+ append_default_pci_opts(optslist, pci_defopts))
back['opts-%i' % pcidevid] = opts
back['dev-%i' % pcidevid] = "%04x:%02x:%02x.%01x" % \
@@ -118,10 +131,6 @@ class PciController(DevController):
back['num_devs']=str(pcidevid)
back['uuid'] = config.get('uuid','')
- if 'pci_msitranslate' in self.vm.info['platform']:
- back['msitranslate']=str(self.vm.info['platform']['pci_msitranslate'])
- if 'pci_power_mgmt' in self.vm.info['platform']:
- back['power_mgmt']=str(self.vm.info['platform']['pci_power_mgmt'])
return (0, back, {})