All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: xen-devel@lists.xensource.com
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>,
	Dexuan Cui <dexuan.cui@intel.com>
Subject: [patch 16/16] xend: pass-through: Clean up hvm_destroyPCIDevice()
Date: Mon, 15 Jun 2009 11:55:31 +1000	[thread overview]
Message-ID: <20090615015913.868826453@vergenet.net> (raw)
In-Reply-To: 20090615015515.927085604@vergenet.net

[-- Attachment #1: xm-clean-up-hvm_destroyPCIDevice-2.patch --]
[-- Type: text/plain, Size: 3364 bytes --]

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.

Cc: Dexuan Cui <dexuan.cui@intel.com>
Cc: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>

Index: xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xend/XendDomainInfo.py	2009-06-15 11:24:37.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py	2009-06-15 11:24:43.000000000 +1000
@@ -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,39 +1098,19 @@ 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
         # list of D's co-assignment devices, DD is not assigned (to domN).
         # 
         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)
 

-- 

      parent reply	other threads:[~2009-06-15  1:55 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-15  1:55 [patch 00/16] xend: pass-through: various clean-ups and infrastructure Simon Horman
2009-06-15  1:55 ` [patch 01/16] xend: pass-through: Only call setupOneDevice() once per device Simon Horman
2009-06-15  1:55 ` [patch 02/16] xend: pass-through: fix typo: spx -> sxp Simon Horman
2009-06-15  1:55 ` [patch 03/16] xend: pass-through: tidy up PciController() Simon Horman
2009-06-15  1:55 ` [patch 04/16] xend: pass-through: cleanupDevice: move and remove recently added vslot entry Simon Horman
2009-06-15  1:55 ` [patch 05/16] xend: pass-through: sxp.merge() cant deal with values being a list Simon Horman
2009-06-15  1:55 ` [patch 06/16] xend: pass-through: Remove PciDeviceNotFoundError, it is never used Simon Horman
2009-06-15  1:55 ` [patch 07/16] xend: pass-through: Use PCIDevice as the parameter for the constructor for PCIQuirk Simon Horman
2009-06-15  1:55 ` [patch 08/16] xend: pass-through: Common parse_pci_name() Simon Horman
2009-06-16 10:43   ` Keir Fraser
2009-06-16 11:20     ` Simon Horman
2009-06-16 12:22       ` Keir Fraser
2009-06-16 12:38         ` Simon Horman
2009-06-15  1:55 ` [patch 09/16] xend: pass-through: Use common parsing code in preprocess_pci() Simon Horman
2009-06-15  1:55 ` [patch 10/16] xend: pass-through: Add pci_dict_cmp() Simon Horman
2009-06-15  1:55 ` [patch 11/16] xend: pass-through: Move pci conversion functions to pci.py Simon Horman
2009-06-15  5:58   ` [patch 11/16] xend: pass-through: Move pci conversionfunctions " Masaki Kanno
2009-06-15  6:15     ` Simon Horman
2009-06-15  7:02       ` [patch 11/16] xend: pass-through: Move pciconversionfunctions " Masaki Kanno
2009-06-15  9:04         ` Simon Horman
2009-06-15 11:58           ` [patch v2] xend: pass-through: Move pci conversion functions " Simon Horman
2009-06-15 23:36             ` [patch 11/16 v3] " Simon Horman
2009-06-15  1:55 ` [patch 12/16] xend: pass-through: Use generic code in pci_opts_list_to_sxp() Simon Horman
2009-06-15 11:59   ` [patch v2] " Simon Horman
2009-06-15  1:55 ` [patch 13/16] xend: pass-through: Add pci_tuple_to_dict() Simon Horman
2009-06-15  1:55 ` [patch 14/16] xend: pass-through: Use common parsing code in parse_pci_configuration() Simon Horman
2009-06-15  1:55 ` [patch 15/16] xend: pass-through: Use common parsing code in getDeviceConfiguration() Simon Horman
2009-06-15  1:55 ` Simon Horman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090615015913.868826453@vergenet.net \
    --to=horms@verge.net.au \
    --cc=dexuan.cui@intel.com \
    --cc=kanno.masaki@jp.fujitsu.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.