1271696Sdelphij# $FreeBSD: stable/10/etc/devd/hyperv.conf 322129 2017-08-07 02:15:13Z sephe $ 2271696Sdelphij# 3271696Sdelphij# Hyper-V specific events 4271696Sdelphij 5271696Sdelphijnotify 10 { 6271696Sdelphij match "system" "DEVFS"; 7271696Sdelphij match "subsystem" "CDEV"; 8271696Sdelphij match "type" "CREATE"; 9272322Sdelphij match "cdev" "hv_kvp_dev"; 10271696Sdelphij action "/usr/sbin/hv_kvp_daemon"; 11271696Sdelphij}; 12271696Sdelphij 13271696Sdelphijnotify 10 { 14271696Sdelphij match "system" "DEVFS"; 15271696Sdelphij match "subsystem" "CDEV"; 16271696Sdelphij match "type" "DESTROY"; 17272322Sdelphij match "cdev" "hv_kvp_dev"; 18271696Sdelphij action "pkill -x hv_kvp_daemon"; 19271696Sdelphij}; 20310735Ssephe 21310735Ssephenotify 11 { 22310735Ssephe match "system" "DEVFS"; 23310735Ssephe match "subsystem" "CDEV"; 24310735Ssephe match "type" "CREATE"; 25310735Ssephe match "cdev" "hv_fsvss_dev"; 26310735Ssephe action "/usr/sbin/hv_vss_daemon"; 27310735Ssephe}; 28310735Ssephe 29310735Ssephenotify 11 { 30310735Ssephe match "system" "DEVFS"; 31310735Ssephe match "subsystem" "CDEV"; 32310735Ssephe match "type" "DESTROY"; 33310735Ssephe match "cdev" "hv_fsvss_dev"; 34310735Ssephe action "pkill -x hv_vss_daemon"; 35310735Ssephe}; 36322129Ssephe 37322129Ssephe# 38322129Ssephe# Rules for non-transparent network VF. 39322129Ssephe# 40322129Ssephe# How network VF works with hn(4) on Hyper-V in non-transparent mode: 41322129Ssephe# 42322129Ssephe# - Each network VF has a cooresponding hn(4). 43322129Ssephe# - The network VF and the it's cooresponding hn(4) have the same hardware 44322129Ssephe# address. 45322129Ssephe# - Once the network VF is up, e.g. ifconfig VF up: 46322129Ssephe# o All of the transmission should go through the network VF. 47322129Ssephe# o Most of the reception goes through the network VF. 48322129Ssephe# o Small amount of reception may go through the cooresponding hn(4). 49322129Ssephe# This reception will happen, even if the the cooresponding hn(4) is 50322129Ssephe# down. The cooresponding hn(4) will change the reception interface 51322129Ssephe# to the network VF, so that network layer and application layer will 52322129Ssephe# be tricked into thinking that these packets were received by the 53322129Ssephe# network VF. 54322129Ssephe# o The cooresponding hn(4) pretends the physical link is down. 55322129Ssephe# - Once the network VF is down or detached: 56322129Ssephe# o All of the transmission should go through the cooresponding hn(4). 57322129Ssephe# o All of the reception goes through the cooresponding hn(4). 58322129Ssephe# o The cooresponding hn(4) fallbacks to the original physical link 59322129Ssephe# detection logic. 60322129Ssephe# 61322129Ssephe# All these features are mainly used to help live migration, during which 62322129Ssephe# the network VF will be detached, while the network communication to the 63322129Ssephe# VM must not be cut off. In order to reach this level of live migration 64322129Ssephe# transparency, we use failover mode lagg(4) with the network VF and the 65322129Ssephe# cooresponding hn(4) attached to it. 66322129Ssephe# 67322129Ssephe# To ease user configuration for both network VF and non-network VF, the 68322129Ssephe# lagg(4) will be created by the following rules, and the configuration 69322129Ssephe# of the cooresponding hn(4) will be applied to the lagg(4) automatically. 70322129Ssephe# 71322129Ssephe# NOTE: 72322129Ssephe# If live migration is not needed at all, the following rules could be 73322129Ssephe# commented out, and the network VF interface could be used exclusively. 74322129Ssephe# Most often the cooresponding hn(4) could be completely ignored. 75322129Ssephe# 76322129Ssephe# 77322129Ssephe# Default workflow for the network VF bringup: 78322129Ssephe# 1) ETHERNET/IFATTACH -> VF interface up (delayed by rc.conf hyperv_vf_delay 79322129Ssephe# seconds). This operation will trigger HYPERV_NIC_VF/VF_UP. 80322129Ssephe# 2) HYPERV_NIC_VF/VF_UP: 81322129Ssephe# a) Create laggX coresponding to hnX. 82322129Ssephe# b) Add hnX and VF to laggX. 83322129Ssephe# c) Whack all previous network configuration on hnX, including stopping 84322129Ssephe# dhclient. 85322129Ssephe# d) Apply rc.conf ifconfig_hnX to laggX; i.e. including starting dhclient. 86322129Ssephe# 87322129Ssephe# NOTE: 88322129Ssephe# HYPERV_NIC_VF/VF_UP action script could be customized per-interface by 89322129Ssephe# adding /usr/libexec/hyperv/hyperv_vfup.hnX script. 90322129Ssephe# /usr/libexec/hyperv/hyperv_vfup could be used as the template for the 91322129Ssephe# customized per-interface script. 92322129Ssephe# 93322129Ssephe# NOTE: 94322129Ssephe# For transparent network VF, hyperv_vfattach does nothing and 95322129Ssephe# HYPERV_NIC_VF/VF_UP will not be triggered at all. 96322129Ssephe# 97322129Ssephe 98322129Ssephenotify 10 { 99322129Ssephe match "system" "HYPERV_NIC_VF"; 100322129Ssephe match "type" "VF_UP"; 101322129Ssephe action "/usr/libexec/hyperv/hyperv_vfup $subsystem"; 102322129Ssephe}; 103322129Ssephe 104322129Ssephenotify 10 { 105322129Ssephe match "system" "ETHERNET"; 106322129Ssephe match "type" "IFATTACH"; 107322129Ssephe action "/usr/libexec/hyperv/hyperv_vfattach $subsystem 0"; 108322129Ssephe}; 109