xref: /src/sbin/devd/hyperv.conf (revision d4a0e749cc66cd5d019d8fb8f43427109aef4c9f)
176cd7220SXin LI#
276cd7220SXin LI# Hyper-V specific events
376cd7220SXin LI
476cd7220SXin LInotify 10 {
576cd7220SXin LI	match "system"		"DEVFS";
676cd7220SXin LI	match "subsystem"	"CDEV";
776cd7220SXin LI	match "type"		"CREATE";
802032ae5SHiroki Sato	match "cdev"		"hv_kvp_dev";
976cd7220SXin LI	action "/usr/sbin/hv_kvp_daemon";
1076cd7220SXin LI};
1176cd7220SXin LI
1276cd7220SXin LInotify 10 {
1376cd7220SXin LI	match "system"		"DEVFS";
1476cd7220SXin LI	match "subsystem"	"CDEV";
1576cd7220SXin LI	match "type"		"DESTROY";
1602032ae5SHiroki Sato	match "cdev"		"hv_kvp_dev";
1776cd7220SXin LI	action "pkill -x hv_kvp_daemon";
1876cd7220SXin LI};
19168fce73SSepherosa Ziehau
20168fce73SSepherosa Ziehaunotify 11 {
21168fce73SSepherosa Ziehau	match "system"		"DEVFS";
22168fce73SSepherosa Ziehau	match "subsystem"	"CDEV";
23168fce73SSepherosa Ziehau	match "type"		"CREATE";
24168fce73SSepherosa Ziehau	match "cdev"		"hv_fsvss_dev";
25168fce73SSepherosa Ziehau	action "/usr/sbin/hv_vss_daemon";
26168fce73SSepherosa Ziehau};
27168fce73SSepherosa Ziehau
28168fce73SSepherosa Ziehaunotify 11 {
29168fce73SSepherosa Ziehau	match "system"		"DEVFS";
30168fce73SSepherosa Ziehau	match "subsystem"	"CDEV";
31168fce73SSepherosa Ziehau	match "type"		"DESTROY";
32168fce73SSepherosa Ziehau	match "cdev"		"hv_fsvss_dev";
33168fce73SSepherosa Ziehau	action "pkill -x hv_vss_daemon";
34168fce73SSepherosa Ziehau};
35c6859569SSepherosa Ziehau
36c6859569SSepherosa Ziehau#
37c6859569SSepherosa Ziehau# Rules for non-transparent network VF.
38c6859569SSepherosa Ziehau#
39c6859569SSepherosa Ziehau# How network VF works with hn(4) on Hyper-V in non-transparent mode:
40c6859569SSepherosa Ziehau#
41dae3a64fSEitan Adler# - Each network VF has a corresponding hn(4).
42dae3a64fSEitan Adler# - The network VF and the it's corresponding hn(4) have the same hardware
43c6859569SSepherosa Ziehau#   address.
44c6859569SSepherosa Ziehau# - Once the network VF is up, e.g. ifconfig VF up:
45c6859569SSepherosa Ziehau#   o  All of the transmission should go through the network VF.
46c6859569SSepherosa Ziehau#   o  Most of the reception goes through the network VF.
47dae3a64fSEitan Adler#   o  Small amount of reception may go through the corresponding hn(4).
48dae3a64fSEitan Adler#      This reception will happen, even if the corresponding hn(4) is
49dae3a64fSEitan Adler#      down.  The corresponding hn(4) will change the reception interface
50c6859569SSepherosa Ziehau#      to the network VF, so that network layer and application layer will
51c6859569SSepherosa Ziehau#      be tricked into thinking that these packets were received by the
52c6859569SSepherosa Ziehau#      network VF.
53dae3a64fSEitan Adler#   o  The corresponding hn(4) pretends the physical link is down.
54c6859569SSepherosa Ziehau# - Once the network VF is down or detached:
55dae3a64fSEitan Adler#   o  All of the transmission should go through the corresponding hn(4).
56dae3a64fSEitan Adler#   o  All of the reception goes through the corresponding hn(4).
57dae3a64fSEitan Adler#   o  The corresponding hn(4) fallbacks to the original physical link
58c6859569SSepherosa Ziehau#      detection logic.
59c6859569SSepherosa Ziehau#
60c6859569SSepherosa Ziehau# All these features are mainly used to help live migration, during which
61c6859569SSepherosa Ziehau# the network VF will be detached, while the network communication to the
62c6859569SSepherosa Ziehau# VM must not be cut off.  In order to reach this level of live migration
63c6859569SSepherosa Ziehau# transparency, we use failover mode lagg(4) with the network VF and the
64dae3a64fSEitan Adler# corresponding hn(4) attached to it.
65c6859569SSepherosa Ziehau#
66c6859569SSepherosa Ziehau# To ease user configuration for both network VF and non-network VF, the
67c6859569SSepherosa Ziehau# lagg(4) will be created by the following rules, and the configuration
68dae3a64fSEitan Adler# of the corresponding hn(4) will be applied to the lagg(4) automatically.
69c6859569SSepherosa Ziehau#
70c6859569SSepherosa Ziehau# NOTE:
71c6859569SSepherosa Ziehau# If live migration is not needed at all, the following rules could be
72c6859569SSepherosa Ziehau# commented out, and the network VF interface could be used exclusively.
73dae3a64fSEitan Adler# Most often the corresponding hn(4) could be completely ignored.
74c6859569SSepherosa Ziehau#
75c6859569SSepherosa Ziehau#
76c6859569SSepherosa Ziehau# Default workflow for the network VF bringup:
77c6859569SSepherosa Ziehau# 1) ETHERNET/IFATTACH -> VF interface up (delayed by rc.conf hyperv_vf_delay
78c6859569SSepherosa Ziehau#    seconds).  This operation will trigger HYPERV_NIC_VF/VF_UP.
79c6859569SSepherosa Ziehau# 2) HYPERV_NIC_VF/VF_UP:
80e09d161bSGordon Bergling#    a) Create laggX corresponding to hnX.
81c6859569SSepherosa Ziehau#    b) Add hnX and VF to laggX.
82c6859569SSepherosa Ziehau#    c) Whack all previous network configuration on hnX, including stopping
83c6859569SSepherosa Ziehau#       dhclient.
84c6859569SSepherosa Ziehau#    d) Apply rc.conf ifconfig_hnX to laggX; i.e. including starting dhclient.
85c6859569SSepherosa Ziehau#
86c6859569SSepherosa Ziehau# NOTE:
87c6859569SSepherosa Ziehau# HYPERV_NIC_VF/VF_UP action script could be customized per-interface by
88c6859569SSepherosa Ziehau# adding /usr/libexec/hyperv/hyperv_vfup.hnX script.
89c6859569SSepherosa Ziehau# /usr/libexec/hyperv/hyperv_vfup could be used as the template for the
90c6859569SSepherosa Ziehau# customized per-interface script.
91c6859569SSepherosa Ziehau#
92c6859569SSepherosa Ziehau# NOTE:
93c6859569SSepherosa Ziehau# For transparent network VF, hyperv_vfattach does nothing and
94c6859569SSepherosa Ziehau# HYPERV_NIC_VF/VF_UP will not be triggered at all.
95c6859569SSepherosa Ziehau#
96c6859569SSepherosa Ziehau
97c6859569SSepherosa Ziehaunotify 10 {
98c6859569SSepherosa Ziehau	match "system"		"HYPERV_NIC_VF";
99c6859569SSepherosa Ziehau	match "type"		"VF_UP";
100c6859569SSepherosa Ziehau	action "/usr/libexec/hyperv/hyperv_vfup $subsystem";
101c6859569SSepherosa Ziehau};
102c6859569SSepherosa Ziehau
103c6859569SSepherosa Ziehaunotify 10 {
104c6859569SSepherosa Ziehau	match "system"		"ETHERNET";
105c6859569SSepherosa Ziehau	match "type"		"IFATTACH";
106*d4a0e749SEugene Grosbein	match "vm_guest"	"hv";
107c6859569SSepherosa Ziehau	action "/usr/libexec/hyperv/hyperv_vfattach $subsystem 0";
108c6859569SSepherosa Ziehau};
109