From: Simon Horman <horms@verge.net.au>
To: xen-devel@lists.xensource.com
Cc: Zhigang Wang <zhigang.x.wang@oracle.com>,
Akio Takebe <takebe_akio@jp.fujitsu.com>,
Masaki Kanno <kanno.masaki@jp.fujitsu.com>,
Dexuan Cui <dexuan.cui@intel.com>
Subject: [patch 11/17] xend: pass-through: Add pci_dict_cmp()
Date: Wed, 17 Jun 2009 12:56:23 +1000 [thread overview]
Message-ID: <20090617032046.568374047@vergenet.net> (raw)
In-Reply-To: 20090617025612.786241401@vergenet.net
[-- Attachment #1: pci_dict_cmp.patch --]
[-- Type: text/plain, Size: 3933 bytes --]
pci_dict_cmp() compares the two pci devices in dict format.
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/util/pci.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-15 11:24:32.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-15 11:24:34.000000000 +1000
@@ -205,6 +205,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 = []
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:32.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xend/XendDomainInfo.py 2009-06-15 11:24:34.000000000 +1000
@@ -40,7 +40,7 @@ from xen.util.blkif import blkdev_uname_
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:
--
next prev parent reply other threads:[~2009-06-17 2:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-17 2:56 [patch 00/17] xend: pass-through: various clean-ups and infrastructure: take iii Simon Horman
2009-06-17 2:56 ` [patch 01/17] xend: Support older pciutils without -vmm option Simon Horman
2009-06-17 2:56 ` [patch 02/17] xend: pass-through: Only call setupOneDevice() once per device Simon Horman
2009-06-17 2:56 ` [patch 03/17] xend: pass-through: fix typo: spx -> sxp Simon Horman
2009-06-17 2:56 ` [patch 04/17] xend: pass-through: tidy up PciController() Simon Horman
2009-06-17 2:56 ` [patch 05/17] xend: pass-through: cleanupDevice: move and remove recently added vslot entry Simon Horman
2009-06-17 2:56 ` [patch 06/17] xend: pass-through: sxp.merge() cant deal with values being a list Simon Horman
2009-06-17 2:56 ` [patch 07/17] xend: pass-through: Remove PciDeviceNotFoundError, it is never used Simon Horman
2009-06-17 2:56 ` [patch 08/17] xend: pass-through: Use PCIDevice as the parameter for the constructor for PCIQuirk Simon Horman
2009-06-17 2:56 ` [patch 09/17] xend: pass-through: Common parse_pci_name() Simon Horman
2009-06-17 2:56 ` [patch 10/17] xend: pass-through: Use common parsing code in preprocess_pci() Simon Horman
2009-06-17 2:56 ` Simon Horman [this message]
2009-06-17 2:56 ` [patch 12/17] xend: pass-through: Move pci conversion functions to pci.py Simon Horman
2009-06-17 2:56 ` [patch 13/17] xend: pass-through: Use generic code in pci_opts_list_to_sxp() Simon Horman
2009-06-17 2:56 ` [patch 14/17] xend: pass-through: Add pci_tuple_to_dict() Simon Horman
2009-06-17 2:56 ` [patch 15/17] xend: pass-through: Use common parsing code in parse_pci_configuration() Simon Horman
2009-06-17 2:56 ` [patch 16/17] xend: pass-through: Use common parsing code in getDeviceConfiguration() Simon Horman
2009-06-17 2:56 ` [patch 17/17] xend: pass-through: Clean up hvm_destroyPCIDevice() Simon Horman
2009-06-17 6:12 ` [patch 00/17] xend: pass-through: various clean-ups and infrastructure: take iii Keir Fraser
2009-06-17 6:41 ` Keir Fraser
2009-06-17 6:55 ` Simon Horman
2009-06-17 7:17 ` Simon Horman
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=20090617032046.568374047@vergenet.net \
--to=horms@verge.net.au \
--cc=dexuan.cui@intel.com \
--cc=kanno.masaki@jp.fujitsu.com \
--cc=takebe_akio@jp.fujitsu.com \
--cc=xen-devel@lists.xensource.com \
--cc=zhigang.x.wang@oracle.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.