vircgroup: enforce range limit for cpu.shares

Before the conversion to using systemd DBus API to set the cpu.shares
there was some magic conversion done by kernel which was documented in
virsh manpage as well. Now systemd errors out if the value is out of
range.

Since we enforce the range for other cpu cgroup attributes 'quota' and
'period' it makes sense to do the same for 'shares' as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Pavel Hrdina
2021-03-03 14:10:15 +01:00
parent b5abf9a192
commit 1d9d9961ad
6 changed files with 35 additions and 5 deletions

View File

@@ -742,7 +742,8 @@ CPU Tuning
the domain. If this is omitted, it defaults to the OS provided defaults. NB,
There is no unit for the value, it's a relative measure based on the setting
of other VM, e.g. A VM configured with value 2048 will get twice as much CPU
time as a VM configured with value 1024. :since:`Since 0.9.0`
time as a VM configured with value 1024. The value should be in range
[2, 262144]. :since:`Since 0.9.0`
``period``
The optional ``period`` element specifies the enforcement interval (unit:
microseconds). Within ``period``, each vCPU of the domain will not be allowed

View File

@@ -3807,10 +3807,7 @@ If *--config* is specified, affect the next start of a persistent guest.
If *--current* is specified, it is equivalent to either *--live* or
*--config*, depending on the current state of the guest.
``Note``: The cpu_shares parameter has a valid value range of 0-262144; Negative
values are wrapped to positive, and larger values are capped at the maximum.
Therefore, -1 is a useful shorthand for 262144. On the Linux kernel, the
values 0 and 1 are automatically converted to a minimal value of 2.
``Note``: The cpu_shares parameter has a valid value range of 2-262144.
``Note``: The weight and cap parameters are defined only for the
XEN_CREDIT scheduler.