All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Pretty-printing xm network-list/block-list/vtpm-list
@ 2006-02-10 19:36 Stefan Berger
  2006-02-10 19:46 ` Ewan Mellor
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Berger @ 2006-02-10 19:36 UTC (permalink / raw)
  To: ewan, xen-devel

[-- Attachment #1: Type: text/plain, Size: 175 bytes --]

The attached patch prints a list of devices instead of an S-Expr.
Might need some tweaking with spaces in between items...

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>


[-- Attachment #2: xm-format.diff --]
[-- Type: text/x-patch, Size: 3601 bytes --]

Index: xen/xen-unstable.hg/tools/python/xen/xm/main.py
===================================================================
--- xen.orig/xen-unstable.hg/tools/python/xen/xm/main.py
+++ xen/xen-unstable.hg/tools/python/xen/xm/main.py
@@ -684,29 +684,94 @@ def xm_log(args):
     from xen.xend.XendClient import server
     print server.xend_node_log()
 
+def parse_dev_info(info):
+    def get_info(n, t, d):
+        i = 0
+        while i < len(info):
+            if (info[i][0] == n):
+                return t(info[i][1])
+            i = i + 1
+        return t(d)
+    return {
+        #common
+        'backend-id' : get_info('backend-id',   int,   -1),
+        'handle'     : get_info('handle',       int,    0),
+        'state'      : get_info('state',        int,   -1),
+        'be-path'    : get_info('backend',      str,   '??'),
+        'event-ch'   : get_info('event-channel',int,   -1),
+        #network specific
+        'virtual-device' : get_info('virtual-device', str, '??'),
+        'tx-ring-ref': get_info('tx-ring-ref',  int,   -1),
+        'rx-ring-ref': get_info('rx-ring-ref',  int,   -1),
+        'mac'        : get_info('mac',          str,   '??'),
+        #block-device specific
+        'ring-ref'   : get_info('ring-ref',     int,   -1),
+        }
+
+
 def xm_network_list(args):
     arg_check(args, "network-list", 1)
     dom = args[0]
     from xen.xend.XendClient import server
+    hdr = 0
     for x in server.xend_domain_devices(dom, 'vif'):
-        sxp.show(x)
-        print
+        if hdr == 0:
+            print 'Attached network devices:'
+            print 'Idx BE     MAC Addr.     handle state evt-ch tx-/rx-ring-ref BE-path'
+            hdr = 1
+        ni = parse_dev_info(x[1])
+        ni['idx'] = int(x[0])
+        print ("%(idx)-3d "
+               "%(backend-id)-3d"
+               "%(mac)-17s    "
+               "%(handle)-3d   "
+               "%(state)-3d    "
+               "%(event-ch)-3d   "
+               "%(tx-ring-ref)-5d/%(rx-ring-ref)-5d   "
+               "%(be-path)-30s  "
+               % ni)
 
 def xm_block_list(args):
     arg_check(args, "block-list", 1)
     dom = args[0]
     from xen.xend.XendClient import server
+    hdr = 0
     for x in server.xend_domain_devices(dom, 'vbd'):
-        sxp.show(x)
-        print
+        if hdr == 0:
+            print 'Attached block devices:'
+            print 'Vdev  BE handle state evt-ch ring-ref BE-path'
+            hdr = 1
+        ni = parse_dev_info(x[1])
+        ni['idx'] = int(x[0])
+        print ("%(idx)-3d    "
+               "%(backend-id)-3d  "
+               "%(handle)-3d   "
+               "%(state)-3d    "
+               "%(event-ch)-3d    "
+               "%(ring-ref)-5d "
+               "%(be-path)-30s  "
+               % ni)
 
 def xm_vtpm_list(args):
     arg_check(args, "vtpm-list", 1)
     dom = args[0]
     from xen.xend.XendClient import server
+    hdr = 0
     for x in server.xend_domain_devices(dom, 'vtpm'):
-        sxp.show(x)
-        print
+        if hdr == 0:
+            print 'Attached virtual TPM devices:'
+            print 'Idx  BE handle state evt-ch ring-ref BE-path'
+            hdr = 1
+        ni = parse_dev_info(x[1])
+        ni['idx'] = int(x[0])
+        print ("%(idx)-3d   "
+               "%(backend-id)-3d  "
+               "%(handle)-3d   "
+               "%(state)-3d    "
+               "%(event-ch)-3d    "
+               "%(ring-ref)-5d "
+               "%(be-path)-30s  "
+               % ni)
 
 def xm_block_attach(args):
     arg_check(args, 'block-attach', 4, 5)

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Pretty-printing xm network-list/block-list/vtpm-list
  2006-02-10 19:36 [PATCH] Pretty-printing xm network-list/block-list/vtpm-list Stefan Berger
@ 2006-02-10 19:46 ` Ewan Mellor
  0 siblings, 0 replies; 2+ messages in thread
From: Ewan Mellor @ 2006-02-10 19:46 UTC (permalink / raw)
  To: Stefan Berger; +Cc: xen-devel

On Fri, Feb 10, 2006 at 02:36:00PM -0500, Stefan Berger wrote:

> The attached patch prints a list of devices instead of an S-Expr.
> Might need some tweaking with spaces in between items...

Great, thank you!  Could you keep the s-expression output though, for
debugging?  I think an additional --long flag would be best, for
consistency with xm list.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-02-10 19:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-10 19:36 [PATCH] Pretty-printing xm network-list/block-list/vtpm-list Stefan Berger
2006-02-10 19:46 ` Ewan Mellor

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.