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-devel

[Xen-devel] [rfc 5/9] xend: pass-through: Add pci_dict_bin_to_str()

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [rfc 5/9] xend: pass-through: Add pci_dict_bin_to_str()
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Wed, 17 Jun 2009 18:08:47 +1000
Cc: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>, Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>, Dexuan Cui <dexuan.cui@xxxxxxxxx>
Delivery-date: Wed, 17 Jun 2009 01:18:29 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20090617080842.095632501@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: quilt/0.46-1
Break out the device list gathering code from xm_pci_list()
so that it can be re-used by subsequent changes.

Cc: Dexuan Cui <dexuan.cui@xxxxxxxxx>
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

--- 

 tools/python/xen/xm/main.py |   47 ++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 16 deletions(-)

Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/main.py    2009-06-14 
23:28:35.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-06-14 23:34:08.000000000 
+1000
@@ -2171,37 +2171,52 @@ def xm_vtpm_list(args):
                    "%(be-path)-30s  "
                    % ni)
 
-
-def xm_pci_list(args):
-    (use_long, params) = arg_check_for_resource_list(args, "pci-list")
-
-    dom = params[0]
-
+def attached_pci_dict_bin(dom):
     devs = []
     if serverType == SERVER_XEN_API:
         for dpci_ref in server.xenapi.VM.get_DPCIs(get_single_vm(dom)):
             ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
             ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
             dev = {
-                "domain":   int(ppci_record["domain"]),
-                "bus":      int(ppci_record["bus"]),
-                "slot":     int(ppci_record["slot"]),
-                "func":     int(ppci_record["func"]),
-                "vslot":    int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
+                'domain': int(ppci_record['domain']),
+                'bus':    int(ppci_record['bus']),
+                'slot':   int(ppci_record['slot']),
+                'func':   int(ppci_record['func']),
+                'vslot':  int(server.xenapi.DPCI.get_hotplug_slot(dpci_ref))
             }
             devs.append(dev)
 
     else:
         for x in server.xend.domain.getDeviceSxprs(dom, 'pci'):
             dev = {
-                "domain":   int(x["domain"], 16),
-                "bus":      int(x["bus"], 16),
-                "slot":     int(x["slot"], 16),
-                "func":     int(x["func"], 16),
-                "vslot":    int(x["vslot"], 16)
+                'domain': int(x['domain'], 16),
+                'bus':    int(x['bus'], 16),
+                'slot':   int(x['slot'], 16),
+                'func':   int(x['func'], 16),
+                'vslot':  int(x['vslot'], 16)
             }
             devs.append(dev)
 
+    return devs
+
+def pci_dict_bin_to_str(pci_dev):
+    new_dev = pci_dev.copy()
+
+    new_dev['domain'] = '0x%04x' % pci_dev['domain']
+    new_dev['bus']    = '0x%02x' % pci_dev['bus']
+    new_dev['slot']   = '0x%02x' % pci_dev['slot']
+    new_dev['func']   = '0x%x'   % pci_dev['func']
+    new_dev['vslot']  = '0x%02x' % pci_dev['vslot']
+
+    return new_dev
+
+def attached_pci_dict(dom):
+    return map(pci_dict_bin_to_str, attached_pci_dict_bin(dom))
+
+def xm_pci_list(args):
+    (use_long, params) = arg_check_for_resource_list(args, "pci-list")
+
+    devs = attached_pci_dict_bin(params[0])
     if len(devs) == 0:
         return
 

-- 

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