ia64/xen-unstable

changeset 19717:94f6bf69e8e8

xm: xen-api, pass-through: Dont pass empty opts

Internally 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.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:39:03 2009 +0100 (2009-06-04)
parents a3125a83e40b
children 19fc31fe2e31
files tools/python/xen/util/pci.py tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Thu Jun 04 10:38:13 2009 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Thu Jun 04 10:39:03 2009 +0100
     1.3 @@ -120,6 +120,9 @@ def serialise_pci_opts(opts):
     1.4  def split_pci_opts(opts):
     1.5      return map(lambda x: x.split('='), opts.split(','))
     1.6  
     1.7 +def pci_opts_list_to_spx(list):
     1.8 +    ['dev'] + map(lambda x: ['opts', x], list)
     1.9 +
    1.10  def parse_hex(val):
    1.11      try:
    1.12          if isinstance(val, types.StringTypes):
     2.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Jun 04 10:38:13 2009 +0100
     2.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Jun 04 10:39:03 2009 +0100
     2.3 @@ -39,7 +39,7 @@ from xen.util import asserts, auxbin
     2.4  from xen.util.blkif import blkdev_uname_to_file, blkdev_uname_to_taptype
     2.5  import xen.util.xsm.xsm as security
     2.6  from xen.util import xsconstants
     2.7 -from xen.util.pci import serialise_pci_opts
     2.8 +from xen.util.pci import serialise_pci_opts, pci_opts_list_to_spx
     2.9  
    2.10  from xen.xend import balloon, sxp, uuid, image, arch
    2.11  from xen.xend import XendOptions, XendNode, XendConfig
    2.12 @@ -3771,23 +3771,21 @@ class XendDomainInfo:
    2.13          opts_dict = xenapi_pci.get('options')
    2.14          for k in opts_dict.keys():
    2.15              dpci_opts.append([k, opts_dict[k]])
    2.16 +        opts_sxp = pci_opts_list_to_spx(dpci_opts)
    2.17  
    2.18          # Convert xenapi to sxp
    2.19          ppci = XendAPIStore.get(xenapi_pci.get('PPCI'), 'PPCI')
    2.20  
    2.21 -        target_pci_sxp = \
    2.22 -            ['pci', 
    2.23 -                ['dev',
    2.24 -                    ['domain', '0x%02x' % ppci.get_domain()],
    2.25 -                    ['bus', '0x%02x' % ppci.get_bus()],
    2.26 -                    ['slot', '0x%02x' % ppci.get_slot()],
    2.27 -                    ['func', '0x%1x' % ppci.get_func()],
    2.28 -                    ['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
    2.29 -                    ['opts', dpci_opts],
    2.30 -                    ['uuid', dpci_uuid]
    2.31 -                ],
    2.32 -                ['state', 'Initialising']
    2.33 -            ]
    2.34 +        dev_sxp = ['dev',
    2.35 +                   ['domain', '0x%02x' % ppci.get_domain()],
    2.36 +                   ['bus', '0x%02x' % ppci.get_bus()],
    2.37 +                   ['slot', '0x%02x' % ppci.get_slot()],
    2.38 +                   ['func', '0x%1x' % ppci.get_func()],
    2.39 +                   ['vslot', '0x%02x' % xenapi_pci.get('hotplug_slot')],
    2.40 +                   ['uuid', dpci_uuid]]
    2.41 +        dev_sxp = sxp.merge(dev_sxp, opts_sxp)
    2.42 +
    2.43 +        target_pci_sxp = ['pci', dev_sxp, ['state', 'Initialising'] ]
    2.44  
    2.45          if self._stateGet() != XEN_API_VM_POWER_STATE_RUNNING:
    2.46