Improve xm uptime command for inactive managed domains
PATCH 1/1 Improve xm uptime command for inactive managed domains
Hi,
When I tried xm uptime command to a inactive managed domain, I saw the following error messages.
At first, I tried xm uptime command to the inactive managed domain only. I thought that the error message is adequate because the domain is inactive.
Next, I tried xm uptime command to both the inactive managed domain and a active domain. The uptime of the active domain was shown by xm uptime command, but the uptime of the inactive managed domain was not shown by xm uptime command. I felt sad because xm uptime command caused error halfway.
# xm list Name ID Mem VCPUs State Time(s) Domain-0 0 747 2 r----- 63.7 vm1 1 256 2 r----- 209.5 vm2 128 1 0.0 # xm uptime vm2 Name ID Uptime Error: Invalid argument. Usage: xm uptime [-s] <Domain>
Print uptime for a domain.
# xm uptime vm1 vm2 Name ID Uptime vm1 1 0:04:00 Error: Invalid argument. Usage: xm uptime [-s] <Domain>
Print uptime for a domain.
This patch improves xm uptime command for inactive managed domains. xm uptime command always shows 0:00:00 in uptime if domain is inactive.
# xm uptime vm2 Name ID Uptime vm2 0:00:00 # xm uptime vm1 vm2 Name ID Uptime vm1 1 0:05:50 vm2 0:00:00
Best regards,
Kan
tools/python/xen/xm/main.py +4 -2
@@ -1722,14 +1722,16 @@ def xm_uptime(args): if k in ['-s', '--short']: short_mode = 1 - doms = getDomains(params, 'running') + doms = getDomains(params, 'all') if short_mode == 0: print '%-33s %4s %s ' % ('Name','ID','Uptime') for dom in doms: d = parse_doms_info(dom) - if int(d['domid']) > 0: + if d['domid'] == '': + uptime = 0 + elif int(d['domid']) > 0: uptime = int(round(d['up_time'])) else: f=open('/proc/uptime', 'r')
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel