Skip to contentSkip to conversation

Improve xm vcpu-pin command for releasing CPU affinity

PATCH New Masaki Kanno 1 participant 1 message Mar 13, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve xm vcpu-pin command for releasing CPU affinity

Hi,

Currently, if users would like to release CPU affinity of virtual CPU, they should specify the following values to the third argument of the xm vcpu-pin command.
- 0-<Maximum physical CPU number>, or
- 0-63

Generally, almost all users know the number of the physical CPU of the machines they are using. Therefore when they would like to release CPU affinity of virtual CPU, they will be able to specify an appropriate value to the third argument of the xm vcpu-pin command. However, I think it will be more convenient if they can release CPU affinity by specifying a special keyword.

This patch improves the third argument of the xm vcpu-pin command. They are able to release CPU affinity of virtual CPU by specifying the special keyword "all".

# xm vcpu-list vm1
Name                              ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                9     0     1   -b-     552.7 1
vm1                                9     1     0   -b-     560.2 0
# xm vcpu-pin vm1 0 all
# xm vcpu-list vm1
Name                              ID  VCPU   CPU State   Time(s) CPU Affinity
vm1                                9     0     0   -b-     553.1 any cpu
vm1                                9     1     0   -b-     560.6 0

Best regards,
Kan

tools/python/xen/xm/main.py +5 -2
diff -r 09da174827ea tools/python/xen/xm/main.py
@@ -139,7 +139,7 @@ SUBCOMMAND_HELP = {
                      'Send a trigger to a domain.'),
     'vcpu-list'   : ('[<Domain>]',
                      'List the VCPUs for a domain or all domains.'),
-    'vcpu-pin'    : ('<Domain> <VCPU> <CPUs>',
+    'vcpu-pin'    : ('<Domain> <VCPU|all> <CPUs|all>',
                      'Set which CPUs a VCPU can use.'),
     'vcpu-set'    : ('<Domain> <vCPUs>',
                      'Set the number of active VCPUs for allowed for the'
@@ -1084,7 +1084,10 @@ def xm_vcpu_pin(args):
 
     dom  = args[0]
     vcpu = args[1]
-    cpumap = cpu_make_map(args[2])
+    if args[2] == 'all':
+        cpumap = cpu_make_map('0-63')
+    else:
+        cpumap = cpu_make_map(args[2])
     
     server.xend.domain.pincpu(dom, vcpu, cpumap)
 

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