Bug 1452581 - libvirt sets duplicated pci address when hot-plug rng device on a specific condition
Summary: libvirt sets duplicated pci address when hot-plug rng device on a specific c...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.4
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ján Tomko
QA Contact: Fangge Jin
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-19 09:02 UTC by Fangge Jin
Modified: 2017-08-02 01:34 UTC (History)
7 users (show)

Fixed In Version: libvirt-3.2.0-6.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-02 01:34:35 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2017:1846 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2017-08-01 18:02:50 UTC

Description Fangge Jin 2017-05-19 09:02:33 UTC
Description of problem:
First, attach a rng device with pci address set to higher than the current occupied pci address in guest.

Second, attach the rng device again. It failed with expected error:
error: XML error: Attempted double use of PCI Address 0000:00:0c.0

Then,attach a rng device or other device without specified pci address. It failed with:
error: internal error: unable to execute QEMU command 'device_add': PCI: slot 12 function 0 not available for rtl8139, in use by virtio-rng-pci


Version-Release number of selected component:
libvirt-3.2.0-5.virtcov.el7.x86_64
qemu-kvm-rhev-2.9.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
0.Prepare a guest, whose pci address has been occupied from 0000:00:01 to 0000:00:0b

1. Prepare a rng xml with pci address set to 0000:00:0c like below:
# cat random-pci.xml 
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </rng>

2.Start guest
# virsh start rhel7.4
Domain rhel7.4 started

3.Attach rng device:
# virsh attach-device rhel7.4 random-pci.xml 
Device attached successfully

4.Attach same rng device again:
# virsh attach-device rhel7.4 random-pci.xml 
error: Failed to attach device from random-pci.xml
error: XML error: Attempted double use of PCI Address 0000:00:0c.0

5.Remove address from random-pci.xml and re-attach
# cat random.xml
    <rng model='virtio'>
      <backend model='random'>/dev/random</backend>
    </rng>

# virsh attach-device rhel7.4 random.xml 
error: Failed to attach device from random.xml
error: internal error: unable to execute QEMU command 'device_add': PCI: slot 12 function 0 not available for virtio-rng-pci, in use by virtio-rng-pci

7.Attach an interface without specified pci address:
# cat interface.xml 
    <interface type='network'>
      <source network='default' bridge='virbr0'/>
    </interface>

# virsh attach-device rhel7.4 interface.xml 
error: Failed to attach device from interface.xml
error: internal error: unable to execute QEMU command 'device_add': PCI: slot 12 function 0 not available for rtl8139, in use by virtio-rng-pci



Actual results:
In step6&&7, libvirt still use 0000:00:0c.0 when attaching rng/interface device

Expected results:
In step6&&7, libvirt should use new pci address and attach should succeed

Comment 2 Ján Tomko 2017-05-19 12:16:38 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2017-May/msg00697.html

Comment 3 Ján Tomko 2017-05-22 08:51:24 UTC
Pushed as:
commit f25f30aff548636d0c8782d3eaee049c77548dd5
Author:     Ján Tomko <jtomko@redhat.com>
CommitDate: 2017-05-22 10:29:01 +0200

    Do not release unreserved address in qemuDomainAttachRNGDevice
    
    Only set releaseaddr to true after the address has been
    reserved successfully.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1452581
    
    Reviewed-by: John Ferlan <jferlan@redhat.com>

git describe: v3.3.0-113-gf25f30a

Comment 6 Fangge Jin 2017-05-27 02:25:07 UTC
Verify with build libvirt-3.2.0-6.virtcov.el7.x86_64.

Libvirt uses new pci address in step6&&step7, attach device successfully.

Comment 7 errata-xmlrpc 2017-08-02 01:34:35 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


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