Fix xm network-list/block-list/vtpm-list
PATCH 1/1 Fix xm network-list/block-list/vtpm-list
Hi,
When I tested xm commands, I saw the following error messages. The cause is because arg_check() counts a split(--).
#xm network-list -l -- -vm1
Error: 'xm network-list' requires between 1 and 2 arguments.
#xm block-list -l -- -vm1
Error: 'xm block-list' requires between 1 and 2 arguments.
#xm vtpm-list -l -- -vm1
Error: 'xm vtpm-list' requires between 1 and 2 arguments.
I corrected for arg_check() not to count the split(--). The following are test results.
# xm network-list -l -- -vm1
(0
((backend-id 0)
(mac 00:16:3e:10:56:fa)
(handle 0)
(state 4)
(backend /local/domain/0/backend/vif/11/0)
(tx-ring-ref 521)
(rx-ring-ref 522)
(event-channel 7)
)
)
# xm network-list --long -- -vm1
(0
((backend-id 0)
(mac 00:16:3e:10:56:fa)
(handle 0)
(state 4)
(backend /local/domain/0/backend/vif/11/0)
(tx-ring-ref 521)
(rx-ring-ref 522)
(event-channel 7)
)
)# xm block-list --long -- -vm1
(2049
((virtual-device 2049)
(backend-id 0)
(state 4)
(backend /local/domain/0/backend/vbd/12/2049)
(ring-ref 8)
(event-channel 6)
)
)
# xm block-list -l -- -vm1
(2049
((virtual-device 2049)
(backend-id 0)
(state 4)
(backend /local/domain/0/backend/vbd/12/2049)
(ring-ref 8)
(event-channel 6)
)
)# xm vtpm-list -l -- -vm1
(0
((backend-id 0)
(state 1)
(handle 0)
(backend /local/domain/0/backend/vtpm/10/0)
)
)
# xm vtpm-list --long -- -vm1
(0
((backend-id 0)
(state 1)
(handle 0)
(backend /local/domain/0/backend/vtpm/10/0)
)
)Best regards,
Kan
tools/python/xen/xm/main.py +7 -1
@@ -276,7 +276,13 @@ for command in all_commands: #################################################################### def arg_check(args, name, lo, hi = -1): - n = len(args) + # remove split(--) from args + new_args = [] + for x in args: + if x != '--': + new_args.append(x) + + n = len(new_args) if hi == -1: if n != lo:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 5 lines
diff -r
411a3c01bb40tools/python/xen/xm/main.pytools/python/xen/xm/main.py +0
-0@@ -276,7 +276,13 @@ for command in all_commands: ####################################################################
tools/python/xen/xm/main.py for command in all_commands: · line 285
Quoted 10 lines
tools/python/xen/xm/main.py +7
-1def arg_check(args, name, lo, hi = -1): - n = len(args) + # remove split(--) from args + new_args = [] + for x in args: + if x != '--': + new_args.append(x) + + n = len(new_args)
You don't mean "n = len([i for i in args if i != '--'])"?
Bastian
Signature · 2 lines
Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4
Hi Bastian,
Thanks for your comment. I send new patch.
Best regards,
Kan
Quoted 18 lines
Quoted 5 lines
diff -r
411a3c01bb40tools/python/xen/xm/main.pytools/python/xen/xm/main.py +0
-0@@ -276,7 +276,13 @@ for command in all_commands: ####################################################################tools/python/xen/xm/main.py for command in all_commands: · line 285
Quoted 10 lines
tools/python/xen/xm/main.py +7
-1def arg_check(args, name, lo, hi = -1): - n = len(args) + # remove split(--) from args + new_args = [] + for x in args: + if x != '--': + new_args.append(x) + + n = len(new_args)You don't mean "n =
len([i for i in args if i != '--'])"?
Quoted 10 lines
Bastian
Signature · 7 lines
Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
tools/python/xen/xm/main.py +1 -1
@@ -273,7 +273,7 @@ for command in all_commands: #################################################################### def arg_check(args, name, lo, hi = -1): - n = len(args) + n = len([i for i in args if i != '--']) if hi == -1: if n != lo:
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
PATCH RESEND 1/1 Fix xm network-list/block-list/vtpm-list
Hi,
Sorry, my patch includes a small miss. A command error occurred when the split(--) was added to other xm commands before. However, the command error does not occur because of my patch. The following is example.
Before:
# xm log -- Error: 'xm log' requires 0 argument. After: # xm log -- [2006-04-23 22:37:19 xend.XendDomainInfo] DEBUG (XendDomainInfo:877) XendDomainInfo.handleShutdownWatch [2006-04-23 22:41:14 xend] INFO (SrvDaemon:278) Xend Daemon started (snip)
When I tested xm network-list/block-list/vtpm-list command more, I found other bug. When these xm commands specify two domains, a command error does not occur. However, when these xm commands specify more than three domains, the command error occurs. The following is example.
# xm block-list vm1 vm2 Vdev BE handle state evt-ch ring-ref BE-path 769 0 0 4 6 8 /local/domain/0/backend/vbd/2/769 # xm block-list vm1 vm2 vm3 Error: 'xm block-list' requires between 1 and 2 arguments.
block-list <DomId> [--long] List virtual block devices for a domain
I made a new patch that solved these problems. New patch processes these commands as follows.
1. Remove has_long_option() and add arg_check_for_resource_list() instead.
2. 'args' tells 'options' from 'params' by using gnu_getopt().
3. 'options' checks whether -l/--long option is specified.
4. If 'params' not given, print out 'No domain parameter given' and usage.
5. If 'params' given multiple domains, print out
'No multiple domain parameters allowed' and usage.
6. Then it displays the resources as usual.
Best regards,
Kan
Quoted 39 lines
Hi Bastian,
Thanks for your comment. I send new patch.
Signed-off-by Masaki Kanno <[email protected]>Best regards,
KanQuoted 18 lines
Quoted 5 lines
diff -r
411a3c01bb40tools/python/xen/xm/main.pytools/python/xen/xm/main.py +0
-0@@ -276,7 +276,13 @@ for command in all_commands: ####################################################################tools/python/xen/xm/main.py for command in all_commands: · line 285
Quoted 10 lines
tools/python/xen/xm/main.py +7
-1def arg_check(args, name, lo, hi = -1): - n = len(args) + # remove split(--) from args + new_args = [] + for x in args: + if x != '--': + new_args.append(x) + + n = len(new_args)You don't mean "n =
len([i for i in args if i != '--'])"?Quoted 10 lines
Bastian
Signature · 7 lines
Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xensource.com/xen-devel
Quoted 5 lines
-------------------------------text/plain-------------------------------
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
tools/python/xen/xm/main.py +15 -22
@@ -858,7 +858,7 @@ def parse_dev_info(info): 'ring-ref' : get_info('ring-ref', int, -1), } -def has_long_option(args): +def arg_check_for_resource_list(args, name): use_long = 0 try: (options, params) = getopt.gnu_getopt(args, 'l', ['long'])
@@ -869,16 +869,19 @@ def has_long_option(args): 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, 2) - - (use_long, params) = has_long_option(args) if len(params) == 0: print 'No domain parameter given' - sys.exit(1) + usage(name) + if len(params) > 1: + print 'No multiple domain parameters allowed' + usage(name) + + return (use_long, params) + +def xm_network_list(args): + (use_long, params) = arg_check_for_resource_list(args, "network-list") + dom = params[0] if use_long: devs = server.xend.domain.getDeviceSxprs(dom, 'vif')
@@ -902,13 +905,8 @@ def xm_network_list(args): % ni) def xm_block_list(args): - 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) + (use_long, params) = arg_check_for_resource_list(args, "block-list") + dom = params[0] if use_long: devs = server.xend.domain.getDeviceSxprs(dom, 'vbd')
@@ -931,13 +929,8 @@ def xm_block_list(args): % ni) def xm_vtpm_list(args): - 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) + (use_long, params) = arg_check_for_resource_list(args, "vtpm-list") + dom = params[0] if use_long: devs = server.xend.domain.getDeviceSxprs(dom, 'vtpm')
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel