RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1741837 - [cgroup_v2] Cannot get and set cpu cgroup params due to cpu.max error
Summary: [cgroup_v2] Cannot get and set cpu cgroup params due to cpu.max error
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: libvirt
Version: 8.1
Hardware: x86_64
OS: Linux
high
high
Target Milestone: rc
: 8.1
Assignee: Pavel Hrdina
QA Contact: yisun
URL:
Whiteboard:
Depends On: 1735740
Blocks: 1689297
TreeView+ depends on / blocked
 
Reported: 2019-08-16 08:28 UTC by yisun
Modified: 2020-11-06 03:43 UTC (History)
8 users (show)

Fixed In Version: libvirt-4.5.0-33.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1735740
Environment:
Last Closed: 2019-11-05 20:51:11 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:3345 0 None None None 2019-11-05 20:51:39 UTC

Description yisun 2019-08-16 08:28:34 UTC
+++ This bug was initially created as a clone of Bug #1735740 +++

Description of problem:
[cgroup_v2] Cannot get and set cpu cgroup params due to format error


Version-Release number of selected component (if applicable):
libvirt-5.5.0-2.module+el8.1.0+3773+7dd501bf.x86_64

How reproducible:
100%

Steps to Reproduce:
0. enable cgroup v2
1. having a running vm
# virsh list
 Id   Name             State
--------------------------------
 1    avocado-vt-vm1   running

2. using 'virsh schedinfo' to get its cpu related cgroup values
# virsh schedinfo avocado-vt-vm1
Scheduler      : posix
error: internal error: Failed to parse value 'max 100000' from cpu.max.
<===== error happened


Additional info:
1. cgroup cpu.max default value is:
# cat /sys/fs/cgroup/machine.slice/machine-qemu\\x2d6\\x2davocado\\x2dvt\\x2dvm1.scope/cpu.max 
max 10000

2. libvirtd log's error as follow:
2019-08-01 08:15:47.218+0000: 1750: error : virCgroupV2GetCpuCfsQuota:1590 : internal error: Failed to parse value 'max 100000' from cpu.max.

3.$vim cat src/util/vircgroupv2.c
1574 static int                                                                      
1575 virCgroupV2GetCpuCfsQuota(virCgroupPtr group,                                   
1576 |   |   |   |   |   |   | long long *cfs_quota)                                 
1577 {                                                                               
1578 |   VIR_AUTOFREE(char *) str = NULL;                                            
1579                                                                                 
1580 |   if (virCgroupGetValueStr(group, VIR_CGROUP_CONTROLLER_CPU,                  
1581 |   |   |   |   |   |   |   |"cpu.max", &str) < 0) {                            
1582 |   |   return -1;                                                              
1583 |   }                                                                           
1584                                                                                 
1585 |   if (STREQLEN(str, "max", 3))                                                
1586 |   |   *cfs_quota = ULLONG_MAX / 1000;                                         
1587                                                                                 
1588 |   if (virStrToLong_ll(str, NULL, 10, cfs_quota) < 0) {                        
1589 |   |   virReportError(VIR_ERR_INTERNAL_ERROR,                                  
1590 |   |   |   |   |   |  _("Failed to parse value '%s' from cpu.max."), str);     
1591 |   |   return -1;                                                              
1592 |   }                                                                           
1593                                                                                 
1594 |   return 0;                                                                   
1595 }                                                                               
<===== in line 1588 the str="max 10000", and this will lead "virStrToLong_ll" to return a '-1' due to:
$ vim src/util/virstring.c
 530 int                                                                             
 531 virStrToLong_ll(char const *s, char **end_ptr, int base, long long *result)     
 532 {                                                                               
 533 |   long long val;                                                              
 534 |   char *p;                                                                    
 535 |   int err;                                                                    
 536                                                                                 
 537 |   errno = 0;                                                                  
 538 |   val = strtoll(s, &p, base); /* exempt from syntax-check */                  
 539 |   err = (errno || (!end_ptr && *p) || p == s);                                
 540 |   if (end_ptr)                                                                
 541 |   |   *end_ptr = p;                                                           
 542 |   if (err)                                                                    
 543 |   |   return -1;                                                              
 544 |   *result = val;                                                              
 545 |   return 0;                                                                   
 546 }  
<===== line 538 will be "strtoll("max 10000", &p, 10)", then 'p' will equal to 'max 10000', so line 539 "!end_ptr && *p" and "p==s" will both be true so '-1' will be returned later.

--- Additional comment from  on 2019-08-01 11:35:25 UTC ---

set cpu.max to "1000 10000" will also produce similar error since in src/util/virstring.c line539  "err = (errno || (!end_ptr && *p) || p == s);" the (!end_ptr && *p) will be true.

Comment 1 yisun 2019-08-16 08:29:25 UTC
reproduced on: libvirt-4.5.0-31.module+el8.1.0+3808+3325c1a3.x86_64
so clone to rhel8.1 branch

Comment 8 yisun 2019-09-17 12:02:06 UTC
Verified by auto job with libvirt-4.5.0-35.module+el8.1.0+4227+b2722cb3.x86_64:
https://libvirt-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/job/libvirt-RHEL-8.1-runtest-x86_64-function-guest_resource_control/8/testReport/
(the failed case is script issue, not related with this bz)

Comment 10 errata-xmlrpc 2019-11-05 20: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, 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/RHSA-2019:3345


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