Skip to contentSkip to conversation

Improve xm vcpu-list command for inactive managed domains

PATCH In review Masaki Kanno 1 participant 2 messages Jul 19, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve xm vcpu-list command for inactive managed domains

Hi,

When I tried xm vcpu-list command to an inactive managed domain, I saw the following error message.

# xm list vm1
Name                                        ID   Mem VCPUs      State   Time(s)
vm1                                              256     1                 0.0
# xm vcpu-list vm1
Error: an integer is required
Usage: xm vcpu-list [<Domain>]

List the VCPUs for a domain or all domains.

This patch shows vcpu-list of inactive managed domains as follows. We can confirm CPU Affinity of inactive managed domains by xm vcpu-list command.

# xm new vm1.conf cpus="0"
Using config file "./vm1.conf".
# xm new vm2.conf cpus="1"
Using config file "./vm2.conf".
# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0   941     2     r-----     63.2
vm1                                              256     1                 0.0
vm2                                              256     1                 0.0
# xm vcpu-list
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
Domain-0                                   0     0   r--      32.8 any cpu
Domain-0                                   1     1   -b-      30.8 any cpu
vm1                                        0                   0.0 0
vm2                                        0                   0.0 1

Best regards,
Kan

tools/python/xen/xend/XendDomainInfo.py +21 -10
diff -r 1f348e70a5af tools/python/xen/xend/XendDomainInfo.py
@@ -631,16 +631,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
 
tools/python/xen/xm/main.py +14 -7
diff -r 1f348e70a5af tools/python/xen/xm/main.py
@@ -1016,13 +1016,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:
@@ -1091,8 +1091,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):
@@ -1106,7 +1110,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'
@@ -1118,8 +1125,8 @@ def xm_vcpu_list(args):
                     s += '-'
                 s += '-'
             else:
-                c = "-"
-                s = "--p"
+                c = '-'
+                s = '--p'
 
             print format % locals()
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

Re: [PATCH] Improve xm vcpu-list command for inactivemanaged domains

Quoted 34 lines

Hi,

When I tried xm vcpu-list command to an inactive managed domain, I saw the following error message.

# xm list vm1
Name                                        ID   Mem VCPUs      State   
Time(s)
vm1                                              256     1                 
0.0
# xm vcpu-list vm1
Error: an integer is required
Usage: xm vcpu-list [<Domain>]

List the VCPUs for a domain or all domains.

This patch shows vcpu-list of inactive managed domains as follows. We can confirm CPU Affinity of inactive managed domains by xm vcpu-list command.

# xm new vm1.conf cpus="0"
Using config file "./vm1.conf".
# xm new vm2.conf cpus="1"
Using config file "./vm2.conf".
# xm list
Name                                        ID   Mem VCPUs      State   
Time(s)
Domain-0                                     0   941     2     r-----     
63.2
vm1                                              256     1                 
0.0
vm2                                              256     1                 
Quoted 8 lines
0.0
# xm vcpu-list
Name                                ID  VCPU   CPU State   Time(s) CPU 
Affinity
Domain-0                                   0     0   r--      32.8 any cpu
Domain-0                                   1     1   -b-      30.8 any cpu
vm1                                        0                   0.0 0
vm2                                        0                   0.0 1

Sorry, I attached a wrong result.
I attach a right result.

# xm vcpu-list
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
Domain-0                             0     0     1   r--      57.1 any cpu
Domain-0                             0     1     0   -b-      68.4 any cpu
vm1                                        0                   0.0 0
vm2                                        0                   0.0 1

Best regards,
Kan