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
Included in 7.3.0 release
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.
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
Set the bug to be verified according to comment 6
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