buildroot/package/linux-tools/S10hyperv
Pascal de Bruijn 2703383c72 package/linux-tools: add hyperv integration services
The hyperv integration services offer convenience features for guest
operating systems running on the microsoft hyperv virtualization
platform. They roughly are for HyperV what openvmtools are for VMWare.

The installed binary names are derived from what seems common in large
distros like RedHat:

  linux kernel source name -> installed binary name
             hv_vss_daemon -> hypervvssd
             hv_kvp_daemon -> hypervkvpd
           hv_fcopy_daemon -> hypervfcopyd

Each tool was introduced at different points in the kernel history, so
we need to check each of them.

We provide a single init script that is responsible for starting all
enabled programs. The global status will be the status of the last
program to fail to start, or empty (i.e. success) if they all started
successfuly.

However, we provide one systemd unit per program, because it is not easy
to use a single unit to start (and monitor) more than one executable.
Additionally, we do not provide a template that is filled at tinstall
time either, because it does not gain much (three simple units vs. a
template and some replacement code in the .mk).

Finally, the key-value daemon uses a few helper scripts to get/set the
network config. All are optional (their presence is checked before
running them), but one, hv_set_ifconfig. However, it is not strictly
speaking required either, so we just symlink it to /bin/true to avoid
any warning at runtime. Providing actual helpers is left to the end
user, to adapt to their own environment.

Signed-off-by: Pascal de Bruijn <p.debruijn@unilogic.nl>
[yann.morin.1998@free.fr:
  - aggregate all three tools in a single sub-package
  - introduce the main HV option, use a sub-option for each tool
  - aggregate the three init scripts into one
  - don't install the helpers; symlink the mandatory one
  - don't create symlinks for systemd units (systemctl preset-all does
    it for us now)
  - expand commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2020-01-04 16:08:34 +01:00

67 lines
1.1 KiB
Bash

#!/bin/sh
PROGS="@PROGS@"
PIDDIR="/var/run"
# shellcheck source=/dev/null
[ -r "/etc/default/hyperv" ] && . "/etc/default/hyperv"
start_one() {
printf 'Starting %s: ' "$1"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -m -S -q -p "$PIDDIR/$1.pid" -x "/sbin/$1" -- -n
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return $status
}
start() {
# shellcheck disable=SC2086 # we need the word splitting
for prog in ${PROGS}; do
start_one "${prog}" || ret=$?
done
return $ret
}
stop_one() {
printf 'Stopping %s: ' "$1"
start-stop-daemon -K -q -p "$PIDDIR/$1.pid"
status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDDIR/$1.pid"
echo "OK"
else
echo "FAIL"
fi
return $status
}
stop() {
# shellcheck disable=SC2086 # we need the word splitting
for prog in ${PROGS}; do
stop_one "${prog}" || ret=$?
done
return $ret
}
restart() {
stop
sleep 1
start
}
case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature.
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac