Bug 1430275

Summary: cannot attach a virtual disk **with iothread enabled** to vm if pci address not provided
Product: Red Hat Enterprise Linux 7 Reporter: yisun
Component: libvirtAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: jiyan <jiyan>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: dyuan, hhan, lmen, pzhang, rbalakri, xuzhang, yisun
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.2.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:24:15 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 yisun 2017-03-08 09:30:37 UTC
Description of problem:
cannot attach a virtual disk **with iothread enabled** to vm if pci address not provided

Version-Release number of selected component (if applicable):
libvirt-3.1.0-1.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1. having a vm with iothreads enabled
## virsh dumpxml vm1 | grep iothreads -a10
<domain type='kvm' id='10'>
 ...
  <iothreads>4</iothreads>
 ...

2.start the vm
## virsh start vm1
Domain vm1 started

3.prepare a disk xml
## cat disk1.xml 
<disk device="disk" type="file">
    <driver name="qemu"  iothread='1'/>
    <source file="/var/lib/libvirt_ci/runtest_avocado-vt/avocado-vt/shared/test.raw" />
    <target bus="virtio" dev="vdb" />
</disk>

4. attach the disk to vm
## virsh attach-device vm1 disk1.xml 
error: Failed to attach device from disk1.xml
error: unsupported configuration: IOThreads are only available for virtio pci and virtio ccw disk


Actual results:
attaching failed, with error as above

Expected results:
Attaching successfully

Additional info:
1. this is not reproducible with libvirt-3.0.0-2.el7.x86_64
2. if pci address explicitly added in disk xml, then attach will be successful
## cat disk2.xml 
<disk device="disk" type="file">
    <driver name="qemu"  iothread='1'/>
    <source file="/var/lib/libvirt_ci/runtest_avocado-vt/avocado-vt/shared/test.raw" />
    <target bus="virtio" dev="vdb" />
    <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

## virsh attach-device vm1 disk2.xml 
Device attached successfully

Comment 3 Jaroslav Suchanek 2017-03-08 10:43:51 UTC
Result of this?

commit c96bd78e4e71c799dc391566fa9f0652dec55dca
Author:     Pavel Hrdina <phrdina>
AuthorDate: Sun Feb 12 15:05:53 2017 +0100
Commit:     Pavel Hrdina <phrdina>
CommitDate: Mon Feb 20 18:42:24 2017 +0100

    conf: move iothread XML validation from qemu_command
    
    This will ensure that IOThreads are properly validated while
    a domain is defined.
    
    Signed-off-by: Pavel Hrdina <phrdina>

Comment 4 Pavel Hrdina 2017-03-08 11:55:53 UTC
Yes it is a result of that commit, I'll fix it ASAP.

Comment 5 Pavel Hrdina 2017-03-08 16:51:13 UTC
Upstream patch posted:

https://www.redhat.com/archives/libvir-list/2017-March/msg00355.html

Comment 6 Pavel Hrdina 2017-03-09 16:42:23 UTC
Upstream commit:

commit cba1672de8b0220869ede5f9f26a0767e8a390eb
Author: Pavel Hrdina <phrdina>
Date:   Mon Feb 27 17:16:17 2017 +0100

    conf: properly skip graphics listen element in migratable XML

Comment 7 Pavel Hrdina 2017-03-09 16:44:18 UTC
Ahem, upstream commit:

commit c27020dd4f6ddb9ef5354e75dc7005a5efafe536
Author: Pavel Hrdina <phrdina>
Date:   Thu Mar 9 14:55:44 2017 +0100

    Revert "conf: move iothread XML validation from qemu_command"

Comment 10 jiyan 2017-06-01 03:07:18 UTC
Version-Release number of selected component:
libvirt-3.2.0-6.el7.x86_64
qemu-kvm-rhev-2.9.0-7.el7.x86_64
Kernel-3.10.0-675.el7.x86_64

Steps to verify:
1.configure the vm with iothreads enabled ,prepare disk.xml without pci address and disk1.xml with pci address 
# virsh dumpxml cow |grep iothreads
  <iothreads>4</iothreads>

# cat disk.xml 
<disk device="disk" type="file">
    <driver name="qemu"  iothread='1'/>
    <source file="/var/lib/libvirt/images/RHEL-7.4-x86_64-latest.raw" />
    <target bus="virtio" dev="vda" />
</disk>

# cat disk1.xml 
<disk device="disk" type="file">
    <driver name="qemu"  iothread='1'/>
    <source file="/var/lib/libvirt/images/RHEL-7.4-x86_64-latest.raw" />
    <target bus="virtio" dev="vda" />
    <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</disk>

2.confirm the vm can start and destroy normally with iothreads enabled 
# virsh start cow
Domain cow started

# virsh destroy cow
Domain cow destroyed

3.confirm that the disk.xml without  pci address can be attached and dettached normally when vm is running, check 'disk' element in dumpxml file  
# virsh start cow
Domain cow started

# virsh attach-device cow disk.xml 
Device attached successfully

# virsh dumpxml cow |grep "<disk" -A 10
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' iothread='1'/>
      <source file='/var/lib/libvirt/images/RHEL-7.4-x86_64-latest.raw'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

# virsh detach-device cow disk.xml 
Device detached successfully

4.confirm that the disk1.xml with  pci address can be attached and dettached normally when vm is running, check 'disk' element in dumpxml file  
# virsh start cow
Domain cow started

# virsh attach-device cow disk1.xml 
Device attached successfully

# virsh dumpxml cow |grep "<disk" -A 10
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' iothread='1'/>
      <source file='/var/lib/libvirt/images/RHEL-7.4-x86_64-latest.raw'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </disk>

# virsh detach-device cow disk1.xml 
Device detached successfully

5.confirm that neither disk.xml(without pci address) or disk1.xml(with pci address) can be attached when the vm is down
# virsh destroy cow
Domain cow destroyed

# virsh attach-device cow disk.xml 
error: Failed to attach device from disk.xml
error: Requested operation is not valid: domain is not running

# virsh attach-device cow disk1.xml 
error: Failed to attach device from disk1.xml
error: Requested operation is not valid: domain is not running

Comment 11 errata-xmlrpc 2017-08-01 17:24:15 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/RHEA-2017:1846

Comment 12 errata-xmlrpc 2017-08-02 00:03:43 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/RHEA-2017:1846