Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-154240

PCI device fails to rebind to original host driver after hotunplug it despite managed='yes'

Linking RHIVOS CVEs to...Migration: Automation ...Sync from "Extern...XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • rhel-9.8, rhel-10.2
    • libvirt / General
    • None
    • None
    • None
    • rhel-virt-core-libvirt-1
    • None
    • False
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • Unspecified
    • Unspecified
    • Unspecified
    • None

      What were you trying to do that didn't work?

      Hotplug 2 pci devices to guest with managed = 'yes' another with managed ignored. The first hot-unplug the pci device with managed = 'yes'  then hot-unplug another pci device with managed ignored. After that found the pci device with managed = 'yes' fails to rebind to original host driver.

      Please provide the package NVR for which the bug is seen:

      On rhel10.2
      # rpm -q libvirt qemu-kvm
      libvirt-11.10.0-10.el9.x86_64
      qemu-kvm-10.1.0-15.el9.x86_64

       

      On rhel9.8
      # rpm -q libvirt qemu-kvm
      libvirt-11.10.0-11.el9_8.x86_64
      qemu-kvm-10.1.0-15.el9.x86_64

       

      How reproducible is this bug?:100%

      Steps to reproduce

      1. There are 2 pci devices then detach one of them then the drivers like below:

      # virsh nodedev-detach pci_0000_01_00_1
      Device pci_0000_01_00_1 detached
      
      # ls -l /sys/bus/pci/devices/0000\:01\:00.1/driver
      lrwxrwxrwx. 1 root root 0 Mar  9 04:12 /sys/bus/pci/devices/0000:01:00.1/driver -> ../../../../bus/pci/drivers/vfio-pci
      # ls -l /sys/bus/pci/devices/0000\:01\:00.0/driver
      lrwxrwxrwx. 1 root root 0 Mar  9 06:42 /sys/bus/pci/devices/0000:01:00.0/driver -> ../../../../bus/pci/drivers/tg3

      2. Start a guest

      # virsh start vm2
      Domain 'vm2' started

      3. Hotplug first pci device with managed = 'yes':

      # cat pci-0.xml
      <hostdev mode='subsystem' type='pci' managed='yes'>
            <driver iommufd='yes'/>
            <source>
              <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
            </source>
          </hostdev>
      
      # virsh attach-device vm2 pci-0.xml
      Device attached successfully

      4. Hotplug second pci device with managed ignored:

      # cat pci-1.xml
      <hostdev mode='subsystem' type='pci' >
            <driver iommufd='yes'/>
            <source>
              <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
            </source>
          </hostdev>
      # virsh attach-device vm2 pci-1.xml
      Device attached successfully

      5. Check 2 pci devices drivers on host:

      # ls -l /sys/bus/pci/devices/0000\:01\:00.0/driver
      lrwxrwxrwx. 1 root root 0 Mar  9 06:46 /sys/bus/pci/devices/0000:01:00.0/driver -> ../../../../bus/pci/drivers/vfio-pci
      # ls -l /sys/bus/pci/devices/0000\:01\:00.1/driver
      lrwxrwxrwx. 1 root root 0 Mar  9 04:12 /sys/bus/pci/devices/0000:01:00.1/driver -> ../../../../bus/pci/drivers/vfio-pci

      6. Hot-unplug first pci device with managed = 'yes':

      # virsh detach-device vm2 pci-0.xml
      Device detached successfully

      7. Hot-unplug second pci device with managed ignored:

      # virsh detach-device vm2 pci-1.xml
      Device detached successfully

      8. Check the 2 pci devices drivers:

      # ls -l /sys/bus/pci/devices/0000\:01\:00.0/driver
      ls: cannot access '/sys/bus/pci/devices/0000:01:00.0/driver': No such file or directory
      # ls -l /sys/bus/pci/devices/0000\:01\:00.1/driver
      lrwxrwxrwx. 1 root root 0 Mar  9 04:12 /sys/bus/pci/devices/0000:01:00.1/driver -> ../../../../bus/pci/drivers/vfio-pci

      Expected results

      The first pci device should rebind to its original host driver

      Actual results

      The first pci device fails to rebind to  its original host driver

       

       

      Additional info: Issue disappear if hot-unplug the pci device with managed ignored first.

       

        1. vm2.log
          12 kB
          Liang Cong
        2. libvirtd.log
          1.06 MB
          Liang Cong

              virt-maint virt-maint
              lcong@redhat.com Liang Cong
              virt-maint virt-maint
              virt-bugs virt-bugs
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated: