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] [patch] xm: Unify the output of pci-list

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] xm: Unify the output of pci-list
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Fri, 29 May 2009 14:54:57 +1000
Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Delivery-date: Thu, 28 May 2009 21:55:24 -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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.18 (2008-05-17)
This is another attempt at having pci-list produce consistent output.
Without this change there differences in the output of both vslots
and domain occur for domains that have never been started and domains
that have been started.

In order to address this I have taken the approach of
using integers where possible and explicitly formating them,
rather than relying on string representations that are present in
data structures.

I have also re-used the common part of the format, to try
and mitigate. the possibility of future inconsistencies there.

This patch also:
* Removes trailing whitespace
* Removes unnecessary brackets and whitespace from print invocations
* Prints the header outside of the loop to avoid having
  to maintain a state variable

Cc: Masaki Kanno <kanno.masaki@xxxxxxxxxxxxxx>
Signed-off-by: Simon Horman <horms@xxxxxxxxxxxx>

Index: xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen-unstable.hg.orig/tools/python/xen/xm/main.py    2009-05-28 
10:37:26.000000000 +1000
+++ xen-unstable.hg/tools/python/xen/xm/main.py 2009-05-28 11:24:21.000000000 
+1000
@@ -2150,43 +2150,45 @@ def xm_pci_list(args):
             ppci_ref = server.xenapi.DPCI.get_PPCI(dpci_ref)
             ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
             dev = {
-                "domain":   "0x%04x" % int(ppci_record["domain"]),
-                "bus":      "0x%02x" % int(ppci_record["bus"]),
-                "slot":     "0x%02x" % int(ppci_record["slot"]),
-                "func":     "0x%01x" % int(ppci_record["func"]),
-                "vslot":    "0x%02x" % \
-                            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:
-        devs = server.xend.domain.getDeviceSxprs(dom, 'pci')
+        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(assigned_or_requested_vslot(x), 16)
+            }
+            devs.append(dev)
 
     if len(devs) == 0:
         return
 
     has_vslot = False
     for x in devs:
-        vslot = assigned_or_requested_vslot(x)
-        if int(vslot, 16) == AUTO_PHP_SLOT:
-            x['vslot'] = '-'
+        if x['vslot'] == AUTO_PHP_SLOT:
+            x['show_vslot'] = '-'
         else:
-            x['vslot'] = vslot
+            x['show_vslot'] = "0x%02x" % x['vslot']
             has_vslot = True
 
+    hdr_str = 'domain bus  slot func'
+    fmt_str = '0x%(domain)04x 0x%(bus)02x 0x%(slot)02x 0x%(func)x'
     if has_vslot:
-        hdr_str = 'VSlt domain   bus   slot   func'
-        fmt_str =  "%(vslot)-4s %(domain)-6s   %(bus)-4s  %(slot)-4s   
%(func)-3s    "
-    else:
-        hdr_str = 'domain   bus   slot   func'
-        fmt_str =  "%(domain)-6s   %(bus)-4s  %(slot)-4s   %(func)-3s    "
-    hdr = 0
+        hdr_str = 'VSlt ' + hdr_str
+        fmt_str = '%(show_vslot)-4s ' + fmt_str
 
+    print hdr_str
     for x in devs:
-        if hdr == 0:
-            print (hdr_str)
-            hdr = 1
-        print ( fmt_str % x )
+        print fmt_str % x
 
 
 def parse_pci_info(info):

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [patch] xm: Unify the output of pci-list, Simon Horman <=