Return-Path: <xen-changelog-bounces@lists.xensource.com>
Received: from localhost ([unix socket])
	by imap.linux.ibm.com (Cyrus v2.1.16) with LMTP;
	Fri, 17 Feb 2006 14:45:35 -0500
X-Sieve: CMU Sieve 2.2
Return-Path: <xen-changelog-bounces@lists.xensource.com>
Received: from smtp.linux.ibm.com (linux.ibm.com [9.26.4.197])
	by imap.linux.ibm.com (Postfix) with ESMTP id E3FE97C008
	for <aliguori@imap.linux.ibm.com>; Fri, 17 Feb 2006 14:45:24 -0500 (EST)
Received: from localhost (localhost.localdomain [127.0.0.1])
	by smtp.linux.ibm.com (Postfix) with ESMTP id 952F898047
	for <aliguori@linux.ibm.com>; Fri, 17 Feb 2006 14:45:24 -0500 (EST)
Received: from d01relay05.pok.ibm.com (d01relay05.pok.ibm.com [9.56.227.237])
	by smtp.linux.ibm.com (Postfix) with ESMTP id 520F598045
	for <aliguori@linux.ibm.com>; Fri, 17 Feb 2006 14:45:24 -0500 (EST)
Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216])
	by d01relay05.pok.ibm.com (8.12.10/NCO/VERS6.8) with ESMTP id
	k1HJjOPc199984
	for <aliguori@us.ibm.com>; Fri, 17 Feb 2006 14:45:24 -0500
Received: from d01av02.pok.ibm.com (loopback [127.0.0.1])
	by d01av02.pok.ibm.com (8.12.11/8.13.3) with ESMTP id k1HJjNc5020503
	for <aliguori@us.ibm.com>; Fri, 17 Feb 2006 14:45:23 -0500
Received: from d01as02.pok.ibm.com (d01as02 [9.56.224.38])
	by d01av02.pok.ibm.com (8.12.11/8.12.11) with ESMTP id k1HJjNvY020417
	for <aliguori@us.ibm.com>; Fri, 17 Feb 2006 14:45:23 -0500
Received: from e2.ny.us.ibm.com (e2.pok.ibm.com [9.56.232.142])
	by d01as02.pok.ibm.com (8.12.11/8.12.11) with ESMTP id k1HJjL5m007908
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
	for <aliguori@us.ibm.com>; Fri, 17 Feb 2006 14:45:21 -0500
Received: from lists.xensource.com (host01-bcn-london.deploy.xenoserver.org
	[217.147.82.46])
	by e2.ny.us.ibm.com (8.12.11/8.12.11) with ESMTP id k1HJjJDx001745
	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO)
	for <aliguori@us.ibm.com>; Fri, 17 Feb 2006 14:45:20 -0500
Received: from localhost ([127.0.0.1] helo=lists.xensource.com)
	by host-192-168-0-1-bcn-london with esmtp (Exim 4.50)
	id 1FABjV-00017Q-1H; Fri, 17 Feb 2006 19:57:37 +0000
Received: from host-192-168-0-12-bcn-london ([192.168.0.12]
	helo=xenbits.xensource.com)
	by host-192-168-0-1-bcn-london with esmtp (Exim 4.50)
	id 1FABjQ-00016T-Lj
	for xen-changelog@lists.xensource.com; Fri, 17 Feb 2006 19:57:32 +0000
Received: from xen by xenbits.xensource.com with local (Exim 4.43)
	id 1FABWR-0001gR-KN
	for xen-changelog@lists.xensource.com; Fri, 17 Feb 2006 19:44:07 +0000
Date: Fri, 17 Feb 2006 19:44:07 +0000
From: Xen patchbot -unstable <patchbot-unstable@lists.xensource.com>
To: xen-changelog@lists.xensource.com
Message-Id: <E1FABWR-0001gR-KN@xenbits.xensource.com>
Subject: [Xen-changelog] This patch displays the
	network-list/block-list/vtpm-list using the 'xm'
X-BeenThere: xen-changelog@lists.xensource.com
X-Mailman-Version: 2.1.5
Precedence: list
Reply-To: xen-devel@lists.xensource.com
List-Id: BK change log <xen-changelog.lists.xensource.com>
List-Unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>,
	<mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xensource.com>
List-Help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-Subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>,
	<mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
Sender: xen-changelog-bounces@lists.xensource.com
Errors-To: xen-changelog-bounces@lists.xensource.com
X-Virus-Scanned: amavisd-new at linux.ibm.com
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on
	imap.rtp.raleigh.ibm.com
X-Spam-Status: No, hits=0.0 required=5.0 tests=HTML_MESSAGE autolearn=no
	version=2.63
X-Spam-Level: 

# HG changeset patch
# User emellor@leeni.uk.xensource.com
# Node ID 34f6a1efe52d8c5c722a2d423a0b26b469540a3a
# Parent  aeeeedc6c9b754dc9d26b4bc12ab9d025578da6e
This patch displays the network-list/block-list/vtpm-list using the 'xm'
command. It supports the '--long' option.

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

diff -r aeeeedc6c9b7 -r 34f6a1efe52d tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py	Fri Feb 17 17:22:23 2006
+++ b/tools/python/xen/xm/main.py	Fri Feb 17 18:35:38 2006
@@ -90,18 +90,18 @@
                                     where <DevId> may either be the device ID
                                     or the device name as mounted in the guest"""
 
-block_list_help = "block-list <DomId>               List virtual block devices for a domain"
+block_list_help = "block-list <DomId> [--long]      List virtual block devices for a domain"
 network_attach_help = """network-attach  <DomID> [script=<script>] [ip=<ip>] [mac=<mac>]
                            [bridge=<bridge>] [backend=<backDomID>]
                                     Create a new virtual network device """
 network_detach_help = """network-detach  <DomId> <DevId>  Destroy a domain's virtual network
                                     device, where <DevId> is the device ID."""
 
-network_list_help = "network-list <DomId>             List virtual network interfaces for a domain"
+network_list_help = "network-list <DomId> [--long]    List virtual network interfaces for a domain"
 vnet_list_help = "vnet-list [-l|--long]            list vnets"
 vnet_create_help = "vnet-create <config>             create a vnet from a config file"
 vnet_delete_help = "vnet-delete <vnetid>             delete a vnet"
-vtpm_list_help = "vtpm-list <DomId>                list virtual TPM devices"
+vtpm_list_help = "vtpm-list <DomId> [--long]       list virtual TPM devices"
 
 short_command_list = [
     "console",
@@ -684,29 +684,133 @@
     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 has_long_option(args):
+    use_long = 0
+    try:
+        (options, params) = getopt.gnu_getopt(args, 'l', ['long'])
+    except getopt.GetoptError, opterr:
+        err(opterr)
+        sys.exit(1)
+
+    for (k, v) in options:
+        if k in ['-l', '--long']:
+            use_long = 1
+    return (use_long, params)
+
 def xm_network_list(args):
-    arg_check(args, "network-list", 1)
-    dom = args[0]
-    from xen.xend.XendClient import server
-    for x in server.xend_domain_devices(dom, 'vif'):
-        sxp.show(x)
-        print
+    arg_check(args, "network-list", 1, 2)
+
+    (use_long, params) = has_long_option(args)
+
+    if len(params) == 0:
+        print 'No domain parameter given'
+        sys.exit(1)
+    dom = params[0]
+    from xen.xend.XendClient import server
+    if use_long:
+        devs = server.xend_domain_devices(dom, 'vif')
+        map(PrettyPrint.prettyprint, devs)
+    else:
+        hdr = 0
+        for x in server.xend_domain_devices(dom, 'vif'):
+            if hdr == 0:
+                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
-    for x in server.xend_domain_devices(dom, 'vbd'):
-        sxp.show(x)
-        print
+    arg_check(args, "block-list", 1, 2)
+
+    (use_long, params) = has_long_option(args)
+
+    if len(params) == 0:
+        print 'No domain parameter given'
+        sys.exit(1)
+    dom = params[0]
+    from xen.xend.XendClient import server
+    if use_long:
+        devs = server.xend_domain_devices(dom, 'vbd')
+        map(PrettyPrint.prettyprint, devs)
+    else:
+        hdr = 0
+        for x in server.xend_domain_devices(dom, 'vbd'):
+            if hdr == 0:
+                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
-    for x in server.xend_domain_devices(dom, 'vtpm'):
-        sxp.show(x)
-        print
+    arg_check(args, "vtpm-list", 1, 2)
+
+    (use_long, params) = has_long_option(args)
+
+    if len(params) == 0:
+        print 'No domain parameter given'
+        sys.exit(1)
+    dom = params[0]
+    from xen.xend.XendClient import server
+    if use_long:
+        devs = server.xend_domain_devices(dom, 'vtpm')
+        map(PrettyPrint.prettyprint, devs)
+    else:
+        hdr = 0
+        for x in server.xend_domain_devices(dom, 'vtpm'):
+            if hdr == 0:
+                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)

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

