ia64/xen-unstable

changeset 19783:61ec78692b13

xend: pass-through: Clean up hvm_destroyPCIDevice()

There seems to be little need to use the domain, bus, slot and
function to look up the virtual slot to pass as the argument to
hvm_destroyPCIDevice(), only to have hvm_destroyPCIDevice() use the
virtual slot for the sole purpose of looking up the domain, bus, slot
and function.

Signed-off-by: Simon Horman <horms@verge.net.au>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 17 07:39:27 2009 +0100 (2009-06-17)
parents 902df7680e2e
children 44fe7ad6fee8
files tools/python/xen/xend/XendDomainInfo.py
line diff
     1.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Wed Jun 17 07:39:03 2009 +0100
     1.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Wed Jun 17 07:39:27 2009 +0100
     1.3 @@ -844,7 +844,7 @@ class XendDomainInfo:
     1.4                      raise VmError("Device %s is not connected" %
     1.5                                    pci_dict_to_bdf_str(dev))
     1.6                  new_dev = new_devs[0]
     1.7 -                self.hvm_destroyPCIDevice(int(new_dev['vslot'], 16))
     1.8 +                self.hvm_destroyPCIDevice(new_dev)
     1.9                  # Update vslot
    1.10                  dev['vslot'] = new_dev['vslot']
    1.11                  for n in sxp.children(pci_dev):
    1.12 @@ -1098,39 +1098,19 @@ class XendDomainInfo:
    1.13          for devclass in XendDevices.valid_devices():
    1.14              self.getDeviceController(devclass).waitForDevices()
    1.15  
    1.16 -    def hvm_destroyPCIDevice(self, vslot):
    1.17 -        log.debug("hvm_destroyPCIDevice called %s", vslot)
    1.18 +    def hvm_destroyPCIDevice(self, pci_dev):
    1.19 +        log.debug("hvm_destroyPCIDevice: %s", pci_dev)
    1.20  
    1.21          if not self.info.is_hvm():
    1.22              raise VmError("hvm_destroyPCIDevice called on non-HVM guest")
    1.23  
    1.24 -        #all the PCI devs share one conf node
    1.25 -        devid = '0'
    1.26 -        vslot = int(vslot)
    1.27 -        dev_info = self._getDeviceInfo_pci('0')#from self.info['devices']
    1.28 -        dev_uuid = sxp.child_value(dev_info, 'uuid')
    1.29 -
    1.30 -        #delete the pci bdf config under the pci device
    1.31 -        pci_conf = self.info['devices'][dev_uuid][1]
    1.32 -        pci_len = len(pci_conf['devs'])
    1.33 -
    1.34 -        #find the pass-through device with the virtual slot
    1.35 -        devnum = 0
    1.36 -        for x in pci_conf['devs']:
    1.37 -            if int(x['vslot'], 16) == vslot:
    1.38 -                break
    1.39 -            devnum += 1
    1.40 -
    1.41 -        if devnum >= pci_len:
    1.42 -            raise VmError("Device @ vslot 0x%x doesn't exist." % (vslot))
    1.43 -
    1.44          # Check the co-assignment.
    1.45          # To pci-detach a device D from domN, we should ensure: for each DD in the
    1.46          # list of D's co-assignment devices, DD is not assigned (to domN).
    1.47          # 
    1.48          from xen.xend.server.pciif import PciDevice
    1.49          try:
    1.50 -            pci_device = PciDevice(x)
    1.51 +            pci_device = PciDevice(pci_dev)
    1.52          except Exception, e:
    1.53              raise VmError("pci: failed to locate device and "+
    1.54                      "parse it's resources - "+str(e))
    1.55 @@ -1145,8 +1125,8 @@ class XendDomainInfo:
    1.56                      )% (pci_device.name, self.info['name_label'], pci_str))
    1.57  
    1.58  
    1.59 -        bdf_str = pci_dict_to_bdf_str(x)
    1.60 -        log.info("hvm_destroyPCIDevice:%s:%s!", x, bdf_str)
    1.61 +        bdf_str = pci_dict_to_bdf_str(pci_dev)
    1.62 +        log.info("hvm_destroyPCIDevice:%s:%s!", pci_dev, bdf_str)
    1.63          if self.domid is not None:
    1.64              self.image.signalDeviceModel('pci-rem', 'pci-removed', bdf_str)
    1.65