Bug 1460143 - detect double use of implicit controller PCI address
Summary: detect double use of implicit controller PCI address
Keywords:
Status: CLOSED DEFERRED
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Virtualization Maintenance
QA Contact: Meina Li
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-06-09 08:45 UTC by jiyan
Modified: 2020-02-18 13:21 UTC (History)
5 users (show)

Fixed In Version: libvirt-3.9.0-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-02-18 13:21:33 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)
Dumpxml file of vm when verifying this bug (4.33 KB, text/plain)
2017-11-06 05:25 UTC, jiyan
no flags Details

Description jiyan 2017-06-09 08:45:10 UTC
Description of problem:
Attempted double use of PCI Address for 'usb controller' and 'ide controller' shoud be dectected while saving the dumpxml file after editing, not starting the vm.

Version-Release number of selected component (if applicable):
libvirt-3.2.0-9.el7.x86_64
kernel-3.10.0-679.el7.x86_64
qemu-kvm-rhev-2.9.0-9.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.1 Edit the vm's two usb controllers with same PCI address, then save and check the dumpxml: 
<controller type='usb' index='0' model='piix3-uhci'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='usb' index='1' model='piix3-uhci'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>

# virsh edit snapshot2-1
Domain snapshot2-1 XML configuration edited.

# virsh dumpxml snapshot2-1 | grep "piix3-uhci" -A 3
<controller type='usb' index='0' model='piix3-uhci'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='usb' index='1' model='piix3-uhci'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>

1.2 Try to start the vm
# virsh start snapshot2-1
Domain snapshot2-1 destroyed
error: Failed to start domain snapshot2-1
error: internal error: qemu unexpectedly closed the monitor: 2017-06-09T07:16:52.824847Z qemu-kvm: -chardev pty,id=charserial0: char device redirected to /dev/pts/1 (label charserial0)
2017-06-09T07:16:52.842881Z qemu-kvm: -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2: PCI: slot 1 function 2 not available for piix3-usb-uhci, in use by piix3-usb-uhci


2.1 Edit the vm's two pci controllers with same PCI address, then save and check the dumpxml: 
<controller type='ide' index='0'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='ide' index='1'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>

# virsh edit 1
Domain 1 XML configuration edited.

# virsh dumpxml 1 |grep "type='ide'" -C 2
    <controller type='ide' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='ide' index='1'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>

2.2 Try to start the vm
# virsh start 1
error: Failed to start domain 1
error: unsupported configuration: Only a single IDE controller is supported for this machine type


Actual results:
As reproducing steps above 


Expected results:
Attempted double use of PCI Address for 'usb controller' and 'ide controller' shoud be dectected while saving the dumpxml file after editing,like the following.
# virsh edit 1
<controller type='virtio-serial' index='0'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</controller>
<controller type='usb' index='1' model='piix3-uhci'>
 <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
error: XML error: Attempted double use of PCI Address 0000:00:05.0
Failed. Try again? [y,n,i,f,?]:


Additional info:

Comment 2 Ján Tomko 2017-09-26 11:06:05 UTC
Upstream patch:
https://www.redhat.com/archives/libvir-list/2017-September/msg00915.html

Comment 3 Ján Tomko 2017-10-16 08:11:30 UTC
Pushed upstream as:
commit d007ec33445490f77fc999c6216d9bae9fe09260
Author:     Ján Tomko <jtomko>
CommitDate: 2017-10-16 09:53:34 +0200

    qemu: reserve PCI addresses for implicit i440fx devices
    
    Somewhere around commit 9ff9d9f reserving entire PCI slots was
    eliminated, as demonstrated by commit 6cc2014.
    
    Reserve the functions required by the implicit devices:
    00:01.0 ISA Bridge
    00:01.1 IDE Controller
    00:01.2 USB Controller (unless USB is disabled)
    00:01.3 Bridge
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1460143

git describe: v3.8.0-113-gd007ec334

Comment 5 jiyan 2017-11-06 05:25:25 UTC
Created attachment 1348414 [details]
Dumpxml file of vm when verifying this bug

Comment 6 jiyan 2017-11-06 05:26:51 UTC
Hi, Ján.
The verifying steps are as above, however, when checking IDE controller and USB controller, that seems not as expected, other controller can also using reserved address, could you help to check it again?

I have uploaded the dumpxml file of vm, if needed, thank~

Test env components:
qemu-kvm-rhev-2.10.0-4.el7.x86_64
kernel-3.10.0-768.el7.x86_64
libvirt-3.9.0-1.el7.x86_64

Test scenarios:
1. Prepare a running vm named 'qcow2' without using "00:01.0,00:01.1,00:01.2,00:01.3" address
# virsh list --all |grep qcow2 
 -     qcow2                          shut off

# virsh dumpxml qcow2 |grep address |sort
...
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
      <listen type='address' address='127.0.0.1'/>
      <mac address='52:54:00:c4:85:a2'/>
...


2. Edit vm as following, checking whether libvirt reserves the functions required by ISA bridge (00:01.0)
# virsh edit qcow2
...
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </controller>
...
error: XML error: Attempted double use of PCI Address 0000:00:01.0
Failed. Try again? [y,n,i,f,?]:


3. Edit vm as following, checking whether libvirt reserves the functions required by Bridge (00:01.3)
# virsh edit qcow2
...
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
    </controller>
...
error: XML error: Attempted double use of PCI Address 0000:00:01.3
Failed. Try again? [y,n,i,f,?]: 


4. Edit vm as following, checking whether libvirt reserves the functions required by IDE Controller (00:01.1)
# virsh edit qcow2
...
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
...
Domain qcow2 XML configuration edited.

# virsh dumpxml qcow2 --inactive |grep virtio-scsi -A2
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>

# virsh start qcow2
error: Failed to start domain qcow2
error: internal error: qemu unexpectedly closed the monitor: 2017-11-06T05:04:00.703344Z qemu-kvm: -chardev pty,id=charserial0: char device redirected to /dev/pts/1 (label charserial0)
2017-11-06T05:04:00.721080Z qemu-kvm: -device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x1.0x1: PCI: slot 1 function 1 not available for virtio-scsi-pci, in use by piix3-ide


5. Checking whether libvirt reserves the functions required by USB Controller (00:01.2)
5.1 When USB is enabled, edit vm as following, checking whether libvirt reserves the functions required by USB Controller (00:01.2)
# virsh edit qcow2
...
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
...
Domain qcow2 XML configuration edited.

# virsh dumpxml qcow2 --inactive
...
    <controller type='usb' index='0' model='nec-xhci'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
...

# virsh start qcow2
Domain qcow2 started

# virsh dumpxml qcow2 
    <controller type='usb' index='0' model='nec-xhci'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>


5.2 When USB is disabled
# virsh edit qcow2
...
    <controller type='usb' index='0' model='none'/>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
...
Domain qcow2 XML configuration edited.

# virsh dumpxml qcow2 --inactive |grep virtio-scsi -C3
    <controller type='usb' index='0' model='none'/>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>

# virsh start qcow2
Domain qcow2 started

# virsh dumpxml qcow2  |grep virtio-scsi -C3
    <controller type='usb' index='0' model='none'>
      <alias name='usb'/>
    </controller>
    <controller type='scsi' index='0' model='virtio-scsi'>
      <alias name='scsi0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>

Comment 7 Ján Tomko 2017-12-04 12:19:46 UTC
My patches only reserve the address for the controller if it's present in the domain definition, but unlike other implicit controllers we only add it to the XML if there is an IDE drive present.

Always adding the IDE controller if it's present in the machine seems like the cleanest solution, but maybe there are backwards-compatibility reasons why we don't do that already.

Comment 9 Jaroslav Suchanek 2020-02-18 13:21:33 UTC
This bug was closed deferred as a result of bug triage.

Please reopen if you disagree and provide justification why this bug should
get enough priority. Most important would be information about impact on
customer or layered product. Please indicate requested target release.


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