WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] Subject: xend: pass-through: Add pci_dict

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Subject: xend: pass-through: Add pci_dict_cmp()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 19 Jun 2009 00:56:06 -0700
Delivery-date: Fri, 19 Jun 2009 01:02:57 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1245220551 -3600
# Node ID 60588f1f055f40debf5b9f65dc012009d36c8cd1
# Parent  9e36ef77f658b3b62476ea585f04d56dcd687965
Subject: xend: pass-through: Add pci_dict_cmp()

pci_dict_cmp() compares the two pci devices in dict format.

Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>
---
 tools/python/xen/util/pci.py            |    4 ++++
 tools/python/xen/xend/XendDomainInfo.py |   26 +++++++++-----------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff -r 9e36ef77f658 -r 60588f1f055f tools/python/xen/util/pci.py
--- a/tools/python/xen/util/pci.py      Wed Jun 17 07:34:59 2009 +0100
+++ b/tools/python/xen/util/pci.py      Wed Jun 17 07:35:51 2009 +0100
@@ -204,6 +204,10 @@ def pci_dict_to_bdf_str(dev):
 
 def pci_dict_to_xc_str(dev):
     return __pci_dict_to_fmt_str('0x%x, 0x%x, 0x%x, 0x%x', dev)
+
+def pci_dict_cmp(a, b, keys=['domain', 'bus', 'slot', 'func']):
+    return reduce(lambda x, y: x and y,
+                  map(lambda k: int(a[k], 16) == int(b[k], 16), keys))
 
 def extract_the_exact_pci_names(pci_names):
     result = []
diff -r 9e36ef77f658 -r 60588f1f055f tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Wed Jun 17 07:34:59 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Wed Jun 17 07:35:51 2009 +0100
@@ -40,7 +40,7 @@ import xen.util.xsm.xsm as security
 import xen.util.xsm.xsm as security
 from xen.util import xsconstants
 from xen.util.pci import serialise_pci_opts, pci_opts_list_to_sxp, \
-                         pci_dict_to_bdf_str, pci_dict_to_xc_str
+                         pci_dict_to_bdf_str, pci_dict_to_xc_str, pci_dict_cmp
 
 from xen.xend import balloon, sxp, uuid, image, arch
 from xen.xend import XendOptions, XendNode, XendConfig
@@ -645,10 +645,7 @@ class XendDomainInfo:
                    int(x['vslot'], 16) != AUTO_PHP_SLOT):
                     raise VmError("vslot %s already have a device." % 
(new_dev['vslot']))
 
-                if (int(x['domain'], 16) == int(new_dev['domain'], 16) and
-                   int(x['bus'], 16)    == int(new_dev['bus'], 16) and
-                   int(x['slot'], 16)   == int(new_dev['slot'], 16) and
-                   int(x['func'], 16)   == int(new_dev['func'], 16) ):
+                if (pci_dict_cmp(x, new_dev)):
                     raise VmError("device is already inserted")
 
         # Test whether the devices can be assigned with VT-d
@@ -839,23 +836,18 @@ class XendDomainInfo:
                 existing_dev_uuid = sxp.child_value(existing_dev_info, 'uuid')
                 existing_pci_conf = self.info['devices'][existing_dev_uuid][1]
                 existing_pci_devs = existing_pci_conf['devs']
-                vslot = ""
-                for x in existing_pci_devs:
-                    if ( int(x['domain'], 16) == int(dev['domain'], 16) and
-                         int(x['bus'], 16) == int(dev['bus'], 16) and
-                         int(x['slot'], 16) == int(dev['slot'], 16) and
-                         int(x['func'], 16) == int(dev['func'], 16) ):
-                        vslot = x['vslot']
-                        break
-                if vslot == "":
+                new_devs = filter(lambda x: pci_dict_cmp(x, dev),
+                                  existing_pci_devs)
+                if len(new_devs) < 0:
                     raise VmError("Device %s is not connected" %
                                   pci_dict_to_bdf_str(dev))
-                self.hvm_destroyPCIDevice(int(vslot, 16))
+                new_dev = new_devs[0]
+                self.hvm_destroyPCIDevice(int(new_dev['vslot'], 16))
                 # Update vslot
-                dev['vslot'] = vslot
+                dev['vslot'] = new_dev['vslot']
                 for n in sxp.children(pci_dev):
                     if(n[0] == 'vslot'):
-                        n[1] = vslot
+                        n[1] = new_dev['vslot']
 
         # If pci platform does not exist, create and exit.
         if existing_dev_info is None:

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] Subject: xend: pass-through: Add pci_dict_cmp(), Xen patchbot-unstable <=