Documentation: networking: net_failover: Fix documentation

Update net_failover documentation with missing and incomplete
details to get a proper working setup.

Signed-off-by: Vasudev Kamath <vasudev@copyninja.info>
Reviewed-by: Krishna Kumar <krikku@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Vasudev Kamath 2021-11-16 12:51:48 +05:30 committed by David S. Miller
parent 2b425ef8c1
commit 738baea497
1 changed files with 88 additions and 23 deletions

View File

@ -35,7 +35,7 @@ To support this, the hypervisor needs to enable VIRTIO_NET_F_STANDBY
feature on the virtio-net interface and assign the same MAC address to both feature on the virtio-net interface and assign the same MAC address to both
virtio-net and VF interfaces. virtio-net and VF interfaces.
Here is an example XML snippet that shows such configuration. Here is an example libvirt XML snippet that shows such configuration:
:: ::
<interface type='network'> <interface type='network'>
@ -45,18 +45,32 @@ Here is an example XML snippet that shows such configuration.
<model type='virtio'/> <model type='virtio'/>
<driver name='vhost' queues='4'/> <driver name='vhost' queues='4'/>
<link state='down'/> <link state='down'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> <teaming type='persistent'/>
<alias name='ua-backup0'/>
</interface> </interface>
<interface type='hostdev' managed='yes'> <interface type='hostdev' managed='yes'>
<mac address='52:54:00:00:12:53'/> <mac address='52:54:00:00:12:53'/>
<source> <source>
<address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/> <address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
</source> </source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> <teaming type='transient' persistent='ua-backup0'/>
</interface> </interface>
In this configuration, the first device definition is for the virtio-net
interface and this acts as the 'persistent' device indicating that this
interface will always be plugged in. This is specified by the 'teaming' tag with
required attribute type having value 'persistent'. The link state for the
virtio-net device is set to 'down' to ensure that the 'failover' netdev prefers
the VF passthrough device for normal communication. The virtio-net device will
be brought UP during live migration to allow uninterrupted communication.
The second device definition is for the VF passthrough interface. Here the
'teaming' tag is provided with type 'transient' indicating that this device may
periodically be unplugged. A second attribute - 'persistent' is provided and
points to the alias name declared for the virtio-net device.
Booting a VM with the above configuration will result in the following 3 Booting a VM with the above configuration will result in the following 3
netdevs created in the VM. interfaces created in the VM:
:: ::
4: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 4: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
@ -65,13 +79,36 @@ netdevs created in the VM.
valid_lft 42482sec preferred_lft 42482sec valid_lft 42482sec preferred_lft 42482sec
inet6 fe80::97d8:db2:8c10:b6d6/64 scope link inet6 fe80::97d8:db2:8c10:b6d6/64 scope link
valid_lft forever preferred_lft forever valid_lft forever preferred_lft forever
5: ens10nsby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master ens10 state UP group default qlen 1000 5: ens10nsby: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master ens10 state DOWN group default qlen 1000
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
7: ens11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens10 state UP group default qlen 1000 7: ens11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens10 state UP group default qlen 1000
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
ens10 is the 'failover' master netdev, ens10nsby and ens11 are the slave Here, ens10 is the 'failover' master interface, ens10nsby is the slave 'standby'
'standby' and 'primary' netdevs respectively. virtio-net interface, and ens11 is the slave 'primary' VF passthrough interface.
One point to note here is that some user space network configuration daemons
like systemd-networkd, ifupdown, etc, do not understand the 'net_failover'
device; and on the first boot, the VM might end up with both 'failover' device
and VF accquiring IP addresses (either same or different) from the DHCP server.
This will result in lack of connectivity to the VM. So some tweaks might be
needed to these network configuration daemons to make sure that an IP is
received only on the 'failover' device.
Below is the patch snippet used with 'cloud-ifupdown-helper' script found on
Debian cloud images:
::
@@ -27,6 +27,8 @@ do_setup() {
local working="$cfgdir/.$INTERFACE"
local final="$cfgdir/$INTERFACE"
+ if [ -d "/sys/class/net/${INTERFACE}/master" ]; then exit 0; fi
+
if ifup --no-act "$INTERFACE" > /dev/null 2>&1; then
# interface is already known to ifupdown, no need to generate cfg
log "Skipping configuration generation for $INTERFACE"
Live Migration of a VM with SR-IOV VF & virtio-net in STANDBY mode Live Migration of a VM with SR-IOV VF & virtio-net in STANDBY mode
================================================================== ==================================================================
@ -80,40 +117,68 @@ net_failover also enables hypervisor controlled live migration to be supported
with VMs that have direct attached SR-IOV VF devices by automatic failover to with VMs that have direct attached SR-IOV VF devices by automatic failover to
the paravirtual datapath when the VF is unplugged. the paravirtual datapath when the VF is unplugged.
Here is a sample script that shows the steps to initiate live migration on Here is a sample script that shows the steps to initiate live migration from
the source hypervisor. the source hypervisor. Note: It is assumed that the VM is connected to a
software bridge 'br0' which has a single VF attached to it along with the vnet
device to the VM. This is not the VF that was passthrough'd to the VM (seen in
the vf.xml file).
:: ::
# cat vf_xml # cat vf.xml
<interface type='hostdev' managed='yes'> <interface type='hostdev' managed='yes'>
<mac address='52:54:00:00:12:53'/> <mac address='52:54:00:00:12:53'/>
<source> <source>
<address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/> <address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
</source> </source>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> <teaming type='transient' persistent='ua-backup0'/>
</interface> </interface>
# Source Hypervisor # Source Hypervisor migrate.sh
#!/bin/bash #!/bin/bash
DOMAIN=fedora27-tap01 DOMAIN=vm-01
PF=enp66s0f0 PF=ens6np0
VF_NUM=5 VF=ens6v1 # VF attached to the bridge.
TAP_IF=tap01 VF_NUM=1
VF_XML= TAP_IF=vmtap01 # virtio-net interface in the VM.
VF_XML=vf.xml
MAC=52:54:00:00:12:53 MAC=52:54:00:00:12:53
ZERO_MAC=00:00:00:00:00:00 ZERO_MAC=00:00:00:00:00:00
# Set the virtio-net interface up.
virsh domif-setlink $DOMAIN $TAP_IF up virsh domif-setlink $DOMAIN $TAP_IF up
bridge fdb del $MAC dev $PF master
virsh detach-device $DOMAIN $VF_XML # Remove the VF that was passthrough'd to the VM.
virsh detach-device --live --config $DOMAIN $VF_XML
ip link set $PF vf $VF_NUM mac $ZERO_MAC ip link set $PF vf $VF_NUM mac $ZERO_MAC
virsh migrate --live $DOMAIN qemu+ssh://$REMOTE_HOST/system # Add FDB entry for traffic to continue going to the VM via
# the VF -> br0 -> vnet interface path.
bridge fdb add $MAC dev $VF
bridge fdb add $MAC dev $TAP_IF master
# Destination Hypervisor # Migrate the VM
virsh migrate --live --persistent $DOMAIN qemu+ssh://$REMOTE_HOST/system
# Clean up FDB entries after migration completes.
bridge fdb del $MAC dev $VF
bridge fdb del $MAC dev $TAP_IF master
On the destination hypervisor, a shared bridge 'br0' is created before migration
starts, and a VF from the destination PF is added to the bridge. Similarly an
appropriate FDB entry is added.
The following script is executed on the destination hypervisor once migration
completes, and it reattaches the VF to the VM and brings down the virtio-net
interface.
::
# reattach-vf.sh
#!/bin/bash #!/bin/bash
virsh attach-device $DOMAIN $VF_XML bridge fdb del 52:54:00:00:12:53 dev ens36v0
virsh domif-setlink $DOMAIN $TAP_IF down bridge fdb del 52:54:00:00:12:53 dev vmtap01 master
virsh attach-device --config --live vm01 vf.xml
virsh domif-setlink vm01 vmtap01 down