Bug 1218577

Summary: iothreaddel can make a vm have broken settings which will make vm lose track after restart libvirtd
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: dyuan, honzhang, mzhan, rbalakri, shyu
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.2.16-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-11-19 06:30:06 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:

Description Luyao Huang 2015-05-05 09:48:56 UTC
description of problem:
iothreaddel can make a vm have broken settings which will make vm
lose track after restart libvirtd

Version-Release number of selected component (if applicable):
libvirt-1.2.15-1.el7.x86_64
qemu-kvm-rhev-2.3.0-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.
prepare a offline vm:

# virsh dumpxml test3

  <iothreads>2</iothreads>
  <iothreadids>
    <iothread id='1'/>
  </iothreadids>

2. start it
# virsh start  test3
Domain test3 started

3.
# virsh iothreadinfo test3
 IOThread ID     CPU Affinity  
---------------------------------------------------
 1               0-3
 2               0-3

4.
use iothreaddel remove thread 1

# virsh iothreaddel test3 1

5.
bind thread 2 to cpu 1

# virsh iothreadpin test3 2 1

# virsh dumpxml test3
  <iothreads>1</iothreads>
  <cputune>
    <iothreadpin iothread='2' cpuset='1'/>
  </cputune>


6. check the cgroup

# cgget -g cpuset /machine.slice/machine-qemu\\x2dtest3.scope/iothread2
/machine.slice/machine-qemu\x2dtest3.scope/iothread2:
cpuset.memory_spread_slab: 0
cpuset.memory_spread_page: 0
cpuset.memory_pressure: 0
cpuset.memory_migrate: 1
cpuset.sched_relax_domain_level: -1
cpuset.sched_load_balance: 1
cpuset.mem_hardwall: 0
cpuset.mem_exclusive: 0
cpuset.cpu_exclusive: 0
cpuset.mems: 0
cpuset.cpus: 1

7. restart libvirtd vm will lose track:

# virsh list
 Id    Name                           State
----------------------------------------------------

8. check the log

2015-05-05 06:29:48.382+0000: 17710: error : virDomainIOThreadPinDefParseXML:13374 : unsupported configuration: Cannot find 'iothread' : 2

Actual results:
iothreaddel can make a vm have broken settings which will make vm
lose track after restart libvirtd

Expected results:
guest still exist after restart libvirtd

infomation:

Comment 1 John Ferlan 2015-05-06 14:51:49 UTC
Posted patches upstream:

http://www.redhat.com/archives/libvir-list/2015-May/msg00156.html

Comment 2 John Ferlan 2015-05-14 12:56:59 UTC
Pushed a fix upstream to resolve this:

commit 361801362fb047ceb63e303efec224aea73a179a
Author: John Ferlan <jferlan>
Date:   Wed May 6 10:19:30 2015 -0400

    qemu: Clear autofil fill flag when pinning iothread
    


git describe 361801362fb047ceb63e303efec224aea73a179a
v1.2.15-79-g3618013

Comment 4 Luyao Huang 2015-07-30 07:19:34 UTC
Verify this bug with libvirt-1.2.17-2.el7.x86_64:

1. 

# virsh dumpxml rhel7.0-rhel |grep iothread
  <iothreads>2</iothreads>
  <iothreadids>
    <iothread id='1'/>
  </iothreadids>

2. 
# virsh start rhel7.0-rhel
Domain rhel7.0-rhel started

3.
# virsh iothreadinfo rhel7.0-rhel
 IOThread ID     CPU Affinity   
---------------------------------------------------
 1               0-3
 2               0-3

4.
# virsh iothreaddel rhel7.0-rhel 1

5.
# virsh iothreadinfo rhel7.0-rhel
 IOThread ID     CPU Affinity   
---------------------------------------------------
 2               0-3

6.
# virsh dumpxml rhel7.0-rhel |grep iothread
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='2'/>
  </iothreadids>

7.
# virsh iothreadpin rhel7.0-rhel 2 1

8.
# virsh dumpxml rhel7.0-rhel |grep iothread
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='2'/>
  </iothreadids>
    <iothreadpin iothread='2' cpuset='1'/>

9.

# virsh list
 Id    Name                           State
----------------------------------------------------
 16    rhel7.0-rhel                   running

10.
# virsh dumpxml rhel7.0-rhel |grep iothread
  <iothreads>1</iothreads>
  <iothreadids>
    <iothread id='2'/>
  </iothreadids>
    <iothreadpin iothread='2' cpuset='1'/>

Comment 6 errata-xmlrpc 2015-11-19 06:30:06 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://rhn.redhat.com/errata/RHBA-2015-2202.html