Bug 1747440

Summary: [cgroup_v2] Crash happens when set cpu related cgroup values by “schedinfo”
Product: Red Hat Enterprise Linux 8 Reporter: yisun
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: yisun
Severity: high Docs Contact:
Priority: high    
Version: 8.1CC: dyuan, jdenemar, lmen, phrdina, rbalakri, wchadwic, xuzhang, yisun
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-4.5.0-34.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1747482 (view as bug list) Environment:
Last Closed: 2019-11-05 20:51:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1747482    

Description yisun 2019-08-30 12:48:36 UTC
Description:
[cgroup_v2] Crash happens when set cpu related cgroup values by “schedinfo”

Versions:
kernel-4.18.0-135.el8.x86_64
libvirt-4.5.0-33.module+el8.1.0+4066+0f1aadab.x86_64

How reproducible:
100%

Steps:
1. Having a running vm
# virsh list
 Id    Name                           State
----------------------------------------------------
 1     avocado-vt-vm1                 running

2. Set cpu related cgroup params by schedinfo, crash happened
# virsh schedinfo avocado-vt-vm1 --set vcpu_period=9999 --set vcpu_quota=8888
Scheduler      : posix
error: Disconnected from qemu:///system due to end of file
error: End of file while reading data: Input/output error

3 backtrace info as follow:
#gdb -p `pidof libvirtd`
…
(gdb) c
Continuing.

Thread 6 "libvirtd" received signal SIGABRT, Aborted.
[Switching to Thread 0x7f33eaf71700 (LWP 26133)]
0x00007f33f2bf08df in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f33f2bf08df in raise () from /lib64/libc.so.6
#1  0x00007f33f2bdacf5 in abort () from /lib64/libc.so.6
#2  0x00007f33f2c33c17 in __libc_message () from /lib64/libc.so.6
#3  0x00007f33f2c3a53c in malloc_printerr () from /lib64/libc.so.6
#4  0x00007f33f2c3bc64 in _int_free () from /lib64/libc.so.6
#5  0x00007f33f60a514f in virFree () from /lib64/libvirt.so.0
#6  0x00007f33f60b6143 in virCgroupV2GetCpuCfsQuota () from /lib64/libvirt.so.0
#7  0x00007f33ad84cd40 in qemuGetVcpuBWLive () from /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#8  0x00007f33ad85b4f4 in qemuDomainGetSchedulerParametersFlags () from /usr/lib64/libvirt/connection-driver/libvirt_driver_qemu.so
#9  0x00007f33f62bd111 in virDomainGetSchedulerParameters () from /lib64/libvirt.so.0
#10 0x000055c934e9ef7c in remoteDispatchDomainGetSchedulerParametersHelper ()
#11 0x00007f33f61f88b4 in virNetServerProgramDispatch () from /lib64/libvirt.so.0
#12 0x00007f33f61fed6c in virNetServerHandleJob () from /lib64/libvirt.so.0
#13 0x00007f33f612cba0 in virThreadPoolWorker () from /lib64/libvirt.so.0
#14 0x00007f33f612beac in virThreadHelper () from /lib64/libvirt.so.0
#15 0x00007f33f2f842de in start_thread () from /lib64/libpthread.so.0
#16 0x00007f33f2cb5133 in clone () from /lib64/libc.so.6


Expected result:
No crash

Additional info:
Setting other values have same crash and backtrace, record it here for future reference. 
 virsh schedinfo avocado-vt-vm1 --set vcpu_period=9999 --set vcpu_quota=8888
Scheduler : posix
error: Disconnected from qemu:///system due to end of file
error: End of file while reading data: Input/output error


# virsh schedinfo avocado-vt-vm1 --set emulator_period=-1 --set emulator_quota=8888
Scheduler : posix
error: Disconnected from qemu:///system due to end of file
error: End of file while reading data: Input/output error


# virsh schedinfo avocado-vt-vm1 --set global_period=9999 --set global_quota=8888
Scheduler : posix
error: Disconnected from qemu:///system due to end of file
error: End of file while reading data: Input/output error


# virsh schedinfo avocado-vt-vm1 --set iothread_period=2000 --set iothread_quota=2000
Scheduler : posix
error: Disconnected from qemu:///system due to end of file
error: End of file while reading data: Input/output error

Comment 1 Pavel Hrdina 2019-08-30 14:33:08 UTC
Upstream commit:

commit 9a99b01f8d3b2be491f9f8412c6f894d30d7e2fe
Author: Pavel Hrdina <phrdina>
Date:   Fri Aug 30 16:15:15 2019 +0200

    vircgroupv2: fix abort in VIR_AUTOFREE

Comment 7 yisun 2019-09-05 11:29:35 UTC
no crash happens with libvirt-4.5.0-34.module+el8.1.0+4158+21722aaf, PASSED

Comment 9 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