Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services
@ 2020-01-03  8:53 Pascal de Bruijn
  0 siblings, 0 replies; 6+ messages in thread
From: Pascal de Bruijn @ 2020-01-03  8:53 UTC (permalink / raw)
  To: buildroot

The hyperv integration services offer convenience features
for guest operating systems running on the microsoft hyperv
virtualization platform.

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

The installed binary names are derived from what seems common
in large distros like RedHat/Ubuntu.

The hyperv integration services are a rough functional
equivalent of openvmtools (in context of vmware)

This commits depends on
  "add hooks for busybox init and systemd service installation"

Signed-off-by: Pascal de Bruijn <p.debruijn@unilogic.nl>
---
 DEVELOPERS                                         |  9 +++++
 package/linux-tools/Config.in                      | 43 ++++++++++++++++++++
 .../linux-tools/linux-tool-hv_fcopy_daemon.init    | 47 ++++++++++++++++++++++
 .../linux-tools/linux-tool-hv_fcopy_daemon.mk.in   | 39 ++++++++++++++++++
 .../linux-tools/linux-tool-hv_fcopy_daemon.service | 11 +++++
 package/linux-tools/linux-tool-hv_kvp_daemon.init  | 47 ++++++++++++++++++++++
 package/linux-tools/linux-tool-hv_kvp_daemon.mk.in | 42 +++++++++++++++++++
 .../linux-tools/linux-tool-hv_kvp_daemon.service   | 11 +++++
 package/linux-tools/linux-tool-hv_vss_daemon.init  | 47 ++++++++++++++++++++++
 package/linux-tools/linux-tool-hv_vss_daemon.mk.in | 38 +++++++++++++++++
 .../linux-tools/linux-tool-hv_vss_daemon.service   | 11 +++++
 11 files changed, 345 insertions(+)
 create mode 100644 package/linux-tools/linux-tool-hv_fcopy_daemon.init
 create mode 100644 package/linux-tools/linux-tool-hv_fcopy_daemon.mk.in
 create mode 100644 package/linux-tools/linux-tool-hv_fcopy_daemon.service
 create mode 100644 package/linux-tools/linux-tool-hv_kvp_daemon.init
 create mode 100644 package/linux-tools/linux-tool-hv_kvp_daemon.mk.in
 create mode 100644 package/linux-tools/linux-tool-hv_kvp_daemon.service
 create mode 100644 package/linux-tools/linux-tool-hv_vss_daemon.init
 create mode 100644 package/linux-tools/linux-tool-hv_vss_daemon.mk.in
 create mode 100644 package/linux-tools/linux-tool-hv_vss_daemon.service

diff --git a/DEVELOPERS b/DEVELOPERS
index 90941dd..209b546 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1861,6 +1861,15 @@ F:	package/scrypt/
 
 N:	Pascal de Bruijn <p.debruijn@unilogic.nl>
 F:	package/libargon2/
+F:	package/linux-tools/linux-tool-hv_fcopy_daemon.init
+F:	package/linux-tools/linux-tool-hv_fcopy_daemon.mk.in
+F:	package/linux-tools/linux-tool-hv_fcopy_daemon.service
+F:	package/linux-tools/linux-tool-hv_kvp_daemon.init
+F:	package/linux-tools/linux-tool-hv_kvp_daemon.mk.in
+F:	package/linux-tools/linux-tool-hv_kvp_daemon.service
+F:	package/linux-tools/linux-tool-hv_vss_daemon.init
+F:	package/linux-tools/linux-tool-hv_vss_daemon.mk.in
+F:	package/linux-tools/linux-tool-hv_vss_daemon.service
 
 N:	Pascal Huerst <pascal.huerst@gmail.com>
 F:	package/google-breakpad/
diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
index ab8cc38..c37a8c1 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -116,4 +116,47 @@ config BR2_PACKAGE_LINUX_TOOLS_TMON
 	  tmon is a terminal-based tool (using curses) that allows the
 	  user to access thermal information about the system.
 
+menu "Microsoft HyperV Integration Services"
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_VSS_DAEMON
+	bool "hypervvssd (hv_vss_daemon)"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_LINUX_TOOLS
+	help
+	  Microsoft HyperV Volume Snapshot Service daemon
+
+	  HyperV uses hypervvssd to freeze your filesystems
+	  during snapshots and backups
+
+	  Relevant kernel configuration options:
+	  HYPERV, HYPERV_UTILS
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON
+	bool "hypervkvpd (hv_kvp_daemon)"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_LINUX_TOOLS
+	help
+	  Microsoft HyperV Key/Value Pair daemon
+
+	  HyperV uses hypervkvpd to retrieve status information
+	  from your virtualized guest OS
+
+	  Relevant kernel configuration options:
+	  HYPERV, HYPERV_UTILS
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_FCOPY_DAEMON
+	bool "hypervfcopyd (hv_fcopy_daemon)"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_LINUX_TOOLS
+	help
+	  Microsoft HyperV File Copy daemon
+
+	  HyperV uses hypervfcopyd to easily transfer files
+	  to and from your virtualized guest OS
+
+	  Relevant kernel configuration options:
+	  HYPERV, HYPERV_UTILS
+
+endmenu
+
 endmenu
diff --git a/package/linux-tools/linux-tool-hv_fcopy_daemon.init b/package/linux-tools/linux-tool-hv_fcopy_daemon.init
new file mode 100644
index 0000000..260aed3
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_fcopy_daemon.init
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+DAEMON="hypervfcopyd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+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
diff --git a/package/linux-tools/linux-tool-hv_fcopy_daemon.mk.in b/package/linux-tools/linux-tool-hv_fcopy_daemon.mk.in
new file mode 100644
index 0000000..b0c150d
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_fcopy_daemon.mk.in
@@ -0,0 +1,39 @@
+################################################################################
+#
+# hv_fcopy_daemon
+#
+################################################################################
+
+LINUX_TOOLS += hv_fcopy_daemon
+
+HV_FCOPY_DAEMON_MAKE_OPTS = CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)"
+
+define HV_FCOPY_DAEMON_BUILD_CMDS
+	$(Q)if test ! -f $(LINUX_DIR)/tools/hv/hv_fcopy_daemon.c ; then \
+		echo "Your kernel version is too old and does not have the HyperV FCOPY daemon tool." ; \
+		exit 1 ; \
+	fi
+
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/hv \
+		$(HV_FCOPY_DAEMON_MAKE_OPTS) \
+		hv_fcopy_daemon
+endef
+
+define HV_FCOPY_DAEMON_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/hv_fcopy_daemon \
+		$(TARGET_DIR)/usr/sbin/hypervfcopyd
+endef
+
+define HV_FCOPY_DAEMON_INSTALL_INIT_SYSTEMD
+        mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+        $(INSTALL) -m 0644 -D package/linux-tools/linux-tool-hv_fcopy_daemon.service \
+                $(TARGET_DIR)/usr/lib/systemd/system/hypervfcopyd.service
+	ln -sf ../../../../usr/lib/systemd/system/hv_fcopy_daemon.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/hypervfcopyd.service
+endef
+
+define HV_FCOPY_DAEMON_INSTALL_INIT_SYSV
+	$(INSTALL) -m 0755 -D package/linux-tools/linux-tool-hv_fcopy_daemon.init \
+		$(TARGET_DIR)/etc/init.d/S10hypervfcopyd
+endef
+
diff --git a/package/linux-tools/linux-tool-hv_fcopy_daemon.service b/package/linux-tools/linux-tool-hv_fcopy_daemon.service
new file mode 100644
index 0000000..c43fc1b
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_fcopy_daemon.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV FCopy daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervfcopyd -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/linux-tools/linux-tool-hv_kvp_daemon.init b/package/linux-tools/linux-tool-hv_kvp_daemon.init
new file mode 100644
index 0000000..dd47179
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_kvp_daemon.init
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+DAEMON="hypervkvpd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+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
diff --git a/package/linux-tools/linux-tool-hv_kvp_daemon.mk.in b/package/linux-tools/linux-tool-hv_kvp_daemon.mk.in
new file mode 100644
index 0000000..08199b1
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_kvp_daemon.mk.in
@@ -0,0 +1,42 @@
+################################################################################
+#
+# hv_kvp_daemon
+#
+################################################################################
+
+LINUX_TOOLS += hv_kvp_daemon
+
+HV_KVP_DAEMON_MAKE_OPTS = CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)"
+
+define HV_KVP_DAEMON_BUILD_CMDS
+	$(Q)if test ! -f $(LINUX_DIR)/tools/hv/hv_kvp_daemon.c ; then \
+		echo "Your kernel version is too old and does not have the HyperV KVP daemon tool." ; \
+		exit 1 ; \
+	fi
+
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/hv \
+		$(HV_KVP_DAEMON_MAKE_OPTS) \
+		hv_kvp_daemon
+endef
+
+define HV_KVP_DAEMON_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/hv_kvp_daemon \
+		$(TARGET_DIR)/usr/sbin/hypervkvpd
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/hv_get_dhcp_info.sh \
+		$(TARGET_DIR)/usr/libexec/hypervkvpd/hv_get_dhcp_info
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/hv_get_dns_info.sh \
+		$(TARGET_DIR)/usr/libexec/hypervkvpd/hv_get_dns_info
+endef
+
+define HV_KVP_DAEMON_INSTALL_INIT_SYSTEMD
+        mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+        $(INSTALL) -m 0644 -D package/linux-tools/linux-tool-hv_kvp_daemon.service \
+                $(TARGET_DIR)/usr/lib/systemd/system/hypervkvpd.service
+	ln -sf ../../../../usr/lib/systemd/system/hv_kvp_daemon.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/hypervkvpd.service
+endef
+
+define HV_KVP_DAEMON_INSTALL_INIT_SYSV
+        $(INSTALL) -m 0755 -D package/linux-tools/linux-tool-hv_kvp_daemon.init \
+                $(TARGET_DIR)/etc/init.d/S10hypervkvpd
+endef
diff --git a/package/linux-tools/linux-tool-hv_kvp_daemon.service b/package/linux-tools/linux-tool-hv_kvp_daemon.service
new file mode 100644
index 0000000..6ed6302
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_kvp_daemon.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV KVP daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervkvpd -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/linux-tools/linux-tool-hv_vss_daemon.init b/package/linux-tools/linux-tool-hv_vss_daemon.init
new file mode 100644
index 0000000..664c5ba
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_vss_daemon.init
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+DAEMON="hypervvssd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" -- -n
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+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
diff --git a/package/linux-tools/linux-tool-hv_vss_daemon.mk.in b/package/linux-tools/linux-tool-hv_vss_daemon.mk.in
new file mode 100644
index 0000000..e165f45
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_vss_daemon.mk.in
@@ -0,0 +1,38 @@
+################################################################################
+#
+# hv_vss_daemon
+#
+################################################################################
+
+LINUX_TOOLS += hv_vss_daemon
+
+HV_VSS_DAEMON_MAKE_OPTS = CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)"
+
+define HV_VSS_DAEMON_BUILD_CMDS
+	$(Q)if test ! -f $(LINUX_DIR)/tools/hv/hv_vss_daemon.c ; then \
+		echo "Your kernel version is too old and does not have the HyperV VSS daemon tool." ; \
+		exit 1 ; \
+	fi
+
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/hv \
+		$(HV_VSS_DAEMON_MAKE_OPTS) \
+		hv_vss_daemon
+endef
+
+define HV_VSS_DAEMON_INSTALL_TARGET_CMDS
+	$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/hv_vss_daemon \
+		$(TARGET_DIR)/usr/sbin/hypervvssd
+endef
+
+define HV_VSS_DAEMON_INSTALL_INIT_SYSTEMD
+        mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+        $(INSTALL) -m 0644 -D package/linux-tools/linux-tool-hv_vss_daemon.service \
+                $(TARGET_DIR)/usr/lib/systemd/system/hypervvssd.service
+	ln -sf ../../../../usr/lib/systemd/system/hv_vss_daemon.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/hypervvssd.service
+endef
+
+define HV_VSS_DAEMON_INSTALL_INIT_SYSV
+        $(INSTALL) -m 0755 -D package/linux-tools/linux-tool-hv_vss_daemon.init \
+                $(TARGET_DIR)/etc/init.d/S10hypervvssd
+endef
diff --git a/package/linux-tools/linux-tool-hv_vss_daemon.service b/package/linux-tools/linux-tool-hv_vss_daemon.service
new file mode 100644
index 0000000..3fd8002
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv_vss_daemon.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV VSS daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervvssd -n
+
+[Install]
+WantedBy=multi-user.target
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 0/2] package/linux-tools: add microsoft HyperV integration services (branch yem/hyperv)
@ 2020-01-03 19:57 Yann E. MORIN
  2020-01-03 19:57 ` [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files Yann E. MORIN
  2020-01-03 19:57 ` [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services Yann E. MORIN
  0 siblings, 2 replies; 6+ messages in thread
From: Yann E. MORIN @ 2020-01-03 19:57 UTC (permalink / raw)
  To: buildroot

Hello All!

This small series introduces the Microsoft HyperV (HV) integration
services daemons, as options to the linux-tools package.

The guts of the changes were done by Pascal, and Pascal deserve the most
kudos for their initial work. ;-)

However, I (Yann) have done quite some deep changes.

Where Pascal provided three init scripts, one for each daemon, all
identical save for the name of the daemon itself, I did gather the three
into a single one, which is responsible for starting all three daemons;
see the details in patch 2. On IRC, Pascal said they were not totally
very happy with this change. We need to come to a conclusion on this
(initial patch: https://patchwork.ozlabs.org/patch/1217243/).

Additionally, the initial work used three independent sub-packages, one
for each program. Again, they were mostly identical, save for the name
of the program, and a very trivial deviation for one of them. There
again, I aggregated the three into a single sub-package, and removed the
sub-menu in favour of three sub-options (like we already had for perf).

Finally, after discussions on IRC, Pascal and I concluded that we did
not need to install the helper scripts for one of the program, because
they do not make sense for Pascal's use-case (they would not be able to
test them), and the ones installed by the kernel are just templates that
would not even work in Buildroot's case anyway.

What I did not change, however, was the renaming of the programs.
Pascal's initial work did a rename of the programs upon installation,
and names them as RedHat/Ubuntu do. However, I checked that Ubuntu does
in fact not rename the tools, but Pascal has a good case that the names
are better, and at least matches the name of the runtime helpers
location directory. I kept the renaming, but still think this is up for
debate...

Now, I'd like to thank Pascal for their initial work, and for their
precious help and comments on IRC. Thanks! :-)


Regards,
Yann E. MORIN.


The following changes since commit 198bdaadd03f75fe959c21089c354d36c90069bc

  .gitlab-ci.yml: add missing python-avro test (2020-01-02 21:55:22 +0100)


are available in the git repository at:

  git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 07a3e4666570e40666cc8dd518ffce582bbf7f38

  package/linux-tools: add hyperv integration services (2020-01-03 20:50:02 +0100)


----------------------------------------------------------------
Pascal de Bruijn (2):
      package/linux-tools: add support for installing init system files
      package/linux-tools: add hyperv integration services

 DEVELOPERS                               |  3 ++
 package/linux-tools/Config.in            | 37 ++++++++++++++++++
 package/linux-tools/S10hyperv            | 66 ++++++++++++++++++++++++++++++++
 package/linux-tools/hypervfcopyd.service | 11 ++++++
 package/linux-tools/hypervkvpd.service   | 11 ++++++
 package/linux-tools/hypervvssd.service   | 11 ++++++
 package/linux-tools/linux-tool-hv.mk.in  | 61 +++++++++++++++++++++++++++++
 package/linux-tools/linux-tools.mk       | 22 +++++++++++
 8 files changed, 222 insertions(+)
 create mode 100644 package/linux-tools/S10hyperv
 create mode 100644 package/linux-tools/hypervfcopyd.service
 create mode 100644 package/linux-tools/hypervkvpd.service
 create mode 100644 package/linux-tools/hypervvssd.service
 create mode 100644 package/linux-tools/linux-tool-hv.mk.in

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files
  2020-01-03 19:57 [Buildroot] [PATCH 0/2] package/linux-tools: add microsoft HyperV integration services (branch yem/hyperv) Yann E. MORIN
@ 2020-01-03 19:57 ` Yann E. MORIN
  2020-01-04 15:19   ` Thomas Petazzoni
  2020-01-03 19:57 ` [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services Yann E. MORIN
  1 sibling, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2020-01-03 19:57 UTC (permalink / raw)
  To: buildroot

From: Pascal de Bruijn <p.debruijn@unilogic.nl>

Some linux tools (e.g. the Microsoft HyperV convenience utilities) will
install programs tostart at boot time, so they need to be able to
install init files (systemd units, sysv init script, or openrc units).

Unlike the other commands, we are redefining the real _INSTALL_INIT_*
macros, rather than use hooks, to let the infra call those at the right
moment.

We must be careful about the openrc support, though: if two tools are
enabled, one which provides sysv scripts but no openrc config, and the
other which provides openrc config, and we are using openrc as init
system, then we want to use the sysv scripts from the former as well as
the openrc config of the latter. Thus we need to duplicate a bit the
openrc logic here.

Signed-off-by: Pascal de Bruijn <p.debruijn@unilogic.nl>
[yann.morin.1998 at free.fr:
  - define macros, not hooks
  - introduce support for openrc too
  - expand commit log
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 package/linux-tools/linux-tools.mk | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/package/linux-tools/linux-tools.mk b/package/linux-tools/linux-tools.mk
index ac4da59b17..65d9e850e0 100644
--- a/package/linux-tools/linux-tools.mk
+++ b/package/linux-tools/linux-tools.mk
@@ -42,4 +42,26 @@ LINUX_TOOLS_POST_INSTALL_TARGET_HOOKS += $(foreach tool,$(LINUX_TOOLS),\
 	$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
 		$(call UPPERCASE,$(tool))_INSTALL_TARGET_CMDS))
 
+define LINUX_TOOLS_INSTALL_INIT_SYSTEMD
+	$(foreach tool,$(LINUX_TOOLS),\
+		$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+			$($(call UPPERCASE,$(tool))_INSTALL_INIT_SYSTEMD))
+	)
+endef
+
+define LINUX_TOOLS_INSTALL_INIT_SYSV
+	$(foreach tool,$(LINUX_TOOLS),\
+		$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+			$($(call UPPERCASE,$(tool))_INSTALL_INIT_SYSV))
+	)
+endef
+
+define LINUX_TOOLS_INSTALL_INIT_OPENRC
+	$(foreach tool,$(LINUX_TOOLS),\
+		$(if $(BR2_PACKAGE_LINUX_TOOLS_$(call UPPERCASE,$(tool))),\
+			$(or $($(call UPPERCASE,$(tool))_INSTALL_INIT_OPENRC),\
+			     $($(call UPPERCASE,$(tool))_INSTALL_INIT_SYSV)))
+	)
+endef
+
 $(eval $(generic-package))
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services
  2020-01-03 19:57 [Buildroot] [PATCH 0/2] package/linux-tools: add microsoft HyperV integration services (branch yem/hyperv) Yann E. MORIN
  2020-01-03 19:57 ` [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files Yann E. MORIN
@ 2020-01-03 19:57 ` Yann E. MORIN
  2020-01-04 15:20   ` Thomas Petazzoni
  1 sibling, 1 reply; 6+ messages in thread
From: Yann E. MORIN @ 2020-01-03 19:57 UTC (permalink / raw)
  To: buildroot

From: Pascal de Bruijn <p.debruijn@unilogic.nl>

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 at 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>
---
 DEVELOPERS                               |  3 ++
 package/linux-tools/Config.in            | 37 +++++++++++++
 package/linux-tools/S10hyperv            | 66 ++++++++++++++++++++++++
 package/linux-tools/hypervfcopyd.service | 11 ++++
 package/linux-tools/hypervkvpd.service   | 11 ++++
 package/linux-tools/hypervvssd.service   | 11 ++++
 package/linux-tools/linux-tool-hv.mk.in  | 61 ++++++++++++++++++++++
 7 files changed, 200 insertions(+)
 create mode 100644 package/linux-tools/S10hyperv
 create mode 100644 package/linux-tools/hypervfcopyd.service
 create mode 100644 package/linux-tools/hypervkvpd.service
 create mode 100644 package/linux-tools/hypervvssd.service
 create mode 100644 package/linux-tools/linux-tool-hv.mk.in

diff --git a/DEVELOPERS b/DEVELOPERS
index 90941dd4c8..63e6981570 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1861,6 +1861,9 @@ F:	package/scrypt/
 
 N:	Pascal de Bruijn <p.debruijn@unilogic.nl>
 F:	package/libargon2/
+F:	package/linux-tools/S10hyperv
+F:	package/linux-tools/hyperv*.service
+F:	package/linux-tools/linux-tool-hv.mk.in
 
 N:	Pascal Huerst <pascal.huerst@gmail.com>
 F:	package/google-breakpad/
diff --git a/package/linux-tools/Config.in b/package/linux-tools/Config.in
index ab8cc3891c..0936ce31b4 100644
--- a/package/linux-tools/Config.in
+++ b/package/linux-tools/Config.in
@@ -116,4 +116,41 @@ config BR2_PACKAGE_LINUX_TOOLS_TMON
 	  tmon is a terminal-based tool (using curses) that allows the
 	  user to access thermal information about the system.
 
+config BR2_PACKAGE_LINUX_TOOLS_HV
+	bool "hv"
+	depends on BR2_i386 || BR2_x86_64
+	select BR2_PACKAGE_LINUX_TOOLS
+	select BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON if !BR2_PACKAGE_LINUX_TOOLS_HV_HAS_ONE
+	help
+	  Microsoft HyperV integration services
+
+	  Relevant kernel configuration options: HYPERV, HYPERV_UTILS
+
+if BR2_PACKAGE_LINUX_TOOLS_HV
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_HAS_ONE
+	bool
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON
+	bool "hypervkvpd (hv_kvp_daemon)"
+	help
+	  HyperV uses hypervkvpd (Key/Value Pair daemon) to retrieve
+	  status information from your virtualized guest OS
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_FCOPY_DAEMON
+	bool "hypervfcopyd (hv_fcopy_daemon)"
+	select BR2_PACKAGE_LINUX_TOOLS_HV_HAS_ONE
+	help
+	  HyperV uses hypervfcopyd (File Copy daemon) to easily transfer
+	  files to and from your virtualized guest OS
+
+config BR2_PACKAGE_LINUX_TOOLS_HV_VSS_DAEMON
+	bool "hypervvssd (hv_vss_daemon)"
+	select BR2_PACKAGE_LINUX_TOOLS_HV_HAS_ONE
+	help
+	  HyperV uses hypervvssd (Volume Snapshot Service daemon) to
+	  freeze your filesystems during snapshots and backups
+
+endif # BR2_PACKAGE_LINUX_TOOLS_HV
+
 endmenu
diff --git a/package/linux-tools/S10hyperv b/package/linux-tools/S10hyperv
new file mode 100644
index 0000000000..ec934bc972
--- /dev/null
+++ b/package/linux-tools/S10hyperv
@@ -0,0 +1,66 @@
+#!/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
diff --git a/package/linux-tools/hypervfcopyd.service b/package/linux-tools/hypervfcopyd.service
new file mode 100644
index 0000000000..c43fc1bc8e
--- /dev/null
+++ b/package/linux-tools/hypervfcopyd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV FCopy daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervfcopyd -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/linux-tools/hypervkvpd.service b/package/linux-tools/hypervkvpd.service
new file mode 100644
index 0000000000..6ed630278c
--- /dev/null
+++ b/package/linux-tools/hypervkvpd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV KVP daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervkvpd -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/linux-tools/hypervvssd.service b/package/linux-tools/hypervvssd.service
new file mode 100644
index 0000000000..3fd80029c7
--- /dev/null
+++ b/package/linux-tools/hypervvssd.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=HyperV VSS daemon
+After=syslog.target
+ConditionVirtualization=microsoft
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/hypervvssd -n
+
+[Install]
+WantedBy=multi-user.target
diff --git a/package/linux-tools/linux-tool-hv.mk.in b/package/linux-tools/linux-tool-hv.mk.in
new file mode 100644
index 0000000000..6996c55271
--- /dev/null
+++ b/package/linux-tools/linux-tool-hv.mk.in
@@ -0,0 +1,61 @@
+################################################################################
+#
+# hv_fcopy_daemon
+#
+################################################################################
+
+LINUX_TOOLS += hv
+
+# The programs to build, as known by the kernel:
+HV_PROGS_$(BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON) += hv_kvp_daemon
+HV_PROGS_$(BR2_PACKAGE_LINUX_TOOLS_HV_FCOPY_DAEMON) += hv_fcopy_daemon
+HV_PROGS_$(BR2_PACKAGE_LINUX_TOOLS_HV_VSS_DAEMON) += hv_vss_daemon
+
+# Give each tools the name most distros install them as:
+HV_hv_kvp_daemon = hypervkvpd
+HV_hv_fcopy_daemon = hypervfcopyd
+HV_hv_vss_daemon = hypervvssd
+
+HV_MAKE_OPTS = CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)"
+
+define HV_BUILD_CMDS
+	$(Q)for prog in $(HV_PROGS_y); do \
+		if test ! -f $(LINUX_DIR)/tools/hv/$${prog}.c ; then \
+			printf "Your kernel version is too old and does not have the HyperV %s tool." "$${prog}" ; \
+			exit 1 ; \
+		fi; \
+	done
+
+	$(TARGET_MAKE_ENV) $(MAKE) -C $(LINUX_DIR)/tools/hv \
+		$(HV_MAKE_OPTS) \
+		$(HV_PROGS_y)
+endef
+
+ifeq ($(BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON),y)
+define HV_KVP_HELPER
+	@mkdir -p $(TARGET_DIR)/usr/libexec/hypervkvpd
+	$(Q)ln -sf /bin/true $(TARGET_DIR)/usr/libexec/hypervkvpd/hv_set_ifconfig
+endef
+endif
+
+define HV_INSTALL_TARGET_CMDS
+	$(foreach prog,$(HV_PROGS_y), \
+		$(INSTALL) -m 0755 -D $(LINUX_DIR)/tools/hv/$(prog) \
+			$(TARGET_DIR)/usr/sbin/$(HV_$(prog))
+	)
+	$(HV_KVP_HELPER)
+endef
+
+define HV_INSTALL_INIT_SYSTEMD
+	$(foreach prog,$(HV_PROGS_y), \
+		$(INSTALL) -m 0644 -D package/linux-tools/$(HV_$(prog)).service \
+			$(TARGET_DIR)/usr/lib/systemd/system/$(HV_$(prog)).service
+	)
+endef
+
+define HV_INSTALL_INIT_SYSV
+	$(INSTALL) -m 0755 -D package/linux-tools/S10hyperv \
+		$(TARGET_DIR)/etc/init.d/S10hyperv
+	$(SED) 's/@PROGS@/$(foreach prog,$(HV_PROGS_y),$(HV_$(prog)))/' \
+		$(TARGET_DIR)/etc/init.d/S10hyperv
+endef
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files
  2020-01-03 19:57 ` [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files Yann E. MORIN
@ 2020-01-04 15:19   ` Thomas Petazzoni
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2020-01-04 15:19 UTC (permalink / raw)
  To: buildroot

On Fri,  3 Jan 2020 20:57:04 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> From: Pascal de Bruijn <p.debruijn@unilogic.nl>
> 
> Some linux tools (e.g. the Microsoft HyperV convenience utilities) will
> install programs tostart at boot time, so they need to be able to
> install init files (systemd units, sysv init script, or openrc units).
> 
> Unlike the other commands, we are redefining the real _INSTALL_INIT_*
> macros, rather than use hooks, to let the infra call those at the right
> moment.
> 
> We must be careful about the openrc support, though: if two tools are
> enabled, one which provides sysv scripts but no openrc config, and the
> other which provides openrc config, and we are using openrc as init
> system, then we want to use the sysv scripts from the former as well as
> the openrc config of the latter. Thus we need to duplicate a bit the
> openrc logic here.
> 
> Signed-off-by: Pascal de Bruijn <p.debruijn@unilogic.nl>
> [yann.morin.1998 at free.fr:
>   - define macros, not hooks
>   - introduce support for openrc too
>   - expand commit log
> ]
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> ---
>  package/linux-tools/linux-tools.mk | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services
  2020-01-03 19:57 ` [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services Yann E. MORIN
@ 2020-01-04 15:20   ` Thomas Petazzoni
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni @ 2020-01-04 15:20 UTC (permalink / raw)
  To: buildroot

On Fri,  3 Jan 2020 20:57:05 +0100
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> From: Pascal de Bruijn <p.debruijn@unilogic.nl>
> 
> 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 at 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>

Thanks applied to master, with just one very minor change.

> +config BR2_PACKAGE_LINUX_TOOLS_HV
> +	bool "hv"
> +	depends on BR2_i386 || BR2_x86_64
> +	select BR2_PACKAGE_LINUX_TOOLS
> +	select BR2_PACKAGE_LINUX_TOOLS_HV_KVP_DAEMON if !BR2_PACKAGE_LINUX_TOOLS_HV_HAS_ONE
> +	help
> +	  Microsoft HyperV integration services
> +
> +	  Relevant kernel configuration options: HYPERV, HYPERV_UTILS

Changed to CONFIG_HYPERV and CONFIG_HYPERV_UTILS, as we generally point
to kernel options including their CONFIG_ prefix.

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-04 15:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-03 19:57 [Buildroot] [PATCH 0/2] package/linux-tools: add microsoft HyperV integration services (branch yem/hyperv) Yann E. MORIN
2020-01-03 19:57 ` [Buildroot] [PATCH 1/2] package/linux-tools: add support for installing init system files Yann E. MORIN
2020-01-04 15:19   ` Thomas Petazzoni
2020-01-03 19:57 ` [Buildroot] [PATCH 2/2] package/linux-tools: add hyperv integration services Yann E. MORIN
2020-01-04 15:20   ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2020-01-03  8:53 Pascal de Bruijn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox