ia64/xen-unstable

changeset 19450:b183684130fd

xend: fix hotplug for integrated devices

For integrated devices(with bus number 0), self.find_parent() returns
None, causing a python exception here.

Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:29:53 2009 +0100 (2009-03-31)
parents 46188402c2d9
children ef56cfbdd390
files tools/python/xen/util/pci.py
line diff
     1.1 --- a/tools/python/xen/util/pci.py	Tue Mar 31 11:28:49 2009 +0100
     1.2 +++ b/tools/python/xen/util/pci.py	Tue Mar 31 11:29:53 2009 +0100
     1.3 @@ -417,7 +417,10 @@ class PciDevice:
     1.4  
     1.5      def find_the_uppermost_pci_bridge(self):
     1.6          # Find the uppermost PCI/PCI-X bridge
     1.7 -        (dom, b, d, f) = self.find_parent()
     1.8 +        dev = self.find_parent()
     1.9 +        if dev is None:
    1.10 +            return None
    1.11 +        (dom, b, d, f) = dev
    1.12          dev = dev_parent = PciDevice(dom, b, d, f)
    1.13          while dev_parent.dev_type != DEV_TYPE_PCIe_BRIDGE:
    1.14              parent = dev_parent.find_parent()
    1.15 @@ -463,6 +466,11 @@ class PciDevice:
    1.16                  element,  the caller itself can remove it explicitly.
    1.17          '''
    1.18          dev = self.find_the_uppermost_pci_bridge()
    1.19 +
    1.20 +        # The 'self' device is on bus0.
    1.21 +        if dev is None:
    1.22 +            return [self.name]
    1.23 +
    1.24          dev_list = dev.find_all_devices_behind_the_bridge(ignore_bridge)
    1.25          dev_list = re.findall(PCI_DEV_REG_EXPRESS_STR, '%s' % dev_list)
    1.26          return dev_list
    1.27 @@ -559,7 +567,8 @@ class PciDevice:
    1.28              return self.find_all_the_multi_functions()
    1.29          elif self.dev_type == DEV_TYPE_PCI and not self.pci_af_flr:
    1.30              coassigned_pci_list = self.find_coassigned_pci_devices(True)
    1.31 -            del coassigned_pci_list[0]
    1.32 +            if len(coassigned_pci_list) > 1:
    1.33 +                del coassigned_pci_list[0]
    1.34              return coassigned_pci_list
    1.35          else:
    1.36              return [self.name]