From: Simon Horman Subject: [patch 9/9] xm: pass-through: sort the output of xm pci-list Date: Thu, 04 Jun 2009 13:21:24 +1000 Message-ID: <20090604032231.130929850@vergenet.net> References: <20090604032115.934982694@vergenet.net> Return-path: Content-Disposition: inline; filename=xm-pci-list-sort.patch List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Masaki Kanno , Dexuan Cui List-Id: xen-devel@lists.xenproject.org Other than being arguably more human readable, this patch reconciles the output differences between using Xen API and xmlrpc to manipulate domains. Cc: Dexuan Cui Cc: Masaki Kanno Signed-off-by: Simon Horman Index: xen-unstable.hg/tools/python/xen/util/pci.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/util/pci.py 2009-06-04 09:34:36.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/util/pci.py 2009-06-04 09:35:10.000000000 +1000 @@ -114,6 +114,10 @@ PAGE_MASK=~(PAGE_SIZE - 1) def PCI_DEVFN(slot, func): return ((((slot) & 0x1f) << 3) | ((func) & 0x07)) +def PCI_BDF(domain, bus, slot, func): + return (((domain & 0xffff) << 16) | ((bus & 0xff) << 8) | + PCI_DEVFN(slot, func)) + def serialise_pci_opts(opts): return reduce(lambda x, y: x+','+y, map(lambda (x, y): x+'='+y, opts)) Index: xen-unstable.hg/tools/python/xen/xm/main.py =================================================================== --- xen-unstable.hg.orig/tools/python/xen/xm/main.py 2009-06-04 09:33:27.000000000 +1000 +++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-04 11:03:13.000000000 +1000 @@ -2205,6 +2205,9 @@ def xm_pci_list(args): if len(devs) == 0: return + devs.sort(None, lambda x: x['vslot'] << 32 | PCI_BDF(x['domain'], x['bus'], + x['slot'], x['func'])) + has_vslot = False for x in devs: if x['vslot'] == AUTO_PHP_SLOT: --