Modifying the number of virtual CPUs
Modify the number of virtual CPUs or the maximum number of available virtual CPUs for a defined virtual server.
About this task
The number of virtual CPUs that you can assign to a virtual server is limited by the maximum number of available virtual CPUs. Both numbers are configured with the vcpu element and can be modified during operation.
To display the number of virtual CPUs, use the virsh vcpucount command. For
example,
issue:
# virsh vcpucount vserv1
maximum config 5
maximum live 5
current config 3
current live 3
where
- maximum config
- Specifies the maximum number of virtual CPUs that can be made available for the virtual server after the next restart.
- maximum live
- Specifies the maximum number of virtual CPUs that can be made available for the running or paused virtual server.
- current config
- Specifies the actual number of virtual CPUs which will be available for the virtual server with the next restart.
- current live
- Specifies the actual number of virtual CPUs which are available for the running or paused virtual server.
You can modify the following values:
- maximum config
- The maximum value can be modified only in combination with a virtual server restart.
The maximum number of available virtual CPUs is not limited. If no value is specified, the maximum number of available virtual CPUs is 1.
- current config
- The current value can be modified in combination with a virtual server restart. It is limited by the maximum number of available virtual CPUs. Consider to set the surplus virtual CPUs offline until the next restart.
- current live
- You can increase the actual number of virtual CPUs for a running or paused virtual server. This number is limited by the maximum number of
available CPUs.
Additional virtual CPUs are provided in the halted state. Depending on the guest setup, the virtual server user has to bring them online.
Procedure
Use the virsh setvcpus command to modify the number of virtual CPUs or the maximum number of available virtual CPUs for a defined virtual server.
Example
- Change the maximum number of available virtual CPUs with the next virtual server
restart.
# virsh vcpucount vserv1 maximum config 5 maximum live 5 current config 4 current live 4 # virsh setvcpus vserv1 6 --maximum --config # virsh vcpucount vserv1 maximum config 6 maximum live 5 current config 4 current live 4
- You cannot remove virtual CPUs from a running virtual server.
- This example removes two virtual CPUs from the virtual server vserv1 with the next virtual server
restart:
# virsh vcpucount vserv1 maximum config 5 maximum live 5 current config 4 current live 4 # virsh setvcpus vserv1 2 --config # virsh vcpucount vserv1 maximum config 5 maximum live 5 current config 2 current live 4
- To set the CPUs offline until the next virtual server
restart, the virtual server user might set the virtual CPUs
offline:
[root@guest:] # chcpu -d 2 CPU 2 disabled [root@guest:] # chcpu -d 3 CPU 3 disabled
- This example removes two virtual CPUs from the virtual server vserv1 with the next virtual server
restart:
- Add virtual CPUs to a running virtual server.
- This example adds a virtual CPU to the virtual server
vserv1:
# virsh vcpucount vserv1 maximum config 5 maximum live 5 current config 3 current live 3 # virsh setvcpus vserv1 4 --live # virsh vcpucount vserv1 maximum config 5 maximum live 5 current config 3 current live 4
- To set the additional CPU online, the virtual server user might
enter:
[root@guest:] # chcpu -e 3 CPU 3 enabled
- This example adds a virtual CPU to the virtual server
vserv1: