Bug 1249981 - iothreadpin will pin one of libvirtd thread with qemu 1.5
iothreadpin will pin one of libvirtd thread with qemu 1.5
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt (Show other bugs)
7.2
x86_64 Linux
low Severity low
: rc
: ---
Assigned To: John Ferlan
Virtualization Bugs
:
: 1272349 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-04 05:56 EDT by Luyao Huang
Modified: 2016-11-03 14:22 EDT (History)
5 users (show)

See Also:
Fixed In Version: libvirt-1.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-03 14:22:13 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Luyao Huang 2015-08-04 05:56:32 EDT
Description of problem:
iothreadpin will pin one of libvirtd thread with qemu 1.5

Version-Release number of selected component (if applicable):
qemu-kvm-1.5.3-97.el7.x86_64
libvirt-1.2.17-3.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

1. prepare a guest with iothreadpin:

# virsh dumpxml test4 |grep iothread
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='1'/>
  </iothreadids>
    <iothreadpin iothread='1' cpuset='2'/>


2. start it and check libvirt set in cgroup

# ll /proc/9580/task/
total 0
dr-xr-xr-x. 6 qemu qemu 0 Jul 27 10:31 9580    <----emulator
dr-xr-xr-x. 6 qemu qemu 0 Jul 27 10:32 9589    <----vcpu0
dr-xr-xr-x. 6 qemu qemu 0 Jul 27 10:32 9591    <----vcpu1
dr-xr-xr-x. 6 qemu qemu 0 Jul 27 10:32 9600    <----???

# cat /sys/fs/cgroup/cpuset/machine.slice/machine-qemu\\x2dtest4.scope/iothread1/cpuset.cpus
2

# cat /sys/fs/cgroup/cpuset/machine.slice/machine-qemu\\x2dtest4.scope/iothread1/tasks 
4402

# ps -eLf |grep 4402
root      4391     1  4402  0   16 10:28 ?        00:00:00 /usr/sbin/libvirtd
root     16347 19012 16347  0    1 11:15 pts/0    00:00:00 grep --color=auto 4402

3. check taskset
# taskset --cpu-list -p 4402
pid 4402's current affinity list: 2


4. Then try to change the iothreadpin and recheck the result:

# virsh iothreadpin test4 1 3 

# taskset --cpu-list -p 4402
pid 4402's current affinity list: 3

# cat /sys/fs/cgroup/cpuset/machine.slice/machine-qemu\\x2dtest4.scope/iothread1/cpuset.cpus
3


Actual results:
iothreadpin will pin one of libvirtd thread with qemu 1.5

Expected results:
forbid use iotreadpin with qemu which not support iothread

Additional info:

This is because we cannot get iothread_id and it's value is 0, and then we call
sched_setaffinity() and attach thread in cgroup, but when the pid/task is 0, these functions will attach the current thread, you can check kernel doc Documentation/cgroups/cgroups.txt:

You can attach the current shell task by echoing 0:

# echo 0 > tasks

and manual of sched_setaffinity(2):

Specifying pid as 0 will set the attribute for the calling thread

So i think we should also forbid set 0 as a pid when call these functions.
Comment 1 John Ferlan 2015-10-15 17:30:36 EDT
Posted some patches upstream...

v1: http://www.redhat.com/archives/libvir-list/2015-October/msg00417.html
(patches 1 & 2)

v2:  http://www.redhat.com/archives/libvir-list/2015-October/msg00550.html
(patches 1 -> 3)
Comment 2 John Ferlan 2015-10-16 07:10:38 EDT
Patches pushed upstream

$ git describe cc2d49f9be13e439efcdbd4e1c161750f4208995
v1.2.20-112-gcc2d49f
$
Comment 3 John Ferlan 2015-12-02 15:58:59 EST
*** Bug 1272349 has been marked as a duplicate of this bug. ***
Comment 5 Luyao Huang 2016-08-10 22:36:48 EDT
Verify this bug with qemu-kvm-1.5.3-121.el7.x86_64 and libvirt-2.0.0-5.el7.x86_64:

1. try to start a guest with iothread:

# virsh dumpxml r7-old
<domain type='kvm'>
  <name>r7-old</name>
  <uuid>5b256268-87b9-40bf-a857-38715dd8a37b</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='auto' current='6'>10</vcpu>
  <iothreads>1</iothreads>

# virsh start r7-old
error: Failed to start domain r7-old
error: unsupported configuration: IOThreads not supported for this QEMU

2. try to attach iothread to a exist guest:

# virsh list
 Id    Name                           State
----------------------------------------------------
 12    r7-old                         running

# virsh iothreadinfo r7-old
error: Unable to get domain IOThreads information
error: unsupported configuration: IOThreads not supported with this binary

# virsh iothreadadd r7-old 1
error: unsupported configuration: IOThreads not supported with this binary

# virsh iothreaddel r7-old 1
error: unsupported configuration: IOThreads not supported with this binary
Comment 7 errata-xmlrpc 2016-11-03 14:22:13 EDT
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://rhn.redhat.com/errata/RHSA-2016-2577.html

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