Skip to content

Commit 738baea

Browse files
copyninjadavem330
authored andcommitted
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>
1 parent 2b425ef commit 738baea

File tree

1 file changed

+88
-23
lines changed

1 file changed

+88
-23
lines changed

Documentation/networking/net_failover.rst

Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ To support this, the hypervisor needs to enable VIRTIO_NET_F_STANDBY
3535
feature on the virtio-net interface and assign the same MAC address to both
3636
virtio-net and VF interfaces.
3737

38-
Here is an example XML snippet that shows such configuration.
38+
Here is an example libvirt XML snippet that shows such configuration:
3939
::
4040

4141
<interface type='network'>
@@ -45,18 +45,32 @@ Here is an example XML snippet that shows such configuration.
4545
<model type='virtio'/>
4646
<driver name='vhost' queues='4'/>
4747
<link state='down'/>
48-
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
48+
<teaming type='persistent'/>
49+
<alias name='ua-backup0'/>
4950
</interface>
5051
<interface type='hostdev' managed='yes'>
5152
<mac address='52:54:00:00:12:53'/>
5253
<source>
5354
<address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
5455
</source>
55-
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
56+
<teaming type='transient' persistent='ua-backup0'/>
5657
</interface>
5758

59+
In this configuration, the first device definition is for the virtio-net
60+
interface and this acts as the 'persistent' device indicating that this
61+
interface will always be plugged in. This is specified by the 'teaming' tag with
62+
required attribute type having value 'persistent'. The link state for the
63+
virtio-net device is set to 'down' to ensure that the 'failover' netdev prefers
64+
the VF passthrough device for normal communication. The virtio-net device will
65+
be brought UP during live migration to allow uninterrupted communication.
66+
67+
The second device definition is for the VF passthrough interface. Here the
68+
'teaming' tag is provided with type 'transient' indicating that this device may
69+
periodically be unplugged. A second attribute - 'persistent' is provided and
70+
points to the alias name declared for the virtio-net device.
71+
5872
Booting a VM with the above configuration will result in the following 3
59-
netdevs created in the VM.
73+
interfaces created in the VM:
6074
::
6175

6276
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.
6579
valid_lft 42482sec preferred_lft 42482sec
6680
inet6 fe80::97d8:db2:8c10:b6d6/64 scope link
6781
valid_lft forever preferred_lft forever
68-
5: ens10nsby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master ens10 state UP group default qlen 1000
82+
5: ens10nsby: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master ens10 state DOWN group default qlen 1000
6983
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
7084
7: ens11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens10 state UP group default qlen 1000
7185
link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
7286

73-
ens10 is the 'failover' master netdev, ens10nsby and ens11 are the slave
74-
'standby' and 'primary' netdevs respectively.
87+
Here, ens10 is the 'failover' master interface, ens10nsby is the slave 'standby'
88+
virtio-net interface, and ens11 is the slave 'primary' VF passthrough interface.
89+
90+
One point to note here is that some user space network configuration daemons
91+
like systemd-networkd, ifupdown, etc, do not understand the 'net_failover'
92+
device; and on the first boot, the VM might end up with both 'failover' device
93+
and VF accquiring IP addresses (either same or different) from the DHCP server.
94+
This will result in lack of connectivity to the VM. So some tweaks might be
95+
needed to these network configuration daemons to make sure that an IP is
96+
received only on the 'failover' device.
97+
98+
Below is the patch snippet used with 'cloud-ifupdown-helper' script found on
99+
Debian cloud images:
100+
101+
::
102+
@@ -27,6 +27,8 @@ do_setup() {
103+
local working="$cfgdir/.$INTERFACE"
104+
local final="$cfgdir/$INTERFACE"
105+
106+
+ if [ -d "/sys/class/net/${INTERFACE}/master" ]; then exit 0; fi
107+
+
108+
if ifup --no-act "$INTERFACE" > /dev/null 2>&1; then
109+
# interface is already known to ifupdown, no need to generate cfg
110+
log "Skipping configuration generation for $INTERFACE"
111+
75112

76113
Live Migration of a VM with SR-IOV VF & virtio-net in STANDBY mode
77114
==================================================================
@@ -80,40 +117,68 @@ net_failover also enables hypervisor controlled live migration to be supported
80117
with VMs that have direct attached SR-IOV VF devices by automatic failover to
81118
the paravirtual datapath when the VF is unplugged.
82119

83-
Here is a sample script that shows the steps to initiate live migration on
84-
the source hypervisor.
120+
Here is a sample script that shows the steps to initiate live migration from
121+
the source hypervisor. Note: It is assumed that the VM is connected to a
122+
software bridge 'br0' which has a single VF attached to it along with the vnet
123+
device to the VM. This is not the VF that was passthrough'd to the VM (seen in
124+
the vf.xml file).
85125
::
86126

87-
# cat vf_xml
127+
# cat vf.xml
88128
<interface type='hostdev' managed='yes'>
89129
<mac address='52:54:00:00:12:53'/>
90130
<source>
91131
<address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
92132
</source>
93-
<address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
133+
<teaming type='transient' persistent='ua-backup0'/>
94134
</interface>
95135

96-
# Source Hypervisor
136+
# Source Hypervisor migrate.sh
97137
#!/bin/bash
98138

99-
DOMAIN=fedora27-tap01
100-
PF=enp66s0f0
101-
VF_NUM=5
102-
TAP_IF=tap01
103-
VF_XML=
139+
DOMAIN=vm-01
140+
PF=ens6np0
141+
VF=ens6v1 # VF attached to the bridge.
142+
VF_NUM=1
143+
TAP_IF=vmtap01 # virtio-net interface in the VM.
144+
VF_XML=vf.xml
104145

105146
MAC=52:54:00:00:12:53
106147
ZERO_MAC=00:00:00:00:00:00
107148

149+
# Set the virtio-net interface up.
108150
virsh domif-setlink $DOMAIN $TAP_IF up
109-
bridge fdb del $MAC dev $PF master
110-
virsh detach-device $DOMAIN $VF_XML
151+
152+
# Remove the VF that was passthrough'd to the VM.
153+
virsh detach-device --live --config $DOMAIN $VF_XML
154+
111155
ip link set $PF vf $VF_NUM mac $ZERO_MAC
112156

113-
virsh migrate --live $DOMAIN qemu+ssh://$REMOTE_HOST/system
157+
# Add FDB entry for traffic to continue going to the VM via
158+
# the VF -> br0 -> vnet interface path.
159+
bridge fdb add $MAC dev $VF
160+
bridge fdb add $MAC dev $TAP_IF master
161+
162+
# Migrate the VM
163+
virsh migrate --live --persistent $DOMAIN qemu+ssh://$REMOTE_HOST/system
164+
165+
# Clean up FDB entries after migration completes.
166+
bridge fdb del $MAC dev $VF
167+
bridge fdb del $MAC dev $TAP_IF master
114168

115-
# Destination Hypervisor
169+
On the destination hypervisor, a shared bridge 'br0' is created before migration
170+
starts, and a VF from the destination PF is added to the bridge. Similarly an
171+
appropriate FDB entry is added.
172+
173+
The following script is executed on the destination hypervisor once migration
174+
completes, and it reattaches the VF to the VM and brings down the virtio-net
175+
interface.
176+
177+
::
178+
# reattach-vf.sh
116179
#!/bin/bash
117180

118-
virsh attach-device $DOMAIN $VF_XML
119-
virsh domif-setlink $DOMAIN $TAP_IF down
181+
bridge fdb del 52:54:00:00:12:53 dev ens36v0
182+
bridge fdb del 52:54:00:00:12:53 dev vmtap01 master
183+
virsh attach-device --config --live vm01 vf.xml
184+
virsh domif-setlink vm01 vmtap01 down

0 commit comments

Comments
 (0)