net_failover.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ============
  3. NET_FAILOVER
  4. ============
  5. Overview
  6. ========
  7. The net_failover driver provides an automated failover mechanism via APIs
  8. to create and destroy a failover master netdev and manages a primary and
  9. standby slave netdevs that get registered via the generic failover
  10. infrastructure.
  11. The failover netdev acts a master device and controls 2 slave devices. The
  12. original paravirtual interface is registered as 'standby' slave netdev and
  13. a passthru/vf device with the same MAC gets registered as 'primary' slave
  14. netdev. Both 'standby' and 'failover' netdevs are associated with the same
  15. 'pci' device. The user accesses the network interface via 'failover' netdev.
  16. The 'failover' netdev chooses 'primary' netdev as default for transmits when
  17. it is available with link up and running.
  18. This can be used by paravirtual drivers to enable an alternate low latency
  19. datapath. It also enables hypervisor controlled live migration of a VM with
  20. direct attached VF by failing over to the paravirtual datapath when the VF
  21. is unplugged.
  22. virtio-net accelerated datapath: STANDBY mode
  23. =============================================
  24. net_failover enables hypervisor controlled accelerated datapath to virtio-net
  25. enabled VMs in a transparent manner with no/minimal guest userspace changes.
  26. To support this, the hypervisor needs to enable VIRTIO_NET_F_STANDBY
  27. feature on the virtio-net interface and assign the same MAC address to both
  28. virtio-net and VF interfaces.
  29. Here is an example XML snippet that shows such configuration.
  30. ::
  31. <interface type='network'>
  32. <mac address='52:54:00:00:12:53'/>
  33. <source network='enp66s0f0_br'/>
  34. <target dev='tap01'/>
  35. <model type='virtio'/>
  36. <driver name='vhost' queues='4'/>
  37. <link state='down'/>
  38. <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
  39. </interface>
  40. <interface type='hostdev' managed='yes'>
  41. <mac address='52:54:00:00:12:53'/>
  42. <source>
  43. <address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
  44. </source>
  45. <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
  46. </interface>
  47. Booting a VM with the above configuration will result in the following 3
  48. netdevs created in the VM.
  49. ::
  50. 4: ens10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
  51. link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
  52. inet 192.168.12.53/24 brd 192.168.12.255 scope global dynamic ens10
  53. valid_lft 42482sec preferred_lft 42482sec
  54. inet6 fe80::97d8:db2:8c10:b6d6/64 scope link
  55. valid_lft forever preferred_lft forever
  56. 5: ens10nsby: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master ens10 state UP group default qlen 1000
  57. link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
  58. 7: ens11: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ens10 state UP group default qlen 1000
  59. link/ether 52:54:00:00:12:53 brd ff:ff:ff:ff:ff:ff
  60. ens10 is the 'failover' master netdev, ens10nsby and ens11 are the slave
  61. 'standby' and 'primary' netdevs respectively.
  62. Live Migration of a VM with SR-IOV VF & virtio-net in STANDBY mode
  63. ==================================================================
  64. net_failover also enables hypervisor controlled live migration to be supported
  65. with VMs that have direct attached SR-IOV VF devices by automatic failover to
  66. the paravirtual datapath when the VF is unplugged.
  67. Here is a sample script that shows the steps to initiate live migration on
  68. the source hypervisor.
  69. ::
  70. # cat vf_xml
  71. <interface type='hostdev' managed='yes'>
  72. <mac address='52:54:00:00:12:53'/>
  73. <source>
  74. <address type='pci' domain='0x0000' bus='0x42' slot='0x02' function='0x5'/>
  75. </source>
  76. <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
  77. </interface>
  78. # Source Hypervisor
  79. #!/bin/bash
  80. DOMAIN=fedora27-tap01
  81. PF=enp66s0f0
  82. VF_NUM=5
  83. TAP_IF=tap01
  84. VF_XML=
  85. MAC=52:54:00:00:12:53
  86. ZERO_MAC=00:00:00:00:00:00
  87. virsh domif-setlink $DOMAIN $TAP_IF up
  88. bridge fdb del $MAC dev $PF master
  89. virsh detach-device $DOMAIN $VF_XML
  90. ip link set $PF vf $VF_NUM mac $ZERO_MAC
  91. virsh migrate --live $DOMAIN qemu+ssh://$REMOTE_HOST/system
  92. # Destination Hypervisor
  93. #!/bin/bash
  94. virsh attach-device $DOMAIN $VF_XML
  95. virsh domif-setlink $DOMAIN $TAP_IF down