[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xend: pass-through: Clean up hvm_destroyPCIDevice()



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1245220767 -3600
# Node ID 61ec78692b13bd83392f169de793b677b3b24db0
# Parent  902df7680e2e311ba281a0ed6bf999ab525630a9
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@xxxxxxxxxxxx>
---
 tools/python/xen/xend/XendDomainInfo.py |   32 ++++++--------------------------
 1 files changed, 6 insertions(+), 26 deletions(-)

diff -r 902df7680e2e -r 61ec78692b13 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Jun 17 07:39:03 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Jun 17 07:39:27 2009 +0100
@@ -844,7 +844,7 @@ class XendDomainInfo:
                     raise VmError("Device %s is not connected" %
                                   pci_dict_to_bdf_str(dev))
                 new_dev = new_devs[0]
-                self.hvm_destroyPCIDevice(int(new_dev['vslot'], 16))
+                self.hvm_destroyPCIDevice(new_dev)
                 # Update vslot
                 dev['vslot'] = new_dev['vslot']
                 for n in sxp.children(pci_dev):
@@ -1098,31 +1098,11 @@ class XendDomainInfo:
         for devclass in XendDevices.valid_devices():
             self.getDeviceController(devclass).waitForDevices()
 
-    def hvm_destroyPCIDevice(self, vslot):
-        log.debug("hvm_destroyPCIDevice called %s", vslot)
+    def hvm_destroyPCIDevice(self, pci_dev):
+        log.debug("hvm_destroyPCIDevice: %s", pci_dev)
 
         if not self.info.is_hvm():
             raise VmError("hvm_destroyPCIDevice called on non-HVM guest")
-
-        #all the PCI devs share one conf node
-        devid = '0'
-        vslot = int(vslot)
-        dev_info = self._getDeviceInfo_pci('0')#from self.info['devices']
-        dev_uuid = sxp.child_value(dev_info, 'uuid')
-
-        #delete the pci bdf config under the pci device
-        pci_conf = self.info['devices'][dev_uuid][1]
-        pci_len = len(pci_conf['devs'])
-
-        #find the pass-through device with the virtual slot
-        devnum = 0
-        for x in pci_conf['devs']:
-            if int(x['vslot'], 16) == vslot:
-                break
-            devnum += 1
-
-        if devnum >= pci_len:
-            raise VmError("Device @ vslot 0x%x doesn't exist." % (vslot))
 
         # Check the co-assignment.
         # To pci-detach a device D from domN, we should ensure: for each DD in 
the
@@ -1130,7 +1110,7 @@ class XendDomainInfo:
         # 
         from xen.xend.server.pciif import PciDevice
         try:
-            pci_device = PciDevice(x)
+            pci_device = PciDevice(pci_dev)
         except Exception, e:
             raise VmError("pci: failed to locate device and "+
                     "parse it's resources - "+str(e))
@@ -1145,8 +1125,8 @@ class XendDomainInfo:
                     )% (pci_device.name, self.info['name_label'], pci_str))
 
 
-        bdf_str = pci_dict_to_bdf_str(x)
-        log.info("hvm_destroyPCIDevice:%s:%s!", x, bdf_str)
+        bdf_str = pci_dict_to_bdf_str(pci_dev)
+        log.info("hvm_destroyPCIDevice:%s:%s!", pci_dev, bdf_str)
         if self.domid is not None:
             self.image.signalDeviceModel('pci-rem', 'pci-removed', bdf_str)
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.