Modifying the virtual CPU weight

Modify the share of run time that is assigned to a virtual server.

About this task

The available CPU time is shared between the running virtual servers. Each virtual server receives the share that is configured with the shares element, or the default value.

To display the current CPU weight of a virtual server, enter:
# virsh schedinfo <VS>

You can modify this share for a running virtual server or persistently across virtual server restarts.

Procedure

  • To modify the current CPU weight of a running virtual server, use the virsh schedinfo command with the --live option (see schedinfo):
    # virsh schedinfo <VS> --live cpu_shares=<number>
  • To modify the CPU weight in the libvirt-internal configuration of the virtual server, which will persistently affect the CPU weight beginning with the next restart, use the --config option:
    # virsh schedinfo <VS> --config cpu_shares=<number>
    <number>
    Specifies the CPU weight.
    <VS>
    Is the name of the virtual server.

Example

  • A virtual server with a CPU weight of 2048 receives twice as much run time as a virtual server with a CPU weight of 1024.
  • The following example modifies the CPU weight of vserv1 to 2048 while it is running:
    virsh schedinfo vserv1 --live cpu_shares=2048
    Scheduler : posix
    cpu_shares : 2048
    vcpu_period : 100000
    vcpu_quota : -1
    emulator_period: 100000
    emulator_quota : -1
  • The following example changes the libvirt-internal configuration, which will persistently affect the CPU weight, beginning with the next restart of vserv1.
    virsh schedinfo vserv1 --config cpu_shares=2048
    Scheduler : posix
    cpu_shares : 2048
    vcpu_period : 0
    vcpu_quota : 0
    emulator_period: 0
    emulator_quota : 0