5.12 Modifying the Number of Virtual CPUs Allocated to a User Domain

Note the following about modifying the number of virtual CPUs (vCPUs):

  • All actions to modify the number of vCPUs allocated to a user domain are performed in the management domain.

  • The number of vCPUs allowed for a user domain may be changed dynamically to a lower value or to a higher value provided it does not exceed the setting of maxvcpus parameter for the user domain.

  • It is possible to over-commit vCPUs such that the total number of vCPUs assigned to all domains exceeds the number of physical CPUs on the system. However, over-committing CPUs should be done only when competing workloads for oversubscribed resources are well understood and concurrent demand does not exceed physical capacity.

The following procedure describes how to modify the number of virtual CPUs allocated to a user domain:

  1. Determine the number of physical CPUs as follows:

    1. Use the following command in the management domain:

      # xm info | grep -A3 nr_cpus
      nr_cpus                : 24
      nr_nodes               : 2
      cores_per_socket       : 6
      threads_per_core       : 2
      

      In the output, note that the nr_nodes line refers to the number of sockets. The Exadata database server where the command is run is a 2-socket 6 cores per socket processor, resulting in 24 physical CPU threads (2 sockets x 6 cores/socket = 12 cores. 12 cores x 2 threads per core = 24 CPU threads).

    2. Use the following command to determine the current setting of vCPUs configured and online for a user domain:

      # xm list DomainName -l | grep vcpus
      
          (vcpus 4)
          (online_vcpus 2)
      

      In the preceding command, DomainName is the name of the user domain. The output from the command indicates the maximum number of vCPUs for the user domain is 4, and the current number of online vCPUs is 2. This user domain may have the number of online vCPUs adjusted to any value not greater than the vcpus parameter while the user domain remains online. The user domain must be taken offline to increase the number of online vCPUs to a value higher than the vcpus parameter.

  2. Reduce or increase the number of vCPUs as follows:

    • To reduce the number of vCPUs:

      1. Determine the currently allocated number of vCPUs for the user domain using the following command:

        # xm list DomainName
        
      2. Reduce the currently allocated number of vCPUs using the following command:

        # xm vcpu-set DomainName vCPUs_preferred
        

        In the preceding command, vCPUs_preferred is the value of the preferred number of vCPUs

    • To increase the number of vCPUs

      1. Determine the current settings of the vcpus parameter using the following command:

        # xm list DomainName -l | grep vcpus
            (vcpus 4)
            (online_vcpus 2)
        
      2. If the preferred number of vCPUs is less than or equal to the value of the vcpus parameter, then run the following command to increase the number of online vCPUs.

        # xm vcpu-set DomainName vCPUs_preferred
        

        In the preceding command, vCPUs_preferred is the value of the preferred number of vCPUs

      3. If the preferred number of vCPUs is greater than the value of the vcpus parameter, then the user domain must be taken offline to increase the number of online vCPUs to a value higher than the vcpus parameter. Do the following:

        i. Shut down the user domain.

        ii. Create a backup copy of the /EXAVMIMAGES/GuestImages/DomainName/vm.cfg file.

        iii. Edit the /EXAVMIMAGES/GuestImages/DomainName/vm.cfg file to set the vcpus parameter to the desired number of vCPUs.

        Note: By default a user domain will online the number of vCPUs configured via the vcpus parameter. If you want a user domain to start with some vCPUs offline, then add the maxvcpus parameter to vm.cfg, setting it to the maximum number of vCPUs the user domain is permitted to have online. Set the vcpus parameter to the number of vCPUs to online when the user domain starts. For example, to start a user domain with 2 vCPUs online and to allow an additional 6 vCPUs to be added to the user domain while it remains online, use the following settings in vm.cfg:

        maxvcpus=8
        vcpus=2
        

        iv. Start the user domain.