RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2040548 - 'unassigned' address type changed after hotplug
Summary: 'unassigned' address type changed after hotplug
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.0
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-14 03:03 UTC by Yanqiu Zhang
Modified: 2022-11-15 10:36 UTC (History)
11 users (show)

Fixed In Version: libvirt-8.1.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-15 10:03:03 UTC
Type: Bug
Target Upstream Version: 8.1.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github autotest tp-libvirt pull 4073 0 None Merged sriov: Add 3 cases 2022-05-10 07:13:25 UTC
Red Hat Issue Tracker RHELPLAN-108151 0 None None None 2022-01-14 03:06:19 UTC
Red Hat Product Errata RHSA-2022:8003 0 None None None 2022-11-15 10:03:22 UTC

Description Yanqiu Zhang 2022-01-14 03:03:14 UTC
Description of problem:
If start guest with hostdev, <address type='unassigned'/> will not change in live xml. But if hotplug a hostdev with 'unassigned' address, it will changed to normal pci address.

Version-Release number of selected component (if applicable):
libvirt-8.0.0-0rc1.1.el9.x86_64
Qemu-kvm-6.2.0-3.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1.start with
# virsh dumpxml r8|grep hostdev -B8
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x0a' function='0x0'/>
      </source>
      <rom enabled='no'/>
      <address type='unassigned'/>
    </hostdev>

# virsh start r8
Domain 'r8' started

# virsh dumpxml r8|grep hostdev -B8
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x0a' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <rom enabled='no'/>
      <address type='unassigned'/>
    </hostdev>

2.hotplug
# virsh dumpxml r8|grep /hostdev -B8
(no output)
# cat hostdev-romno-unassigned.xml 
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x0a' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <rom enabled='no'/>
      <address type='unassigned'/>
    </hostdev>

# virsh attach-device r8 hostdev-romno-unassigned.xml
Device attached successfully

# virsh dumpxml r8|grep /hostdev -B8
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x0a' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <rom enabled='no'/>
      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
    </hostdev>


Actual results:


Expected results:
1. Hotplug should not assign pci address for 'unassigned' type.
2. Or block hotplug for 'unassigned' address type hostdev since the scenario may be meaningless.

Additional info:
1.After checking codes, we found that hotplug uses qemuDomainEnsurePCIAddress, will not call qemuDomainAssignDevicePCISlots(which includes  /* do not reserve address for info->type='unassigned' */). Only start and reconnect will go to qemuDomainAssignDevicePCISlots.
2. Not produces on coldplug, it keeps 'unassigned'.

Comment 1 Cole Robinson 2022-01-17 15:41:58 UTC
Yes this seems like a bug. type='unassigned' are treated like PCI devices for vfio purposes, but are not passed to the qemu command line. they shouldn't require a virtual PCI address to be allocated, and the address type shouldn't change on hotplug.

Comment 2 Michal Privoznik 2022-01-25 12:09:11 UTC
FYI it's not just hotplug that suffers the same problem. A <hostdev/> with unassigned address can't be hotunpluged either.

Comment 3 Michal Privoznik 2022-01-25 12:17:35 UTC
Patches posted on the list:

https://listman.redhat.com/archives/libvir-list/2022-January/msg01111.html

Comment 5 Michal Privoznik 2022-01-27 13:03:45 UTC
Merged upstream as:

7251307199 qemuDomainDetachDeviceLive: Handle hostevs with unassigned type of address
f5de3af7f4 qemuDomainAttachHostPCIDevice: Handle hostevs with unassigned type of address
89f9346791 domain_validate: Refuse VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED

v8.0.0-206-g7251307199

Comment 6 Yanqiu Zhang 2022-03-31 10:33:18 UTC
Tested with:
libvirt-8.1.0-1.el9.x86_64
qemu-kvm-6.2.0-12.el9.x86_64

1. # cat hostdev-unassigned.xml 
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x02' function='0x0'/>
      </source>
      <address type='unassigned'/>
    </hostdev>

# virsh dumpxml r9|grep hostdev
(nothing)

# virsh attach-device r9 hostdev-unassigned.xml 
Device attached successfully

# virsh dumpxml r9|grep /hostdev -B8
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x3b' slot='0x02' function='0x0'/>
      </source>
      <alias name='hostdev0'/>
      <address type='unassigned'/>
    </hostdev>

# virsh detach-device r9 hostdev-unassigned.xml 
Device detached successfully

# virsh dumpxml r9|grep /hostdev -B8
(nothing)

2. # cat iface-hostdev.xml 
<interface type='hostdev' managed='yes'>
      <source>
        <address type='pci' domain='0x0000' bus='0x3b' slot='0x02' function='0x0'/>
      </source>
      <address type='unassigned'/>
    </interface>

# virsh attach-device r9 iface-hostdev.xml 
error: Failed to attach device from iface-hostdev.xml
error: unsupported configuration: address of type 'unassigned' is supported only for hostdevs

# virsh edit r9
error: unsupported configuration: address of type 'unassigned' is supported only for hostdevs
Failed. Try again? [y,n,i,f,?]: 

# virsh define r9.xml-hostdeviface 
error: Failed to define domain from r9.xml-hostdeviface
error: unsupported configuration: address of type 'unassigned' is supported only for hostdevs


Hi Michal,
Could you help confirm whether result of step2 is expected please? The hostdev interface can not use 'unassigned' address type anymore.
Thank you!

Comment 8 Yanqiu Zhang 2022-04-01 01:46:41 UTC
Thanks Michal.

Comment 11 Yanqiu Zhang 2022-04-14 04:43:16 UTC
Verified with:
libvirt-8.2.0-1.el9.x86_64
qemu-kvm-6.2.0-12.el9.x86_64

Same steps and results as comment6.

And same behaviors for coldplug/unplug.

Comment 13 errata-xmlrpc 2022-11-15 10:03:03 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 (Low: libvirt security, bug fix, and enhancement update), 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/RHSA-2022:8003


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