Comment 0 for bug 1815268

Revision history for this message
Si-Wei Liu (siwliu) wrote :

Host has a QEMU/KVM setup with standby virtio-net [1]:

# qemu-system-x86_64 -name guest=ubuntu-xenial,debug-threads=on -machine pc,accel=kvm,usb=off -cpu host -m 4096 -realtime mlock=off -smp 4,sockets=1,cores=2,threads=2 -monitor stdio -vnc :1 -boot order=n,menu=on -serial telnet:127.0.0.1:4567,server -netdev tap,fd=20,id=hostnet0,vhost=on,vhostfd=21 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=d6:36:08:7f:b4:d9,standby=on

Guest is loaded with Xenial Xerus (16.04.5),

vsbalakr@ubuntu-16:~$ uname -a
Linux ubuntu-16 4.15.0-1007-oracle #9~16.04.1-Ubuntu SMP Wed Dec 12 19:49:55 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
vsbalakr@ubuntu-16:~$ cat /proc/version_signature
Ubuntu 4.15.0-1007.9~16.04.1-oracle 4.15.18
vsbalakr@ubuntu-16:~$ cat /etc/os*release
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
vsbalakr@ubuntu-16:~$

ens3 is the master interface of net_failover, while ens3nsby is its standby slave [2]:

vsbalakr@ubuntu-16:~$ ip a sh
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d6:36:08:7f:b4:d9 brd ff:ff:ff:ff:ff:ff
    inet 10.211.15.21/21 brd 10.211.15.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 fe80::d436:8ff:fe7f:b4d9/64 scope link
        valid_lft forever preferred_lft forever
3: ens3nsby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ens3 state UP group default qlen 1000
    link/ether d6:36:08:7f:b4:d9 brd ff:ff:ff:ff:ff:ff
    inet 10.211.15.21/21 brd 10.211.15.255 scope global dynamic ens3nsby
       valid_lft 2154sec preferred_lft 2154sec
    inet6 fe80::d436:8ff:fe7f:b4d9/64 scope link
        valid_lft forever preferred_lft forever

Now we hot plug a Virtual Function (with MAC set to same address d6:36:08:7f:b4:d9 in prior) into the guest, via QEMU HMP console:

(qemu) device_add vfio-pci,host=02:10.1,id=hostdev_vf0
(qemu)

VF now shows up in guest as "eth0" instead of the expected "ens4":

vsbalakr@ubuntu-16:~$ ip a sh
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d6:36:08:7f:b4:d9 brd ff:ff:ff:ff:ff:ff
    inet 10.211.15.21/21 brd 10.211.15.255 scope global ens3
       valid_lft forever preferred_lft forever
    inet6 2606:b400:400:3451:61b8:3bbd:dba3:7f93/64 scope global temporary dynamic valid_lft 604753sec preferred_lft 86209sec
    inet6 2606:b400:400:3451:d436:8ff:fe7f:b4d9/64 scope global mngtmpaddr dynamic valid_lft 2591959sec preferred_lft 604759sec
    inet6 fe80::d436:8ff:fe7f:b4d9/64 scope link
       valid_lft forever preferred_lft forever
3: ens3nsby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ens3 state UP group default qlen 1000
    link/ether d6:36:08:7f:b4:d9 brd ff:ff:ff:ff:ff:ff
    inet 10.211.15.21/21 brd 10.211.15.255 scope global dynamic ens3nsby
       valid_lft 2072sec preferred_lft 2072sec
    inet6 fe80::d436:8ff:fe7f:b4d9/64 scope link
       valid_lft forever preferred_lft forever
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens3 state UP group default qlen 1000
    link/ether d6:36:08:7f:b4:d9 brd ff:ff:ff:ff:ff:ff
vsbalakr@ubuntu-16:~$

/var/log/syslog shows that renaming to "ens4" had failed because of "Device or resource busy",

Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.231623] ixgbevf 0000:00:04.0: NIC Link is Up 10 Gbps
Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.233188] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: RUN 'ifupdown-hotplug' /lib/udev/rules.d/80-ifupdown.rules:5
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: IMPORT builtin 'path_id' /lib/udev/rules.d/80-net-setup-link.rules:5
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: IMPORT builtin 'net_setup_link' /lib/udev/rules.d/80-net-setup-link.rules:9
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: Config file /lib/systemd/network/99-default.link applies to device eth0
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: NAME 'ens4' /lib/udev/rules.d/80-net-setup-link.rules:11
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name' /lib/udev/rules.d/99-systemd.rules:51
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: error changing net interface name 'eth0' to 'ens4': Device or resource busy
Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.236275] virtio_net virtio0 ens3: failover primary slave:eth0 registered
Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.236308] ixgbevf 0000:00:04.0: d6:36:08:7f:b4:d9
Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.236310] ixgbevf 0000:00:04.0: MAC: 4
Feb 8 18:24:05 ubuntu-16 kernel: [ 5270.236313] ixgbevf 0000:00:04.0: Intel(R) 82599 Virtual Function
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: could not rename interface '8' from 'eth0' to 'ens4': Device or resource busy
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2340]: created db file '/run/udev/data/n8' for '/devices/pci0000:00/0000:00:04.0/net/eth0'
Feb 8 18:24:05 ubuntu-16 NetworkManager[1348]: <warn> [1549679045.5610] device (eth0): failed to find device 8 'eth0' with udev
Feb 8 18:24:05 ubuntu-16 systemd-udevd[2341]: starting 'vlan-network-interface UDEV'
Feb 8 18:24:05 ubuntu-16 NetworkManager[1348]: <info> [1549679045.5620] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/7)
Feb 8 18:24:05 ubuntu-16 NetworkManager[1348]: <info> [1549679045.5621] device (eth0): enslaved to non-master-type device ens3; ignoring
Feb 8 18:24:05 ubuntu-16 systemd-udevd[516]: could not create device: Invalid argument

it's desirable to get a consistent and preditable name, as otherwise any persistent configuration in userspace can't be applied properly on the Virtual Function that gets hot plugged in.

[1] https://patchwork.kernel.org/patch/10384967/
[2] https://www.kernel.org/doc/html/latest/networking/net_failover.html