[libvirt PATCH 0/2] followup fix for cpu quota limits

Pavel Hrdina (2): domain_validate: use defines for cpu period and quota limits docs: use proper cpu quota value in our documentation docs/formatdomain.rst | 8 ++++---- docs/manpages/virsh.rst | 2 +- docs/schemas/domaincommon.rng | 2 +- src/conf/domain_validate.c | 20 +++++++++++++------- 4 files changed, 19 insertions(+), 13 deletions(-) -- 2.29.2

Commints <bc760f4d7c4f964fadcb2a73e126b0053e7a9b06> and <98a09ca48ed4fc011abf2aa290e02ce1b8f1bb5f> fixed the code to use defines instead of magic numbers but missed this place. Following commit <ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a> changed the cpu quota limit to reflect what kernel actually allows so using the defines fixes XML validations as well. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/conf/domain_validate.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index b47ecba86b..b4e09e21fe 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -23,6 +23,7 @@ #include "domain_validate.h" #include "domain_conf.h" #include "snapshot_conf.h" +#include "vircgroup.h" #include "virconftypes.h" #include "virlog.h" #include "virutil.h" @@ -1200,10 +1201,13 @@ virDomainDefOSValidate(const virDomainDef *def, #define CPUTUNE_VALIDATE_PERIOD(name) \ do { \ if (def->cputune.name > 0 && \ - (def->cputune.name < 1000 || def->cputune.name > 1000000)) { \ + (def->cputune.name < VIR_CGROUP_CPU_PERIOD_MIN || \ + def->cputune.name > VIR_CGROUP_CPU_PERIOD_MAX)) { \ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \ - _("Value of cputune '%s' must be in range " \ - "[1000, 1000000]"), #name); \ + _("Value of cputune '%s' must be in range [%llu, %llu]"), \ + #name, \ + VIR_CGROUP_CPU_PERIOD_MIN, \ + VIR_CGROUP_CPU_PERIOD_MAX); \ return -1; \ } \ } while (0) @@ -1211,11 +1215,13 @@ virDomainDefOSValidate(const virDomainDef *def, #define CPUTUNE_VALIDATE_QUOTA(name) \ do { \ if (def->cputune.name > 0 && \ - (def->cputune.name < 1000 || \ - def->cputune.name > 18446744073709551LL)) { \ + (def->cputune.name < VIR_CGROUP_CPU_QUOTA_MIN || \ + def->cputune.name > VIR_CGROUP_CPU_QUOTA_MAX)) { \ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \ - _("Value of cputune '%s' must be in range " \ - "[1000, 18446744073709551]"), #name); \ + _("Value of cputune '%s' must be in range [%llu, %llu]"), \ + #name, \ + VIR_CGROUP_CPU_QUOTA_MIN, \ + VIR_CGROUP_CPU_QUOTA_MAX); \ return -1; \ } \ } while (0) -- 2.29.2

Commit <d505b8af58912ae1e1a211fabc9995b19bd40828> changed the cpu quota value that reflects what kernel allows but did not update our documentation. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- docs/formatdomain.rst | 8 ++++---- docs/manpages/virsh.rst | 2 +- docs/schemas/domaincommon.rng | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 2587106191..e23bcc3e5a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -754,7 +754,7 @@ CPU Tuning microseconds). A domain with ``quota`` as any negative value indicates that the domain has infinite bandwidth for vCPU threads, which means that it is not bandwidth controlled. The value should be in range [1000, - 18446744073709551] or less than 0. A quota with value 0 means no value. You + 17592186044415] or less than 0. A quota with value 0 means no value. You can use this feature to ensure that all vCPUs run at the same speed. :since:`Only QEMU driver support since 0.9.4, LXC since 0.9.10` ``global_period`` @@ -768,7 +768,7 @@ CPU Tuning (unit: microseconds) within a period for the whole domain. A domain with ``global_quota`` as any negative value indicates that the domain has infinite bandwidth, which means that it is not bandwidth controlled. The value should - be in range [1000, 18446744073709551] or less than 0. A ``global_quota`` with + be in range [1000, 17592186044415] or less than 0. A ``global_quota`` with value 0 means no value. :since:`Only QEMU driver support since 1.3.3` ``emulator_period`` The optional ``emulator_period`` element specifies the enforcement interval @@ -783,7 +783,7 @@ CPU Tuning vCPUs). A domain with ``emulator_quota`` as any negative value indicates that the domain has infinite bandwidth for emulator threads (those excluding vCPUs), which means that it is not bandwidth controlled. The value should be - in range [1000, 18446744073709551] or less than 0. A quota with value 0 means + in range [1000, 17592186044415] or less than 0. A quota with value 0 means no value. :since:`Only QEMU driver support since 0.10.0` ``iothread_period`` The optional ``iothread_period`` element specifies the enforcement interval @@ -797,7 +797,7 @@ CPU Tuning bandwidth (unit: microseconds) for IOThreads. A domain with ``iothread_quota`` as any negative value indicates that the domain IOThreads have infinite bandwidth, which means that it is not bandwidth controlled. The - value should be in range [1000, 18446744073709551] or less than 0. An + value should be in range [1000, 17592186044415] or less than 0. An ``iothread_quota`` with value 0 means no value. You can use this feature to ensure that all IOThreads run at the same speed. :since:`Only QEMU driver support since 2.1.0` diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e3afa48f7b..8a4328faa0 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3818,7 +3818,7 @@ XEN_CREDIT scheduler. ``Note``: The vcpu_period, emulator_period, and iothread_period parameters have a valid value range of 1000-1000000 or 0, and the vcpu_quota, emulator_quota, and iothread_quota parameters have a valid value range of -1000-18446744073709551 or less than 0. The value 0 for +1000-17592186044415 or less than 0. The value 0 for either parameter is the same as not specifying that parameter. diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index e6de934456..d73db65742 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -7010,7 +7010,7 @@ <define name="cpuquota"> <data type="long"> <param name="pattern">-?[0-9]+</param> - <param name="maxInclusive">18446744073709551</param> + <param name="maxInclusive">17592186044415</param> <param name="minInclusive">-1</param> </data> </define> -- 2.29.2

On 2/19/21 7:55 PM, Pavel Hrdina wrote:
Pavel Hrdina (2): domain_validate: use defines for cpu period and quota limits docs: use proper cpu quota value in our documentation
docs/formatdomain.rst | 8 ++++---- docs/manpages/virsh.rst | 2 +- docs/schemas/domaincommon.rng | 2 +- src/conf/domain_validate.c | 20 +++++++++++++------- 4 files changed, 19 insertions(+), 13 deletions(-)
Reviewed-by: Michal Privoznik <mprivozn@redhat.com> and SFF. Michal
participants (2)
-
Michal Privoznik
-
Pavel Hrdina