From f38530676caf0a6e9637453a93d886cd96f5c9ae Mon Sep 17 00:00:00 2001 From: delphij Date: Wed, 17 Sep 2014 02:32:22 +0000 Subject: [PATCH] Use a devd event to start hv_kvpd instead of doing so in rc.d script. This is cleaner and eliminates the unneeded startup of KVP daemon on systems that do not run as a Hyper-V guest. Submitted by: hrs X-MFC-with: 271493, 271688, 271699 --- ObsoleteFiles.inc | 2 ++ etc/defaults/rc.conf | 2 -- etc/devd/Makefile | 4 ++++ etc/devd/hyperv.conf | 19 +++++++++++++++++++ etc/rc.d/Makefile | 5 ----- etc/rc.d/hv_kvpd | 16 ---------------- tools/build/mk/OptionalObsoleteFiles.inc | 2 +- 7 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 etc/devd/hyperv.conf delete mode 100644 etc/rc.d/hv_kvpd diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index ede94fdd130e..e2f431771f31 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20140917: hv_kvpd rc.d script removed in favor of devd configuration +OLD_FILES+=etc/rc.d/hv_kvpd # 20140814: libopie version bump OLD_LIBS+=usr/lib/libopie.so.7 OLD_LIBS+=usr/lib32/libopie.so.7 diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 5efe78b9c166..b24e869cdd43 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -684,8 +684,6 @@ jail_enable="NO" # Set to NO to disable starting of any jails jail_parallel_start="NO" # Start jails in the background jail_list="" # Space separated list of names of jails -hv_kvpd_enable="NO" # Start the Hyper-V key-value Pair Driver hv_kvp(4) - ############################################################## ### Define source_rc_confs, the mechanism used by /etc/rc.* ## ### scripts to source rc_conf_files overrides safely. ## diff --git a/etc/devd/Makefile b/etc/devd/Makefile index 94cafdc66288..82a5000ff8ae 100644 --- a/etc/devd/Makefile +++ b/etc/devd/Makefile @@ -18,6 +18,10 @@ FILES+= uath.conf usb.conf FILES+= zfs.conf .endif +.if ${MK_HYPERV} != "no" +FILES+= hyperv.conf +.endif + NO_OBJ= FILESDIR= /etc/devd FILESMODE= 644 diff --git a/etc/devd/hyperv.conf b/etc/devd/hyperv.conf new file mode 100644 index 000000000000..8abafa9dba4e --- /dev/null +++ b/etc/devd/hyperv.conf @@ -0,0 +1,19 @@ +# $FreeBSD$ +# +# Hyper-V specific events + +notify 10 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "CREATE"; + match "cdev" "/dev/hv_kvp_dev"; + action "/usr/sbin/hv_kvp_daemon"; +}; + +notify 10 { + match "system" "DEVFS"; + match "subsystem" "CDEV"; + match "type" "DESTROY"; + match "cdev" "/dev/hv_kvp_dev"; + action "pkill -x hv_kvp_daemon"; +}; diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile index d0897e3e905d..64e83ac8ca50 100644 --- a/etc/rc.d/Makefile +++ b/etc/rc.d/Makefile @@ -57,7 +57,6 @@ FILES= DAEMON \ hostid \ hostid_save \ hostname \ - ${_hv_kvpd} \ inetd \ initrandom \ ip6addrctl \ @@ -193,10 +192,6 @@ _ubthidhci= ubthidhci _casperd= casperd .endif -.if ${MK_HYPERV} != "no" -_hv_kvpd= hv_kvpd -.endif - .if ${MK_UNBOUND} != "no" _unbound= local_unbound .endif diff --git a/etc/rc.d/hv_kvpd b/etc/rc.d/hv_kvpd deleted file mode 100644 index 164ec53c2400..000000000000 --- a/etc/rc.d/hv_kvpd +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -# -# $FreeBSD$ -# - -# PROVIDE: hv_kvpd - -. /etc/rc.subr - -name="hv_kvp_daemon" -rcvar="hv_kvpd_enable" -command="/usr/sbin/${name}" -required_dirs="/var/db/hyperv" - -load_rc_config $name -run_rc_command "$1" diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index a0cffcfe0a07..faa59cb77f27 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4768,7 +4768,7 @@ OLD_FILES+=usr/share/examples/dma/mailer.conf .endif .if ${MK_HYPERV} == no -OLD_FILES+=etc/rc.d/hv_kvpd +OLD_FILES+=etc/devd/hyperv.conf OLD_FILES+=usr/libexec/hyperv/hv_set_ifconfig OLD_FILES+=usr/libexec/hyperv/hv_get_dns_info OLD_FILES+=usr/libexec/hyperv/hv_get_dhcp_info