From: Simon Horman Subject: [patch 3/9] xm: xen-api, pass-through: Dont pass empty opts Date: Thu, 04 Jun 2009 13:21:18 +1000 Message-ID: <20090604032230.034834176@vergenet.net> References: <20090604032115.934982694@vergenet.net> Return-path: Content-Disposition: inline; filename=xenapi-no-empty-opts.patch List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Masaki Kanno , Dexuan Cui List-Id: xen-devel@lists.xenproject.org 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. Cc: Dexuan Cui Cc: Masaki Kanno Signed-off-by: Simon Horman Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py 2009-06-04 12:45:58.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-06-04 12:46:06.000000000 +1000 @@ -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: Index: xen-unstable.hg/tools/python/xen/util/pci.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-04 12:40:28.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-04 12:46:06.000000000 +1000 @@ -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): --