Configuring the number of virtual CPUs

Configure the number of virtual CPUs for a virtual server.

Procedure

  1. You can configure the number of virtual CPUs that are available for the defined virtual server by using the vcpu element.

    If you do not specify the vcpu element, the maximum number of virtual CPUs available for a virtual server is 1.

    vcpu element: <number-of-CPUs>
    Note: It is not useful to configure more virtual CPUs than available host CPUs.
  2. To configure the actual number of virtual CPUs that are available for the virtual server when it is started, specify the current attribute. The value of the current attribute is limited by the maximum number of available virtual CPUs.

    If you do not specify the current attribute, the maximum number of virtual CPUs is available at startup.

    vcpu current attribute: <number>

Example

This example configures 5 virtual CPUs, which are all available at startup:
<domain type="kvm">
    ...
    <vcpu>5</vcpu>
    ...
</domain>
This example configures a maximum of 5 available virtual CPUs for the virtual server. When the virtual server is started, only 2 virtual CPUs are available. You can modify the number of virtual CPUs that are available for the running virtual server using the virsh setvcpus command .
<domain type="kvm">
    ...
    <vcpu current="2">5</vcpu>
    ...
</domain>