aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-19 17:17:25 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2007-07-19 17:17:25 +0100
commit9d53b5f351f8e80a1ab392961b3b96daf30e6bad (patch)
tree8cddaa299625fe49846b8e71bfc4a1867d67c56e /tools
parentbd99184d5427f133f09ac870ac3e925c3377dce1 (diff)
downloadxen-9d53b5f351f8e80a1ab392961b3b96daf30e6bad.tar.gz
xen-9d53b5f351f8e80a1ab392961b3b96daf30e6bad.tar.bz2
xen-9d53b5f351f8e80a1ab392961b3b96daf30e6bad.zip
Improve xm vcpu-list command for inactive managed domains.
Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py31
-rw-r--r--tools/python/xen/xm/main.py21
2 files changed, 35 insertions, 17 deletions
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index 94a02049a6..eb5c57556c 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -632,16 +632,27 @@ class XendDomainInfo:
['vcpu_count', self.info['VCPUs_max']]]
for i in range(0, self.info['VCPUs_max']):
- info = xc.vcpu_getinfo(self.domid, i)
-
- sxpr.append(['vcpu',
- ['number', i],
- ['online', info['online']],
- ['blocked', info['blocked']],
- ['running', info['running']],
- ['cpu_time', info['cpu_time'] / 1e9],
- ['cpu', info['cpu']],
- ['cpumap', info['cpumap']]])
+ if self.domid is not None:
+ info = xc.vcpu_getinfo(self.domid, i)
+
+ sxpr.append(['vcpu',
+ ['number', i],
+ ['online', info['online']],
+ ['blocked', info['blocked']],
+ ['running', info['running']],
+ ['cpu_time', info['cpu_time'] / 1e9],
+ ['cpu', info['cpu']],
+ ['cpumap', info['cpumap']]])
+ else:
+ sxpr.append(['vcpu',
+ ['number', i],
+ ['online', 0],
+ ['blocked', 0],
+ ['running', 0],
+ ['cpu_time', 0.0],
+ ['cpu', -1],
+ ['cpumap', self.info['cpus'] and \
+ self.info['cpus'] or range(64)]])
return sxpr
diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py
index e58b1418eb..9bd95605c7 100644
--- a/tools/python/xen/xm/main.py
+++ b/tools/python/xen/xm/main.py
@@ -1023,13 +1023,13 @@ def xm_vcpu_list(args):
if args:
dominfo = map(server.xend.domain.getVCPUInfo, args)
else:
- doms = server.xend.domains(False)
+ doms = server.xend.domains_with_state(False, 'all', False)
dominfo = map(server.xend.domain.getVCPUInfo, doms)
print '%-32s %5s %5s %5s %5s %9s %s' % \
('Name', 'ID', 'VCPU', 'CPU', 'State', 'Time(s)', 'CPU Affinity')
- format = '%(name)-32s %(domid)5d %(number)5d %(c)5s %(s)5s ' \
+ format = '%(name)-32s %(domid)5s %(number)5d %(c)5s %(s)5s ' \
' %(cpu_time)8.1f %(cpumap)s'
for dom in dominfo:
@@ -1098,8 +1098,12 @@ def xm_vcpu_list(args):
return format_pairs(list_to_rangepairs(cpumap))
- name = get_info('name')
- domid = int(get_info('domid'))
+ name = get_info('name')
+ domid = get_info('domid')
+ if domid is not None:
+ domid = str(domid)
+ else:
+ domid = ''
for vcpu in sxp.children(dom, 'vcpu'):
def vinfo(n, t):
@@ -1113,7 +1117,10 @@ def xm_vcpu_list(args):
running = vinfo('running', int)
blocked = vinfo('blocked', int)
- if online:
+ if cpu < 0:
+ c = ''
+ s = ''
+ elif online:
c = str(cpu)
if running:
s = 'r'
@@ -1125,8 +1132,8 @@ def xm_vcpu_list(args):
s += '-'
s += '-'
else:
- c = "-"
- s = "--p"
+ c = '-'
+ s = '--p'
print format % locals()