VMware ESX Server 2.0Features | Documentation | Knowledge Base | Discussion ForumsYou can manage CPU resources from the VMware Management Interface or from the service console. You may also view and change settings from the virtual machine details pages in the VMware Management Interface.
You must log in as root in order to change resource management settings using either the management interface or procfs. You can also manage CPU resources by editing the virtual machine configuration (.vmx) file or using procfs. The following configuration options enable you to manage CPU resources.
sched.cpu.shares = <n> If the number of CPU shares is not specified, the default allocation is normal, that by default, is set to 1000 shares per virtual CPU. The default allocation for a uniprocessor virtual machine is 1000 shares, or 2000 shares for a dual-virtual CPU (SMP) virtual machine.
sched.cpu.min = <min> Note: If ESX Server is unable to guarantee a virtual machine's specified minimum percentage(s), you cannot power on that virtual machine. For example, if you have two uniprocessor (UP) virtual machines, each has a CPU minimum of 80%, and both are bound to the same processor, then ESX Server does not allow you to power on both virtual machines. The total CPU percentage is 160%, greater than a single processor.
sched.cpu.max = <max> Note: A virtual machine will never use more CPU time than the specified maximum percentage.
sched.cpu.affinity = <set> Note: For SMP virtual machines, the affinity set applies to all virtual CPUs on the virtual machine. You can also use procfs to manage CPU resources. Use the following command: echo <new_value> > <proc_filename> in the service console, where <new_value> is the value you wish to set and <proc_filename> is the full path name of the configuration option's proc entry. See Examples for additional information. Note: For SMP virtual machines, you can use the <id> of any of the virtual CPUs to view or change configuration options for that virtual machine.
/proc/vmware/vm/<id>/cpu/min Specifying a percentage <minPercent>, to this file changes the minimum percentage allocated to the virtual machine identified by <id> to <minPercent>. The valid range of values for <minPercent> is 0 to 100 multiplied by the number of virtual CPUs; that is, 100 percent for uniprocessor virtual machines, and 200 percent for dual-virtual CPU virtual machines. Note: If there is not enough unreserved CPU time available in the system to satisfy a demand for an increase in min, then the reservation will not be changed.
/proc/vmware/vm/<id>/cpu/max Specifying a percentage <maxPercent>, to this file changes the maximum percentage allocated to the virtual machine identified by <id> to <maxPercent>. The valid range of values for <maxPercent> is 0 to 100 multiplied by the number of virtual CPUs, or 100 percent for uniprocessor virtual machines, and 200 percent for dual-virtual CPU virtual machines.
/proc/vmware/vm/<id>/cpu/shares Writing a number <n> to this file changes the number of shares allocated to the virtual machine identified by <id> to <n>. The valid range of numerical values for <n> is 1 to 100000. Or, you may use the special values low, normal and high. These values are automatically converted into numbers, through the configuration options CpuSharesPerVcpuLow, CpuSharesPerVcpuNormal and CpuSharesPerVcpuHigh, described in this section.
/proc/vmware/vm/<id>/cpu/affinity Writing a comma-separated list of CPU numbers to this file, such as 0,2,3, changes the affinity set for the virtual machine identified by <id>. Writing all or default to this file changes the affinity set to contain all available processors. For SMP virtual machines, writing to this file changes the affinity of all virtual CPUs in the virtual machine to the specified affinity set.
/proc/vmware/vm/<vcpuid>/cpu/status
/proc/vmware/sched/cpu
/proc/vmware/config/CpuSharesPerVcpuLow
/proc/vmware/config/CpuSharesPerVcpuNormal
/proc/vmware/config/CpuSharesPerVcpuHigh Suppose that we are interested in the CPU allocation for the virtual machine with ID 103. To query the number of shares allocated to virtual machine 103, simply read the file. cat /proc/vmware/vm/103/cpu/shares The number of shares is displayed. 1000 This indicates that virtual machine 103 is currently allocated 1,000 shares. To change the number of shares allocated to virtual machine 103, simply write to the file. Note that you need root privileges in order to change share allocations. echo 2000 > /proc/vmware/vm/103/cpu/shares You can also write to the file by specifying low, normal, or high. ESX Server writes the numerical value for these special values. echo high > /proc/vmware/vm/103/cpu/shares The change can be confirmed by reading the file again. cat /proc/vmware/vm/103/cpu/shares The number of shares is displayed. 2000 To query the affinity set for virtual machine 103, simply read the file: cat /proc/vmware/vm/103/cpu/affinity The identifying numbers of the processors in the affinity set are displayed. 0,1 This indicates that virtual machine 103 is allowed to run on CPUs 0 and 1. To restrict virtual machine 103 to run only on CPU 1, simply write to the file. Note that you need root privileges in order to change affinity sets. echo 1 > /proc/vmware/vm/103/cpu/affinity The change can be confirmed by reading the file again. Note: The affinity set must contain at least as many CPUs as virtual CPUs; that is, 1 CPU for a uniprocessor (UP) virtual machine, and 2 CPU for a SMP virtual machine. |

