vcpu-list [domain-id]
Lists VCPU information for a specific domain. If no domain is
specified, VCPU information for all domains will be provided.
vcpu-pin domain-id vcpu cpus
Pins the the VCPU to only run on the specific CPUs. The keyword
all can be used to apply the cpus list to all VCPUs in the domain.
Normally VCPUs can float between available CPUs whenever Xen deems
a different run state is appropriate. Pinning can be used to
restrict this, by ensuring certain VCPUs can only run on certain
physical CPUs.[重启后失效]
[root@localhost ~]# xm list
Name ID Mem VCPUs State Time(s)
Domain-0 0 486 2 r----- 341.0
centosA 1 512 1 -b---- 36.1
[root@localhost ~]# xm vcpu-list
Name ID VCPU CPU State Time(s) CPU Affinity
Domain-0 0 0 0 r-- 121.2 any cpu
Domain-0 0 1 1 -b- 137.4 any cpu
centosA 1 0 1 -b- 35.7 any cpu
[root@localhost ~]# xm vcpu-pin 0 0 0
[root@localhost ~]# xm vcpu-pin 1 0 1
[root@localhost ~]# xm vcpu-list
Name ID VCPU CPU State Time(s) CPU Affinity
Domain-0 0 0 0 r-- 129.7 0
Domain-0 0 1 1 -b- 147.4 any cpu
centosA 1 0 1 -b- 35.8 1
[root@localhost ~]# xm vcpu-pin 0 1 0
[root@localhost ~]# xm vcpu-list
Name ID VCPU CPU State Time(s) CPU Affinity
Domain-0 0 0 0 r-- 135.8 0
Domain-0 0 1 0 -b- 152.5 0
centosA 1 0 1 -b- 35.9 1
1.Name : Guest (Domain) name
2.ID : Domain ID
3.VCPUs : 虚拟的 vcpu 个数,0 为第一顆,以此类推.
4.CPU :目前 vcpu 对应到的物理 CPU 是哪一顆.
5.State :
r - running
目前有使用到 CPU 支援的 Guest
b - blocked
可能 Guest 在 sleep 状态或是等待 I/O 装置.
p - paused
我們可以使用 xm pause domainID 让系统进入暂停模式.有点像是进入S1 - "Sleep" 的状态.
6.Time(s) : 截至目前为止 Domain 的 CPU 使用到的时间单位为秒
7.CPU Affinity: Guest 的 vcpu 对应到哪一个物理CPU .如果为 any cpu 就代表由系統去动态配置、
另:Set (dom-cpus=1) in /etc/xen/xend-config.sxp.
domain0的VCPU是不能通过xm vcpu-pin来设置的,只能用以上处理,要重启,之后,可以看到其中一个状态为 pause
xm vcpu-list
[root@localhost ~]# xm vcpu-list
Name ID VCPU CPU State Time(s) CPU Affinity
Domain-0 0 0 0 r-- 8266.6 0
Domain-0 0 1 - --p 14.6 any cpu
centosA 1 0 1 -b- 1405.0 1
下面的命令可以显示被测试主机的CPU和内存使用率:
xentop -bn 1 -i 61 -d 1 | awk '{if($1=/^.*centos/) print $4,$6}'