With this series applied it is possible to get stable NIC device naming
in combination with QEMU >= 6.0.0 (release imminent), by setting the
ACPI device index against NICs.
<acpi index="NNN"/>
The index is an unique integer that can be assigned to any PCI/PCIe
device. systemd uses this value for its stable NIC naming scheme.
If not present, then it falls back to an SMBIOS device index, but
QEMU doesn't support that concept.
Note that although this is only known to be useful for NICs, the
ACPI feature is conceptually available for any PCI device, and so
libvirt doesn't restrict the usage to only NICs.
Tested with current QEMU git master, and Fedora 30 guest. It works
with i440fx, but fails with Q35. The latter problem is reported to
qemu-devel and awaiting response.
<interface type="network">
<mac address="52:54:00:c3:d3:ef" />
<source network="default"
portid="c2361e1b-3ebf-484e-813e-9ee8e2b760c7" bridge="virbr0" />
<target dev="vnet6" />
<model type="virtio" />
<alias name="net0" />
<acpi index="103" />
<address type="pci" domain="0x0000" bus="0x00"
slot="0x03" function="0x0" />
</interface>
<interface type="network">
<mac address="52:54:00:98:22:a6" />
<source network="default"
portid="e6cdb3da-ca24-42fa-973e-8cdb92fcad3f" bridge="virbr0" />
<target dev="vnet7" />
<model type="virtio" />
<alias name="net1" />
<acpi index="113" />
<address type="pci" domain="0x0000" bus="0x00"
slot="0x0a" function="0x0" />
</interface>
<interface type="network">
<mac address="52:54:00:42:00:bc" />
<source network="default"
portid="10efeab4-f59c-4ef7-90a3-32b3895080b7" bridge="virbr0" />
<target dev="vnet8" />
<model type="virtio" />
<alias name="net2" />
<acpi index="123" />
<address type="pci" domain="0x0000" bus="0x00"
slot="0x0b" function="0x0" />
</interface>
<interface type="network">
<mac address="52:54:00:36:8e:5a" />
<source network="default"
portid="fb016189-d764-41b2-b256-f5783ade3726" bridge="virbr0" />
<target dev="vnet9" />
<model type="virtio" />
<alias name="net3" />
<acpi index="133" />
<address type="pci" domain="0x0000" bus="0x00"
slot="0x0c" function="0x0" />
</interface>
Name MAC address Protocol Address
-------------------------------------------------------------------------------
vnet6 52:54:00:c3:d3:ef ipv4 192.168.122.61/24
vnet7 52:54:00:98:22:a6 ipv4 192.168.122.69/24
vnet8 52:54:00:42:00:bc ipv4 192.168.122.17/24
vnet9 52:54:00:36:8e:5a ipv4 192.168.122.13/24
$ ip -4 addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
qlen 1000
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eno103: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group
default qlen 1000
inet 192.168.122.61/24 brd 192.168.122.255 scope global dynamic noprefixroute eno103
valid_lft 2987sec preferred_lft 2987sec
3: eno113: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group
default qlen 1000
inet 192.168.122.69/24 brd 192.168.122.255 scope global dynamic noprefixroute eno113
valid_lft 2987sec preferred_lft 2987sec
4: eno123: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group
default qlen 1000
inet 192.168.122.17/24 brd 192.168.122.255 scope global dynamic noprefixroute eno123
valid_lft 2987sec preferred_lft 2987sec
5: eno133: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group
default qlen 1000
inet 192.168.122.13/24 brd 192.168.122.255 scope global dynamic noprefixroute eno133
valid_lft 2988sec preferred_lft 2988sec
Daniel P. Berrangé (6):
conf: add support for <acpi index='NNN'/> for PCI devices
tests: re-generate QEMU 6.0.0 x86_64 capabilities data
qemu: fix indentation off-by-1
qemu: use a switch when building device addresses
qemu: probe for "acpi-index" property
qemu: wire up command line support for ACPI index
docs/formatdomain.rst | 6 +
docs/schemas/domaincommon.rng | 73 +
src/conf/device_conf.h | 3 +
src/conf/domain_conf.c | 12 +
src/qemu/qemu_capabilities.c | 8 +
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 41 +-
src/qemu/qemu_validate.c | 35 +
.../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 58 +-
tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 58 +-
.../caps_6.0.0.x86_64.replies | 3761 +++++++++--------
.../caps_6.0.0.x86_64.xml | 752 ++--
.../cpu-tsc-high-frequency.x86_64-latest.args | 9 +-
.../devices-acpi-index.x86_64-latest.args | 57 +
tests/qemuxml2argvdata/devices-acpi-index.xml | 62 +
.../hugepages-memaccess3.x86_64-latest.args | 8 +-
tests/qemuxml2argvtest.c | 2 +
17 files changed, 2682 insertions(+), 2266 deletions(-)
create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.xml
--
2.30.2