Bug 1918183 - [cgroup] libvirt has new max value for cpu quota, but virsh manual not mention it.
Summary: [cgroup] libvirt has new max value for cpu quota, but virsh manual not mentio...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.4
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: 8.4
Assignee: Pavel Hrdina
QA Contact: Jing Qi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-20 08:54 UTC by yisun
Modified: 2021-11-16 08:06 UTC (History)
4 users (show)

Fixed In Version: libvirt-7.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:51:11 UTC
Type: Bug
Target Upstream Version: 7.1.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:51:34 UTC

Description yisun 2021-01-20 08:54:18 UTC
Description:
[cgroup] libvirt has new max value for cpu quota, but virsh manual not mention it.

Version:
libvirt-7.0.0-1.module+el8.4.0+9464+3e71831a.x86_64

Reproduce:
100%

Steps:
1. set vcpu_quota to 17592186044416 for a running vm
(.libvirt-ci-venv-ci-runtest-YmmKNI) [root@dell-per740-19 machine-qemu\x2d1\x2dvm1.scope]# virsh schedinfo vm1 --set vcpu_quota=17592186044416
Scheduler      : posix
error: invalid argument: value of 'vcpu_quota' is out of range [1000, 17592186044415]
<=== error happened, result is different from rhelav8.3 libvirt.


2. check virsh manual, still mention the max value is 18446744073709551
(.libvirt-ci-venv-ci-runtest-YmmKNI) [root@dell-per740-19 machine-qemu\x2d1\x2dvm1.scope]# man virsh
   schedinfo
       Syntax:

          schedinfo domain [[--config] [--live] | [--current]] [[--set] parameter=value]...
          schedinfo [--weight number] [--cap number] domain
...  the vcpu_quota, emulator_quota, and iothread_quota parameters have a valid value range of 1000-18446744073709551 or less than 0.



3. in libvirt git log, there is an intentional change about this
root@yisun-test1 /home/libvirt-rhel/src/util 21:38:21$ git show ed1ba69f5a8
commit ed1ba69f5a8132f8c1e73d2a1f142d70de0b564a
Author: Pavel Hrdina <phrdina>
Date:   Wed Nov 25 12:41:16 2020 +0100

    vircgroup: fix cpu quota maximum limit
    
    Kernel commit <d505b8af58912ae1e1a211fabc9995b19bd40828> added proper
    check for cpu quota maximum limit to prevent internal overflow.
    
    Even though this change is not present in all kernels it makes sense
    to enforce the same limit in libvirt.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1750315
    
    Signed-off-by: Pavel Hrdina <phrdina>
    Reviewed-by: Daniel Henrique Barboza <danielhb413>

diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 2a9b341985..ec0902e301 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -233,7 +233,9 @@ int virCgroupSetupCpuShares(virCgroupPtr cgroup, unsigned long long shares,
 #define VIR_CGROUP_CPU_PERIOD_MIN 1000LL
 #define VIR_CGROUP_CPU_PERIOD_MAX 1000000LL
 #define VIR_CGROUP_CPU_QUOTA_MIN 1000LL
-#define VIR_CGROUP_CPU_QUOTA_MAX 18446744073709551LL
+/* Based on kernel code ((1ULL << MAX_BW_BITS) - 1) where MAX_BW_BITS is
+ * (64 - BW_SHIFT) and BW_SHIFT is 20 */
+#define VIR_CGROUP_CPU_QUOTA_MAX 17592186044415LL


Expected result:
The virsh manual shoud use the new max value to make sure no misunderstanding for quota setting.

Comment 3 Pavel Hrdina 2021-02-23 11:00:38 UTC
Hi, thanks for the report.

Fixed in upstream:

992635b142 docs: use proper cpu quota value in our documentation
22cae2ea4b domain_validate: use defines for cpu period and quota limits

There was one more place in the code missing the change to use new limits and our XML documentation was not updated as well.

Comment 6 Jing Qi 2021-02-24 07:51:07 UTC
Tested with upstream libvirt : v7.1.0-rc1-7-gfa58f571ee

# man virsh schedinfo |grep "value range"|grep vcpu_quota
       
       vcpu_quota, emulator_quota, and iothread_quota parameters have a valid value range of 1000-17592186044415 or less  than  0.  

# virsh schedinfo pc vcpu_quota=999 
Scheduler      : posix
error: invalid argument: value of 'vcpu_quota' is out of range [1000, 17592186044415]

# virsh schedinfo pc vcpu_quota=17592186044416
Scheduler      : posix
error: invalid argument: value of 'vcpu_quota' is out of range [1000, 17592186044415]

Comment 14 Jing Qi 2021-05-14 12:39:06 UTC
Verified with libvirt-daemon-7.3.0-1.module+el8.5.0+11004+f4810536.x86_64  
& qemu-kvm-6.0.0-16.module+el8.5.0+10848+2dccc46d.x86_64

Steps as comment6.

Comment 16 errata-xmlrpc 2021-11-16 07:51:11 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4684


Note You need to log in before you can comment on or make changes to this bug.