Bug 1946719 - RFE: support setting ACPI index for PCI devices to enable systemd predictable NIC device naming
Summary: RFE: support setting ACPI index for PCI devices to enable systemd predictable...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.5
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.4
Assignee: Daniel Berrangé
QA Contact: yalzhang@redhat.com
URL:
Whiteboard:
Depends On: 1946716
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-06 18:03 UTC by Daniel Berrangé
Modified: 2021-12-10 09:21 UTC (History)
10 users (show)

Fixed In Version: libvirt-7.3.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-11-16 07:52:31 UTC
Type: Feature Request
Target Upstream Version: 7.3.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4684 0 None None None 2021-11-16 07:53:15 UTC

Description Daniel Berrangé 2021-04-06 18:03:52 UTC
Description of problem:
Historically NICs in VMs get given the "ethNNN" naming, where NNN is assigned based on the order the NICs are detected by the kernel. This is potentially unstable across reboots of the guest, especially if any device hotplug/unplug of NICs has taken place. It is also potentially unstable if the same guest image is booted with different machine types i440fx vs Q35, due to differing PCI topology.

Systemd supports several NIC naming schemes with varying characteristics

  https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

This is a request to support setting the ACPI device index for PCI devices, since that will enable support for systemd's preferred naming scheme, "enoNNN", , though PCI express hotplug slot numbers come a close second "ensNNNN" in usefulness.

An initial impl proposde for libvirt 7.3.0 is available at

https://listman.redhat.com/archives/libvir-list/2021-April/msg00089.html

which supports an

  <acpi index="NNN"/> 

property against any PCI device in libvirt XML.

This has a dependency on the corresponding acpi-index=NNN feature added to QEMU 6.0.0

Note the QEMU part currently only works for i440fx machine types, not Q35, but libvirt does not attempt to restrict the usage to match this (presumed to be temporary) impl limitation in QEMU.

Version-Release number of selected component (if applicable):
libvirt-7.0.0-12.el8

Comment 1 Daniel Berrangé 2021-07-28 15:24:30 UTC
Included in 7.3.0 release

Comment 2 Igor Mammedov 2021-07-28 16:33:39 UTC
just heads up,
even though ACPI PCI hotplug for Q35 was merged in QEMU-6.1,
acpi-index will work only with hotpluggable devices (i.e. NICs attached to root ports/other bridges).
for devices directly attached to pcie.0 it will not work.
So we will need extra patches on top to make it work to the same extent as on PC.

Comment 6 yalzhang@redhat.com 2021-08-09 02:17:30 UTC
Hi Daniel, I have tested the feature with below scenarios, all results are expected except the virsh command "update-device". Libvirt should forbid any live update for the "acpi index". Could you please help to confirm it, Thank you!

Test with below packages with pc machine type:
# rpm -q libvirt qemu-kvm
libvirt-7.6.0-1.module+el8.5.0+12097+2c77910b.x86_64
qemu-kvm-6.0.0-27.module+el8.5.0+12121+c40c8708.x86_64

Scenarios:
1. Start vm with <acpi index='NNN'/> and check the interface name, the interface will get name as “enoNNN”. While the one without index set will get name as “ensX”(X is the slot number) - PASS;
2. Hotplug and unplug interface with “acpi index” defined - PASS;
3. Boundary test - PASS
4. Unique test - PASS
5. Update device - FAIL
 
Details:
Start vm with interfaces set with ‘acpi index’:
<interface type='network'>
      <mac address='52:54:00:69:68:30'/>
      <source network='default'/>
      <model type='virtio'/>
      <acpi index='13'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:eb:e2:ab'/>
      <source network='default'/>
      <model type='e1000e'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </interface>
 
Check the interface name, they will get:
# ip l 
2: eno13: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:69:68:30 brd ff:ff:ff:ff:ff:ff
3: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:eb:e2:ab brd ff:ff:ff:ff:ff:ff
 
Hotplug and unplug interface with ‘acpi index’:
Hot unplug the first interface, and plug another interface with different index:
# virsh detach-device test interface.xml 
Device detached successfully
# cat interface.xml 
<interface type='network'>
      <source network='default'/>
      <model type='virtio'/>
      <acpi index='16383'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
# virsh attach-device test interface.xml 
Device attached successfully
# ip l 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:eb:e2:ab brd ff:ff:ff:ff:ff:ff
4: eno16383: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:d6:7a:5b brd ff:ff:ff:ff:ff:ff
 
Test duplicate index
Try to attach an interface with duplicate index ‘16383’:
# cat hostdev_interface.xml 
<hostdev mode='subsystem' type='pci' managed='yes'>
    <source>
      <address domain='0x0000' bus='0x5e' slot='0x01' function='0x3'/>
    </source>
    <acpi index='16383'/>
  </hostdev>
# virsh attach-device test hostdev_interface.xml 
error: Failed to attach device from hostdev_interface.xml
error: internal error: unable to execute QEMU command 'device_add': a PCI device with acpi-index = 16383 already exist
# cat interface.xml 
<interface type='network'>
      <source network='default'/>
      <model type='virtio'/>
      <acpi index='16383'/>
    </interface>
# virsh attach-device test interface.xml 
error: Failed to attach device from interface.xml
error: internal error: unable to execute QEMU command 'device_add': a PCI device with acpi-index = 16383 already exist
 
Destroy the vm and edit the vm to includes duplicate index:
# virsh dumpxml test | grep 'acpi index'
      <acpi index='13'/>
      <acpi index='13'/>
# virsh start test
error: Failed to start domain 'test'
error: internal error: qemu unexpectedly closed the monitor: 2021-08-09T02:03:58.531356Z qemu-kvm: -device e1000e,netdev=hostnet1,id=net1,mac=52:54:00:eb:e2:ab,bus=pci.0,addr=0xa,acpi-index=13: a PCI device with acpi-index = 13 already exist
 
Try to start with ‘acpi index=16384’
# virsh start test 
error: Failed to start domain 'test'
error: internal error: qemu unexpectedly closed the monitor: 2021-08-09T02:06:17.770232Z qemu-kvm: -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:69:68:30,bus=pci.0,addr=0x9,acpi-index=16384: acpi-index should be less or equal to 16383
 
Hotplug with  ‘acpi index=16384’
# virsh attach-device test interface.xml 
error: Failed to attach device from interface.xml
error: internal error: unable to execute QEMU command 'device_add': acpi-index should be less or equal to 16383
 
Update device fail
# virsh dupmxml test | grep /interface -B 12
<interface type='network'>
      <mac address='52:54:00:69:68:30'/>
      <source network='default' portid='2e78e325-cadf-4295-a4f0-0262c58f7f45' bridge='virbr0'/>
      <target dev='vnet86'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
# cat update_interface.xml 
<interface type='network'>
      <mac address='52:54:00:69:68:30'/>
      <source network='default' portid='2e78e325-cadf-4295-a4f0-0262c58f7f45' bridge='virbr0'/>
      <target dev='vnet86'/>
      <model type='virtio'/>
      <alias name='net0'/>
       <acpi index='16383'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </interface>
 
# virsh update-device test update_interface.xml
Device updated successfully
 
Check the live xml, there is no changes

Comment 7 yalzhang@redhat.com 2021-08-25 01:51:46 UTC
Set the bug to be verified according to comment 6

Comment 9 errata-xmlrpc 2021-11-16 07:52:31 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 (virt:av 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/RHBA-2021:4684


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